A single reply will suffice in the future.
 
May we see your output from both signed and unsigned PDFs?
 
--Mark Storer
  Senior Software Engineer
  Cardiff.com
 
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
 
 


________________________________

        From: Kiran Nepal [mailto:[email protected]] 
        Sent: Thursday, April 28, 2011 11:25 AM
        To: Post all your questions about iText here
        Subject: Re: [iText-questions] How to watermark a digitally
signed pdfprogramatically
        
        
Hi Leonard,
 
The code doesn't throw any error, it executes fine but there is no
change in digitally signed pdf. It is fine for me even it would show the
signature invalid after the modification.
 
My code works fine for normal pdf i.e pdf without digital signature.
 
I would really appreciate any help.
 
Regards,
Kiran

--- On Thu, 4/28/11, Leonard Rosenthol <[email protected]> wrote:



        From: Leonard Rosenthol <[email protected]>
        Subject: Re: [iText-questions] How to watermark a digitally
signed pdf programatically
        To: "Post all your questions about iText here"
<[email protected]>
        Date: Thursday, April 28, 2011, 10:00 AM
        
        

        What do you mean "doesn't work"?  

         

        An error is thrown?  The code executes fine but nothing shows on
the PDF?  Other?!?!? 

          

        Be aware, of course, that modifying a digitally signed PDF will
cause the signature to show as INVALID (for obvious reasons) 

          

        Leonard 

          

        From: Kiran Nepal [mailto:[email protected]] 
        Sent: Thursday, April 28, 2011 9:27 AM
        To: [email protected]
        Subject: [iText-questions] How to watermark a digitally signed
pdf programatically

          

Hi Friends, 

I urgently need to add watermark on a digitally signed pdf
programatically using C#. I can watermark normal pdf using the code
below but, it doesn't work for a pdf that with digital signature. Can
you please help me to solve this issue. 

The following code works and adds watermark on a normal pdf and doesn't
work for digitally signed pdf 

        public void AddWatermarkText(string sourceFile, string
outputFile, string watermarkText, iTextSharp.text.pdf.BaseFont
watermarkFont, float watermarkFontSize, iTextSharp.text.Color
watermarkFontColor, float watermarkFontOpacity, float
watermarkRotation,string waterMarkWord) 
        { 
            iTextSharp.text.pdf.PdfReader reader = null; 
            iTextSharp.text.pdf.PdfStamper stamper = null; 
            iTextSharp.text.pdf.PdfGState gstate = null; 
            iTextSharp.text.pdf.PdfContentByte underContent = null; 
            iTextSharp.text.Rectangle rect = null; 

            int pageCount = 0; 
            try 
            { 
                               { 
                    reader = new
iTextSharp.text.pdf.PdfReader(sourceFile); 
                    rect = reader.GetPageSizeWithRotation(1); 
                    //stamper = new
iTextSharp.text.pdf.PdfStamper(reader, new
System.IO.FileStream(outputFile, System.IO.FileMode.Create));//original
working but not for signed certificate 
                    stamper = new PdfStamper(reader, new
System.IO.FileStream(outputFile, System.IO.FileMode.CreateNew), '\0',
true); //Runs but doesn't work for signed pdf 

                    //PdfStamper stamp = new PdfStamper(reader, new
BinaryReader("c:\\my_dir\\" + SignedPdf + "-watermarked.pdf"), '\0',
true); //Google for writing in Signed Pdf 


                    if (watermarkFont == null) 
                    { 
                        watermarkFont =
iTextSharp.text.pdf.BaseFont.CreateFont(iTextSharp.text.pdf.BaseFont.HEL
VETICA, iTextSharp.text.pdf.BaseFont.CP1252,
iTextSharp.text.pdf.BaseFont.NOT_EMBEDDED); 
                    } 
                    if (watermarkFontColor == null) 
                    { 
                        watermarkFontColor = iTextSharp.text.Color.BLUE;

                    } 
                    gstate = new iTextSharp.text.pdf.PdfGState(); 
                    gstate.FillOpacity = watermarkFontOpacity; 
                    gstate.StrokeOpacity = watermarkFontOpacity; 
                    pageCount = reader.NumberOfPages; 
                    for (int i = 1; i <= pageCount; i++) 
                    { 
                        //underContent = stamper.GetUnderContent(1);
//If we need just one page, comment for loop and pagecount and write (1)
instead of i 
                        underContent = stamper.GetUnderContent(i);
//write uder the other text///GetOverContent for above the existing page

                        //_with1 = underContent; 
                        underContent.SaveState(); 
                        underContent.SetGState(gstate); 
                        underContent.SetColorFill(watermarkFontColor); 
                        underContent.BeginText(); 
                        underContent.SetFontAndSize(watermarkFont,
watermarkFontSize); 
                        underContent.SetTextMatrix(30, 30); 
 
underContent.ShowTextAligned(iTextSharp.text.Element.ALIGN_CENTER,
watermarkText, rect.Width / 2, rect.Height / 2, watermarkRotation); 
                        underContent.EndText(); 
                        underContent.RestoreState(); 
                    } 
                } 
              stamper.Close(); 
                reader.Close(); 
            } 
            catch (Exception ex) 
            { 
                throw ex; 
            } 
        } 

 

Thanks

Kiran

          

        -----Inline Attachment Follows-----
        
        
        
------------------------------------------------------------------------
------
        WhatsUp Gold - Download Free Network Management Software
        The most intuitive, comprehensive, and cost-effective network 
        management toolset available today.  Delivers lowest initial 
        acquisition cost and overall TCO of any competing solution.
        http://p.sf.net/sfu/whatsupgold-sd

        -----Inline Attachment Follows-----
        
        
        _______________________________________________
        iText-questions mailing list
        [email protected]
<http://us.mc330.mail.yahoo.com/mc/[email protected]
ceforge.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

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
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