Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'page.AddDocumentLink’ The selected area is incorrect #30

Closed
soul-soft opened this issue Aug 24, 2023 · 2 comments
Closed

'page.AddDocumentLink’ The selected area is incorrect #30

soul-soft opened this issue Aug 24, 2023 · 2 comments
Labels

Comments

@soul-soft
Copy link

soul-soft commented Aug 24, 2023

Code

The selected areas of these two functions are incorrect, it seems that they are mirror symmetric

var pdf = new PdfDocument();
var page = pdf.AddPage();
page.AddDocumentLink(new PdfRectangle(new XRect(0, 0, page.Width, 40)), 2);

var graphics = XGraphics.FromPdfPage(page);
graphics.DrawRectangle(XBrushes.Black, new XRect(0, 0, page.Width, 40));
pdf.Save("D:\\test2.pdf");
@ThomasHoevel
Copy link
Member

From the source code documentation:

/// <summary>
/// Adds an internal document link.
/// </summary>
/// <param name="rect">The link area in default page coordinates.</param>
/// <param name="destinationName">The Named Destination's name.</param>
public PdfLinkAnnotation AddDocumentLink(PdfRectangle rect, string destinationName)

Conversion:

rect = gfx.Transformer.WorldToDefaultPage(new XRect(new XPoint(100, 400), new XSize(350, 150)));

@soul-soft
Copy link
Author

soul-soft commented Aug 25, 2023

从源代码文档中:

/// <summary>
/// Adds an internal document link.
/// </summary>
/// <param name="rect">The link area in default page coordinates.</param>
/// <param name="destinationName">The Named Destination's name.</param>
public PdfLinkAnnotation AddDocumentLink(PdfRectangle rect, string destinationName)

转换:

rect = gfx.Transformer.WorldToDefaultPage(new XRect(new XPoint(100, 400), new XSize(350, 150)));

nice!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants