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

Copying Pages which include Tables #1701

Open
2 tasks done
tomhands1 opened this issue Nov 26, 2024 · 0 comments
Open
2 tasks done

Copying Pages which include Tables #1701

tomhands1 opened this issue Nov 26, 2024 · 0 comments

Comments

@tomhands1
Copy link

What were you trying to do?

Trying to copy pages from an existing PDF Document into a new document

How did you attempt to do it?

const fullPDFDoc = await PDFDocument.load(fileBuffer);
        const pageNumbers: number[] = Array((endPage - startPage) - 1).fill(startPage - 1).map((startPage, pageIndex) => pageIndex + startPage);
        const newPDFDoc = await PDFDocument.create();
        const pages = await newPDFDoc.copyPages(fullPDFDoc, pageNumbers)
        pages.forEach(page => newPDFDoc.addPage(page));
        const bytes = await newPDFDoc.save();

What actually happened?

This works for buffers of PDF's where the pages that I am copying include text only, but does not appear to work if the pages being copied include tables which is the primary need that I have here.

What did you expect to happen?

I expected the tables to be copied over to the newly created document like what happens with PDF document without tables

How can we reproduce the issue?

const fullPDFDoc = await PDFDocument.load(fileBuffer);
        const pageNumbers: number[] = Array((endPage - startPage) - 1).fill(startPage - 1).map((startPage, pageIndex) => pageIndex + startPage);
        const newPDFDoc = await PDFDocument.create();
        const pages = await newPDFDoc.copyPages(fullPDFDoc, pageNumbers)
        pages.forEach(page => newPDFDoc.addPage(page));
        const bytes = await newPDFDoc.save();

Version

1.17.1

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

@tomhands1 tomhands1 changed the title CopyingPages which include Tables Copying Pages which include Tables Nov 26, 2024
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