The annotation isn‘t displayed on the image converted from the page

Hi Aspose team,

When I use Aspose.Pdf for .NET, I found a problem.
.
When I add a text annotation to the pdf page, then convert this page into an image, I find that the annotation I added will not be displayed on the converted image (I used the sample code and tried jepg, png, bmp, emf, etc.).

But when I save the above pdf and open it with Adobe, I can see the annotation I added. And if I make some modification and saving the pdf, then do the convert using Aspose.Pdf, The annotation I added before will be displayed on the image normally this time.

Here is the file TextAnnotation.pdf (27.9 KB), and code snippet for adding text annotation:

public void AddAnnotation(int currentPage, string name, string commentText, Rectangle rect)
{
	Page page = _document.Pages[currentPage];
	
	TextAnnotation textAnnotation = new TextAnnotation(page, rect);
	textAnnotation.Name = name;
	textAnnotation.Title = "Sample";
	textAnnotation.Subject = "Sample";
	textAnnotation.State = AnnotationState.None;
	textAnnotation.Color = Color.Blue;
	textAnnotation.Contents = commentText;
	textAnnotation.Icon = TextIcon.Comment;
	textAnnotation.Flags = AnnotationFlags.NoZoom | AnnotationFlags.NoRotate | AnnotationFlags.Print;
	Border border = new Border(textAnnotation);
	border.Width = 1;

	page.Annotations.Add(textAnnotation);
}

The annotations directly added by Adobe can be displayed correctly on the converted image. Did I miss or mistake something when adding the annotation? How can I get the correct image with the annotation I added?

Best Regards!

@Glority_Developer

We were able to notice the issue at our side while using Aspose.PDF for .NET 20.12. However, could you please share below information with us for our reference so that we can log the issue accordingly and share the issue ID with you:

  • The sample code snippet to convert PDF to Image
  • The sample PDF document annotated using Adobe Reader along with generated output image.

The code snippets to convert PDF to Image,

  • Code snippet 1,

      Document pdfDocument = new Document(inputFileName);
      string fileDir = Path.GetDirectoryName(inputFileName);
      using (FileStream imageStream = new FileStream(fileDir + "//image.png", FileMode.Create))
      {
      	Resolution resolution = new Resolution(500);
      	PngDevice PngDevice = new PngDevice(resolution);
      	PngDevice.Process(pdfDocument.Pages[1], imageStream);
      	imageStream.Close();
      }
    
  • Code snippet 2,

      public BitmapImage GetPageImage(int currentPage)
      {
      	Page page = _document.Pages[currentPage];	
      	try
      	{
      		var memory = page.ConvertToPNGMemoryStream();
    
      		BitmapImage bitmap = new BitmapImage();
      		bitmap.BeginInit();
      		bitmap.StreamSource = memory;
      		bitmap.EndInit();
    
      		return bitmap;
      	}
      	catch (Exception e)
      	{
      		var ex = e.InnerException;
      	}
      	return null;
      }
    

The sample PDF document annotated using Adobe Reader AdobeAnnotation.pdf (35.0 KB) and the generated output image(by code snippet 1) AdobeAnnotation_image.png (480.7 KB)

@Glority_Developer

We have logged an issue as PDFNET-49196 in our issue tracking system with all relevant details of the case. 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.

Hi Aspose team,

Did you have any progress on it? Looking forward to hearing from you.

@Glority_Developer

We regret to share that earlier logged ticket has not been resolved yet. We will surely post an update in this forum thread as soon as we have some regarding ticket resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hi Aspose team,

Did you have any progress on it? Will it be fixed within 1-2 months?

@Glority_Developer

We really regret to inform that the earlier logged ticket is not fully investigated yet and we are not certain about its fix ETA as it will be resolved on a first come first serve basis. We have recorded your concerns and will surely consider them during issue analysis. Please give us some time.

We apologize for your inconvenience.

Hi Aspose team,

Is this bug fixed or is there any progress?

@Glority_Developer

Regretfully, the issue could not get resolved due to other pending issue in the queue. However, we will surely let you know via this forum thread as soon as the ticket is fixed. We really apologize for the inconvenience and the delay you have been facing.

Aspose-

Is there an update on this? It is impeding our development also.

@ChadAll

We are afraid that the earlier logged ticket is not yet resolved. Your concerns have been recorded and we will surely inform you once we make some progress towards ticket resolution. We apologize for the inconvenience.