PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Remove box around hyperlink?
https://forum.pdfsharp.net/viewtopic.php?f=2&t=872
Page 1 of 1

Author:  djMax [ Tue Sep 15, 2009 4:31 pm ]
Post subject:  Remove box around hyperlink?

I'm new to MigraDoc, so apologies if one of the 30 ways I tried to search for the answer should have worked. I'm adding a hyperlink to a document and it's showing up with borders. The Hyperlink style doesn't seem to have borders set on it, so I'm not sure who's adding them. How can I make Hyperlinks look like "normal web links", e.g. underlined without a border.

Code:
         paragraph = document.LastSection.AddParagraph();
         Hyperlink hl = paragraph.AddHyperlink(o.Url, HyperlinkType.Web);
         hl.AddText(o.Url);

Author:  Thomas Hoevel [ Wed Sep 16, 2009 7:59 am ]
Post subject:  Re: Remove box around hyperlink?

Hyperlinks don't have borders by default (AFAIK).

Set the Hyperlink style to look as you want it.
Or use hl.AddFormattedText.

Author:  SmirkinGherkin [ Tue Oct 27, 2009 3:06 pm ]
Post subject:  Re: Remove box around hyperlink?

Hi,

I don't know if you managed to resolve this but I had the same issue and after a while managed to find a solution which seems to work although someone may advise that it causes other issues.

After a while investigating I determined that this issue wasn't caused by any formatting on the text but by the actual annotation in the PDF which provides the link functionality. Debugging showed that the color of the annotation was black (same color as the border) so I assumed that the border was the background showing through. Changing the color of the annotation within the PDFSharp code resolved the issue. The change in question was in the file PdfLinkAnnotation.cs in the PDFSharp project. Amending the CreateWebLink method to:
Code:
    public static PdfLinkAnnotation CreateWebLink(PdfRectangle rect, string url)
    {
      PdfLinkAnnotation link = new PdfLinkAnnotation();
      link.linkType = PdfLinkAnnotation.LinkType.Web;
      link.Rectangle = rect;
      link.url = url;
      link.Color = PdfSharp.Drawing.XColor.FromArgb(0, 255, 255, 255);
      return link;
    }


resolve the issue for me.

Hope this helps someone.

Author:  SmirkinGherkin [ Thu Nov 26, 2009 8:58 am ]
Post subject:  Re: Remove box around hyperlink?

This is a different topic to what was initially posted about so should have been in a new thread.
{Admin note: the previous post was removed; the reply was left here though it's a bit off topic.}

To have a link which opens a new mail message in your email client use "mailto:" in the link url e.g. to send an email to foo@bar.com you would use the link "mailto:foo@bar.com".

An MSDN article on different options is at http://msdn.microsoft.com/en-us/library/aa767737%28VS.85%29.aspx

Author:  jvdneut [ Thu Mar 17, 2011 9:21 am ]
Post subject:  Re: Remove box around hyperlink?

Hi,

I encountered the same issue. Turns out that, as Thomas indicated, there is indeed no border around hyperlinks. For me the issue was caused by my PDF viewer (Foxit Reader). When opening the same PDF in another reader (OS X Preview) no border showed.

Hope that helps someone.

Author:  tawulf [ Tue Nov 20, 2012 11:12 am ]
Post subject:  Remove box around hyperlink?

Hi,

this is not really a new issue, but I started it as a new thread anyway, to indicate, that it really deserves your attention; I hope that won't break some forum rules.

Like it was stated in viewtopic.php?f=2&t=872 there is a problem with ugly boxes showing up around hyperlinks.

Thomas stated, that there ARE no borders for PDFsharp's hyperlinks and that the problem is with the readers, that display the document.

Well, that is true but not a solution. Actually, from all I have gathered, the absence of borders in hyperlinks created by PDFsharp is exactly the source of the whole issue: without explicit border attributes all readers must somehow decide which default they should use. That was not a problem when Adobe's Reader, by far the most widely used reader, defaulted to 'no border' or 'borderwidth=0' or 'bordercolor=transparent' or what ever made the border not show up.

But that has changed: It looks now that somewhere hidden in the specs ther is a rule that calls for box-borders in absence of document-provided borders and the newer version of Abode reader do just that. Foxit does not, at the moment, but some folks call for it to adhere to the spec, too. And on the Mac the borders are there too, both on the Adobe reader and on the Apple preview.

Links created by other libraries do it right, but I'd much rather stay with PDFsharp!!

So this is really a problem that ought to be solved here in PDFsharp and I guess simply adding the borderwidth=0 and/or bordercolor=transparent would be enough. The hyperlink-text could still be styled and useres of the library would need to change anything at all.

thanks for listening, Thomas Wulf

Author:  Thomas Hoevel [ Tue Nov 20, 2012 11:25 am ]
Post subject:  Re: Remove box around hyperlink?

Hi!

Bug fix was posted here:
viewtopic.php?p=6161#p6161

Both threads were merged.

Author:  Thomas Hoevel [ Tue Nov 20, 2012 11:29 am ]
Post subject:  Re: Remove box around hyperlink?

jvdneut wrote:
Turns out that, as Thomas indicated, there is indeed no border around hyperlinks.
Well, now we know that I was wrong.

PDFsharp always created hyperlinks with boxes, but Adobe Reader 4 through Adobe Reader 10.0.3 didn't display these boxes. Adobe fixed the bug with Adobe Reader 10.0.4.

See here how to change PDFsharp to avoid the boxes:
viewtopic.php?p=6161#p6161

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/