Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1
  • 2

TOPIC:

Maximum open Documents? 150? 9 years 6 months ago #7465

  • apait
  • apait's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 50
  • Thank you received: 0
Hi,
this is rather time-sensitive...

Is there a leak or restriction in your library for opening a bigger amount of documents?

I tested it with pdfs and with images (loaded into an empty pdf).
Everytime it reaches 150 i've got the EMFILE-Exception "Too Many Files opened"

Example:
Load 200 bitmaps in 200 documents. crashes at 150.
final int TESTSIZE = 200;
for(int i = 0; i < TESTSIZE; i++) {
	Document doc = new Document();
	doc.Create(tempPdf);
	doc.SetCache(cache);
	
	Page page = doc.NewPage(0, 200, 200);
	
	PageContent content = new PageContent();
	content.Create();
	
	//set alpha for both fill and stroke
	DocGState dgs = doc.NewGState();
	dgs.SetFillAlpha(0x80);//set alpha value to 0.5
	dgs.SetStrokeAlpha(0x80);//set alpha value to 0.5
	ResGState rgs = page.AddResGState(dgs);
	content.GSSet(rgs);
	
	//write a bitmap
	content.GSSave();
	dgs = doc.NewGState();
	dgs.SetFillAlpha(255);//set alpha value to 1
	dgs.SetStrokeAlpha(255);//set alpha value to 1
	rgs = page.AddResGState(dgs);
	content.GSSet(rgs);
	
	
	Bitmap bmp = Bitmap.createBitmap(300, 600, Config.ARGB_8888);//must be ARGB_8888
	Bitmap bit=BitmapFactory.decodeFile(directoryPlusThumbnail);
	bmp = bit;
	
	DocImage dimg = doc.NewImage(bmp, true);
	bmp.recycle();
	ResImage rimg = page.AddResImage(dimg);
	Matrix mat = new Matrix( 200, 200, 0, 0 );
	
	content.GSSetMatrix(mat);
	mat.Destroy();
	content.DrawImage(rimg);
	content.GSRestore();
	
	page.AddContent(content, true);
	content.Destroy();
	
	page.Close();
}

Please Log in or Create an account to join the conversation.

Maximum open Documents? 150? 9 years 6 months ago #7466

  • apait
  • apait's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 50
  • Thank you received: 0
i am using the last version of your library...

Please Log in or Create an account to join the conversation.

Maximum open Documents? 150? 9 years 6 months ago #7469

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
Do you close the doc object?
m_doc.Save();
m_doc.Close();
m_doc = null;

Please Log in or Create an account to join the conversation.

Maximum open Documents? 150? 9 years 6 months ago #7470

  • apait
  • apait's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 50
  • Thank you received: 0
well, i would close it, when leaving the activity, of course.
but i can't close it while displaying the documents.

Please Log in or Create an account to join the conversation.

Maximum open Documents? 150? 9 years 6 months ago #7471

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
in your test codes, you opened 200 documents and not close it.

Please Log in or Create an account to join the conversation.

Maximum open Documents? 150? 9 years 6 months ago #7472

  • apait
  • apait's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 50
  • Thank you received: 0
i know. why should i open a document and close it rightafter?
that makes no sense, then i would not be able to display it...

(like i said, i'm recyling all the documents in my ondestroy()... but thats not the point).

we've got a viewpager. for every view, we got a single pdfreadercontroller with a document. everything works fine until the underlying document-array exceeds 150 documents. --> to many files open-exception

my example should just show you, that maybe it has something to do with not-closed-sockets/streams in your library ... ?
i figure you're closing everything on document.close(), but at the same time: you can't call document.close before exiting the activity.

same goes using PDFFileStream ...
it's not possible to open more than 150 docs.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Powered by Kunena Forum