Maximum open Documents? 150? - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
13 Jul 2017
Microsoft has ended support for Windows Phone 8.1
Read More...
Questions about Android development and PDF
  • Page:
  • 1
  • 2

TOPIC: Maximum open Documents? 150?

Maximum open Documents? 150? 3 years 4 months ago #7465

  • apait
  • apait's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 38
  • 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? 3 years 4 months ago #7466

  • apait
  • apait's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 38
  • 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? 3 years 4 months ago #7469

  • nermeen
  • nermeen's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 754
  • Karma: 20
  • Thank you received: 55
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? 3 years 4 months ago #7470

  • apait
  • apait's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 38
  • 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? 3 years 4 months ago #7471

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 830
  • Karma: 43
  • Thank you received: 10
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? 3 years 4 months ago #7472

  • apait
  • apait's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 38
  • 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