{"id":90,"date":"2018-08-20T13:13:57","date_gmt":"2018-08-20T18:13:57","guid":{"rendered":"http:\/\/www.offtherichterdesign.com\/Blog\/?p=90"},"modified":"2018-12-12T15:35:52","modified_gmt":"2018-12-12T21:35:52","slug":"acro-javascript-flatten-form-fields","status":"publish","type":"post","link":"https:\/\/offtherichterdesign.com\/Blog\/acro-javascript-flatten-form-fields\/","title":{"rendered":"Acro-JavaScript: Flatten Form Fields"},"content":{"rendered":"<p style=\"text-align: left;\"><strong>Developer Software Required<\/strong>: Adobe Acrobat A.K.A Adobe Acrobat Pro<br \/>\n<strong>End User Software Required<\/strong>: Adobe Reader A.K.A. Adobe Acrobat Reader<\/p>\n<p style=\"text-align: left;\">JavaScript can be used to lock down form fields or flatten .pdf form fields so entered data cannot be changed by a typical user. This can be extremely handy when a document is available to end users submitting filled forms to various departments where the department end users should not be changing contents submitted via the .pdf form.<\/p>\n<p style=\"text-align: left;\">To do this effectively, I typically append the code to the custom submit button within the .pdf form. For more information about the custom submit button, check out <a href=\"\/Blog\/acro-javascript-custom-submit-button\" target=\"_blank\" rel=\"noopener\">Acro-Javascript: Custom Submit Button<\/a>.<\/p>\n<p style=\"text-align: left;\">Here&#8217;s the code used:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nflattenFields()\r\n\r\nfunction flattenFields() {\r\n\r\nif (app.viewerType==&quot;Reader&quot;) {\r\n\r\nfor (var i=0 ; i&lt;this.numFields ; i++) {  \r\n\r\nvar f = this.getField(this.getNthFieldName(i));\r\n\r\nif (f==null) continue;\r\n\r\nf.readonly = true;\r\n\r\n}\r\n}\r\n}\r\n<\/pre>\n<p style=\"text-align: left;\">Here&#8217;s the code with the <a href=\"\/Blog\/acro-javascript-custom-submit-button\" target=\"_blank\" rel=\"noopener\">Custom Submit Button<\/a> code:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nflattenFields()\r\n\r\nfunction flattenFields() {\r\n\r\nif (app.viewerType==&quot;Reader&quot;) {\r\n\r\nfor (var i=0 ; i&lt;this.numFields ; i++) {  \r\n\r\nvar f = this.getField(this.getNthFieldName(i));\r\n\r\nif (f==null) continue;\r\n\r\nf.readonly = true;\r\n\r\n}\r\n}\r\n\r\nvar cToAddr = &quot;travis@offtherichterdesign.com&quot;\r\nvar cCCAddr = &quot;service@offtherichterdesign.com&quot;\r\nvar cBody = &quot;Off The Richter Design: Business Training Request\\n&quot; + &quot;\\nThe attached file is the filled-out form. Please open it to review the data.&quot;\r\nvar cSubLine = &quot;Business Training Request&quot;\r\nthis.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr, cSubject: cSubLine + &quot;Off The Richter Design&quot;, cMsg: cBody}); \r\n}\r\n<\/pre>\n<p style=\"text-align: left;\">Addtionally, one can also leave specific form fields editable if desired. Here&#8217;s how we can accomplish this:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nthis.getField(&quot;submit&quot;).hidden = true;\r\n\r\nflattenFields()\r\n\r\nfunction flattenFields() {\r\nif (app.viewerType==&quot;Reader&quot;) {\r\n\r\nfor (var i=0 ; i&lt;this.numFields ; i++) {\r\n\r\nvar fname = this.getNthFieldName(i);\r\nif (fname!=&quot;Your Form Field Here&quot; &amp;&amp; &quot;Your Other Form Field Here&quot;){\r\nthis.getField(fname).readonly = true;\r\n}\r\n}\r\n}\r\nvar cToAddr = &quot;travis@offtherichterdesign.com&quot;\r\nvar cCCAddr = &quot;service@offtherichterdesign.com&quot;\r\nvar cBody = &quot;Off The Richter Design: Business Training Request\\n&quot; + &quot;\\nThe attached file is the filled-out form. Please open it to review the data.&quot;\r\nvar cSubLine = &quot;Business Training Request&quot;\r\nthis.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr, cSubject: cSubLine + &quot;Off The Richter Design&quot;, cMsg: cBody}); \r\n}\r\n<\/pre>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Developer Software Required: Adobe Acrobat A.K.A Adobe Acrobat Pro End User Software Required: Adobe Reader A.K.A. Adobe Acrobat Reader JavaScript can be used to lock down form fields or flatten .pdf form fields so entered data cannot be changed by a typical user. This can be extremely handy when a document is available to end&#8230;<\/p>\n<p class=\"more-link\"><a href=\"https:\/\/offtherichterdesign.com\/Blog\/acro-javascript-flatten-form-fields\/\" 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":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,105],"tags":[14,12,11,15,17,16,10,13],"class_list":["post-90","post","type-post","status-publish","format-standard","hentry","category-coding-with-coffee","category-acro-javascript","tag-acro-javascript","tag-acrobat","tag-adobe","tag-fillable-forms","tag-flatten-form-fields","tag-forms","tag-javascript","tag-reader"],"_links":{"self":[{"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/posts\/90","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=90"}],"version-history":[{"count":1,"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":564,"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/posts\/90\/revisions\/564"}],"wp:attachment":[{"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/offtherichterdesign.com\/Blog\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}