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