{"id":533,"date":"2018-12-12T15:30:00","date_gmt":"2018-12-12T21:30:00","guid":{"rendered":"https:\/\/offtherichterdesign.com\/Blog\/?p=533"},"modified":"2019-01-02T15:45:45","modified_gmt":"2019-01-02T21:45:45","slug":"acro-javascript-folder-level-script-for-save-as-pdf","status":"publish","type":"post","link":"https:\/\/offtherichterdesign.com\/Blog\/acro-javascript-folder-level-script-for-save-as-pdf\/","title":{"rendered":"Acro JavaScript: Folder Level Script for Save As PDF"},"content":{"rendered":"<p>Have you ever needed to submit a PDF to a specific file path, but couldn&#8217;t figure out how to accomplish this? Let&#8217;s do it!<\/p>\n<p>Here&#8217;s how the file name will appear when the users selects the submit button in the form in this scenario.<br \/>\n<a href=\"https:\/\/offtherichterdesign.com\/Blog\/wp-content\/uploads\/2018\/12\/acrobat-javascript-file-name.jpg\" data-rel=\"lightbox-image-0\" data-magnific_type=\"image\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/offtherichterdesign.com\/Blog\/wp-content\/uploads\/2018\/12\/acrobat-javascript-file-name.jpg\" class=\"wp-image-541 size-full aligncenter\" alt=\"\" height=\"162\" width=\"292\"><\/a><\/p>\n<p>Here&#8217;s the JavaScript placed on the submit button in the PDF:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nif(typeof(mySaveAs) == &quot;function&quot;){\r\nmySaveAs(this,this.path);\r\napp.alert(&quot;Your file has been submitted.\\n&quot; + &quot;\\Please close this document.&quot;, 2, 0, &quot;Success&quot;);\r\n}else{\r\napp.alert(&quot;Missing Save Function\\n&quot; + &quot;\\nPlease contact forms administrator&quot;, 1, 0, &quot;Error&quot;);\r\n}\r\n<\/pre>\n<p>Here&#8217;s the Folder Level JavaScript saved as mySaveAs.js:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\r\nvar getLoginName = app.trustedFunction(\r\n\r\nfunction () {\r\n\r\n\/\/Get and return the user's login name\r\napp.beginPriv();\r\nreturn identity.loginName;\r\napp.EndPriv();\r\n\r\n});\r\n\r\nvar mySaveAs = app.trustedFunction(function()\r\n{\r\n\r\n\/\/Create AlphaNumeric String for Filename\r\nfunction myIdString(){\r\nvar text = &quot;&quot;;\r\nvar possible = &quot;0123456789&quot;;\r\n\r\nfor (var i = 0; i &lt; 8; i++)\r\ntext += possible.charAt(Math.floor(Math.random() * possible.length));\r\n\r\nreturn text;\r\n}\r\n\r\n\/\/Create Date and Time\r\nfunction myDateString(){\r\nreturn util.printd(&quot;m-d-yyyy h-MM-ss tt&quot;, new Date()).toUpperCase();;\r\n}\r\n\r\n\/\/Create Filename\r\nvar myFileName = getLoginName() + &quot;\u2013&quot; + myIdString() + &quot;-&quot; + myDateString();\r\n\r\n\/\/Save the File\r\napp.beginPriv();\r\nthis.saveAs(&quot;\/F\/Test\/&quot; + myFileName + &quot;.pdf&quot;);\r\napp.endPriv();\r\n\r\n});\r\n<\/pre>\n<p>In order to perform a SaveAs function that actually writes the file, a Folder Level script is necessary to be placed in a specific file location on the PC for the PDF to reference. To do this, it is important to note, you will need administrative access to all PC&#8217;s of which will be using the PDF form. The above script was placed in the below locations for the PDF to reference upon the users clicking the submit button.<\/p>\n<p>Path for users using Adobe Acrobat Reader DC to fill out and submit this form:<br \/>\nC:\\Program Files (x86)\\Adobe\\Acrobat Reader DC\\Reader\\Javascripts<\/p>\n<p>Path for users using Adobe Acrobat DC to fill out and submit this form:<br \/>\nC:\\Program Files (x86)\\Adobe\\Acrobat DC\\Acrobat\\Javascripts<\/p>\n<p>If you do not have administrator access to the directories necessary to place the Folder Level JavaScript file, here&#8217;s an alternative file location you may use to test functionality.<\/p>\n<p>C:\\Users\\YOUR USERNAME\\AppData\\Roaming\\Adobe\\Acrobat\\Privileged\\DC\\Javascripts<\/p>\n<p><a href=\"https:\/\/offtherichterdesign.com\/Blog\/wp-content\/uploads\/2018\/12\/acrobat-javascript-file-path-trusted-user.jpg\" data-rel=\"lightbox-image-1\" data-magnific_type=\"image\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"https:\/\/offtherichterdesign.com\/Blog\/wp-content\/uploads\/2018\/12\/acrobat-javascript-file-path-trusted-user.jpg\" class=\"wp-image-545 size-medium aligncenter\" width=\"100%\" height=\"270\" alt=\"\" srcset=\"https:\/\/offtherichterdesign.com\/Blog\/wp-content\/uploads\/2018\/12\/acrobat-javascript-file-path-trusted-user.jpg 838w, https:\/\/offtherichterdesign.com\/Blog\/wp-content\/uploads\/2018\/12\/acrobat-javascript-file-path-trusted-user-300x96.jpg 300w, https:\/\/offtherichterdesign.com\/Blog\/wp-content\/uploads\/2018\/12\/acrobat-javascript-file-path-trusted-user-768x246.jpg 768w\" sizes=\"(max-width: 838px) 100vw, 838px\" \/><\/a><\/p>\n<p><strong>Note:<\/strong> you will have to view hidden files, as well as create the &#8220;Privileged&#8221; folder and contents identically there after.<\/p>\n<p><strong>Update<\/strong>: On Apple Macintosh, the application JavaScript folder is in the configuration file inside the Acrobat Application Package.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Have you ever needed to submit a PDF to a specific file path, but couldn&#8217;t figure out how to accomplish this? Let&#8217;s do it! Here&#8217;s how the file name will appear when the users selects the submit button in the form in this scenario. Here&#8217;s the JavaScript placed on the submit button in the PDF:&#8230;<\/p>\n<p class=\"more-link\"><a href=\"https:\/\/offtherichterdesign.com\/Blog\/acro-javascript-folder-level-script-for-save-as-pdf\/\" class=\"themebutton3\">Read More<\/a><\/p>\n<p><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":610,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,105],"tags":[14,11,84,99,101,104,10,100,103,102],"class_list":["post-533","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-coding-with-coffee","category-acro-javascript","tag-acro-javascript","tag-adobe","tag-adobe-acrobat","tag-adobe-reader","tag-filllable-pdf","tag-folder-level-scripts-pdf","tag-javascript","tag-pdf-forms","tag-save-pdf-with-submit","tag-smart-pdf"],"_links":{"self":[{"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/posts\/533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/comments?post=533"}],"version-history":[{"count":30,"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/posts\/533\/revisions"}],"predecessor-version":[{"id":661,"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/posts\/533\/revisions\/661"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/media\/610"}],"wp:attachment":[{"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/media?parent=533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/categories?post=533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/tags?post=533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}