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

InsertPage #455

Open
FreeVB opened this issue Nov 12, 2024 · 0 comments
Open

InsertPage #455

FreeVB opened this issue Nov 12, 2024 · 0 comments

Comments

@FreeVB
Copy link

FreeVB commented Nov 12, 2024

Why is there an error when inserting a picture?

Inserts the specified page in this document. If the page is from an external document, it is imported to this document. In this case the returned page is not the same object as the specified one.

PdfDocument document = PdfReader.Open(sourcePdfPath, PdfDocumentOpenMode.Modify);
PdfPage newPage = document.AddPage();
XImage image = XImage.FromFile(imagePath);
XGraphics gfx = XGraphics.FromPdfPage(newPage);
gfx.DrawImage(image, 0, 0, newPage.Width, newPage.Height);
if (pageIndex < document.PageCount - 1)
{
    document.InsertPage(pageIndex + 1, newPage);
}
else
{
    document.AddPage(newPage);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant