decktape.js
function parseXObject(xObject) {
    const objectId = xObject.getObjectID();
    const pdfStreamInput = cpyCxtParser.parseNewObject(objectId);
    const xObjectDictionary = pdfStreamInput.getDictionary().toJSObject();
    if (xObjectDictionary.Subtype.value === 'Image') {
      // Create a hash of the compressed stream instead of using
      // startReadingFromStream(pdfStreamInput) to skip uneeded decoding
      const stream = cpyCxtParser.getParserStream();
      stream.setPosition(pdfStreamInput.getStreamContentStart());
      const digest = crypto.createHash('SHA1')
        .update(Buffer.from(stream.read(pdfStreamInput.getDictionary().toJSObject().Length.value)))
        .digest('hex');
      if (!context.pdfXObjects[digest]) {
        xObjects[digest] = objectId;
      } else {
        const replacement = {};
        replacement[objectId] = context.pdfXObjects[digest];
        cpyCxt.replaceSourceObjects(replacement);
      }
    } else {
      parseResources(xObjectDictionary);
    }
  }
function parseXObject(xObject) {
    const objectId = xObject.getObjectID();
    const pdfStreamInput = cpyCxtParser.parseNewObject(objectId);
    const xObjectDictionary = pdfStreamInput.getDictionary().toJSObject();
    if (xObjectDictionary.Subtype.value === 'Image') {
      // Create a hash of the compressed stream instead of using
      // startReadingFromStream(pdfStreamInput) to skip uneeded decoding
      const stream = cpyCxtParser.getParserStream();
      stream.setPosition(pdfStreamInput.getStreamContentStart());
      const digest = crypto.createHash('SHA1')
        .update(Buffer.from(stream.read(pdfStreamInput.getDictionary().toJSObject().Length.value)))
        .digest('hex');
      if (!context.pdfXObjects[digest]) {
        xObjects[digest] = objectId;
      } else {
        const replacement = {};
        replacement[objectId] = context.pdfXObjects[digest];
        cpyCxt.replaceSourceObjects(replacement);
      }
    } else {
      parseResources(xObjectDictionary);
    }
  }
function parseXObject ( xObject ) { const objectId = xObject . getObjectID ( ) ; const pdfStreamInput = cpyCxtParser . parseNewObject ( objectId ) ; const xObjectDictionary = pdfStreamInput . getDictionary ( ) . toJSObject ( ) ; if ( xObjectDictionary . Subtype . value === 'Image' ) { // Create a hash of the compressed stream instead of using // startReadingFromStream(pdfStreamInput) to skip uneeded decoding const stream = cpyCxtParser . getParserStream ( ) ; stream . setPosition ( pdfStreamInput . getStreamContentStart ( ) ) ; const digest = crypto . createHash ( 'SHA1' ) . update ( Buffer . from ( stream . read ( pdfStreamInput . getDictionary ( ) . toJSObject ( ) . Length . value ) ) ) . digest ( 'hex' ) ; if ( ! context . pdfXObjects [ digest ] ) { xObjects [ digest ] = objectId ; } else { const replacement = { } ; replacement [ objectId ] = context . pdfXObjects [ digest ] ; cpyCxt . replaceSourceObjects ( replacement ) ; } } else { parseResources ( xObjectDictionary ) ; } }
Consolidate duplicate images
Consolidate duplicate images