Is it possible to remove annotation?

Can I load the pdf containing annotations and delete the annotations?
If is it possible, please let me know how I can remove it.


You can use following code snippet to delete annotations from PDF document:

Document document = new Document("input.pdf");
foreach (Aspose.Pdf.Page p in document.Pages)

In case you face any issue, please share your sample PDF with us along with the information of annotations which you want to delete. We will test the scenario in our environment and address it accordingly.

If I changed name of xImage then error occured when I opened pdf used to adobe acrobat.
below is my sample code.

Aspose.Pdf.Document doc1 = new Aspose.Pdf.Document(“file path”);
System.IO.FileStream fs = new System.IO.FileStream(“image path”, System.IO.FileMode.Open);
System.Drawing.Image image = System.Drawing.Image.FromStream(fs);

Aspose.Pdf.XImage xImage = doc1.Pages[1].Resources.Images[doc1.Pages[1].Resources.Images.Count];
xImage.Name = “Test”;

doc1.Pages[1].Contents.Add(new Aspose.Pdf.Operators.GSave());

Aspose.Pdf.Matrix matrix = new Aspose.Pdf.Matrix(image.Width * 0.75, 0, 0, image.Height * 0.75, 0, 0);
doc1.Pages[1].Contents.Add(new Aspose.Pdf.Operators.ConcatenateMatrix(matrix));
doc1.Pages[1].Contents.Add(new Aspose.Pdf.Operators.Do(xImage.Name));

doc1.Pages[1].Contents.Add(new Aspose.Pdf.Operators.GRestore());

doc1.Save(“save file path”);

How can I put the matrix where I want position?


You can set coordinates of the image while adding it to the PDF. Please check following articles for more information:

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

XImage.Name is changed.pdf (181.9 KB)
XImage.Name is not changed.pdf (181.9 KB)

Please refer to the attached file.


We were able to observe similar issue in our environment and logged it as PDFNET-48396 in our issue tracking system for the sake of correction. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

XImage.Name property value is auto generate when I insert image into page.Resource.Images
And it has pattern like “Im0”, “Im1”.
Is there case that pattern do change?
Are XImage.Name is unique in page or document?


Yes, your understandings are correct. The image name is really auto generated and it must be unique for page. It seems we have issue with renaming of XImage (as you try to do) and we will check how we can fix it.

The issues you have found earlier (filed as PDFNET-48396) have been fixed in Aspose.PDF for .NET 20.7.