Skip to main content
Hasan KOYUNCU
Inspiring
April 24, 2022
Answered

Silent Printing as a new document to local disk via "PDF Printer".

  • April 24, 2022
  • 1 reply
  • 1333 views

Dear all:
After filling the fields in the dynamic form, without touching and changing the master form. I want to use "PDF Printer" to save as a new purely static document cleared of the JavaScript codes which is embedded, by changing the file name from the reference field information (ex.DocumentNumber+DocumentDate). I want to assign a button to all these and use the following User level and button level code combination.

This is JavaScript for User Level

// JavaScript of Silent Print for Folder Level
sPrint = app.trustedFunction(function(doc) {   
    app.beginPriv();   
    var pp = doc.getPrintParams();
    bUI: true
    pp.interactive = pp.constants.interactionLevel.automatic; // pp.interactive = pp.constants.interactionLevel.silent OR automatic;
    pp.printerName = "PDF Printer"; 
    doc.print(pp);   
    app.endPriv();
});

This is JavaScript for Button

// JavaScript For Button
// Add Stamp
this.addAnnot({type:"Stamp",AP:"#-_qO5DiVhB8W6rvdDCXd8D",page:this.pageNum,rect: [306,175,394,263],rotate: 8});
// Set the buttons to hidden
getField("function").display = display.noPrint;
getField("Approve").display = display.noPrint;
event.target.display = display.noPrint;
// Print
sPrint(this);
var annots=this.getAnnots();
for (i in annots) annots[i].destroy();

 

This topic has been closed for replies.
Correct answer try67

Flattening the fields will remove all code associated with them, and doc-level code can be removed using the removeScript method.

1 reply

try67
Community Expert
Community Expert
April 24, 2022

Not possible. You can't specify the file-name in your script when printing to the virtual Adobe PDF printer.

Hasan KOYUNCU
Inspiring
April 24, 2022

Dear @try67 ,

Thanks for your reply. Then how should we proceed for such a result? The file becomes static with the flattening command through the JavaScript, but how to remove the JavaScripts? Deleting scripts manually is not practical.

What is your suggestion?

Thanks and regards,

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 24, 2022

Flattening the fields will remove all code associated with them, and doc-level code can be removed using the removeScript method.