Thanks Paulo. I will grab the SVN copy and test with it. Again, many thanks
for the quick repair.
Gylfi
-----Original Message-----
From: Paulo Soares [mailto:
psoares@...]
Sent: Friday, June 19, 2009 6:56 AM
To: Post all your questions about iTextSharp here
Subject: Re: [itextsharp-questions] PdfSmartCopy generating bad PDFs
Fixed in the SVN. This month will come out a new release if you want to wait
for it.
Paulo
> -----Original Message-----
> From: Gylfi Ingvason [mailto:
Gylfi.Ingvason@...]
> Sent: Thursday, June 18, 2009 6:11 PM
> To:
itextsharp-questions@...
> Subject: [itextsharp-questions] PdfSmartCopy generating bad PDFs
>
>
> The PDF file below, when modified and concatenated with a similar
> file, will generate bad PDF output using PdfSmartCopy. This can be
> replicated doing the
> following:
>
> 1. Cut and paste the PDF file below into a separate .pdf file. Use an
> editor that does not molest line terminators and make sure no line
> wrapping is taking place - all dictionary entries should be contained
> within a single line and not broken up.
>
> 2. After you have verified that the file opens and displays in Acrobat
> (if it asks to save changes when you close it, it means that line
> terminators are not correct), make another copy of the file, and
> change "(Blue Content)"
> to "(Red Content)" and in the line above change "0 0 1 rg"
> to "1 0 0 rg".
> Make sure to add an extra space after "Red" to keep the byte count the
> same.
>
> 3. Concatenate the two files using the following code or something
> similar:
>
> PdfReader reader = new PdfReader("File1.pdf"); Document document = new
> Document(reader.GetPageSizeWithRotation(1));
> PdfSmartCopy writer = new PdfSmartCopy(document, new
> FileStream("Concatenated.pdf", FileMode.Create, FileAccess.Write));
> document.Open();
>
> writer.AddPage(writer.GetImportedPage(reader, 1)); reader.Close();
>
> reader = new PdfReader("File2.pdf");
> writer.AddPage(writer.GetImportedPage(reader, 1)); reader.Close();
> writer.Close();
>
> 5. The "Concatenated.pdf" will contain two pages that both have the
> "Blue Content" displayed. Upon examining the generated file, you will
> find that both pages reference the same content and the "Red Content"
> is missing. A
> slightly different composition of the input file will generate output
> where an XObject Form will reference itself which causes the Foxit
> reader to immediately kill itself and cause Acrobat to complain about
> a damaged file.
>
> The pdf file below was hand created whittling down concatenated
> customer files where single complex invoices and checks were being
> prepared for printing. Personally, I find the re-use of named
> resources like this somewhat questionable, but the PDF specification
> seems to indicate that this is valid since the name re-use is within
> the scope of the Form only.
>
> At any rate, I would like the group to know that using PdfSmartCopy
> can produce erroneous, and under some circumstances, deadly (for the
> Reader) results. I don't trust myself to debug the source for this,
> but perhaps Paulo or somebody else with more knowledge of the code can
> take a closer look and patch this.
>
> Thanks - Gylfi
>
> %PDF-1.4
> %âãÏÓ
> 1 0 obj<</Pages 2 0 R/Type/Catalog>>
> endobj
> 2 0 obj<</Kids[3 0 R]/Count 1/Type/Pages>> endobj
> 3 0 obj<</Resources<</XObject<</Xf1 5 0 R>>/ProcSet [/PDF
> /Text]>>/Parent 2 0 R/MediaBox[0 0 612 792]/Contents 4 0 R/Type/Page>>
> endobj
> 4 0 obj <</Length 26>>stream
> q 1 0 0 1 0 0 cm /Xf1 Do Q
> endstream
> endobj
> 5 0 obj <</BBox[0 0 612 792]/Matrix[1 0 0 1 0 0]/FormType
> 1/Subtype/Form/Length 26/Resources<</XObject<</Xf1 6 0
> R>>/ProcSet[/PDF/Text]>>/Type/XObject>>stream
> q 1 0 0 1 0 0 cm /Xf1 Do Q
> endstream
> endobj
> 6 0 obj <</BBox[0 0 612 792]/Matrix[1 0 0 1 0 0]/FormType
> 1/Subtype/Form/Length 26/Resources<</XObject<</Xf1 7 0
> R>>/ProcSet[/PDF/Text]>>/Type/XObject>>stream
> q 1 0 0 1 0 0 cm /Xf1 Do Q
> endstream
> endobj
> 7 0 obj <</BBox[0 0 612 792]/Matrix[1 0 0 1 0 0]/FormType
> 1/Subtype/Form/Length 26/Resources<</XObject<</Xf1 8 0
> R>>/ProcSet[/PDF/Text]>>/Type/XObject>>stream
> q 1 0 0 1 0 0 cm /Xf1 Do Q
> endstream
> endobj
> 8 0 obj <</BBox[0 0 612 792]/Matrix[1 0 0 1 0 0]/FormType
> 1/Subtype/Form/Length 26/Resources<</XObject<</Xf1 9 0
> R>>/ProcSet[/PDF/Text]>>/Type/XObject>>stream
> q 1 0 0 1 0 0 cm /Xf1 Do Q
> endstream
> endobj
> 9 0 obj <</BBox[0 0 612 792]/Matrix[1 0 0 1 0 0]/FormType
> 1/Subtype/Form/Length 67/Resources<</Font<</F1 10 0
> R>>/ProcSet[/PDF/Text]>>/Type/XObject>>stream
> q
> BT
> 1 0 0 1 10 700 Tm
> /F1 15 Tf
> 0 0 1 rg
> (Blue Content)Tj
> 0 g
> ET
> Q
> endstream
> endobj
> 10 0
> obj<</Subtype/Type1/BaseFont/Courier/Encoding/WinAnsiEncoding/
> Type/Font>>
> endobj
> xref
> 0 11
> 0000000000 65535 f
> 0000000015 00000 n
> 0000000059 00000 n
> 0000000109 00000 n
> 0000000245 00000 n
> 0000000318 00000 n
> 0000000521 00000 n
> 0000000724 00000 n
> 0000000927 00000 n
> 0000001130 00000 n
> 0000001371 00000 n
> trailer
> <</Root 1 0 R/Size 11>>
> startxref
> 1457
> %%EOF
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.
----------------------------------------------------------------------------
--
Crystal Reports - New Free Runtime and 30 Day Trial Check out the new
simplified licensing option that enables unlimited royalty-free distribution
of the report engine for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions