We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

FreeTextAnnotation is not visible by default


When using Aspose PDF for Java 17.2.0, I noticed that after adding a FreeTextAnnotation, it is not visible by default. What I have to do is to locate this annotation in “Comment” task pane of Adobe PDF, then double click on the rectangle to see the annotation content.

If I use PdfContentEditor.createFreeText(), it’s visible by default but this api is not very helpful, I want to have different options for the free text annotation.

Please advice me if I can do anything to get through this issue. Thank you.

Best Regards,

Hi Tuyen,

Thanks for contacting support.

Can you please share the sample output file which can help us in understanding the problem and the code snippet, so that we can test the scenario in our environment. We are sorry for this inconvenience.

Hi Nayyer,

Thanks for your response. Below is my code:

String outputFile = dataDir + File.separatorChar + “output_free_text.pdf”;
String fileName = “pdf-sample - Copy.pdf”;
PdfContentEditor editor = new PdfContentEditor();
editor.bindPdf(dataDir + File.separatorChar + fileName);
Page firstPage = editor.getDocument().getPages().get_Item(1);
Rectangle rect = new Rectangle(100, 400, 400, 500);
DefaultAppearance appearance = new DefaultAppearance();
// Free text annotation: have to double click to show
FreeTextAnnotation freeTxtAnno = new FreeTextAnnotation(firstPage, rect, appearance);
freeTxtAnno.setTitle(“Free Text Anno Title”);
freeTxtAnno.setContents(“Annotation content: not shown by default”);
// This second annotation is shown by default
editor.createFreeText(new java.awt.Rectangle(200, 500, 100, 100), “New text: shown by default”, 1);

I also attached my tested files, please take a look. Thank you.

Best Regards,

Hi Tuyen,

Thanks for sharing further details.

You need to add fontName and fontSize for the default appearance in order to show the text. Please add following two lines in your code. I have also attached the output file for your reference.



If you still face any issue, please feel free to contact us.

Best Regards,

Hi Fahad,

Thanks for your support, it works fine now.

Best Regards,

Hi Tuyen,

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000; min-height: 14.0px} span.s1 {font-kerning: none}

Thanks for your feedback. It is good to know that suggested code worked for you.

Please keep using our API and feel free to contact us for any question or concern, we will be more than happy to extend our support.

Best Regards,