WebForms PdfViewer Updating Fillable PDF

0 Answers 20 Views
PdfViewer UI for ASP.NET AJAX in ASP.NET MVC
Al
Top achievements
Rank 1
Al asked on 01 Apr 2025, 04:01 PM | edited on 01 Apr 2025, 04:07 PM

HI Guys

I was wondering if you WebForms PdfViewer can accomplish updating fillable PDF and save the data entries into a new PDF, explain

I have a fillable PDF with a few fillable textboxes, and I would like to capture the user inputs and save as a new PDF for then later continue filling the blanks loading the new saved PDF.

I've tried accomplishing the task using iTextSharp but it was not possible here is my code for reference.


string existingPdfilePath = Server.MapPath("~/export/I-693_1000_202502191951256806.pdf");
 string updatedPdfPath = Server.MapPath("~/App_Data/I-693_" + Guid.NewGuid().ToString() + ".pdf");

 using (FileStream pdfReaderStream = new FileStream(existingPdfilePath, FileMode.Open, FileAccess.Read))
            {
                using (FileStream pdfWriterStream = new FileStream(updatedPdfPath, FileMode.Create, FileAccess.Write))
                {
                    PdfReader reader = new PdfReader(pdfReaderStream);
                    PdfStamper stamper = new PdfStamper(reader, pdfWriterStream);

                    AcroFields formFields = stamper.AcroFields;
                    foreach (DictionaryEntry de in reader.AcroFields.Fields)
                    {
                        //sb.Append(de.Key.ToString() + Environment.NewLine);
                        var fullname = formFields.GetTranslatedFieldName(de.Key.ToString());
                        formFields.RenameField(fullname, Guid.NewGuid().ToString("N"));
                        if (de.Key.ToString() != fullname)
                            if (!String.IsNullOrEmpty(de.Value.ToString()))
                            {
                                if (fullname != "form1[0].#pageSet[0].Page1[9].PDF417BarCode2[0]")
                                {
                                    formFields.SetField(de.Key.ToString(), de.Value.ToString());
                                }
                            }
                    }
                    stamper.Close();
                    reader.Close();
                }

As a PDFViewer I am using the plain html embed tag

 <embed class="pdf" 
               src=
"~/Templates/I-693_100_2025045512.pdf"
            width="800" height="500" />

The user data entries vanish like a ghost, and when saving it just make a copy of the original with no captured data entries

Can your PDFViewer accomplish the task?

Vasko
Telerik team
commented on 02 Apr 2025, 07:02 AM

Hello Al,

I hope all is well with you!

A similar idea is already available in our feedback portal.

While the PDFViewer doesn't offer direct support for adding input controls (signature or text boxes), you can explore alternatives. Unfortunately, this specific functionality isn't available out of the box and needs to be implemented in conjunction with the PDFPorccessingLibrary.

You can find attached a sample project, in which different kinds of controls can be read from the PDF form. The algorithm then renders and sets the values of WebForms controls based on that. Ultimately, the values will be stored back into the PDF when the Save button impressed, after making changes to the controls.

Additionally, you might find the demos for client export and preview in the PDF Viewer, as well as the signature functionality, helpful as well, due to their offer of similar capabilities:

I hope this helps you out.

Regards,
Vasko
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

No answers yet. Maybe you can help?

Tags
PdfViewer UI for ASP.NET AJAX in ASP.NET MVC
Asked by
Al
Top achievements
Rank 1
Share this question
or