0

I have a pdf file stored at some location on my server. On click of a link I want to add a text-watermark to this pdf file and then print it.

something like this:

in aspx say we have a (button a link-button or a simple link)

     <a id="abc" href="../test.pdf" onclick="watermarkAndPrintPdf()"> PrintPdf </a>
     or
     <asp:linkbutton id="abc" runat="server" onclick="watermarkAndPrintPdf()" Text="Print Pdf"/>

Now when user click this link my code should add watermark(which will probably the loged-in user name) and print this document.

I want to know what ['watermarkAndPrintPdf()'] this function will be.......

Note:-It is a web application in C# asp.net 4.0. (I don't mind if print dialog box opens or It prints without it.)

Please help....

Yagnesh.Dixit
  • 318
  • 7
  • 18
  • While watermarking should be no problem with any decent PDF library (iTextSharp, PdfSharp, etc. pp.), printing might be more interesting. I assume you want it to print on the client machine, not the server. Have you considered to add an on-open action to the PDF during watermark application? This action can trigger a print dialog to open. This might require JavaScript to be enabled in the PdfReader. – mkl Jan 29 '13 at 10:16
  • thanks for the answer... yes watermarking is not a big deal but to print on client machine after watermarking worries me... Please explain more on on-open action to the pdf.... It's the first time I am handling pdf through code. – Yagnesh.Dixit Jan 29 '13 at 10:21
  • You'll find some information on this in the PDF specification [ISO 32000-1](http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf) section 7.7.2 table 28 key **OpenAction** and section 12.6 explaining Actions in general. I guess you'll need a JavaScript Action (12.6.4.16). Cf. [Can a PDF file's print dialog be opened with Javascript?](http://stackoverflow.com/questions/687675/can-a-pdf-files-print-dialog-be-opened-with-javascript). If that sounds like a way to go, I could try and add information on how to insert that action using iTextSharp. – mkl Jan 29 '13 at 10:59

1 Answers1

1

would suggest taking a look at PDFsharp it's an open source dll for producing pdf's through code, there are a number of examples of producing a watermark on this page of the PDFsharp website:

http://www.pdfsharp.com/PDFsharp/index.php?option=com_content&task=view&id=40&Itemid=51

If you need any help using it I am more than willing to lend a hand as I have used this package to produce pdf's in the past.

hope this helps.

CryoFusion87
  • 796
  • 1
  • 8
  • 28
  • Thanks CryoFushion87 that would definitely help me add watermark to my pdf (I have also gone through itextSharp and other tool to add watermark) and at the same go I want to print it... I am sorry If I sound confused...... – Yagnesh.Dixit Jan 29 '13 at 09:55