What is the equivalent of stamper.AddJavaScript fu

2019-08-29 04:39发布

We are writing a program that needs to insert document-level JavaScript with iText 7. We founded that with iText 5, the solution was Stamper.AddJavaScript().

标签: itext7
1条回答
别忘想泡老子
2楼-- · 2019-08-29 05:10

It depends on the type of event you want your JavaScript code to be triggered at.

For instance, to define an action that would be executed as soon as the document is opened, use PdfDocument#getCatalog().setOpenAction.

Example for opening a print dialog when the document is opened:

pdfDocument.getCatalog().setOpenAction(PdfAction.createJavaScript("this.print(true);"));
查看更多
登录 后发表回答