Sample code to watermark existing pdf in asp.net web application

Q: We are evaluating TRON pdf tool, and i have the trial version
downloaded. We have a ecommerce website, where we need to watermark
some text to existing pdf and render them on the fly to our customers.
Our application is developed in ASP.Net and c#. Can you please help me
with sample program that:

1. Reads a pdf file from a physical folder.
2. Watermarks them with some text (for e.g for demo only)
3. Render the pdf on the fly.

I couldnt find examples for asp.net in your website or in the demo
samples. Please help.
---------------------
A: You can use PDFNet SDK in ASP.NET to implement your requirements.

- As a starting point download (http://www.pdftron.com/pdfnet/
downloads.html) the appropriate version of PDFNet for .NET (for
the .NET version that you are targeting and the platform).
- Add a reference to PDFNet.DLL in your project solution.
- Copy & paste some of the sample code and tweak it to match your
requirements.

The following samples are relevant to the task:

- Stamper: http://www.pdftron.com/pdfnet/samplecode.html#Stamper
      Uses pdftron.PDF.Stamper utility to stamp PDF pages with text,
images, or vector art.

- PDFDraw: http://www.pdftron.com/pdfnet/samplecode.html#PDFDraw
      Uses pdftron.PDF.PDFDraw to convert PDF pages to images.

Q:
Thanks for the pointers to create watermark pdf. I'm unable to find an
example for web, as all the samples are available for console
applications.
1. We donot want the generated pdf to be physically created in the
server (i.e we donot want to call PDFDoc.save("location"), rather we
want to read the bytes and render as pdf on the fly. Is it possible to
do that. If so, kindly provide us a sample for the same.
--------------------

A:

Most of PDFNet samples can also be used in web setting. In case you
would like to save the resulting document in memory you would simply
use the overloaded doc.Save() method.

For example:

// C#
byte[] buf = new byte[1];
int buf_sz = 1;
doc.Save(ref buf, ref buf_sz, SDFDoc.SaveOptions.e_remove_unused);

// VB.NET
Dim buf(0) As Byte
Dim buf_sz As Integer = 1
doc.Save(buf, buf_sz, SDF.SDFDoc.SaveOptions.e_remove_unused)

// JAVA
byte[] buf = doc.save(SDFDoc.e_remove_unused, null);

// C++
const char* buf = 0;
size_t buf_sz;
doc.Save(buf, buf_sz, SDFDoc::e_remove_unused, NULL);

// PYTHON
buffer = doc.Save(SDFDoc.e_remove_unused)

... etc

For a concrete sample project please see PDFDocMemory sample:
  http://www.pdftron.com/pdfnet/samplecode.html#PDFDocMemory

On Apr 11, 1:42 pm, Support <supp...@pdftron.com> wrote:

Q: We are evaluating TRON pdf tool, and i have the trial version
downloaded. We have a ecommerce website, where we need to watermark
some text to existing pdf and render them on the fly to our customers.
Our application is developed in ASP.Net and c#. Can you please help me
with sample program that:

1. Reads a pdf file from a physical folder.
2. Watermarks them with some text (for e.g for demo only)
3. Render the pdf on the fly.

I couldnt find examples for asp.net in your website or in the demo
samples. Please help.

---------------------
A: You can use PDFNet SDK in ASP.NET to implement your requirements.

- As a starting point download (http://www.pdftron.com/pdfnet/
downloads.html) the appropriate version of PDFNet for .NET (for
the .NET version that you are targeting and the platform).
- Add a reference to PDFNet.DLL in your project solution.
- Copy & paste some of the sample code and tweak it to match your
requirements.

The following samples are relevant to the task:

- Stamper:http://www.pdftron.com/pdfnet/samplecode.html#Stamper
Uses pdftron.PDF.Stamper utility to stamp PDF pages with text,
images, or vector art.

- PDFDraw:http://www.pdftron.com/pdfnet/samplecode.html#PDFDraw
Uses pdftron.PDF.PDFDraw to convert PDF pages to images.