Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Jun 17, 2016 5:48 pm

When using the latest hotfix for Spire.Pdf (commercial version), the insert hyperlink functionality is broken. The text for the hyperlink is viewable on the page but there will be no hyperlink associated with it. Therefore, the link will appear on a page but it will not be clickable. It worked in prior versions.

Bug introduced in version:
Spire.Pdf 3.6.321.4040

Last worked in version:
Spire.Pdf 3.6.131.4040

Sample code:
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"files\Upgrade.pdf");

string hyperlinkText = "HLText";
string hyperlinkURL = "www.microsoft.com";
string hyperlinkFont = "Veranda";
float hyperlinkFontSize = 12f;
float x = 100;
float y = 100;

// Draw the image...
PdfPageBase page = doc.Pages[0];
PdfBrush brush = PdfBrushes.DarkBlue;
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font(hyperlinkFont, hyperlinkFontSize, System.Drawing.FontStyle.Underline));

PdfTextWebLink link = new PdfTextWebLink();
link.Text = hyperlinkText;
link.Url = hyperlinkURL;
link.Font = font;
link.Brush = brush;
link.DrawTextWebLink(page.Canvas, new PointF(x, y));

// Use Spire.Pdf to do the conversion...
doc.SaveToFile("broken_hyperlink_test.pdf");

rutzelt
 
Posts: 43
Joined: Mon Sep 22, 2014 4:59 pm

Mon Jun 20, 2016 6:00 am

Hi,

Thanks for your posting.
Now the latest version is Spire.PDF Pack(Hot Fix) Version:3.7.91. It works fine with your code. Please use the version.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Mon Jun 20, 2016 1:46 pm

Hi Amy. We are using Spire.Office. The latest hotfix for Spire.Office (which contains Spire.Pdf) is version 3.7.86.4040. That version still has the problem.

Please let us know when you release a hotfix for Spire.Office which contains this correction.

Thank you,
Tom

rutzelt
 
Posts: 43
Joined: Mon Sep 22, 2014 4:59 pm

Tue Jun 21, 2016 1:58 am

Dear Tom,

Thanks for your reply.
I tested your code with Spire.Office 2.14.1 (which contains Spire.Pdf version 3.7.86.4040), and hyperlink functionality in the output pdf file is fine. Attached is output pdf file.
Here is my testing code.
Code: Select all
static void Test_7893()
        {
            PdfDocument doc = new PdfDocument();
           
            string hyperlinkText = "HLText";
            string hyperlinkURL = "www.microsoft.com";
            string hyperlinkFont = "Veranda";
            float hyperlinkFontSize = 12f;
            float x = 100;
            float y = 100;

            PdfPageBase page = doc.Pages.Add();
            PdfBrush brush = PdfBrushes.DarkBlue;
            PdfTrueTypeFont font = new PdfTrueTypeFont(new Font(hyperlinkFont, hyperlinkFontSize,   System.Drawing.FontStyle.Underline));

            PdfTextWebLink link = new PdfTextWebLink();
            link.Text = hyperlinkText;
            link.Url = hyperlinkURL;
            link.Font = font;
            link.Brush = brush;
            link.DrawTextWebLink(page.Canvas, new PointF(x, y));

            string output = "broken_hyperlink_test.pdf";
            doc.SaveToFile(output);
            System.Diagnostics.Process.Start(output);
        }


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Tue Jun 21, 2016 1:15 pm

Hi Amy. For your test case, you added a new page and then added the hyperlink. For my test case, it requires that I add the hyperlink to an existing page. This functionality worked in the past but is broken now.

Please make the following change to your test case and you will see the problem:

Change:
PdfPageBase page = doc.Pages.Add();

To:
PdfPageBase page = doc.Pages[0];

The resulting hyperlink will not be clickable.

Thanks,
Tom

rutzelt
 
Posts: 43
Joined: Mon Sep 22, 2014 4:59 pm

Wed Jun 22, 2016 1:59 am

Dear Tom,

I tested the case that adding the hyperlink to an existing page. Yes, the issue indeed exists. We are so sorry for the inconvenience caused by the issue. We will fix it soon, and inform you when new version is released.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Mon Jun 27, 2016 2:10 am

Hi,

Thanks for waiting.
The issue has been fixed. New version of Spire.PDF has been released, Spire.PDF Pack(Hot Fix) Version:3.7.106. We will build a new version of Spire.Office, and will inform you when it is released.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Mon Jun 27, 2016 2:50 pm

Thank you Amy.

rutzelt
 
Posts: 43
Joined: Mon Sep 22, 2014 4:59 pm

Tue Jul 12, 2016 7:09 pm

Hi Amy. Has the hotfix for Spire.Office been released yet? My clients have been asking for any update.

Thank you,
Tom

rutzelt
 
Posts: 43
Joined: Mon Sep 22, 2014 4:59 pm

Wed Jul 13, 2016 6:19 am

Dear Tom,

Sorry for the delayed update.
We will provide you new hotfix for Spire.Office within this week.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Fri Jul 15, 2016 9:36 am

Dear Tom,

At present, there is temporary version of Spire.Office, welcome to download it via this link:
http://www.e-iceblue.com/downloads/Temp ... 2.14.3.zip

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Fri Jul 15, 2016 2:52 pm

Thank you Amy. This appears to fix the problem. Please let us know when the official hotfix is ready.

Regards,
Tom

rutzelt
 
Posts: 43
Joined: Mon Sep 22, 2014 4:59 pm

Mon Jul 18, 2016 1:45 am

Hi Tom,

Thanks for your feedback.
We will inform you when the official hotfix is released.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Mon Aug 10, 2020 2:49 am

Hi,

I am working on adding the "WebLink" in the existing PDF file , I'm able to add the text but the link is not there.
DrawTextWebLink is working when I add the hyperlink in the new page .

I'm using FreeSpire.PDF Verson :6.2.0
Can you please , let me know how to add the link in existing page with text.

Samridhi
 
Posts: 2
Joined: Mon Aug 10, 2020 2:41 am

Mon Aug 10, 2020 5:44 am

Hi Samridhi,

Thanks for your inquiry.
Please refer to the following code to add the link in existing page with text. If there are any other questions, just feel free to write back.
Code: Select all
    //Load the file
    PdfDocument doc = new PdfDocument();
    doc.LoadFromFile("test.pdf");
    PdfPageBase page = doc.Pages[0];
    PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Calibri", 14));           
    //Add link
    string text = "Spire.PDF";
    PointF location = new PointF(10, 10);
    SizeF size = font.MeasureString(text);
    RectangleF rect = new RectangleF(location, size);
    PdfUriAnnotation link = new PdfUriAnnotation(rect);
    link.Border = new PdfAnnotationBorder(0);
    link.Uri = "https://www.e-iceblue.com/Introduce/pdf-for-net-introduce.html";
    page.AnnotationsWidget.Add(link);
    page.Canvas.DrawString(text, font, PdfBrushes.Black, location);
    doc.SaveToFile("out.pdf");


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.PDF