Dynamic form to static issue

License license = new License();
license.setLicense("Aspose.Pdf.lic");
Document document = new Document("test.pdf");
document.getForm().setType(FormType.Standard);
document.save("test2.pdf");

exception :

Exception in thread “main” java.lang.NullPointerException
at com.aspose.pdf.internal.p60.z2.(Unknown Source)
at com.aspose.pdf.internal.p60.z4.m1(Unknown Source)
at com.aspose.pdf.internal.p61.z1.m4(Unknown Source)
at com.aspose.pdf.internal.p63.z38.m1(Unknown Source)
at com.aspose.pdf.internal.p63.z3.m1(Unknown Source)
at com.aspose.pdf.internal.p63.z3.m1(Unknown Source)
at com.aspose.pdf.internal.p63.z3.m1(Unknown Source)
at com.aspose.pdf.internal.p63.z38.m1(Unknown Source)
at com.aspose.pdf.z354.m1(Unknown Source)
at com.aspose.pdf.z354.m1(Unknown Source)
at com.aspose.pdf.z388.m1(Unknown Source)
at com.aspose.pdf.z388.m1(Unknown Source)
at com.aspose.pdf.z388.m1(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z17.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z11.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z11.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z11.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z11.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z11.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z11.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z11.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z11.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
at com.aspose.pdf.internal.foundation.rendering.z31.accept(Unknown Source)
at com.aspose.pdf.ApsToPdfConverter.m1(Unknown Source)
at com.aspose.pdf.Form.m1(Unknown Source)
at com.aspose.pdf.Form.setType(Unknown Source)

attached the test.pdf

test.pdf (1.9 MB)

@tsuncp

Thanks for contacting support.

We have managed to replicate the same issue, while testing the scenario with Aspose.Pdf for Java 17.8. Hence, we have logged an issue against ticket ID PDFJAVA-37075 in our issue tracking system. We will further investigate the reasons behind this issue and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

and also can you confirmed if the file can be filled with xml

com.aspose.pdf.facades.Form form = new com.aspose.pdf.facades.Form();
form.bindPdf("test.pdf");
java.io.FileInputStream xmlInputStream = new FileInputStream("data35.xml");
form.importXml(xmlInputStream);
//        form.importXfdf(xmlInputStream);  both not work
xmlInputStream.close();
form.save("result.pdf");
form.dispose();

data35.zip (602 Bytes)

I have uploaded the xml file. I can import the xml file using acrobat or itext, however I cannot import the data using the above code

@tsuncp

Thanks for writing back.

I have tested the scenario with Aspose.Pdf for Java 17.8 and observed that form fields were filling by importing the XML file. For your reference, I have attached a copy of generated output over our end along with the screenshot, showing a field value before/after of the XML import.

Import_XML.png (11.4 KB)
dynamictest_output.pdf (1.8 MB)

In case if you are experiencing any issue at your end, please share some more details by highlighting the differences between input/output files, so that we can test the scenario again in our environment and address it accordingly.

Can you provide the code. Thanks

@tsuncp

Thanks for writing back.

Please check following code snippet, which is almost similar to what you have shared earlier.

com.aspose.pdf.facades.Form form = new com.aspose.pdf.facades.Form();
form.bindPdf(dataDir + "dynamictest.pdf");
java.io.FileInputStream xfdfInputStream;
try {
	xfdfInputStream = new java.io.FileInputStream(dataDir + "data35.xml");
	form.importXml(xfdfInputStream);
	xfdfInputStream.close();
	form.save(dataDir + "dynamictest_output.pdf");
	form.dispose();
} catch (IOException e) {
	System.out.println(e.getMessage());
}

I still cannot import the xml file
Environment :

java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

javac 1.8.0_144

Windows 10

uploaded whole test project for your reference

https://drive.google.com/open?id=0BwQCHl5ENPlLdC1VZEQwckUxVVk

And also may I ask the process of my first issue

@tsuncp

Thanks for sharing a sample project.

We have managed to replicate the same issue in our environment and for the sake of correction, we have logged it under the ticket ID PDFJAVA-37114 in our issue tracking system. We will further investigate the issue and keep you posted with the status of its correction.

I would like to share with you that our product team has started the investigation against earlier logged issue and as soon as we have some definite updates, regarding its resolution, we will update you within this forum thread. Please be patient and spare us little time.

We are sorry for the inconvenience.