Export form to PDF read-only

Hi,

I’m exporting an HTML form (with input tags, select, etc.) to PDF. Unfortunately, also in PDF, the form stays a form, i.e. I can enter values or select from a dropdown. In my case, this is counter-productive, because we intentionally use PDF as an immutable snapshot for evidence reasons. Is there a way to suppress the form-functionality in PDF, i.e. make everything pure text or at least read-only form elements?

Yes, I know, that I could manipulate the HTML before exporting. But this is not an option in this case, because it is a generic approach for many different forms.

Thanks in advance for your help!

@jscharr

Would you please share your sample HTML file in .zip format for our reference? We will investigate the possibility to export it to flattened PDF document and share our feedback with you.

I cannot give you the original file due to compliance reasons. But the attached file will do, too.SampleHtmlForm.zip (423 Bytes)

@jscharr

We have logged a ticket as HTMLNET-4084 in our issue tracking system to analyze the feasibility of this requirement. We will look into its details and keep you posted with the status of its resolution. Please be patient and spare us some time.

@jscharr

We will add in version 22.11.0 the ability to replace interactive form elements with their rendered versions.

Cool. Thanks.

@jscharr

We have added a new option “FormFieldBehaviour” with which you can get the desired behavior. An example of its use is shown in the following code snippet:

// Prepare a path to a source HTML file
string documentPath = Path.Combine(dataDir, "SampleHtmlForm.html");

// Prepare a path for converted file saving 
string savePath = Path.Combine(dataDir, "document.pdf");

// Initialize an HTML document from the file
using Aspose.Html.HTMLDocument document = new Aspose.Html.HTMLDocument(documentPath);

var options = new Aspose.Html.Saving.PdfSaveOptions()
{
    HorizontalResolution = 200,
    VerticalResolution = 200,
    JpegQuality = 100,
    // Flatten all form fields
    FormFieldBehaviour = FormFieldBehaviour.Flattened
};

// Convert HTML to PDF
Aspose.Html.Converters.Converter.ConvertHTML(document, options, savePath);

In the resulting PDF document, all form fields will be pre-rendered and therefore not editable. This option will be available in release 22.11.0.

Wow, thanks a lot!

The issues you have found earlier (filed as HTMLNET-4084) have been fixed in this update. This message was posted using Bugs notification tool by avpavlysh