Hello,
Hi Troy,
- createPolygon(…)
- createLine(…)
- createPolyLine(lineInfo, page, annotRect, annotContents)
Thanks Nayyer!
Nayyer,
tekstream: I apologize - but I would also like to know if drawing circles/rectangles in addition to freehand drawing on the pdf document is available.
Hi Troy,
Thanks for sharing the details.
In order to add Circle/Squares to PDF file, please try using following code snippet. A single method `createSquareCircle(…) can be used to accomplish both requirements.
Java
//instantiate pdfContentEditor instance
pdfContentEditor editor = new com.aspose.pdf.facades.PdfContentEditor();
//bind source PDF file
editor.bindPdf("c:/pdftest/font)_output.pdf");
//pass 4th argument as false to draw circle. When using true, square will be added
editor.createSquareCircle(new java.awt.Rectangle(10, 10, 50, 30), "contents", java.awt.Color.BLUE, false, 1, 2);
//save resultant file
editor.save("c:/pdftest/CircleAdded.pdf");
Ps, you do not need to be sorry. We are always delighted to assist our customers with their queries.
Thanks Nayyer! Appreciate your help and prompt response. I’ll try that code you provided.
Hello Nayyer,
Hi Troy,
Nayyer,
Hi Troy,
Please try using following code snippet to set access privileges over PDF file. When using following code snippet, the users viewing the PDF file will not be able to add/modify annotations but the Admin viewing the file with owner password will be able to make any modifications.
For further details, please visit Set Privileges on an Existing PDF File
[Java]
//
load existing PDF file
Document document = new Document("c:/pdftest/font_output.pdf");
try /*JAVA: was using*/
{
// allow all the feature / modifications over PDF file
com.aspose.pdf.facades.DocumentPrivilege documentPrivilege = com.aspose.pdf.facades.DocumentPrivilege.getAllowAll();
documentPrivilege.setAllowScreenReaders(true);
// revoke annotation modification. Only admin will be able to modify comments/annotations
documentPrivilege.setAllowModifyAnnotations(false);
document.encrypt("user", "owner", documentPrivilege, CryptoAlgorithm.AESx128, false);
// save updated file
document.save("c:/pdftest/AnnotationModify_revoked.pdf");
}
finally { if (document != null) document.dispose(); }
Hello Nayyer,
Hi Troy,
Nayyer,
documentPrivilege.setAllowModifyContents(false);
Hi Troy,
Thanks for sharing the details.
I am afraid the above stated requirement is currently not supported. However, for the sake of correction, I have logged it in our issue tracking system as PDFNEWJAVA-34480. We will investigate this issue in details and will keep you updated on the status of a correction.
We apologize for your inconvenience.
Nayyer,
Hi Troy,
Hello Nayyer,
Hi Troy,
Thanks for your inquiry. I am afraid your issue is not resolved as we have noticed it recently. It is pending for investigation in the queue with other priority tasks. As soon as its investigation is completed, we will share our findings or ETA with you.
We are sorry for the inconvenience caused.
Best Regards,
hi nayer, this looks like a way to create drawings in pdf. is this considered an annotation?
Hi Chit,
Thanks for your inquiry. Please note that drawing objects via Graph are not annotations but graphics.
Furthermore, we can add a reply to an annotation as follows. However, we will appreciate it if you please share your sample code along with the document here; it will help us to understand your scenario exactly and will guide you accordingly.
Document pdfDocument = new Document("annotation_out.pdf");
TextAnnotation replyAnnotation = new TextAnnotation(pdfDocument.getPages().get_Item(1), new com.aspose.pdf.Rectangle(200, 300, 300, 400));
replyAnnotation.setTitle("It needs to revisit");
replyAnnotation.setInReplyTo(pdfDocument.getPages().get_Item(1).getAnnotations().get_Item(1));
pdfDocument.getPages().get_Item(1).getAnnotations().add(replyAnnotation);
pdfDocument.save("Replied.pdf");
Best Regards,