It's IMPOSSIBLE to get the exact size of the document without actually writing 
it, since compression is used as part of the writing process – and you can't 
know the output of a compression operation until you actually perform it.

You could come up with some "heuristics" for your specific pages and do the 
math…

Leonard

From: Paul Sachs 
<[email protected]<mailto:[email protected]>>
Reply-To: 
"[email protected]<mailto:[email protected]>"
 
<[email protected]<mailto:[email protected]>>,
 Post here 
<[email protected]<mailto:[email protected]>>
Date: Wed, 25 Jan 2012 07:16:14 -0800
To: Post here 
<[email protected]<mailto:[email protected]>>
Subject: [iText-questions] Getting the document size before closing the 
document when using DirectContent.AddTemplate (C#)

Hi, I am adding between 1000 and 5000 pages to a PdfWriter.  Each page is added 
by using writer.DirectContent.AddTemplate(writer.GetImportedPage(reader, 
pageNumber), a, b, c, d, e, f)

I am using AddTemplate because I may need to rotate a page by 180 depending on 
a test.

I would like to know when the size of the document that will be written has 
exceeded a threshold (e.g. 2 Mb).  Then I can close the document and start a 
new one.

I have tried writer.CurrentDocumentSize and 
writer.DirectContent.InternalBuffer.Size.  Both report very small numbers.

How can I find the size of the document written so far without doing a 
document.Close() ?


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to