I just found one thing which might be helpful to resolve the issue.
By the way, I am asked by my company to evaluate Aspose.pdf for Java to see if our requirements can be met. Your help will be highly appreciated. Thanks in advance!
Hi Jeff,
Attached are the two XFA forms.
Hi Jeff,
Thanks for sharing the input files.
As we are familiar that contents inside XFA form are created during PDF file loading, so in order to merge XAF forms, we need to first convert XFA forms to standard AcroForm and then try concatenating these resultant files. However during my testing, I have observed that contents in resultant/merged file get garbled. For the sake of correction, I have logged it as PDFJAVA-36158 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.
[Java]
// Load first XFA form
com.aspose.pdf.Document doc1 = new com.aspose.pdf.Document("c:/pdftest/B6I.pdf");
// Convert XFA form to standard AcroForm
doc1.getForm().setType(com.aspose.pdf.FormType.Standard);
// Load second XFA form
com.aspose.pdf.Document doc2 = new com.aspose.pdf.Document("c:/pdftest/B6J.pdf");
doc2.getForm().setType(com.aspose.pdf.FormType.Standard);
// Add pages from the second form to the pages collection of the first document
doc1.getPages().add(doc2.getPages());
// Save the resultant concatenated file
doc1.save("c:/pdftest/ConcatenatedFile.pdf");
Hello,
Based on our requirement, we want to merge two flattened pdf files. We don’t want to merge two XFA forms. It seems that you went to a different direction. You may check the difference between a flattened pdf file and a normal pdf file, which is the reason to failed the merge.
Below are my observations based on my test.
-
Aspose.pdf for Java can merge two normal pdf files perfectly. As to normal pdf files, I mean that they are created as a pdf file directly. Say, I create a .docx file and then save it as a pdf type.
-
Aspose.pdf for Java can flatten an XFA form to a plain pdf file perfectly.
-
Aspose.pdf for Java cannot correctly merge two flattened files which are the resultant files from #2 above.
Therefore, you may check the differences (say, metadata difference, etc.) between a normal plain pdf file and a flattened pdf file.
If there is a difference, you may fix it when flattening the XFA forms into a plain pdf file.
Thanks.
Jeff
Hi,
I double-checked with the development team about the requirement. They also need to merge the XFA forms to a single XFA form first and then flatten it to pdf or pdfa. So your approach to fix the issue is still valid.
Thanks.
Jeff
Nayyer,
Our immediate requirement is below.
Step 1: First flatten XFA forms to normal plain pdf files.
Step 2: Then merge these normal plain pdf files into a single normal plain pdf file.
Please consider this use case first when you start to find a solution.
As to step 1 above, the plain pdf files flattened from an XFA forms look fine when being checked by eyes. All the data is correct. I tried to merge them using iText, the error message shows that these are not valid pdf files. So you may need to check what is wrong with the flattened plain pdf file, maybe in the metadata level.
Thanks.
Jeff
Hi Jeff,jeffguo:Nayyer,Our immediate requirement is below.
Step 1: First flatten XFA forms to normal plain pdf files.
Step 2: Then merge these normal plain pdf files into a single normal plain pdf file.
Please consider this use case first when you start to find a solution.
As to step 1 above, the plain pdf files flattened from an XFA forms look fine when being checked by eyes. All the data is correct. I tried to merge them using iText, the error message shows that these are not valid pdf files. So you may need to check what is wrong with the flattened plain pdf file, maybe in the metadata level.
Nayyer,
I understand what you mean.
I try to clarify our two use cases here.
- Flatten an XFA form to a plain pdf file which is NOT an acro form. This can be successfully done by the flattenAllFields() method in the Form in Aspose.pdf for Java.
But I have a question here. What is the difference between a normal plain pdf file and a flattened plain pdf file? The reason to ask is that Aspose.pdf for Java can successfully merge two normal plain pdf files, but failed to merge two flattened plain pdf files.
- Merge multiple plain pdf files into a single plain pdf file. In this case, the input pdf files are the flattened pdf files created in the use case 1 above.
Basically, we do NOT have the use case to merge two XFA forms into a single Acro forms.
Thanks.
Jeff
Hi Jeff,
Thanks for your patience.
The plain PDF file is normal PDF document which do not contain and Form field or form fields appear as flattened (labels instead of fields) and when using following code snippet to first flatten PDF forms and then concatenating them into single resultant file, I have observed that contents/field data for second documents is missing. We will also consider this scenario during the resolution of earlier reported issue.
[Java]
com.aspose.pdf.facades.Form form1 = new com.aspose.pdf.facades.Form();
form1.bindPdf("c:/pdftest/B6I.pdf");
form1.flattenAllFields();
form1.save("c:/pdftest/B6I_Flattened.pdf");
com.aspose.pdf.facades.Form form2 = new com.aspose.pdf.facades.Form();
form2.bindPdf("c:/pdftest/B6J.pdf");
form2.flattenAllFields();
form2.save("c:/pdftest/B6J_Flattened.pdf");
com.aspose.pdf.facades.PdfFileEditor editor = new com.aspose.pdf.facades.PdfFileEditor();
editor.concatenate("c:/pdftest/B6I_Flattened.pdf", "c:/pdftest/B6J_Flattened.pdf", "c:/pdftest/Flattened_Merged.pdf");
Yes, as I reported earlier, the field data are missing in the second flattened file. This issue has the highest priority among all the issues I have reported so far. I hope you guys can resolve this issue first and as soon as possible. This issue will be a blocker for us to make a decision on purchasing Aspose.pdf for Java.
Thanks in advance!
Jeff
Hi Jeff,
Hello,
Good morning!
Is it possible to resolve the merging file and the filling XFA form issues within this week? On Oct 3, I have to do the demo on our listed requirements. These two issues are critical.
Thanks in advance!
Jeff
Hi Jeff,
for what it’s worth, i’ve also been asked to evaluate aspose pdf and ran into the same issue. i have 1 filled and flatted xfa form and appending a page to the document doesn’t work.
Hi Sean,shinkley:for what it’s worth, i’ve also been asked to evaluate aspose pdf and ran into the same issue. i have 1 filled and flatted xfa form and appending a page to the document doesn’t work.
Hi Nayyer, I can see about creating a simple form to highlight the problem for you. However, it is the same issue as described by Jeff above. Do you have any status on resolution for his issue?
Hi Sean,
Do you have a sample code to merge two XFA forms into a single XFA form using the iText Core API (Not XFA Worker API)? If so, could you share? So I can use the iText core API to merge two XFA forms and then use Aspose.pdf to flatten the merged XFA form. Thanks in advance!
Jeff