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

removePage function does not fully remove the page #1588

Open
2 tasks done
vne-celum opened this issue Jan 16, 2024 · 0 comments
Open
2 tasks done

removePage function does not fully remove the page #1588

vne-celum opened this issue Jan 16, 2024 · 0 comments

Comments

@vne-celum
Copy link

vne-celum commented Jan 16, 2024

What were you trying to do?

Remove the first page from a PDF and then copy all its pages to the main PDF.

How did you attempt to do it?

sourcePdf.removePage(0);

const copiedPages= await mainPdf.copyPages(sourcePdf, sourcePdf.getPageIndices());
copiedPages.forEach(page => mainPdf.addPage(page));

What actually happened?

The removed page was copied and the last page of the document was not. From what I noticed this is because getPageIndices works correctly, but inside the copyPages function we call getPages and this still holds a reference to the removed page.

What did you expect to happen?

copyPages/getPages functions are not holding and working with a removed page

How can we reproduce the issue?

https://jsfiddle.net/2mpk8otf/

Link where you can see that getPages still hold reference to the old page after removal, while getPageCount and getPageIndices work correctly.

Version

1.17

What environment are you running pdf-lib in?

Node

Checklist

  • My report includes a Short, Self Contained, Correct (Compilable) Example.
  • I have attached all PDFs, images, and other files needed to run my SSCCE.

Additional Notes

No response

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

No branches or pull requests

1 participant