Remove visible rectangular border when adding local link using Facades

Hi there,

I’m using Aspose.Pdf for .NET, the latest version. I have the next situation. My software obtains an already created PDF document with text on input. It need to modify this document by transforming specified text string onto local links.

I previously asked how to do this on this forum, here is a thread: Attach inner-document links to existing text. It was suggested to use Create Local Link in Existing PDF File (Facades)
This manual works perfect, but with one major notice. When using “PdfContentEditor.CreateLocalLink”, this link always has a visible rectangular border. I thied to use “System.Drawing.Color.Transparent”, but without luck: border is always visible. When using another overload, which doesn’t take a fourth parameter, Aspose.Pdf draws a default black border.

But I want to add local link without visible border. Is it possible and if yes, then how?

This is a source code:

//create dummy PDF
Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
// add page to pages collection of PDF file
Page page = doc.Pages.Add();
// create Text Fragment instance
Aspose.Pdf.Text.TextFragment text = new Aspose.Pdf.Text.TextFragment(“link to page 2”);
page.Paragraphs.Add(text);
doc.Pages.Add();
doc.Pages[2].Paragraphs.Add(new Aspose.Pdf.Text.TextFragment(“this is page 2”));
doc.Save(SharedData.FilesOutputFolder + “input.pdf”);

//open existing PDF and find required text
Aspose.Pdf.Document newDoc = new Aspose.Pdf.Document(SharedData.FilesOutputFolder + “input.pdf”);
Aspose.Pdf.Page firstPage = newDoc.Pages[1];
Aspose.Pdf.Text.TextFragmentAbsorber absorber = new TextFragmentAbsorber();
firstPage.Accept(absorber);
Aspose.Pdf.Text.TextFragmentCollection collection = absorber.TextFragments;
Aspose.Pdf.Text.TextFragment oneFragment = collection[1];
Aspose.Pdf.Rectangle rectange = oneFragment.Rectangle;

//edit existing PDF
PdfContentEditor contentEditor = new PdfContentEditor();
contentEditor.BindPdf(SharedData.FilesOutputFolder + “input.pdf”);
contentEditor.CreateLocalLink(rectange.ToRect(), 2, 1, System.Drawing.Color.Transparent);
contentEditor.Save(SharedData.FilesOutputFolder + “output.pdf”);

In the attachments you can find input and output dummy documents.

Thanks in advance.

With best regards,
Denis Gvardionov

Hi Denis,

Thanks for your inquiry. I have tested your scenario with shared document using Aspose.Pdf for .NET 10.6.0 and managed to observe the reported issue. For further investigation, I have logged an issue in our issue tracking system as PDFNEWNET-39018 and also linked your request to it. We will keep you updated via this thread regarding the issue status.

Moreover, if you want to add local hyper link at the time of PDF file creation then please check this documentation link for details.

Please feel free to contact us for any further assistance.

Best Regards

Hello

I am encountering the same issue with the black border around a local link when using CreateLocalLink. Is this issue resolved? We currently have a site license of Aspose Total and this issue is a showstopper.

Hi,


Thanks for contacting support.

We have further investigated the earlier reported issue and have found that in order to generate correct output (without border around links), please try using following code snippet based on new Document Object Model. For your reference, I have also attached the output generated over my end.

[C#]

Aspose.Pdf.Document
newDoc = new Aspose.Pdf.Document(“c:/pdftest/input.pdf”);<o:p></o:p>

Aspose.Pdf.Page firstPage = newDoc.Pages[1];

Aspose.Pdf.Text.TextFragmentAbsorber absorber = new TextFragmentAbsorber();

firstPage.Accept(absorber);

Aspose.Pdf.Text.TextFragmentCollection collection = absorber.TextFragments;

Aspose.Pdf.Text.TextFragment oneFragment = collection[1];

Aspose.Pdf.Rectangle rectange = oneFragment.Rectangle;

LinkAnnotation link = new LinkAnnotation(newDoc.Pages[1], rectange);

link.Destination = new FitExplicitDestination(newDoc.Pages[2]);

link.Border = new Border(link);

link.Border.Width = 0;

newDoc.Pages[1].Annotations.Add(link);

newDoc.Save("c:/pdftest/Hyperlink_output.pdf");

Thank you, the example works as expected.

Hi there,


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

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

Best Regards,