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

Free Support Forum - aspose.com

Flatten/Print PDF with XFA and render into firefox browser using Aspose.PDF for .NET

I’m looking into using the Aspose.PDF for Java tool set to convert an XFA PDF into a PDF file that can open in a simple renderer, such as Firefox.

It seems that a file with underlying XFA renders at runtime, which doesn’t load in an application without XFA support.

-Flattened document and flattened document.form(). XFA still seems to be present and won’t render
-Converted form to standard Acroform. Breaks document structure that the XFA describes, but does load in Firefox.
-[EDIT] converting to XPS and back. XFA does not render at all.

What works so far:
-[EDIT] Converting to XPS and back does not actually work as expected.
-[EDIT] Manually using Adobe print to PDF option works as expected. Resulting file opens in Firefox and Edge

I’m hoping to find a more direct way to create a prerendered PDF document and that flattens the XFA.


Could you please share your sample PDF document with us. We will test the scenario in our environment and address it accordingly.

Sorry for the delay, I tried to get a version of the document without sensitive information but wasn’t able to, unfortunately.

What we are exploring now is using a print to file method to render the PDF. When the file is printed to file through the Adobe program, it renders perfectly in any viewer.

Is there a way to print an Aspose document to a pdf file?

-Used PdfViewer.save(""), but get the error “java.lang.UnsupportedOperationException: The method is not supported by this facade”
-Used PdfViewer with a PdfPrinterSettings with PrintToFile as true and PrintToFileName set, but resulting PDF file seems to be corrupted
-Tried to use PrintController, but couldn’t find the functionality to actually print.



Thanks for writing back.

Could you please try using following code snippet to print the PDF document to a file. In following code snippet, please use virtual printer e.g. Microsoft Print to PDF to print the document:

com.aspose.pdf.facades.PdfViewer viewer = new com.aspose.pdf.facades.PdfViewer();
com.aspose.pdf.printing.PdfPrinterSettings printerSettings = new com.aspose.pdf.printing.PdfPrinterSettings();
com.aspose.pdf.printing.PrintPageSettings pageSettings = printerSettings.getDefaultPageSettings();
viewer.printDocumentWithSettings(pageSettings, printerSettings);

In case you still face any issue, please feel free to let us know.