HTML conversion to PDF: form values get lost

Hello!

Using Aspose.Words I convert HTML to PDF, but since 24.8 some form values are missing in the converted PDF.
Attached is the input html and converted PDFs (24.7 and 24.9) to compare the results: htmlToPdfFormValueLost.zip (146.5 KB)

Kind regards!

@dvtdaten Unfortunately, I cannot reproduce the problem on my side using the following simple code:

Document doc = new Document("C:\\Temp\\in.html");
doc.save("C:\\Temp\\out.pdf");

Here is output produced on my side: out.pdf (75.5 KB)

Hello Alexey!

I checked my code and I think the updating the fields (for the inserting of page numbers) causes the problem:

if (document.getPageCount() > 1) {
    DocumentBuilder builder = new DocumentBuilder(document);
    builder.moveToHeaderFooter(HeaderFooterType.FOOTER_PRIMARY);

    builder.getFont().setName("Arial");
    builder.getFont().setSize(10);

    builder.insertField("PAGE", "");
    builder.write(" / ");
    builder.insertField("NUMPAGES", "");
    builder.getParagraphFormat().setAlignment(ParagraphAlignment.RIGHT);

    document.updateFields();
}

@dvtdaten It is not required to call Document.updateFields explicitly when saving the document to PDF. By default fields are updated automatically while rendering the document.
If you still need to update fields explicitly, you can lock forma fields to avoid updating them:

Document doc = new Document("C:\\Temp\\in.html");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToHeaderFooter(HeaderFooterType.FOOTER_PRIMARY);

builder.getFont().setName("Arial");
builder.getFont().setSize(10);

builder.insertField("PAGE", "");
builder.write(" / ");
builder.insertField("NUMPAGES", "");
builder.getParagraphFormat().setAlignment(ParagraphAlignment.RIGHT);

// Lock form fields.
for (Field f : doc.getRange().getFields())
{
    if (f.getType() == FieldType.FIELD_FORM_TEXT_INPUT)
        f.isLocked(true);
}
doc.updateFields();

doc.save("C:\\Temp\\out.pdf");

Thank you, that helps.
In my case it is necessary due to PDF/A-2 conversion (HTML to PDF/A2 : missing page numbers).

Kind regards

@dvtdaten In this case simply lock form fields to exclude them from field updating process.