How to edit a pdf in the browser and save it to the server How to edit a pdf in the browser and save it to the server asp.net asp.net

How to edit a pdf in the browser and save it to the server


You can use GhostScript to render a PDF to JPEG.
Command line example:

gswin32c.exe -dSAFER -dBATCH -dNOPAUSE -sDEVICE=jpeg -r300 -sOutputFile=output.jpg input.pdf

You need to call GhostScript via the command line version (as above) or use a wrapper.A Google search turned up this blog post:

For creating a new PDF you have two main alternatives:

  • Modify the JPEG and convert the JPEG into PDF (you can use GhsotScript for the conversion)
  • Use A PDF library that imports your original PDF and add data on top of that

For PDF libraries see this SO question:


My company, Atalasoft, provides components that let you view document images, including PDFs and annotate them and save the annotations back into the PDF. In our product suite, you would need dotImage document imaging and the PDF Reader add-on. You would be using dotAnnotate through our AJAX web controls. Here is a link to our online demo - the document displayed is a TIFF, but you could use a PDF too.


I don't think you will be able to have a user load a pdf in their browser, edit it, then save it to the server without them saving it to their machine and then uploading it to the server.

What you can do is setup a webform with a database backend that can represent the pdf, and when they edit it you can regenerate the PDF using itextsharp and loading the information from the database, that way when the user goes back to edit the PDF you can prepopulate the form with what already exists.

itextsharp is extremely easy to use, here is an example:

string sourceFile = "path/to/pdfTemplate.pdf";PdfReader reader = new PdfReader(sourceFile);PdfStamper stamper = new PdfStamper(reader, new FileStream("path/to/store/pdf/filename.pdf", FileMode.Create));AcroFields fields = stamper.AcroFields;//now assign fields in the form to values from your formfields.SetField("input1", input1.Text);fields.SetField("input2", input2.Text);//close the pdf after filling out fieldsstamper.SetFullCompression();stamper.FormFlattening = true;stamper.Close();

then if you wanted to show the actual PDF you could easily

Response.Redirect("path/to/store/pdf/filename.pdf");