Can't able to highlight the text hyperlink of the pdf in blue colorfor some of the PDF documents

Dear Aspose Support Team,

We are using ASPOSE pdf to give hyperlinks to the text in the pdf and try to make the hyperlinked text in blue color.

For some of the document we are able to give the hyperlink to the text but cant able to make the hyperlinked text in blue color.

Whereas we can able to give the rectangle border for the hyperlinked text for all the documents.

But in our scenario we need hyperlinked text in blue color only (Client raised).

Please find below the sample code we have used.

int SourcePageNumber = Convert.ToInt32(obj.txt_pageNo);
int DestinationPageNumber = Convert.ToInt32(obj.externalLinkPageNo);
double llx1 = Convert.ToDouble(obj.txt_LLX);
double lly1 = Convert.ToDouble(obj.txt_LLY);
double urx1 = Convert.ToDouble(obj.txt_URX);
double ury1 = Convert.ToDouble(obj.txt_URY);
double nativeHeight = Convert.ToDouble(obj.img_native_height);
Document document = new Document(mDocumentLocation);
Page page = document.Pages[SourcePageNumber];
// create Link annotation object
Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation link = new Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation(page, new Aspose.Pdf.Rectangle(llx1, nativeHeight - lly1, urx1, nativeHeight - ury1));
// create border object for LinkAnnotation
Aspose.Pdf.InteractiveFeatures.Annotations.Border border = new Aspose.Pdf.InteractiveFeatures.Annotations.Border(link);
// set the border width value as 0
border.Width = 0;
border.Style = Aspose.Pdf.InteractiveFeatures.Annotations.BorderStyle.Solid;
// set the border for LinkAnnotation
link.Border = border;
link.Color = Aspose.Pdf.Color.Blue;
// specify the link type as remote URI
link.Action = new Aspose.Pdf.InteractiveFeatures.GoToAction(DestinationPageNumber);
link.Destination = new XYZExplicitDestination(DestinationPageNumber, page.Rect.Width, page.Rect.Height, 0);
// add link annotation to annotations collection of first page of PDF file
page.Annotations.Add(link);
TextFragmentAbsorber absorber = new TextFragmentAbsorber(obj.display_text);
absorber.TextSearchOptions.LimitToPageBounds = true;
absorber.TextSearchOptions.Rectangle = new Aspose.Pdf.Rectangle(llx1, nativeHeight - lly1, urx1, nativeHeight - ury1);
// accept the absorber for first page
document.Pages[SourcePageNumber].Accept(absorber);
TextFragmentCollection textFragmentCollection = absorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
{
textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Blue);
}
document.Save(mDocumentLocation);
document.Dispose();​

Also attached the sample documents for your reference …

Thanks
Prabakaran




Hi Prabakaran,

Thanks for your inquiry. I am afraid I could not use code to test the scenario due to the missing references. However, I have used the following code sample to search for some text from your shared documents and created a linkAnnotation with blue text using Aspose.Pdf for .NET 10.1.0. All your files are working fine except for nonworkingDocument2.pdf. So we have logged a ticket PDFNEWNET-38193 in our issue tracking system for further investigation and resolution. We will keep you updated about the issue resolution progress within this forum thread.

//open document
Document pdfDocument = new Document(myDir + "nonworkingDocument1.pdf");

//create TextAbsorber object to find all the phrases matching the regular expression
TextFragmentAbsorber textFragmentAbsorber1 = new TextFragmentAbsorber("D|d(ocument") ;//nonworkingDocument1.pdf

//set text search option to specify regular expression usage
TextSearchOptions textSearchOptions = new TextSearchOptions(true);
textFragmentAbsorber1.TextSearchOptions = textSearchOptions;

//accept the absorber for all the pages
pdfDocument.Pages[1].Accept(textFragmentAbsorber1);

//get the extracted text fragments
TextFragmentCollection textFragmentCollection1 = textFragmentAbsorber1.TextFragments;

//loop through the fragments
foreach (TextFragment textFragment1 in textFragmentCollection1)
{
    textFragment1.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;

    // create Link annotation object
    Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation
    link = new Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation
        (pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(
            textFragment1.Rectangle.LLX,
            textFragment1.Rectangle.LLY,
            textFragment1.Rectangle.URX,
            textFragment1.Rectangle.URY));

    // create border object for LinkAnnotation
    Aspose.Pdf.InteractiveFeatures.Annotations.Border
    border = new
    Aspose.Pdf.InteractiveFeatures.Annotations.Border(link);

    // set the border width value. You can set 0 if you need no border.
    border.Width = 1;

    // set the border for LinkAnnotation
    link.Border = border;

    link.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Transparent);

    // specify the link type as remote URI
    link.Action = new Aspose.Pdf.InteractiveFeatures.GoToURIAction("www.aspose.com");

    // add link annotation to annotations collection of the first page of PDF file
    textFragment1.Page.Annotations.Add(link);
}

pdfDocument.Save(myDir + "nonworkingDocument1_link.pdf");

We are sorry for the inconvenience caused.

Best Regards,

Dear Support Team,

Thanks for the reply.

We would like to know the tentative date for this fix, as this issue was reported by our client ?

Client ask us the date for the fix …

Thanks
Prabakaran

Hi Prabakaran,

Thanks for your inquiry. I am afraid we have recently noticed the issue and yet it is pending for investigation due to the issues already under investigation. As soon as its investigation is completed then we will be in a good position to share an ETA of the fix. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience caused.

Best Regards,

Dear Support Team,

Can you please update the status and release date for this issue …?

Thanks
Prabakaran

Hi Prabakaran,


Thanks for your inquiry. I am afraid your reported issue is still pending for investigation due to other priority issues. We will share an ETA as soon as its investigation is completed.

Thanks for your patience and cooperation.

Best Regards,

The issues you have found earlier (filed as PDFNEWNET-38193) have been fixed in Aspose.Pdf for .NET 10.3.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(4)