I'm using ITextSharp version 5.3.5 to PDF signing and annotating.
Recently I received just one signed PDF file which is being corrupted by
my annotation procedure specifically from the second page. If you use my
code to annotate on first page the problem does not occurs. The code
bellow reproduces the problem only with this pdf (download at
http://www1.tjrj.jus.br/gedcacheweb/default.aspx?GEDID=00037C2E6C14411AA
19CEC4152C23B5D200575C403341703 ). The corruption can be verified on
Adobe Reader 10 or 11 which shows the second page blank and with
corrupted signature. 

 

using iTextSharp.text.pdf;

using iTextSharp.text;

 

                ...

 

        PdfReader pdfr = new PdfReader("signed.pdf");

        PdfStamper stamper = new PdfStamper(pdfr, new
System.IO.FileStream("signed-with-annotation.pdf",
System.IO.FileMode.Create), '0', true);

 

        PdfTemplate templStampPag;

        templStampPag = PdfTemplate.CreateTemplate(stamper.Writer, 100,
100);

        templStampPag.BeginText();

        BaseFont FonteAnot = FontFactory.GetFont("Helvetica",
12).GetCalculatedBaseFont(false);

        templStampPag.SetFontAndSize(FonteAnot, 12);

        templStampPag.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "TEST",
0, 0, 0);

        templStampPag.EndText();

 

        PdfAnnotation AnotacaoPag =
PdfAnnotation.CreateStamp(stamper.Writer, new
iTextSharp.text.Rectangle(0, 0, 100, 100), "", "");

        AnotacaoPag.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL,
templStampPag);

        AnotacaoPag.Flags = PdfAnnotation.FLAGS_PRINT;

 

        stamper.AddAnnotation(AnotacaoPag, 2);

        stamper.Close();

        pdfr.Close();

 

Annotations on the same page done by Acrobat Standard does not corrupt
document.

 

Thanks in advance

 

Marcos

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
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