PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Jul 09, 2024 8:22 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
PostPosted: Tue Sep 15, 2009 4:31 pm 
Offline

Joined: Tue Sep 15, 2009 4:25 pm
Posts: 1
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);


Top
 Profile  
 
PostPosted: Wed Sep 16, 2009 7:59 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Hyperlinks don't have borders by default (AFAIK).

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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
 
PostPosted: Tue Oct 27, 2009 3:06 pm 
Offline

Joined: Tue Oct 27, 2009 2:56 pm
Posts: 2
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.


Top
 Profile  
 
PostPosted: Thu Nov 26, 2009 8:58 am 
Offline

Joined: Tue Oct 27, 2009 2:56 pm
Posts: 2
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


Top
 Profile  
 
PostPosted: Thu Mar 17, 2011 9:21 am 
Offline

Joined: Thu Mar 17, 2011 9:16 am
Posts: 1
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.


Top
 Profile  
 
PostPosted: Tue Nov 20, 2012 11:12 am 
Offline

Joined: Sun Oct 28, 2012 11:27 am
Posts: 6
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


Top
 Profile  
 
PostPosted: Tue Nov 20, 2012 11:25 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Hi!

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

Both threads were merged.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
 
PostPosted: Tue Nov 20, 2012 11:29 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 39 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group