在 Adobe Reader 中使用 Javascript
我目前正在对一些文档使用以下脚本:
var pp = this.getPrintParams();
pp.interactive = pp.constants.interactionLevel.automatic;
this.print(pp);
如何添加另一个命令,例如 document.close()
以便它读取打印函数,然后最后跟随关闭文档?我是否只需在打印命令之后添加关闭命令,以便它会显示
var pp = this.getPrintParams();
pp.interactive = pp.constants.interactionLevel.automatic;
this.print(pp);
document.close();
“谢谢”。
添加
我的问题是我不知道如何完成一个命令并直接进入下一个命令。我已经放弃尝试关闭文档,因为我意识到它将在浏览器中打开。所以现在我的下一个想法是在 print 命令之后使用 history.back(-1);
。我只是不明白如何在 javascript 中启动/停止命令。
I am currently using the following script for a few documents:
var pp = this.getPrintParams();
pp.interactive = pp.constants.interactionLevel.automatic;
this.print(pp);
How do I add another command, say document.close()
so that it reads the print function and then follows the close document last? Do I simply add the close command right after the print command so it would read
var pp = this.getPrintParams();
pp.interactive = pp.constants.interactionLevel.automatic;
this.print(pp);
document.close();
Thanks.
ADDITION
My problem here is I cannot figure out how to finish off one command and get right into the next. I have given up on trying to make the document close, since I realized it will open in the browser. So now my next idea is to use history.back(-1);
after the print command. I just don't understand how to start/stop commands in the javascript.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加此
history.go(-1);
而不是history.back(-1);
add this
history.go(-1);
instead ofhistory.back(-1);
print
函数应该阻塞(暂停),直到用户完成打印对话框的处理,然后继续。您无需执行任何特殊操作即可在其后运行更多代码。也就是说,您真的需要在打印后强制关闭文档吗?作为一名用户,如果网站对我这样做,我会非常生气。如果我想将 PDF 保存到我的电脑上怎么办?如果我的打印机墨水不足并且我需要重新打印怎么办?让我决定何时关闭您的 PDF。
The
print
function should block (pause) until the user finishes dealing with the print dialog, then continue. You don't have to do anything special to run more code after it.That said, do you really need to force the document to close after it prints? As a user, I'd be pretty miffed if a website did this to me. What if I want to save the PDF to my computer? What if my printer was low on ink and I need to print it again? Let me decide when to close your PDF.