StampAnnotation read image data

Is there any way to read the image data for a saved StampAnnotation? The getImage function returns null for saved documents.

Code;

  File oPath = new File(Environment.getExternalStorageDirectory(), "Documents");
  File oPdfLic = new File(oPath, "aspose_pdf.lic");
  File oPdfIn = new File(oPath, "test.pdf");
  File oPdfOut = new File(oPath, "test2.pdf");
  File oImage = new File(oPath, "test.jpg");


  FileInputStream oStream = new FileInputStream(oPdfLic.getAbsolutePath());
  License oLicense = new License();
  oLicense.setLicense(oStream);
  oStream.close();

  // create document
  {
    com.aspose.pdf.Document oDoc = new com.aspose.pdf.Document(oPdfIn.getAbsolutePath());
    Page oPage = oDoc.getPages().get_Item(1);

    FileInputStream oInFile = new FileInputStream(oImage.getAbsolutePath());

    Rectangle oImgRect = new Rectangle(5f, 5f, 150f, 150f);
    StampAnnotation oStamp = new StampAnnotation(oPage, oImgRect);

    oStamp.setImage(oInFile);

    oPage.getAnnotations().add(oStamp);
    oInFile.close();

    oPdfOut.delete();
    oDoc.save(oPdfOut.getAbsolutePath());
    oDoc.close();
  }

  // use saved document
  {
    com.aspose.pdf.Document oDoc = new com.aspose.pdf.Document(oPdfOut.getAbsolutePath());
    Page oPage = oDoc.getPages().get_Item(1);

    StampAnnotation oStamp = (StampAnnotation) oPage.getAnnotations().get_Item(1);

    // stream is null //
    InputStream oStreamIsNull = oStamp.getImage();
    log("onCreate", "is null: " + (oStreamIsNull == null));
  }

@kkoch

Thank you for contacting support.

I have worked with the data shared by you and have been able to reproduce the issue in our environment. A ticket with ID PDFJAVA-37500 has been logged in our issue management system for further investigation and resolution. The issue ID has been linked with this thread so that you will receive notification as soon as the issue is resolved.

We are sorry for the inconvenience.

@kkoch

We have further investigated the issue reported by you and we are unable to reproduce it with Aspose.PDF for Java 18.2, which has been released couple of days ago. Please test the scenario with latest version and then share your kind feedback with us. In case the issue persists with this version then please share source PDF as well as image, generated PDF file and environment details on your end so that we may proceed accordingly.

According to your downloads page, the latest version for android is 17.12. Please advise if there is a 18.2 version for android I can download.

@kkoch

We are investigating the scenario in Android emulator and will get back to you with our findings soon.

Any progress?

@kkoch

We are checking it with the collaboration of our product team and we will get back to you within couple of days. Please be patient and spare us little time.

@kkoch

We have managed to replicate the issue in Android environment with latest available version, 17.12, for Android. A ticket with ID PDFANDROID-507 has been logged in our issue management system, for further investigation and resolution. The issue ID has been linked with this thread so that you will receive notification as soon as the issue is resolved.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFANDROID-507) have been fixed in Aspose.PDF for Android via Java 18.6.

Hello, I have the same problem that the Image property in Stamp Annotation returns null value when I try to get the image stream. Here is my code:
foreach(Annotation annotation in pdfDocument.Pages[i+1].Annotations){
StampAnnotation stamp = (StampAnnotation) annotation;
combinedText += String.Format(“image {0},”,stamp.Image == null ? “true” : “false”);
}
The stamp.Image will return null which results in output “true” in this case, this is C#, not Java. Please help me! Thank you.

@dhm2007

Can you please share the sample document for our reference so that we can test the scenario in our environment and address it accordingly.

TYPES.pdf (235.7 KB)
for(int i = 0;i < 19;i++){
foreach(Annotation annotation in pdfDocument.Pages[i+1].Annotations){
var name = annotation.AnnotationType.ToString();
if(name == “Polygon”){
PolygonAnnotation polygon = (PolygonAnnotation) annotation;
combinedText += String.Format("{0},",polygon.Subject);
}
else if(name == “Stamp”){
StampAnnotation stamp = (StampAnnotation) annotation;
combinedText += String.Format(“image {0},”,stamp.Image == null ? “true” : “false”);
}
else{
combinedText += String.Format("{0},",name);
}
}
}
Here is the pdf document and the sample code, it has 19 pages, and the last page has all the stamps. Thank you for your help.

@dhm2007

We were able to replicate the issue in our environment using 22.5 version of the AP and have logged it as PDFNET-51839 in our issue tracking system. We will further look into its details and let you know once the issue is resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.

Do you have any progress or update on this issue yet?
Thank you

@dhm2007

The ticket has just been logged in our issue management system and it is pending for investigation. We will investigate and resolve it on a first come first serve basis as per free support policies. We will inform you once some progress is made towards issue resolution. Please spare us some time.

We are sorry for the inconvenience.

Hello, I am just checking on the progress of ticket PDFNET-51839? Any progress so far?
By the way, in Annotation class, there is a function called ToImage(), but it is a protected class, is there anyway I can get the image stream for each annotation in a PDF file?
Thank you

@dhm2007

We regret that we are unable to share any feedback at the moment as the ticket is pending for resolution. However, your concerns have been recorded and as soon as we make some definite progress towards ticket resolution, we will inform you in this forum thread. Please be patient and spare us some time.

We are sorry for the inconvenience.

Is there any update on this issue?
Thank you

@dhm2007

We are afraid that the earlier logged ticket could not get resolved. We will surely inform you via this forum thread once we have some certain update about its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.