- Posts: 50
- Thank you received: 0
Microsoft Windows Phone 8.1 support ends (13 Jul 2017)
Microsoft has ended support for Windows Phone 8.1
Questions about Android development and PDF
Maximum open Documents? 150?
IP: 192.168.0.71
11 years 4 months ago #7465
by apait
Maximum open Documents? 150? was created by apait
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.
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.
Code:
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();
}
IP: 192.168.0.71
11 years 4 months ago #7466
by apait
Replied by apait on topic Maximum open Documents? 150?
i am using the last version of your library...
IP: 192.168.0.71
11 years 4 months ago #7469
by nermeen
Replied by nermeen on topic Maximum open Documents? 150?
Do you close the doc object?
Code:
m_doc.Save();
m_doc.Close();
m_doc = null;
IP: 192.168.0.71
11 years 4 months ago #7470
by apait
Replied by apait on topic Maximum open Documents? 150?
well, i would close it, when leaving the activity, of course.
but i can't close it while displaying the documents.
but i can't close it while displaying the documents.
IP: 192.168.0.71
11 years 4 months ago #7471
by radaee
Replied by radaee on topic Maximum open Documents? 150?
in your test codes, you opened 200 documents and not close it.
IP: 192.168.0.71
11 years 4 months ago #7472
by apait
Replied by apait on topic Maximum open Documents? 150?
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.
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.
Time to create page: 0.425 seconds