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

Set "Open in Full Screen mode" #262

Open ckothari opened 6 years ago

ckothari commented 6 years ago

Is it possible to generate/edit pdf with "Open in Full Screen mode" set:

acrobat

galkahana commented 6 years ago

Yes. you can use an event handler on catalog writing (for a new document. for modification scenarios, modify the catalog objects directly). like in this code:

pdfWriter.getEvents().on('OnCatalogWrite',function(eventParams){
    var catalogDictionaryContext = eventParams.catalogDictionaryContext;
    catalogDictionaryContext.writeKey('PageMode');
    catalogDictionaryContext.writeNameValue('FullScreen');

})

For more on how to setup viewing options for an opened PDF, look into the PDF Reference Manual, section 8.1 - View Preferences.

chunyenHuang commented 6 years ago

I thought the event onCatalogWrite will not be triggered at most of the time. Do you want to consider the pull request? #239 Method to enable CatalogUpdateRequired from js

galkahana commented 6 years ago

nope. the onCatalogWrite will trigger when a catalog is written. it is written every time hummus is used to create a new pdf. modification scenarios it the exception, when no pages are added, cause in this case you can modify it direclty.

galkahana commented 6 years ago

@chunyenHuang sorry. i saw the PR now. it's a good idea. i'll add sometimes soon. it allows you to force catalog updates in the cases when the catalog is not updated, which happens in modification schearios. it's a better alternative to writing it directly, because it hides the necessity to know about the logic of when catalog is updated or not. thanks for the reminder.

chunyenHuang commented 6 years ago

Sounds good! Thank you @marcelotavares

galkahana commented 6 years ago

now in 1.0.85