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

Do not remove identical image references #315

Merged
merged 1 commit into from
Nov 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions decktape.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,12 @@ async function printSlide(pdf, slide, context) {
const subtype = object.dict.get(PDFName.of('Subtype'));
if (subtype === PDFName.of('Image')) {
const digest = crypto.createHash('SHA1').update(object.contents).digest('hex');
if (!context.pdfXObjects[digest]) {
const existing = context.pdfXObjects[digest];
if (!existing) {
// Store the entry that'll replace references with the same content
context.pdfXObjects[digest] = entry;
} else {
} else if (entry !== existing) {
// Only remove references from different pages
xObject.set(name, context.pdfXObjects[digest]);
duplicatedEntries.push(entry);
}
Expand Down