Creating Textbox annotation


We are trying to create annotation on pdf as showing in the attached pdf using Aspose PDF for Jave. But could not achieve in the exact same format. Could you please let us know how can this be achieved using Aspose PDF for Java.out.pdf (262.3 KB)


Please try to add free text annotation using below code snippet that will look like the same in your shared PDF:

Document doc = new Document();
Rectangle rect = new Rectangle(0, 0, 100, 100);
DefaultAppearance appearance = new DefaultAppearance("Arial", 14,;
FreeTextAnnotation freeTextAnnotation = new FreeTextAnnotation(doc.getPages().get_Item(1), rect, appearance);
freeTextAnnotation.setContents("text in the box");
doc.getPages().get_Item(1).getAnnotations().add(freeTextAnnotation); + "sampleoutput.pdf");

out_out.pdf (36.9 KB)
Thanks for the code snippet. This code generated the attached document and it did not look like the one which was requested. We are using Aspose PDF 21.5
Could you please check?


The output looks different due to specific properties being set in the share code snippet e.g. Color, Background, Border, Width, Rectangle Size, etc. You need to specify these options for annotation in order to make it look like your desired format.