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

Adding links shows cursor pointer on 2 locations?
https://forum.pdfsharp.net/viewtopic.php?f=3&t=4663
Page 1 of 1

Author:  RolfHesterberg [ Wed Aug 28, 2024 1:57 pm ]
Post subject:  Adding links shows cursor pointer on 2 locations?

In the footer I add an email link with page.AddWebLink(LINK).
LINK is something like "mailto:xxx@yyy.zz".
Clicking on this link, my Outlook opens perfectly. Everthing is perfect.
I'm using pdfsharp.dll version 1.51.5185.0.

Now I observe, that at the top of my pages, in a XRect the mouse cursor turns to the pointer as well as in the link at the end of the page.
The size of the XRect at the top has the same size as the XRect at the bottom.
However, on the top no text is visible.
It seems, that pdfsharp inserts my link twice: once at the bottom, once at the top.
I checked my XRect, no error found. No double call of page.AddWebLink(LINK) in my code.
The same problem was observed when I use page.AddFileLink(...);

Here the code as example:

Code:
for (int p = 0; p < doc.Pages.Count; p++)
{
    px = GetPositionLeft;
    py = GetPositionTop;
    email = "xxxx@yyyy.zz";
    using (XGraphics gfx = XGraphics.FromPdfPage(doc.Pages[p]))
    {
        [...]
        txt = email;
        width = gfx.MeasureString(txt, FontFooter).Width;
        txt = "mailto:" + email;
        XRect rect = new XRect(px, py, width, FontFooter.GetHeight());
        PdfRectangle rectLink = new PdfRectangle(rect);
        doc.Pages[p].AddFileLink(rectLink, txt );
        txt = email;
        gfx.DrawString(txt, FontLink, XBrushes.Blue, px, py, XStringFormats.TopLeft);
        [...]
    }
}


Any help is appreciated. Kind regards.

Attachments:
pdfsharpLinkProblem.jpg
pdfsharpLinkProblem.jpg [ 87.56 KiB | Viewed 1354 times ]

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