Open Elliot128 opened 8 years ago
i'll help with that. in modifications scenarios it is not guaranteed that the catalog will be rewritten (there's already one from the original PDF). for example, if no pages are added, there's no need to write a page tree and therefore the catalog.
this is why you are not getting the oncatalogwrite event.
thing is that in modifications scenarios you don't really need it. want to add an acroform to the catalog object? change it directly. create a new object with the same ID, copy all existing keys, and add acroform. so you don't have to look for an example on how to recreate an object, here's one - https://github.com/galkahana/HummusJS/blob/master/tests/ModifyingExistingFileContent.js#L100
[thirdpage object is being modified. do the same with the catalog object].
Gal.
Thank you for the help! :) I have this diagram from a book on PDF's. If I add text to a page, wouldn't that modify the page content, which is part of the Document Catalog?
https://github.com/galkahana/PDF-Writer/issues/62#issuecomment-240521272
Also, here is a person asking about the Acroform. You say that to create the Acfroform he must '...add a reference to the acroform from the catalog object. you do that by implementing a handler for OnCatalogWrite method of IDocumentContextExtender and attaching a listener prior to the pdfwriter ending.'
But here you say that I do not need to listen to the OnCatalogWrite event. I do not understand why he needs to use the listener to build the Acroform but I do not.
PdfWriter support a way to force catalog rewrite event there is no modifications. See #239
I want to add an acroform dictionary and some forms to my pdf. To do this I am using the OnCatalogWrite event as shown here: https://github.com/galkahana/HummusJS/wiki/Extensibility#oncatalogwrite
However, this event does not fire on pdfWriter.end() in my code. How can I get this event to fire properly so I can build the acroform?