Text style issues when hyperlink added

Hi,


I am using hyperlinks in my PDF document.

Here is the code -

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Section mainSection = pdf.Sections.Add();

Text specText = new Text(mainSection);

Segment specSegment = new Segment();
specSegment = specText.Segments.Add(“1. XXX”);
specSegment.Hyperlink.LinkType = HyperlinkType.Local;
specSegment.Hyperlink.TargetID = “rrr”;

mainSection.Paragraphs.Add(specText);

Text elecReqHeaderText = new Text(mainSection, “YYY”);

elecReqHeaderText.ID = “rrr”;
mainSection.Paragraphs.Add(elecReqHeaderText);

The attached images are the out I am getting.

There is a border around XXX text and an addition rectangle is appearing near the text YYY.
Could you please help me in debugging these

By the way I am using Aspose PDF for .net

Thanks a lot,
Sharanya

Hi Sharanya,

Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 10.1.0 and I am unable to notice any issue. Please try using latest release and in case the problem still persists, please share complete code snippet.

[C#]

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

Section mainSection = pdf.Sections.Add();

Text specText = new Text(mainSection);

Segment specSegment = new Segment();

specSegment = specText.Segments.Add("1. XXX");

specSegment.Hyperlink.LinkType = HyperlinkType.Local;

specSegment.Hyperlink.TargetID = "rrr";

mainSection.Paragraphs.Add(specText);

Text elecReqHeaderText = new Text(mainSection, "YYY");

elecReqHeaderText.ID = "rrr";

mainSection.Paragraphs.Add(elecReqHeaderText);

pdf.Save("c:/pdftest/TextStyle_HyperlinkIssue.pdf");

Hi,

Thanks a lot for the quick reply.

I was using the exact same code. We are using Aspse.Pdf version 6.6.0.0

Could you please try running the code in old version and check?
I guess we cannot afford to update to latest version due to the limited time constraints.

Thanks,
Sharanya

Hi Sharanya,


Thanks for your your feedback. I am afraid you are using quite old version and we can not provide hotfix for old versions. As we maintain a single code base of Aspose Components, all the fixes and new features/enhancements are implemented in latest version of DLL. So it is recommended to use latest version of Aspose.Pdf for .NET. You may also make request a 30 days temporary license, verify your issue and upgrade accordingly.

We are truly sorry for the inconvenience caused.

Best Regards,

Hi,

As you said, I have downloaded the latest dll (10.0.0.0) and found that the hyper link issue is solved.

But the PDF generation is consuming lot of memory and it takes long to generate pdf. This was not found in old (6.6) version

Here is the sample code which took almost 7-8 seconds to generate pdf.

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

Aspose.Pdf.Generator.Section mainSection = pdf .Sections.Add();

for (int i = 0; i < 1000; i++)
{
Aspose.Pdf.Generator.Row headerRow = mainTable.Rows.Add();

headerRow.Cells.Add(“Text”);
}
mainSection.Paragraphs.Add(mainTable);

System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ContentType = “Application/pdf”;
response.AppendHeader(“Content-Disposition”, “attachment; filename=aa.pdf”);

Please suggest

Thanks,
Sharanya


Sorry,

I forgot to mention the last line for saving the pdf

pdf.Save(“aa.pdf”, SaveType.OpenInAcrobat, response);

Hi Sharanya,

Thanks for your inquiry. I have tested your shared scenario with old generator (Aspose.Pdf.Generator) and noticed that it is taking 7-8 seconds. However new generator (Aspose.Pdf) is taking only 1 second. Please use new generator for creating new PDF document, it is improved and efficient.

Aspose.Pdf.Document pdf = new Document();
Page mainSection = pdf.Pages.Add();
Aspose.Pdf.Table mainTable = new Aspose.Pdf.Table();

for (int i = 0; i < 1000; i++) {
    Aspose.Pdf.Row headerRow = mainTable.Rows.Add();
    headerRow.Cells.Add("Text");
}
mainSection.Paragraphs.Add(mainTable);

MemoryStream ms = new MemoryStream();

//System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
//response.ContentType = "Application/pdf";
//response.AppendHeader("Content-Disposition", "attachment; filename=aa.pdf");

pdf.Save(outStream);
byte[] downloadBytes = outStream.ToArray();
HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf");
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + documentTitle + ".pdf");

//HttpContext.Current.Response.AddHeader("Content-Disposition", "inline; filename=" + documentTitle + ".pdf");
HttpContext.Current.Response.BinaryWrite(downloadBytes);
HttpContext.Current.Response.End();

Please feel free to contact us for any further assistance.

Best Regards