Aspose PDF From XML

When trying to use the importxml from the pdf libary I get a null pointer. I am currently just trying to run the example from

but even if I take the example line by line, I still get the error seen below.
I can’t seem to find any solution to the problem, and I hope you can help me.
image.png (31.9 KB)

Best regards
Malte

@MalteBukrinski

Could you please share your sample source files with us as well i.e. XML and PDF so that we can test the scenario in our environment and address it accordingly.

It should create the PDF by the last function
form.Save(Path.GetFileName(xml) + “_ImportDataFromXML_out.pdf”);

and the xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

@MalteBukrinski

The import XML functionality requires a particular format of XML. For example, a sample XML should look like following:

<?xml version="1.0" encoding="utf-8"?>
<fields>
  <field name="textfield">
    <value />
  </field>
  <field name="checkboxfield">
    <value>Off</value>
  </field>
  <field name="comboboxfield">
    <value />
  </field>
  <field name="listboxfield">
    <value />
  </field>
</fields>

The XML which you are using does not seem a correct format. Please modify it according to the sample template that we shared and let us know in case you still notice any issue.

It doesn’t work with any xml.
I keep getting the error on the picture above.
The error is regarding the Form call which doesn’t work. Not even on the example from your page

@MalteBukrinski

There seems an issue with the code snippet that is provided in the online documentation. ImportXml method works only with an existing form, it fills fields by their names. You need to use an existing PDF that has form fields with the same names in the XML template.

As far as the code example in the docs is concerned, we will surely rectify it and will inform you.

Is there a way to dynamically input an XML structure into PDF without having the PDF design. I have the XML’s and I need to export it into a PDF form.

Does one of your product support this?

@MalteBukrinski

In this case, you need to generate a different XML template that will generate a new PDF document from scratch. For more information, please check below articles in the documentation: