-
-
Notifications
You must be signed in to change notification settings - Fork 754
file size problem: 433mb generated from a 15mb document #1338
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
Comments
Hi @Hopding |
Also wondering about this |
Yea, same issue here. Even the simple pages copying increases the result PDF size: const copyDocument = async (buffer) => {
console.log('initial size: ', buffer.byteLength); // 20296
const newPdf = await PDFDocument.create();
const initialPdf = await PDFDocument.load(buffer);
const pages = initialPdf.getPages();
for (let i = 0; i < pages.length; i++) {
const [newPage] = await newPdf.copyPages(initialPdf, [i]);
newPdf.addPage(newPage);
}
const bufferCopy = await newPdf.save();
console.log('copy size: ', bufferCopy.byteLength); // 31691
}; |
Yes, same issue encountered, 9MB file split with each file 10 page, increase to 60MiB for each sub file.
|
Have you tried using // append to created pdf
const [copyPage] = await this.output.copyPages(inputPdf, [0])
this.output.addPage(copyPage) |
Hi @p-kuen |
Oh sorry, I should've watched more closely. I use copyPages myself and use the trick to put the whole merged pdf into ghostscript for compression, so I never had problems with this one. Not the cleanest solution but effective. |
Anybody got any solution on this issue? |
same issue, |
Well it seems that this is the same kind of bug described here: issue 1662 copyPages() seems to copy all object referenced in the source pdf into the new pdf regardless of their appearance in the copied page. I guess this is a severe bug, i wonder why this doesn't come up more. |
Uh oh!
There was an error while loading. Please reload this page.
What were you trying to do?
I'm trying to generate a new PDF document based on an existing one.
See
How can we reproduce the issue?
section to download the original pdf document that is causing this issue.How did you attempt to do it?
I'm using a code similar to this one:
What actually happened?
The original document is 15 Mb in size and the generated document is 433 Mb.
What did you expect to happen?
I expected to get similar sizes from both the original and the generated document.
How can we reproduce the issue?
The code attached in section
How did you attempt to do it?
will reproduce this issue.I think this is an issue specifically with this document, which is based on scanned images.
Version
1.17.1
What environment are you running pdf-lib in?
Node
Checklist
Additional Notes
No response
The text was updated successfully, but these errors were encountered: