pdfjs
pdfjs copied to clipboard
Capability of adding javascript action and named openAction
Hi, Thanks for this library!
I'm looking for a feature of popping up the print dialog when the document is opened. This seems to be possible by adding the javascript action or the namedAction. However, I didn't see an api in this library dealing with the js/named actions. I'm wondering if this is a valid feature request.
There is a way I could see for this feature to work without changing the basic working flow of your lib:
- For adding the javascript action: Referencing to pdf specification-7.7.4 Name Dictionary, it is possible to add the javascript actions similar to the destination, by having a new entry(/Javascript [jsNameTree]) in the document's name dictionary.
- For adding the named action triggered when the document is opened, there are two steps:
- Write the action dictionary entries specific to named actions (referencing to pdf specification-12.6.4.11 Named Actions). The structure is quite simple based on the doc.
- Trigger the named action when the document is opened. This can be implemented by associated the named action dictionary to the
/OpenAction
entry in the catalog dictionary. (referencing to pdf specification-7.7.2 Document Catalog)
Do you think the above solution can be implemented? If this sounds to be a feasible solution, I'd love to work on it and open a pull request to add the apis as doc.javascript()
and doc.namedOpenAction()
.
Hi, it sounds like something worth adding, and I think it can be down like you described it. It would probably also help supporting use-cases like https://github.com/rkusa/pdfjs/issues/235. Since, I personally don't have a use-case for this, a PR would be welcome!