That's a bug that's already fixed in the SVN.
Paulo
________________________________
From: Erik Thelin [mailto:erik.the...@gmail.com]
Sent: Monday, June 21, 2010 12:38 PM
To: itext-questions@lists.sourceforge.net
Subject: [iText-questions] Increasing file size when using PdfSmartCopy
Hello,
I've encountered a strange problem with iTextSharp and concatenating PDFs. I
have used iTextSharp 3.1.8 before to merge several (almost) identical files
into a single PDF to be sent to printing companies, but as the number of
documents increase so does the filesize, much due to images and fonts being
embedded over and over. I was happy to see that 5.0.2 had a way to lessen this
problem by using PdfSmartCopy.
Trying it out was a disaster. The 3.1.8-version would, as an example, turn 3
PDF files of 80k (55k fonts) each into a combined PDF of 156k, where 120k was
fonts. The solution back then was to use PdfContentByte.AddTemplate for every
page in every document.
I was hoping for a real improvement with the new library, but sadly the files
did not shrink, they grew! Concatenating the same PDFs with the new version
(using the old technique) resulted in a 242k big PDF, with 167k of fonts. No
optimization at all, it was more or less the sizes added.
Using PdfSmartCopy was even worse. My three files now resulted in a PDF of
staggering 363k! Fonts was 'only' using 114k, which was better than AddTemplate
and somewhat better than the old version, but the new file has what Adobe calls
'Document Overhead' of 222k!
I tried send in only one of the files into the document, and I had hoped to end
up with a file of around 80k. AddTemplate worked just fine here, but
PdfSmartCopy almost doubled the filesize into 152k. 75k of these were the
mystic 'Overhead' that has appeared from nowhere.
My question is what this overhead is (if anyone knows), and how to get rid of
it. Why is the same code producing smaller files in the earlier versions of
iTextSharp?
In pseudocode my algorithm for PdfSmartCopy is this:
create PdfReader
create Document
create new filestream
create PdfSmartCopy using Document and filestream
for each file
for each page in file
use GetImportedPage to get page from the reader
use AddPage to insert page into the smartcopy object
endfor
free and close reader
open new reader with next file
endfor
From browsing the previous questions I have gathered that embedded fonts and
subsets of fonts are two separate things and are tricky things to manipulate,
so I understand that iText might not be able to reduce the amount of
fontinformation, but ending up with a larger document feels odd. I'm at a loss
for what to try next.
Regards,
Erik
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/