galkahana / HummusJS

Node.js module for high performance creation, modification and parsing of PDF files and streams
http://www.pdfhummus.com
Other
1.14k stars 169 forks source link

Method to enable CatalogUpdateRequired from js #239

Closed marcelotavares closed 6 years ago

marcelotavares commented 6 years ago

The Catalog Write Events is not fired if there is no changes on pdf. But the PdfWriter calls IsCatalogUpdateRequiredForModifiedFile from extender and we can force catalog update if we need.

I'm using these event to create Metadata entry in pdf catalog instead of recreate entire object.

Follows the usage example:

const objectId = objectsContext.startNewIndirectObject(); pdfWriter.requireCatalogUpdate(); pdfWriter.getEvents().on('OnCatalogWrite',function(dictionaryContext){ dictionaryContext.catalogDictionaryContext.writeKey('Metadata'); dictionaryContext.catalogDictionaryContext.writeObjectReferenceValue(objectId); });

galkahana commented 6 years ago

sorry for being so late...very welcome addition. thank you