I am having an issue when I create a new Pdf.Page and add a FreeTextAnnotation to that new page. It is visible in Firefox and IE but not in Chrome, using its proprietary PDF viewer that runs by default in that browser. The LinkAnnotation that I create is clickable but the text of the FreeTextAnnotation is not visible in the Chrome Pdf viewer.
I am doing this in an asp.net application using the Aspose.Pdf dll. Is this a known issue with the Chrome PDF viewer or is there something I need in my code to make this work.
Here is the code:
//Create new document.
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document();
Aspose.Pdf.Page linkPage = (Aspose.Pdf.Page)pdfDocument.Pages.Add();
// create Link annotation object
Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation link = new Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation(linkPage, new Aspose.Pdf.Rectangle(100, 300, 500, 750));
// create border object for LinkAnnotation
Aspose.Pdf.InteractiveFeatures.Annotations.Border border = new Aspose.Pdf.InteractiveFeatures.Annotations.Border(link);
// set the border width
border.Width = 0;
// set the border for LinkAnnotation
link.Border = border;
//Set the link url.
link.Action = new Aspose.Pdf.InteractiveFeatures.GoToURIAction(“http://aspose.com”);
// add link annotation to annotations collection of first page of PDF file
linkPage.Annotations.Add(link);
//create Free Text annotation
Aspose.Pdf.InteractiveFeatures.Annotations.FreeTextAnnotation textAnnotation = new Aspose.Pdf.InteractiveFeatures.Annotations.FreeTextAnnotation(linkPage, new Aspose.Pdf.Rectangle(100, 300, 500, 750), “Link”);
//Create text for link.
string strTextFrag = “Please click here to goto website.”;
// String to be added as Free text
textAnnotation.Contents = strTextFrag;
// set the border for Free Text Annotation
textAnnotation.Border = border;
// add FreeText annotation to annotations collection of first page of Document
linkPage.Annotations.Add(textAnnotation);
return pdfDocument;
Thanks for any help you can provide!
Hi Tom,
Thanks for your inquiry. I have tested the scenario at my end and I am unable to replicate the issue, my Chrome version is 42.0.2311.90. Please upgrade to latest version and share the results. Hopefully it will resolve the issue.
We are sorry for the inconvenience caused.
Best Regards,
Thanks Tilal for the quick reply. I was able to fix the issue by updating to the latest version of the Aspose.Pdf dll.
Thanks for your help.
One other question - is there a way to remove the border from a FreeTextAnnotation? I set the width property to zero but the border still appears.
-Tom
Hi Tom,tomq:Thanks Tilal for the quick reply. I was able to fix the issue by updating to the latest version of the Aspose.Pdf dll.
Thanks for sharing the feedback.
We are glad to hear that your problem is resolved. Please continue using our API and in case of any further query, please feel free to contact.
I am afraid the API currently does not support the feature to hide/remove border from Annotation instance. However for the sake of implementation, I have logged an enhancement ticket as PDFNEWNET-38647 in our issue tracking system. We will further look into the details of this requirement and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for your inconvenience.tomq:One other question - is there a way to remove the border from a FreeTextAnnotation? I set the width property to zero but the border still appears.
With the code below and using version from 24.3 library, the desired result is obtained.
Added line textAnnotation.Border.Width = 0; (made in accordance with the pdf specification - see attachment, although not entirely obvious)
var pdfDocument = new Aspose.Pdf.Document();
Aspose.Pdf.Page linkPage = (Aspose.Pdf.Page)pdfDocument.Pages.Add();
// create Link annotation object
var link = new LinkAnnotation(linkPage, new Aspose.Pdf.Rectangle(100, 300, 500, 750));
link.Color = Aspose.Pdf.Color.Transparent;
// create border object for LinkAnnotation
var border = new Border(link);
// set the border width
border.Width = 0;
// set the border for LinkAnnotation
//link.Border = border;
//Set the link url.
link.Action = new GoToURIAction("http://aspose.com");
// add link annotation to annotations collection of first page of PDF file
linkPage.Annotations.Add(link);
//create Free Text annotation
var textAnnotation = new FreeTextAnnotation(linkPage, new Aspose.Pdf.Rectangle(100, 300, 500, 750), new DefaultAppearance());
textAnnotation.Border.Width = 0; // --------> This line added.
//Create text for link.
string strTextFrag = "Please click here to goto website.";
// String to be added as Free text
textAnnotation.Contents = strTextFrag;
// set the border for Free Text Annotation
//textAnnotation.Border = border;
// add FreeText annotation to annotations collection of first page of Document
linkPage.Annotations.Add(textAnnotation);
pdfDocument.Save(dataDir + "38647-out.pdf");
38647-out.pdf (2.6 KB)
picture607-1.png (70.5 KB)