Free Support Forum - aspose.com

Form.exportXml not working

Hi,
When I am running following code (where test.pdf is any pdf file):

import com.aspose.pdf.kit.;

import java.io.
;

public class converter {

public static void main(String[] args) throws Exception {

Form f = new Form ("/home/sriniv/test.pdf");

try {

f.exportXml ("/tmp/test.xml");

} catch (Exception e) {

e.printStackTrace();

}

f.close();

}

}


I am getting following error:
java.lang.NullPointerException
at com.aspose.pdf.kit.Form.exportXml(Unknown Source)
at com.aspose.pdf.kit.Form.exportXml(Unknown Source)
at converter.main(converter.java:20)
Is this function working for anyone or do I have to change version of kit

giving null pointer exception for all PDF files!!

Hi Chaitanya,

Please share the input PDF and XML files with us, so we could investigate the issue at our end. You’ll be updated with the results accordingly.

We’re sorry for the inconvenience.
Regards,

As I mentioned before the function is not working with any PDF (very simple ones)!!
A empty XML file is generated (0 bytes).

Hi Chaitanya,

I have tested this issue at my end and noticed that this exception is only thrown in case the PDF file doesn’t contain any form fields. If the PDF contains the form fields the output XML file is produced successfully. However, I have logged an issue as PDFKITJAVA-28106 in our issue tracking system. Our team will investigate it and we’ll try to make sure that no exception is thrown even if the PDF file doesn’t contain any form fields. In the meanwhile, you may try using the other PDF files with form fields.

We’re sorry for the inconvenience.
Regards,

Hi,
How do I convert simple PDFs (say with text and images only) to XML files, so that I can later convert it to HTML?

Hi Chaitanya,

I would like to share with you that exportXml method only allows you to export form data to an XML file. I’m afraid, Aspose.Pdf.Kit doesn’t allow you to export or convert the whole PDF to XML. Do you want to convert the PDF into some specific form of XML? Are you referring to MARS here? Please share your requirement in detail, so we could guide you accordingly.

We’re sorry for the inconvenience.
Regards,

Hi Shahzad,
We need a tool which can convert PDF documents to HTML files with reflowable content. I am aware that this is quite an open ended project, but I am checking for existing converters which can do the work. Most of them create HTML which do not have free flow property. Even if Aspose doesn’t provide such an API, can you tell me what can be achieved currently (such as Form.exportXml). It need not serve all the purposes, even if it can do small tasks , we can probably integrate or use it.
And I really appreciate your quick responses.

Thanks
T Srinivasa Chaitanya

Hi Chaitanya,

Currently, Aspose.Pdf.Kit for Java allows you to export different types of data to XML or text files. For example, you can export form data to XML. You can also export annotations and bookmarks. It also allows you to extract text to a text file; this text is in raw format though. You can also extract images separately. Please see if these features can help you. I’m not quite sure if you can get all the individual objects in order to construct HTML of the PDF file like this.

However, we have already logged two new feature requests as shown below:

PDFKITJAVA-14492 - Support PDF to PDFXML (Mars) Conversion
PDFKITJAVA-13730 - Convert PDF to HTML

Nevertheless, these features might not be available in short time. We’ll notify you via this forum thread once these features are supported in future.

We’re sorry for the inconvenience.
Regards,