About the function of the AutoFiller in Java

We are using Aspose.Pdf (java), below is the version infomation:
=== version information begin===
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 1.4.2-b28 (Sun Microsystems Inc.)

Name: Aspose.Pdf.Kit for Java
Specification-Title: Aspose.Pdf.Kit for Java
Specification-Version: 2.0.0.0
Specification-Vendor: Aspose Pty Ltd
Implementation-Title: Aspose.Pdf.Kit for Java
Implementation-Version: 2.0.0.0
Implementation-Vendor: Aspose Pty Ltd
Copyright: Copyright 2005 Aspose Pty Ltd
Release-Date: 2008.02.01
=== version information end===

We use the AutoFiller to fill the Pdf form data. As the AutoFiller has been removed from 22.9.

If we upgrade the version to 23.4 or 23.5, is there a class to implement the function of the AutoFiller? That is, we should how to implement the same function that do with the AutoFiller. Or we can only upgrade to the version before 22.9 if we need upgrade the version?

thank you.

@QZL

AutoFiller class is not implemented yet and will be not implemented in nearest versions. Furthermore, we always recommend to use the latest version as it contains maximum fixes and the improvements. You can use other ways to fill the form data using the latest version of the API. For example:

Thank your reply.

Maybe the method [editor.importXml(new FileInputStream(_dataDir + “Sample-Form-01-upd.xml”));]
can meet our requirement.

Is there a example how to organize the data of the xml?

If we have below data, and want put them to three pages. (Refer to below figures), how we define the PDF template and how to organize the XML file with these data?

Ship_Country: Ireland
Order_Id	Freight
10298	168.22
10309	47.3
10335	42.11

Ship_Country: Poland
Order_Id	Freight
10374	3.94
10611	80.65

Ship_Country: Germany
Order_Id	Freight
10273	76.07
10285	76.83
10286	229.24
10313	1.96

image.png (11.4 KB)
secondPage.PNG (10.4 KB)
thirdPage.PNG (11.6 KB)

@QZL

In order to use the mentioned method, you need to form your XML like in this sample and PDF template should have form fields with the same names as specified in the XML file.

@asad.ali

I do a PdfTemplate (pdfTemplate.pdf) and organize the data as (Data1.xml, Data2.xml and Data3.xml) .

I can only get the first page (output.pdf) with below codes.

com.aspose.pdf.facades.Form form = new com.aspose.pdf.facades.Form(“pdfTemplate.pdf”);
form.importXml(“Data1.xml”);
form.save(“output.pdf”);
form.close();

Would you help check how to write the code to get the second, third… pages?

(these files, please refer to attachment “resource.zip”)

thank you.

resource.zip (52.0 KB)

@QZL

Please check the below code snippet and the attached output PDF and let us know if it still does not meet your requirements:

    private void ImportXML() {
        java.util.List<String> xmlFiles = new ArrayList<>();
        xmlFiles.add(dataDir + "Data1.xml");
        xmlFiles.add(dataDir + "Data2.xml");
        xmlFiles.add(dataDir + "Data3.xml");
        java.util.List<String> savedFiles = new ArrayList<>();
        com.aspose.pdf.facades.Form editor = new com.aspose.pdf.facades.Form();
        try {
            for(String file : xmlFiles) {
                editor.bindPdf(new Document(dataDir + "pdfTemplate.pdf"));
                editor.importXml(new FileInputStream(file));
                editor.save(file + ".pdf");
                savedFiles.add(file + ".pdf");
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        if(savedFiles.size() > 0)
        {
            Document doc = new Document();
            for(String file : savedFiles)
            {
                Document pdf = new Document(file);
                pdf.flatten();
                doc.getPages().add(pdf.getPages());
            }
            doc.save(dataDir + "finalDoc.output.pdf");
        }
    }

finalDoc.output.pdf (88.1 KB)

Thank you very much

That is we wanted.