Convert PDF with form fields to HTML form?

I am using Aspose.PDF for .NET and need to convert some PDF forms to HTML.


I am able to convert a PDF (such as the IRS 1040 form available online at https://www.irs.gov/pub/irs-pdf/f1040.pdf), but it is a read only HTML page. I cannot type into the various textboxes or check the checkboxes that are present in the PDF form.

Is there someway to configure Aspose.PDF to preserve these user inputs when converting from PDF to HTML?

If not, is there any other product (Aspose or somewhere else) that offers this functionality?

Thanks

Hi Scott,

Thanks for your inquiry.

You can fill PDF form fields before converting PDF into HTML by Aspose.Pdf for .NET. This way, values of the fields will be preserved after converting to HTML. Please check following code snippet where I have filled the PDF which you have shared and converted it into HTML.

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(dataDir + “f1040.pdf”);

string[] names = pdfDocument.Form.XFA.FieldNames;

pdfDocument.Form.XFA[names[0]] = "Field 0";

pdfDocument.Form.XFA[names[1]] = "Field 1";

pdfDocument.Save(new MemoryStream());

HtmlSaveOptions htmlOptions = new HtmlSaveOptions();

pdfDocument.Save(dataDir + "HtmlOut.html", htmlOptions);

For your reference, I have also attached an output generated by above code snippet. For more information regarding filling form fields, please check “Working with XFA Forms” article in API documentation, as the PDF which you have shared, contains XFA Form Type. In case of any further assistance, please feel free to contact us.

Best Regards,

Thanks for the reply, but that’s not what I need to be able to do.


I need the form fields in the HTML document so that someone can enter the values into the form fields from their browser.

Is it possible to save a PDF that has form fields as an HTML document with corresponding form fields in the HTML document?

Hi Scott,


Thanks for sharing more details.

We have already logged an enhancement ticket as PDFNET-35415 in our issue tracking system for requested feature. We will further look into this and keep you informed once feature is added. Please be patient and spare us little time. We are sorry for the inconvenience.


Best Regards