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

Free Support Forum - aspose.com

Anchor tag is not working when adding HtmlFragment inside Table Cell - Aspose.PDF for .NET

I am using Aspose Pdf dll (licensed version) in my .Net application for Pdf. In my pdf document, I am putting an hyperlink with a string. Currently when I click it opens in the same tab, but I want it to open in new tab. Is it possible to achieve this using Aspose Pdf for .Net?
Here is how I am adding the link:

Aspose.Pdf.Text.TextFragment hyperlinkText = new Aspose.Pdf.Text.TextFragment(downloadText);
var hpr = new WebHyperlink();
hpr.Url = downloadUrl; // need add hyperlink url here
hyperlinkText.Hyperlink = hpr;
hyperlinkText.TextState.ForegroundColor = Color.Blue;

@glenfield

Would you kindly share an expected PDF output which you want to generate using API. We will test the scenario in our environment and address it accordingly.

@asad.ali

I am passing html tags in the HtmlFragment. The text contains any link coming from other source. As (www.google.com) under the name “Google” which appears in our text here in this example just for testing. But in the generated ouput pdf, the link is just as normal text, it’s not clickable as a link. Here is my code.

   private void AddSummary(Table tableLayout, string textHeader, string textBody)
    {
        HtmlFragment formattedText = new HtmlFragment(textBody);
        formattedText.HtmlLoadOptions = new HtmlLoadOptions();

        //adding text header of the page
        Row headerRow = tableLayout.Rows.Add();
        Cell headerCell = headerRow.Cells.Add(textHeader);
        headerCell.DefaultCellTextState.HorizontalAlignment = HorizontalAlignment.Left;
        headerCell.DefaultCellTextState.FontSize = 12;
        headerCell.DefaultCellTextState.FontStyle = FontStyles.Bold;
        headerCell.ColSpan = 2;
        headerCell.Margin = new MarginInfo(0, 30, 10, 0);

        Row mainRow = tableLayout.Rows.Add();
        Cell leftCell = mainRow.Cells.Add(" ");

        Cell rightCell = mainRow.Cells.Add();
        rightCell.Paragraphs.Add(formattedText);
        rightCell.Margin = new MarginInfo(0, 50, 10, 10);
    } 

Here is the output screenshot.
Link in pdf.PNG (25.8 KB)

Please go through this and try to solve ASAP. It will be a great help.
Thanks

@glenfield

Would you kindly share the value to textBody variable so that we can test the code snippet accordingly.

@asad.ali
I am passing the string to “textBody” containing Html paragraph tag which contains the link which further being passed to HtmlFragment.

<p>This is sample text to check whether our link <a href="http://www.google.com" rel="noopener noreferrer" target="_blank">Google</a> working or not in the pdf.</p>

@glenfield

Thanks for providing requested details.

We have tested the scenario in our environment using Aspose.PDF for .NET 20.5 and were able to reproduce the issue. Hence, we have logged it as PDFNET-48343 in our issue tracking system for the sake of correction. We will further look into details of the issue and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

@asad.ali

Hi Asad,
Is there any progress towards this issue?
We need it urgently.

I request you kindly provide any solution ASAP for the same.
Thanks.

@glenfield

The issue was logged recently in our issue tracking system and currently pending for analysis. Please note that issues are resolved on first come first serve basis in normal support model. However, we do value your concerns and will surely consider them during investigation. As soon as we have some definite updates regarding its resolution, we will inform you. Please spare us little time.

We are sorry for the inconvenience.

@asad.ali

Hello Asad,

Please what is the work-around to this issue?

We are currently having the same problem. While waiting for a fix from your end , is there a way around it in the meantime?

I will appreciate it if you can help us out as this is an urgent issue for us.

Many thanks for your help.

@SojiAde, @glenfield

We would like to share with you that the issue (reported in this thread) has been resolved and its fix will be available in upcoming version of the API i.e. Aspose.PDF for .NET 20.7. It will be released in first week of next month (July). We will notify you as soon as it is available.

The issues you have found earlier (filed as PDFNET-48343) have been fixed in Aspose.PDF for .NET 20.7.