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

Free Support Forum - aspose.com

Flatten all PDF fields

ttt.pdf (52.1 KB)
Hello, our dev team has been utilizing Aspose.Total for a while now and recently also purchased the Conholdate package.

Our application allows uploading of PDF and in the past, we’ve flattened form fields using the Aspose.Pdf.Facades.Form() > FlattenAllFields() method. This routine seems to only flatten form fields however. We also tried the Aspose.Pdf.Document() > Flatten() method and it seems to only flatten form fields as well. The new guideline we have now is we need to flatten all fields (similar to flattening through the “Microsoft Print to PDF” method) including regular text fields, image fields, etc. I’ve attached a test PDF with two simple text fields (with text “Test Signature2” and “Test Signature”) that we need to flatten as an example. Is there a way to accomplish this through Aspose? Thank you!


I request you to share expected output file with flatten fields.

Hello, we need to achieve the same output that Microsoft does using the “Microsoft Print to PDF” printer. I have attached the same document run through the Print to PDF process. They visibly look the same, but Print to PDF version does not get flagged by the agency for having “Fillable fields”.

Thank youttt_printtopdf.pdf (43.1 KB)


You can print the PDF file with Microsoft Print to PDF with following code and share your feedback.

using (Aspose.Pdf.Facades.PdfViewer pdfViewer = new Aspose.Pdf.Facades.PdfViewer())
    pdfViewer.BindPdf(dataDir + "signed.pdf");
    System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
    ps.PrinterName = "Microsoft Print to PDF";
    ps.Copies = 1;

Hi, this works as far as flattening the PDF but after invoking pdfViewer.PrintDocumentWithSettings() and pdfViewer.Close(), looks like the PDF is in use for a while. Bigger the PDF file, longer it is in use. Therefore with bigger PDFs, it is giving us the “The process cannot access the file ‘####.pdf’ because it is being used by another process.” error. If we put something like Threading.Thread.Sleep(5000) right after pdfViewer.Close(), the file is released but this is not a viable option for us (or a good coding practice). Is there a way to ensure the file is fully released after pdfViewer.PrintDocumentWithSettings() and pdfViewer.Close() so we have access to the PDF in the same routine? Thank you.


To avoid this problem, the issue with Flatten() function needs to be investigated. A ticket with ID PDFNET-50334 has been created in our issue tracking system to further investigate the issue on our end. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Thank you. Just to make sure you guys fully understood our last reply, the flattening of the PDF part works, it is just that the PDF is not released right away therefore cannot access the file right away by the code.


We understand your reply and that is probably due to Microsoft Print to PDF file handling as the printing is carried out by it. We will let you know as soon as the logged issue will be fixed.

Hello. Any update on this?

Also, we have noticed that performance is terrible when using this method (running through Microsoft Print to PDF using Aspose.PDF PdfViewer and PrinterSettings etc). Is there anything that can be done to improve performance with this process? We are using similar code to what you posted above, but, especially with large pdfs, the process can take up to 10 minutes, which is not acceptable. It does not take that long to print these documents with the actual Microsoft Print to PDF printer. Any suggestions?




We regret to share that the ticket has not been yet resolved. Furthermore, we already have logged an issue as PDFNET-50987 regarding performance issue during printing. We have linked the ticket ID with this thread as well so that you will receive a notification as soon as it is resolved. We will inform you once we have certain updates about issues resolution. Please spare us some time.

We are sorry for the inconvenience.