We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Wrong control type in generated fillable PDF

Converting HTML to PDF with tag in .NET. While creating, the control is correctly generated as Aspose.Pdf.Forms.NumberField. Once the PDF is saved, I open it again and iterate through Document.Form.Fields collection. Now the field appears to be Aspose.Pdf.Forms.TextBoxField. What am I doing wrong?

Sample code:
var ms = new MemoryStream();
var writer = new StreamWriter(ms);
writer.WriteLine("<input name=“myNumber” type=“number”/>");
writer.Flush();
ms.Position = 0;

        HtmlLoadOptions options = new HtmlLoadOptions();
        var createDocument = new Document(ms, options);
        var createFields = createDocument.Form.Fields;
        foreach (var field in createFields)
            Console.WriteLine(field.PartialName + ": " + field.GetType().FullName);
        createDocument.Save("file.pdf");

        var readDocument = new Document("file.pdf");
        var readFields = readDocument.Form.Fields;
        foreach (var field in readFields)
            Console.WriteLine(field.PartialName + ": " + field.GetType().FullName);

Output:
myNumber: Aspose.Pdf.Forms.NumberField
myNumber: Aspose.Pdf.Forms.TextBoxField

Funny thing, <input id=“myCheckbox” type=“checkbox”> works correctly…
myCheckbox: Aspose.Pdf.Forms.CheckboxField
myCheckbox: Aspose.Pdf.Forms.CheckboxField

Note though that here I have to use id and not name, it won’t recognize name, same it won’t recognize id when type is anything but checkbox.

@vladigubler

Can you please also share the PDF file generated at your end so that we can compare it with our results in our environment and address it accordingly?

Here you go file.pdf (71.4 KB)

Note that I changed the HTML slightly to make the field visible in PDF reader:

<html><body><input name=\"myNumber\" type=\"number\"/></body></html>

It makes no difference in terms of functionality.

@vladigubler

We are checking it and will get back to you shortly.

@vladigubler

We tested the scenario with 23.1 version of the API and both times it returned myNumber: Aspose.Pdf.Forms.TextBoxField as output. The API is converting Number Fields into Textbox. Can you please try using 23.1 at your end and let us know about the results you are getting?

It shows TextBoxField when opening, same as before.

Again, just so we are on the same page. <input type=“checkbox”/> and <select> both work fine. The issue is only with <input type=“number”/> and <input type=“date”/>. I didn’t check any other types.

@vladigubler

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-53579

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.