From df96abbe1016739b7d21dc0fb1df975a0321b6f3 Mon Sep 17 00:00:00 2001 From: Antonin Stefanutti Date: Sat, 4 Nov 2023 16:52:43 +0100 Subject: [PATCH] Do not remove identical image references --- decktape.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/decktape.js b/decktape.js index 99c31ca..ef7cc0c 100755 --- a/decktape.js +++ b/decktape.js @@ -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); }