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

Free Support Forum - aspose.com

Flattern Annotation is not working

Hi Guys
I have attached a sample document for which im trying to flatten all the annotation in the document using
Method A:
'Dim pdfForm As New Aspose.Pdf.Facades.Form()
‘’ Open Document
‘’ Flatten fields

        '    pdfForm.Save(pSourceFile)

Method B:

Dim annotationEditor As New PdfAnnotationEditor()
’ Open Document
annotationEditor.Document.OptimizeSize = True
’ Save output


Neither of these methods produce the desired result…all the annotations remain editable

What am I missing

(PS would like to include sample doc but there does not seem to be a way to upload documents)

Using Aspose 17.5 Win 10 64

Hello Andre,

Thanks for contacting support.

You can definitely upload document(s) with your post. Earlier, there was an issue in attaching file(s) with new post but now it has been fixed and you should be able to upload file(s) with your post. Please check following attached screenshot which shows the upload option.

Add_Attachment.png (5.2 KB)

Please use this option to attach your sample document and in case if you still face any issue, please inform us, so that we can fix this for you.

Best Regards,
Asad Ali

Unfortunately I still carnt attach files to be able to demonstrate the issue and whilst i appreciate your replay i was unable to view the “Add_Attachment.png”

The error was
“Sorry this file is private. Only visible to post creator and staff members”

Can we get this sorted please


Thanks for contacting support.

We are further looking into this matter and will get back to you soon. Meanwhile I have uploaded the file to dropbox and you ca get its copy from this link.

We are sorry for this inconvenience.

Ahh I see please find attached offending file. Could this please be looked at urgently
My problem is now that the upload limit is to small… the file is 9 meg and wont reduce much if it is zipped


Thanks for writing back.

I am unable to see any attachment/file attached with your post. Would you please make sure that you are uploading the file correctly. In case if you are facing issue in uploading attachment(s), please upload them to some public file hosting service (e.g dropbox) and share the link here. We will investigate the scenario and address it accordingly.

In case if your file is of large size, you can split it into low volumes archives with WinRAR utility and upload all parts with your post.

We are sorry for your inconvenience.

Best Regards,
Asad Ali

Ok ill try the dropbox link option…thanks for your suggestion



Thanks for sharing sample document.

I have tested the scenario using DOM approach with Aspose.Pdf for .NET 17.6 and was unable to notice the issue which you have mentioned. Please check following code snippet which I have used to flatten the annotations. For your reference, I have also attached an output generated by below code.

Dim doc As New Document(dataDir + "738676.pdf")

For Each p As Page In doc.Pages
	For Each an As Annotation In p.Annotations
doc.Save(dataDir + "738676_Flat_out.pdf")

Please note that we always encourage to use DOM (Document Object Model) approach with latest version of the API. Please download latest version of the API and use above approach to flatten the annotations. In case of any further assistance, please feel free to contact us.

Output: 738676_Flat_out.pdf

Best Regards,
Asad Ali

Hmm that is very interesting…Thank you very much for progressing this issue did you use the approaches I took as these have worked for me without issue on other documents.
The difference in this case is that this document has bookmarks…thats all i can put it down to.
Please try and replicate the issue using the code sample i provided …you should find that the document annotations remain editable

PS I should add that the approach i took is in line with the documentation that is provided and also matches some of the sample code offered on your web site

PS 2 :wink: I am also using 17.6 and the documentation still offers this as the suggested methodology
The below is a snip from Aspose PDF online documentation which refers to a method of deleting annotations…I can find the one that refers to 'Flattening" annotations but it was similar

// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Annotations();
// Open document
PdfAnnotationEditor annotationEditor = new PdfAnnotationEditor();
annotationEditor.BindPdf(dataDir+ “DeleteAllAnnotations.pdf”);
// Delete specific annoations
// Save updated PDF
annotationEditor.Save(dataDir + “DeleteSpecificAnnotations_out.pdf”);


Thanks for writing back.

Yes I have used the methods which you have shared earlier but they were not working on the document. Sometimes issues are used to be document specific and we have to make sure that if issue is reproducible using latest version of the API and recommended method of the API, which is using DOM approach.

Moreover, please note that Aspose.Pdf.Facades is an old model and soon it is going to be obsoleted, which is why we always recommend to use DOM (Document Object Model) approach which is more flexible and enhanced.

The method which you have mentioned is Facades API based and is used to delete annotations inside PDF document, whereas you wanted to flatten all annotations inside PDF which is different than deleting them.

As shared above, the recommended way to flatten the annotations is by using new Aspose.Pdf DOM approach and in case you face any issue with this approach, please share your sample document, so that we can try to replicate the issue in our environment and address it accordingly.

Best Regards,
Asad Ali

Thank you Ali but you are not addressing my issue.
Firstly, whilst the above example is about deleting annotation (I understand the difference between deleting and flattening and I dont appreciate the tone of your reply) here is the code example as it appears in the current version Aspose documentation. (I stress the word current)
We have paid aprox A $10,000 to use Aspose product and i expect my issue to addressed and not to be lectured and how i should do something especially as the documentation clearly shows the below method for flattening annotations in a document.

[C#]PdfAnnotationEditor editor = new PdfAnnotationEditor();

Please take note of the minor difference.

I would appreciate it if you would address my issue. The code as I have provided appears to work on other documents BUT NOT on the sample document I provided. I would like to understand why. If this is in fact a bug please address as such as inconsistency like the above problem can cause serious issue for my clients


Thanks for contacting support.

First of all please accept our humble apologies for the confusion and inconvenience. As per my understanding from your first post, you need to remove / delete the Annotations from PDF file. In order to accomplish this requirement, please try using following code snippet.

For your reference, I have also attached the output generated over my end.


// load PDF document
Aspose.Pdf.Document doc = new Document("c:/pdftest/738676.pdf");
// delete Annotatiosn from first page of document
// delete Annotations from 22nd page of document
// save PDF document

Hello Again
It is clear that you did not read my first post on this issue,
I wish to make a complaint as the quality o the support I have asked for.
This issue has now dragged on far to long and now I find that Im being offered advice for a situation i did not ask help for
Let be be clear I need to flatten annotations NOT delete them …i though Id made that clear in my first post.
I also need to understand why the CURRENT documentation advises to use the method I have detailed…which by the way works BUT NOT on the document I have submitted. Please address this issue.
If Aspose releases documentation in the current version as to a specific method and that method works “some” of the time why would I even trust the company to provide robust software…What other methods are offered by way of example that may work “some” of the time

On the 28th of June a customer raised an issue in which they state the use the Facades model.
I would like to understand why you responded to them BUT did not advise them to stop using the Farcades Model given your advice to me ONE day later which suggest I stop using the this model. The ticket in question was titled “Checkboxes in reader vrs Acrobat”
Thank you


Thanks for sharing the details and sorry for the delayed response.

First of all please accept our humble apologies for the confusion around Flattening Annotations inside PDF file. In fact the idea of deleting the Annotations came from above discussion in this thread. However as per your initial requirement of Flattening the Annotations in PDF file, I have tested the scenario using Aspose.Pdf for .NET 17.6 using following code snippet, the Annotations are not editable in resultant file.


Document doc = new Document("c:/pdftest/738676.pdf");
foreach (Page p in doc.Pages)
    foreach(Aspose.Pdf.Annotations.Annotation an in p.Annotations)


Thanks for sharing the details.

Aspose.Pdf.Facades is an older approach and sooner or later, it is going to be obsolete so we are recommending customers to try migrating to new DOM approach. Therefore in one of the replies shared earlier by Asad and in my recent post, I have shared the approach of new DOM model.

Furthermore, from your original problem description, we do understand that PdfAnnotationEditor and Aspose.Pdf.Facades.Form are causing issues with 738676.pdf document but the same code snippet works with other documents. So it appears to be an issue related to this specific document. For the sake of correction, I have logged it as PDFNET-42974 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.

The reason same Facades approach was suggested to other customer is because it was fulling his requirement. Whereas in your case, the Facades approach is causing issues and migration to new DOM approach solves the problem and that is why we recommended you to please try using DOM approach.

As explained earlier, Aspose.Pdf.Facades is an older approach and it may be discontinued in near future (we are not certain about the dates) so we are encouraging customers to use new DOM. The reason documentation related to Aspose.Pdf.Facades is still present is because many of the customers are still using Facades and from time to time, they do consult it. Removal of documentation may cause trouble for them.

Should you have any related query, please feel free to contact. We are sorry for this inconvenience.

Thank you …I want to understand what is happening with the PDF file I supplied and its interaction with your product.
Durring the flattening process using the Farcade model NO error was thrown or any sort of warning given that the process had failed.

Perhaps you would be kind enough to point me to the programming guide lines on your company web site which advises the the pending deprecation, As regarding the documentation and its currency perhaps you would be better advised to include a note or warning of pending deprecation or better still a preferred methodology, which i note Asad did not bother advising your other customer ( suited their needs I think was the explanation…hmm You will let them expend resources and man hours so that they will have to re-write code that they could have avoided had Aspose been as enthusiastic as avoiding addressing my issue)…yes there is an issue with the document i presented and there is NO way to know whether this will not affect other customers who use your product.
I will eagerly await Aspose answer to this this riddle and look forward to seeing some official guide lines as to the use of Facades


Thanks for sharing the details.

As shared above, the issue has been logged for investigation process and unless they have completed the investigation process, we may not be able to share the reasons behind this problem. [quote=“Andre123, post:19, topic:471”]
Perhaps you would be kind enough to point me to the programming guide lines on your company web site which advises the the pending deprecation,
We do intimate such deprecation issues in release notes section for each API and currently we do not have any concrete timelines by which Aspose.Pdf.Facades will become obsolete but we shared the information ahead of time so that you prepare yourself and instead of making changes/updates at later stage, you update it ahead of time.

We are working on removing articles which may cause such confusion and working on increasing documentation for DOM model, so that it covers all the aspects currently being offered by older approach. Nevertheless, the reason we are encouraging the usage of new DOM approach of Aspose.Pdf namespace is because it is new model for PDF file creation as well as manipulation and all the enhancements and most of the bug fixes are being made in this area.

Should you have any further query, please feel free to contact.