The PDFs appear fine, so I am going to fall back on the library/code.

Are you using the current version of iTextSharp??

Leonard

From: Kiran Nepal [mailto:[email protected]]
Sent: Thursday, April 28, 2011 12:57 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] How to watermark a digitally signed 
pdfprogramatically

Hi Leonard,

"Unable" ones are After I ran the code. This means all 4 attached pdf are the 
output after running my code.

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 
pdfprogramatically
To: "Post all your questions about iText here" 
<[email protected]>
Date: Thursday, April 28, 2011, 12:45 PM

Are the “unable” ones BEFORE you ran your code over them or AFTER?  WE need 
both…



From: Kiran Nepal [mailto:[email protected]]
Sent: Thursday, April 28, 2011 12:28 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] How to watermark a digitally signed 
pdfprogramatically



Hi Mark,



I have attached 4 pfs herewith. Namely:

  1)UnableToWaterMark1.pdf: This is a digitally signed pdf on which my code 
cannot watermark.



  2)UnableToWaterMark2.pdf: Even though this is not digitally signed pdf my 
code is still not able to water mark.



Finally 3)WaterMarke1.pdf and 4)WaterMarked2.pdf are watermarked using my code 
programatically.



Thanks,

Kiran






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

From: Mark Storer <[email protected]>
Subject: Re: [iText-questions] How to watermark a digitally signed 
pdfprogramatically
To: "Post all your questions about iText here" 
<[email protected]>
Date: Thursday, April 28, 2011, 11:40 AM

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.HELVETICA, 
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]>
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


-----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]>
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




-----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]>
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