简体   繁体   English

如何防止用户使用JavaScript在LiveCycle xfa Form中使用Adobe菜单中的“打印”按钮?

[英]How can we prevent user using Print button from Adobe Menu in LiveCycle xfa Form using JavaScript?

I want to user to use print button on the form not on the adobe menu? 我想让用户使用Adobe菜单上未在表单上的打印按钮吗? How can I disable and pass error message every time user click the print button from adobe menu? 每当用户单击Adobe菜单中的“打印”按钮时,如何禁用和传递错误消息? using JavaScript for Xfa forms that are developed in LiveCycle. 将JavaScript用于LiveCycle中开发的Xfa表单。

A workaround would be to check for a variable in the prePrint event, that you only fill when clicking the button. 一种解决方法是在prePrint事件中检查变量,仅在单击按钮时才填写。 So if the user clicks on the menu the variable won't be filled and you can cancel the print process and show an error msg. 因此,如果用户单击菜单,该变量将不会被填充,您可以取消打印过程并显示错误消息。

So for example in the prePrint event: 因此,例如在prePrint事件中:

//Set a variable (buttonClicked) to true prior in the `click` event of your print button
if(!buttonClicked) {//if the menu print was used cancel and show error
  xfa.event.cancelAction = 1; //Prevent printing
  xfa.host.messageBox("This is a message", "This is a title", 3, 1);
}

What I usually do is calling any function I need in the prePrint event, this way it doesn't matter if the user clicks on the adobe menu print or not. 我通常要做的是在prePrint事件中调用我需要的任何函数,这样,用户是否单击Adobe菜单打印都无关紧要。 And in case I want to print a specific way, I first cancel the print action and then print programtically with the parameters I need. 如果要以特定方式打印,我首先取消打印操作,然后使用所需的参数以编程方式进行打印。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM