We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Issues with flattening a PDF

Hi, I’m evaluating the Aspose PDF/Java library. I have a need to convert PDF’s for archiving (PDF/A, flattened forms, etc). The library seems to be doing most of what I need, but I’m having issues with a few documents. I’ve attached one that has about 20 pages of forms. The curious thing is that the vast majority of the document is flattened with no issues, however the forms on the first page seem to have lost some of their values.

I tried calling Form.flattenAllFields() per the documentation, as well as grabbing all the fields, iterating through them and calling Form.flattenField() directly (which flattenAllFields() probably does internally).

Another potential problem is performance. The flattening process is really slow. I don’t know if there are some ways to speed this up. I was thinking of getting the field list then calling Form.flattenField() using multiple threads, I just don’t know if the API can handle concurrent flattenField calls.

Hello, any update on this issue?

Hi Erich,


Thanks for using our API’s and sorry for the delayed response.

I have tested the scenario using following code snippet with Aspose.Pdf for Java 10.4.1 in Eclipse Juno project with JDK 1.7, running over Windows 7 (x64) and I am unable to notice any issue. As per my observations, the conversion process is completed within 3 seconds and all the values are preserved in resultant file.

[Java]

com.aspose.pdf.Document d = new
com.aspose.pdf.Document(
“C:\pdftest\sourceForm.pdf”);<o:p></o:p>

d.getForm().flatten();

d.save(“c:/pdftest/source_Flattened.pdf”);

Hi, Thanks for getting back to me. I tried your call and yes it works much faster. However it does not actually flatten the fields. I can still edit them in the document. I’m using your Form facade class, per your documentation. This does in fact, flatten the vast majority of the fields in the doc, but with the issue I originally described. The tables on the first page seem to lose their values. And doing it this way is in fact much slower, presumably because the work is actually being done.

        Form pdfForm = new Form();
pdfForm.bindPdf(“input.pdf”);
pdfForm.flattenAllFields();
pdfForm.save(“output.pdf”);



Hi Erich,


Thanks for sharing the feedback.

Please note that Document class is recommended approach and it has better performance as compared to Aspose.Pdf.Facades namespace. However I am unable to notice any issue (unable to edit values in resultant form field) when viewing document in Adobe Reader.

Can you please take a look over attached PDF file and share the areas (section and page number) where you are able to edit form field values.

We are sorry for this inconvenience.

Hi, I’ve been able to download your file, it may be uneditable in Reader, but I am able to edit it in Acrobat Pro. When I use the facade Form class, most of the fields are uneditable as expected even in Acrobat Pro, but there’s the ‘corruption’ with one of first forms. I’ve attached two screenshots. One is your file, where I was able to select the dropdown in the ‘Basis’ column, which I shouldn’t be able to. The second, showing an opened 'flat3.pdf is the same as my original attachment. As you can see, say ‘Basis’ is uneditable, as expected, however the ‘Percentage of Time’ column has lost its value.

Hi Erich,


Thanks for your feedback. I have tested the scenario with both facade(com.aspose.pdf.facades) and generator package(com.aspose.pdf). I have noticed the reported issues and logged in our issue tracking system as following. We will notify you as soon as these are resolved.

PDFNEWJAVA-35027: Missing field values in flatten output of facade package.
PDFNEWJAVA-35028: Performance issue in facade package.
PDFNEWJAVA-35029: com.aspose.pdf package does not flatten form fields.

We are sorry for the inconvenience caused.

Best Regards,

Hi is there an update on when these issues will be fixed. We are trying to make a final decision and I need at least the 35027 fixed in order to move forward.

Hi Erich,


We will surely fix the previously reported issues but as the we recently have noticed these problems, the product team requires little time to investigate and figure out the actual reasons behind these issues. Nevertheless, the team is currently busy fixing other previously reported issues and once these problems are resolved, they will start working over these problems.

As soon as we have some definite updates, we will let you know.

Hi Erich,


Thanks for your inquiry. As we have recently noticed the issue, it is still pending for investigation in the queue. We schedule issue investigation and resolution on first come first serve basis. We feel this is the fairest and most appropriate way to satisfy the needs of the majority of our customers.

However, we have recorded your concern and requested to our product team if they can investigate PDFNEWJAVA-35027 and share an ETA. We will notify you as soon as we get a feedback


Thanks for your patience and cooperation.


Best Regards,

Hi, any updates on this?

Hi Erich,


Thanks for your inquiry. Our team has investigated the PDFNEWJAVA-35027 and found the fields are XFA fields are not being rendered properly. We have noticed that issue is being inherited from Aspose.Pdf for .NET, so we have logged an internal issue to fix it in .NET version first. So later its fix will be ported to Java version. We will keep you updated about the issue resolution progress.

Thanks for your patience and cooperation.

Best Regards,

Hello, is there an ETA on the resolution of this issue. It’s kind of a deal-breaker for us at the moment.

Hi Erich,


Thanks for your patience.

Please note that as a normal rule of practice, issues are resolved in first come first serve basis as we believe its the fairest policy with all the customers. Therefore the team is currently busy fixing the previously reported issues. However in account of urgency and criticallity of these issues, I have shared your concerns with development team. As soon as we have some further updates, we will let you know.

Hello, following up on this again? Is there an ETA for resolution?

Hi Erich,


Thanks for your patience.

The team is still working on fixing earlier reported issues but since their resolution is dependent upon fixes in Aspose.Pdf for .NET, so the team is busy resolving problems in Aspose.Pdf for .NET and same resolution will then be ported to Aspose.Pdf for Java. Also please note that manipulation of XFA forms is a complex scenario, so we need little time to resolve these issues. As soon as we have some further updates, we will let you know.

Hi Erich,


Thanks for your patience. In reference to PDFNEWJAVA-35029, please note the method d.getForm().flatten() should not used for the Dynamic XFA Forms.The Facades should be used instead. As the method (d.getForm().flatten()) does not flatten Dynamic XFA Forms, however the Facades package converts Dynamic XFA Forms and flatten.

Please feel free to contact us for any further assistance.

Best Regards,

I am using the facades as described earlier in the thread. Has the issue been fixed? Which release? I’m currently on 10.6.2 and still see the problem

Hi Erich,

Thanks for your patience.

The team started investigating the earlier reported issues but due to complexity of these issues, they are not yet resolved. However when using source_Flattened.pdf file (for which an issue PDFNEWJAVA-35029 was logged), please try using following code snippet as during my testing with Aspose.Pdf for Java 10.8.0, the output is properly being generated. For your reference, I have also attached the output generated over my end.

[Java]

com.aspose.pdf.facades.Form pdfForm = new
com.aspose.pdf.facades.Form();

pdfForm.bindPdf(“c:/pdftest/source_Flattened.pdf”);

pdfForm.flattenAllFields();

pdfForm.save(“c:/pdftest/source_Flattened_Fac.pdf”);
<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>ZH-TW</w:LidThemeAsian>
<w:LidThemeComplexScript>AR-SA</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
<w:UseFELayout/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

<![endif]–>

The issues you have found earlier (filed as PDFNEWJAVA-35028) have been fixed in Aspose.Pdf for Java 11.0.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.