Copy link to clipboard
Copied
Hi Smart People...
I have a document I need to add a PRINT TO PDF Button to for the team to use after filling in the form fields. The document will be faxed and returned to us signed and sometimes has important info cut off due to the form running too close to the edges. There are Visable but does not print fields on the document as well.
What I am thinking is I can create a PRINT TO PDF button the team can click that will print the document with a Custom Scale of 90% to the Adobe PDF printer. I am assuming I will need to add a Mouse Up trigger to the button to Run a JavaScript to accomplish this. Any chance someone can help me with the JavaScript?
Copy link to clipboard
Copied
You can, but you can't specify the file-name. The user will have to do that manually.
You can use something like this for that:
var pp = this.getPrintParams();
pp.printerName = "Adobe PDF";
pp.pageHandling = pp.constants.handling.fit;
this.print(pp);
Copy link to clipboard
Copied
You can't set the Scale to an exact percentage using a script. You can set it to the Fit option, which will mean all the document's contents will be scaled to fit on the page. But why are you printing to the Adobe PDF printer? Why not print it directly to the physical printer?
Copy link to clipboard
Copied
Hello Try67. I am asking the team to print to PDF so they can fax out using eFax without the "Visable but doesn't print" fields showing on the document. They can print to Adobe PDF to save the document on their desktop without those fields before sending to the recipient.
Copy link to clipboard
Copied
There are much easier ways to do that. You can use a script to change those fields to hidden, then flatten the form fields, for example.
Copy link to clipboard
Copied
Hi again... I need the fields to be visable while the team is filling out the form as they contain instructions and checkboxes that activate javascript. After the document is complete, i need them removed so the recipient does not see them.
Copy link to clipboard
Copied
I understood, and that's what the code I suggested will do.
Copy link to clipboard
Copied
I'm intrigued and would love to learn how to do that. For most of our documents, we also have to print to PDF because we merge the documents in to a packet of other documents that sometimes have form fields with the same name causing the information typed in to them to overwrite info on the document we are adding to the packet.
Copy link to clipboard
Copied
You can do it using this code:
for (var i=0; i<this.numFields; i++) {
var fname = this.getNthFieldName(i);
var f = this.getField(fname);
if (f==null) continue;
if (f.display!=display.visible) f.display = display.hidden;
}
this.flattenPages();
Note that the flatten command is NOT reversible, so make sure to save the file under a new name, or to keep a backup copy of the original, just in case.
Copy link to clipboard
Copied
perfect... you're the best! Ill give it a shot. Any chance you know if I can make the print button still to print to Adobe PDF, even if I can't choose 90% scale?
Copy link to clipboard
Copied
You can, but you can't specify the file-name. The user will have to do that manually.
You can use something like this for that:
var pp = this.getPrintParams();
pp.printerName = "Adobe PDF";
pp.pageHandling = pp.constants.handling.fit;
this.print(pp);
Copy link to clipboard
Copied
Perfect... thank you very much!!

