Hello,
Hi Tuyen,
Document document = new Document(dataDir + “pdf-sample.pdf”);
TextAnnotation text2 = new TextAnnotation(document.getPages().get_Item(1), new Rectangle(200, 500, 220, 550));
text2.setName (“Text annot with manual popup”);
text2.setTitle (“This title not in popup”);
text2.setContents (“Description: Text annot with manual popup annotation”);
text2.setIcon (TextIcon.Comment);
text2.setColor (Color.getBlue());
document.getPages().get_Item(1).getAnnotations().add(text2);
PopupAnnotation popup2 = new PopupAnnotation(document.getPages().get_Item(1), new Rectangle(100, 400, 400, 500));
popup2.setName (“Manual popup”);
popup2.setContents (“Description: Manual popup annotation”);
popup2.setColor (Color.getGreen());
text2.setPopup (popup2);
document.getPages().get_Item(1).getAnnotations().add(popup2);
document.save();
Hi Fahad,
Hi Tuyen,
Best Regards,
Hi Tuyen,
Hi Fahad,
Hi Tuyen,
File file = new File(dataDir, imageName);
byte[] dataBinary = null;
try {
dataBinary = Files.readAllBytes(file.toPath());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Document document = new Document(new ByteArrayInputStream(dataBinary));
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
TextAnnotation text2 = new TextAnnotation(document.getPages().get_Item(1), new Rectangle(200, 500, 220, 550));
text2.setName (“Text annot with manual popup”);
text2.setTitle (“This title not in popup”);
text2.setContents (“Description: Text annot with manual popup annotation”);
text2.setIcon (TextIcon.Comment);
text2.setColor (Color.getBlue());
document.getPages().get_Item(1).getAnnotations().add(text2);
PopupAnnotation popup2 = new PopupAnnotation(document.getPages().get_Item(1), new Rectangle(100, 400, 400, 500));
popup2.setName (“Manual popup”);
popup2.setContents (“Description: Manual popup annotation”);
popup2.setColor (Color.getGreen());
text2.setPopup (popup2);
document.getPages().get_Item(1).getAnnotations().add(popup2);
document.save(outputStream);
byte[] outputBinary = outputStream.toByteArray();
Files.write(file.toPath(), outputBinary);
Hi Fahad,
Hi Tuyen,
Hi Fahad,
Hi Tuyen,
Hi Fahad,
Hi Tuyen,
Aspose PDF Java: If we load a document from binary, then add some annotations, then save to a different binary, the content is totally changed (not Incremental Update)
Hi Fahad,
HI Tuyen,
Hi Tuyen,
Hi Fahad,
Hi Tuyen,
Thanks for your patience.
We are pleased to inform you that earlier reported issues PDFJAVA-36627 and PDFJAVA-36629, have been resolved in latest version Aspose.Pdf for Java 17.12. We have implemented an additional method saveIncrementally(..)
into the Document
class and now you will be able to save document using Incremental Updates into the stream object. Please replace document.save(outputStream);
code line with document.saveIncrementally(outputStream);
in your code snippet to avoid the issue.
Please try suggested method with latest release version and in case you face any issue, please feel free to contact us.