Duplicate PDF when merging #1000
Answered
by
TheProgrammer21
TheProgrammer21
asked this question in
Q&A
-
I try to merge multiple pdf documents to one but my first pdf is in the merged pdf 2 times. (one and a duplicate) const mergedPdf = await PDFDocument.create();
console.log(allPdfs.length);
for (const pdfBytes of allPdfs) {
const pdf = await PDFDocument.load(pdfBytes);
const copiedPages = await mergedPdf.copyPages(pdf, pdf.getPageIndices());
copiedPages.forEach((page) => {
mergedPdf.addPage(page);
});
} When I have 2 pdfs, each one page, my result is a pdf file with 3 pages. The fist page is present 2 times and then the second page (being a third page in the merged pdf) comes. Any ideas? |
Beta Was this translation helpful? Give feedback.
Answered by
TheProgrammer21
Sep 21, 2021
Replies: 1 comment
-
Nevermind, there was another bug in my code. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
TheProgrammer21
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nevermind, there was another bug in my code.