OK, I'm now using PdfSmartCopy. What I'm doing is sending
the output from the original PdfWriter to a ByteArrayOutputStream,
and I then read that using another PdfReader and write it
to a PdfSmartCopy. Works great; the files don't shrink quite
as much as with Acrobat 8, but pretty close.

I have one other question: PdfSmartCopy is a subclass of
PdfWriter, which made me think maybe I can simply replace my
original PdfWriter by a PdfSmartCopy, and thus avoid the
two-stage approach. However, when I do that, the addTemplate()
call does not seem to work (at the end, I get an exception
saying the document has no pages). When I use addPage()
instead, the template pages get copied to the PdfSmartCopy,
but then the text that I'm printing on top of the template
does not show up.

Is it possible to use PdfSmartCopy as a replacement for
PdfWriter somehow, or do I have to use the two-stage
approach?

Thanks for your help. Great product!

 - Thomas

Paulo Soares wrote:

iText doesn't do any object optimization except in PdfSmartCopy.

Paulo

----- Original Message ----- 
From: "Thomas Okken" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, February 23, 2007 10:25 PM
Subject: [iText-questions] Duplicated fonts in iText-generated PDF


Hi all,

I'm working on a report generator that uses iText to generate PDF 
files. The 
content of the individual pages is composed by first printing a 
template, 
which is read from another PDF using PdfWriter.getImportedPage() 
followed by 
PdfContentByte.addTemplate(); then, the actual data are printed on top 
of 
the template using the usual PdfContentByte methods. Repeat for each 
page.

All this works fine, except for one thing: the final reports consist of 
about 80% font data. Simply opening and then saving them in Acrobat 
will 
shrink them considerably, sometimes by more than 50%. Apparently, there 
are 
a lot of duplicated fonts in the generated PDFs, but I don't understand 
how 
they get there.


The templates I use for the individual pages do not contain any 
embedded 
fonts; when I use a font in the code that populates the data, I'll 
create it 
with the BaseFont.EMBEDDED flag, but from the Javadocs, it is my 
understanding that those fonts should only get embedded once. Could it 
be 
the process of reading the templates that is causing the same set of 
fonts 
to be embedded over and over?

Thanks for any insights!

 - Thomas

 
---------------------------------
Don't get soaked.  Take a quick peak at the forecast 
 with theYahoo! Search weather shortcut.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to