I am using editable pdf files (created by Nitro PDF Software) in my application. These pdf files have a lot of editable fields (like textboxes) and one button (like submit).
Try open source library http://pdfsharp.codeplex.com/, sample can be found here http://www.pdfsharp.net/wiki/.
From Wikipedia, PDF Interactive elements there are two possibilities for integrating data and PDFs (there are also links to the specifications):
For compatibility issues I would go for AcroForms. In that case I would use XFDF, because it is XML and therefore easier to parse. I never used Nitro, but when you build a PDF form you usually provide a "Save" button and choose at action for this button "Send/Post form to server" with the data format XML which is just XFDF.
This works only when the PDF is viewed in the browser. So the typical use case is: have an empty PDF template on the server, before returning the PDF to the user mix your data into the PDF, the user enters data in the form (PDF is opened in the browser via a plugin or natively in Chrome), then the user presses the save buttons which posts a xml on the server. The next time the user asks for his PDF, you took the recent data and mix it again with the template.
So only two questions are open:
See the complete process here: http://itextpdf.com/book/chapter.php?id=9 . This example updates the PDF with the form dynamically at run time. Since iText is used there is no difference between Java and C#.
Be aware that previous versions of iText (Java up to 2.1.7 and C# up to 4.1.6) were distributed under the Mozilla Public License or the LGPL, while current versions are distributed under the Affero General Public License. Thats explains why the older versions are still used.
To generate PDF, use following code:
NameSpace:
Using System.IO;
Using.iTextSharp.text;
Using.iTextSharp.text.pdf;
On button click:
private void button1_Click(object sender, EventArgs e)
{
Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35);
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(@"C:\Test.pdf", FileMode.Create));
doc.Open();
Paragraph paragraph = new Paragraph("Hi, \n This is xxx from yyy \n This is my pdf file");
doc.Add(paragraph);
doc.Close();
}
Why dont you do it the way mentioned in the below link.
http://www.gnostice.com/nl_article.asp?id=176&t=Generate_PDF_Forms_In_ASP_NET_Using_PDFOne_NET_v3
It uses another PDF generation tool. But you should be able to do the same with nitro.
User following code for Generate PDF in asp.net:
There's a full code sample below to get you started. // Code
using System;
using System.IO;
using System.Diagnostics;
using iTextSharp.text;
using iTextSharp.text.pdf;
public class iTextDemo
{
public static void Main()
{
Console.WriteLine("iText Demo");
// step 1: creation of a document-object
Document myDocument = new Document(PageSize.A4.Rotate());
try
{
// step 2:
// Now create a writer that listens to this doucment and writes the document to desired Stream.
PdfWriter.GetInstance(myDocument, new FileStream("Salman.pdf", FileMode.Create));
// step 3: Open the document now using
myDocument.Open();
// step 4: Now add some contents to the document
myDocument.Add(new Paragraph("First Pdf File made by Salman using iText"));
}
catch(DocumentException de)
{
Console.Error.WriteLine(de.Message);
}
catch(IOException ioe)
{
Console.Error.WriteLine(ioe.Message);
}
// step 5: Remember to close the documnet
myDocument.Close();
}
}
How do I get all the static and dynamic values that are posted to this page?
You can retreive them as you retrieve any other value from an html control, for example:
string MyVal = Request.Form["FieldName"];
and create another pdf file with the entered data?
Here you can use a PDF library of your choice ( iText.Net, Nitro PDF, Amyuni PDF Creator.Net ), load your PDF form, set the values to each field, flatten your file if needed, and save. The code for this part depends on the library being used, but they are usally well documented so you should be able to find sample code easily.