PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Mar 19, 2024 2:52 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Jun 18, 2012 5:46 pm 
Offline

Joined: Thu Oct 20, 2011 4:33 pm
Posts: 3
I am trying to figure out how to add a simple hyperlink or weblink (not sure what the diff is) onto my pdf document.
Here is my code. in the end i would prefer a link that goes to Google.Com and has text Click Here for Goolge.
I can't find any good examples of how to do this. :(

using (XGraphics gfx = XGraphics.FromPdfPage(page))
{
XRect rec = gfx.Transformer.WorldToDefaultPage(new XRect(new XPoint(30, 60), new XSize(30, 30)));
PdfRectangle rect = new PdfRectangle(rec);

PdfLinkAnnotation link = PdfLinkAnnotation.CreateWebLink(rect, "www.google.com");
page.Annotations.Add(link);

page.AddWebLink(rect, "www.google.com");
gfx.DrawRectangle(XPens.Black, XBrushes.Black, link.ToString());
}


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 19, 2012 9:18 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3092
Location: Cologne, Germany
AddWebLink is the way to go. All AddWebLink does is create a clickable area where Adobe Reader shows a different cursor.
It's up to you to draw text or a frame at that area.

So maybe your link is already working, but you don't see it until you move the mouse to the right spot.

See also:
viewtopic.php?p=3804#p3804

With MigraDoc you would use AddHyperlink. You specify the text for the hyperlink, MigraDoc calculates the rectangle.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 31 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