{"id":879,"date":"2012-09-12T00:41:48","date_gmt":"2012-09-11T16:41:48","guid":{"rendered":"http:\/\/www.jhouseconsulting.com\/?p=879"},"modified":"2012-09-12T00:49:52","modified_gmt":"2012-09-11T16:49:52","slug":"script-to-set-the-adobe-print-as-image-option","status":"publish","type":"post","link":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/2012\/09\/12\/script-to-set-the-adobe-print-as-image-option-879","title":{"rendered":"Script to set the Adobe Print As Image option"},"content":{"rendered":"<p>Having deployed a new printing solution in a large University environment, we were faced with all sorts of printing errors, slow printing, and out of memory errors on the printers themselves; specifically when printing PDFs. This is related to how the PDFs are processed, which becomes a challenge in a higher education environment where the PDFs can be considerably complex. This was not only providing a poor user experience, it was becoming a support nightmare\u00a0to manage when you have thousands of Students and Academics creating and printing PDFs. After some advice, research and testing we found that setting the Adobe &#8220;Print As Image&#8221;\u00a0(cPrintAsImage) option made a big difference to the quality and stability of the solution, clearing up most of the printing errors previously experienced. This option changes the way Adobe works by sending\u00a0the output to the printer as an image file rather than a combination of different elements.<!--more--><\/p>\n<p>As per the following screen shot users can change it manually by selecting the &#8220;Advanced&#8221; button in the Print window and then selecting\u00a0the &#8220;Print As Image&#8221;\u00a0check box\u00a0in the Advanced Print Setup pop-up window.<\/p>\n<p><a href=\"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-content\/uploads\/2012\/09\/PrintAsImage.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone  wp-image-886\" title=\"PrintAsImage\" src=\"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-content\/uploads\/2012\/09\/PrintAsImage.png\" alt=\"\" width=\"595\" height=\"522\" srcset=\"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-content\/uploads\/2012\/09\/PrintAsImage.png 744w, https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-content\/uploads\/2012\/09\/PrintAsImage-300x263.png 300w\" sizes=\"(max-width: 595px) 100vw, 595px\" \/><\/a><\/p>\n<p>However, the challenge was how to automate this for all users, including the various versions of Adobe Acrobat and Acrobat Reader in use. Furthermore, we had to also ensure that the &#8220;Print As Image&#8221; (cPrintAsImage)\u00a0flag was set for all network printers. So I wrote a script, which we implemented to run at logon \ud83d\ude42<\/p>\n<p>Here is the\u00a0<a href=\"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-content\/uploads\/2012\/09\/SetAdobePrintAsImage.vbs_.txt\">SetAdobePrintAsImage.vbs<\/a>\u00a0script:<\/p>\n<pre class=\"brush: vb; auto-links: false; title: ; toolbar: false; notranslate\" title=\"\">\r\n' This script will set the Adobe Acrobat and\/or Acrobat Reader\r\n' &quot;Print as image&quot; option (cPrintAsImage registry key structure)\r\n' for all valid printers in the user's session.\r\n\r\n' There are simple mechanisms in place so that you can easily\r\n' exclude:\r\n' - Printer by name and\/or UNC path\r\n' - Printer by port\r\n' - Microsoft RDP Client Printers\r\n' - Citrix ICA Client Printers\r\n\r\n' You simply set the registry key structure in the arrKeys array\r\n' up to the version number of the Adobe Acrobat and\/or Acrobat\r\n' Reader products you want to check. The default behaviour is to\r\n' check for the following products:\r\n' - Acrobat Reader 9\r\n' - Adobe Acrobat 9\r\n' - Acrobat Reader 10\r\n' - Adobe Acrobat 10\r\n\r\n' If the registry key structure defined in the arrKeys array does\r\n' not exist, no action will be taken.\r\n\r\n' Adobe changed the way it stores the value and data under the\r\n' cPrintAsImage key from version 9 onwards. If you need to run\r\n' this against older versions, this script will need further\r\n' modification.\r\n\r\n' The value written under the cPrintAsImage key must be a lower\r\n' case t. The &quot;Print as image&quot; option will not be selected if an\r\n' upper case T is used.\r\n\r\n' Whilst this script is only checking the registry for valid Adobe\r\n' products, the script can easily be changed to check for files,\r\n' such as Acrobat.exe and AcroRd32.exe.\r\n\r\n' Important: There could be two possible timing issues with this\r\n' script:\r\n' 1) The &quot;HKCU\\Software\\Adobe&quot; registry key structure does not\r\n' exist at the time the script runs for new logons\/profiles.\r\n' A possible solution for this would be to use the HKLM\r\n' structure in the array.\r\n' 2) The Printers pushed out by Group Policy Preferences (GPPs)\r\n' or Deployed Printers have not been created at the time the\r\n' script runs. This script may therefore need to be added to\r\n' the &quot;Items to run at logon&quot; policy, or added as a value to\r\n' the registry &quot;Run&quot; key. Either way, it must be setup so that\r\n' it runs after the network printers have been deployed.\r\n\r\n' Release 1.0\r\n' Written by Jeremy@jhouseconsulting.com on 30th May 2012.\r\n\r\nOption Explicit\r\n\r\nDim objShell, objNetwork, objPrinter, intCounter, arrKeys, strKey\r\nDim arrExcludePrinters, arrExcludePrinterPorts,i, blnDebug\r\nDim blnExcludeRDPClientPrinters, blnExcludeCitrixClientPrinters\r\nDim blnExcludePrinter\r\n\r\n'******************* Variables to set *************************\r\n\r\n' Add the key structures to the array to represent the products\r\n' and versions deployed in the environment.\r\narrKeys = Array(&quot;HKCU\\Software\\Adobe\\Acrobat Reader\\9.0&quot;, _\r\n &quot;HKCU\\Software\\Adobe\\Adobe Acrobat\\9.0&quot;, _\r\n &quot;HKCU\\Software\\Adobe\\Acrobat Reader\\10.0&quot;, _\r\n &quot;HKCU\\Software\\Adobe\\Adobe Acrobat\\10.0&quot;)\r\n\r\n' These are the printers we want to exclude.\r\narrExcludePrinters = Array(&quot;Microsoft XPS Document Writer&quot;,&quot;Generic \/ Text Only&quot;)\r\n\r\n' These are the printer ports we want to exclude.\r\narrExcludePrinterPorts = Array(&quot;XPSPort&quot;)\r\n\r\n' Exclude Microsoft RDP Client Printers\r\nblnExcludeRDPClientPrinters = True\r\n\r\n' Exclude Citrix ICA Client Printers\r\nblnExcludeCitrixClientPrinters = True\r\n\r\n' Do not set blnDebug to True when in production unless launching it using cscript.exe\r\nblnDebug = False\r\n\r\n'**************************************************************\r\n\r\nset objShell = WScript.CreateObject(&quot;WScript.Shell&quot;)\r\nSet objNetwork = CreateObject(&quot;WScript.Network&quot;)\r\nSet objPrinter = objNetwork.EnumPrinterConnections\r\n\r\nFor Each strKey in arrKeys\r\n If RegKeyExists(strKey &amp; &quot;\\General\\cPrintAsImage&quot;) Then\r\n Call DeleteValues(strKey &amp; &quot;\\General\\cPrintAsImage&quot;)\r\n End If\r\n If RegKeyExists(strKey) Then\r\n If objPrinter.Count &lt;&gt; 0 Then\r\n i = 0\r\n For intCounter = 0 To (objPrinter.Count -1) Step 2\r\n If blnDebug Then\r\n WScript.Echo &quot;UNC Path &quot; &amp; objPrinter.Item(intCounter) &amp; &quot; = &quot; &amp; _\r\n objPrinter.Item(intCounter +1)\r\n End If\r\n blnExcludePrinter = False\r\n If Instr(1,objPrinter.Item(intCounter +1),&quot;redirected&quot;,1) &gt; 0 Then\r\n If blnExcludeRDPClientPrinters Then\r\n blnExcludePrinter = True\r\n End If\r\n End If\r\n If Instr(1,objPrinter.Item(intCounter +1),&quot;in session&quot;,1) &gt; 0 Then\r\n If blnExcludeCitrixClientPrinters Then\r\n blnExcludePrinter = True\r\n End If\r\n End If\r\n If IsArray(arrExcludePrinters) Then\r\n If InArray(objPrinter.Item(intCounter +1),arrExcludePrinters) Then\r\n blnExcludePrinter = True\r\n End If\r\n End If\r\n If IsArray(arrExcludePrinterPorts) Then\r\n If InArray(objPrinter.Item(intCounter),arrExcludePrinterPorts) Then\r\n blnExcludePrinter = True\r\n End If\r\n End If\r\n If NOT blnExcludePrinter Then\r\n objShell.RegWrite strKey &amp; &quot;\\General\\cPrintAsImage\\t&quot; &amp; i, objPrinter.Item(intCounter +1), &quot;REG_SZ&quot;\r\n i = i + 1\r\n End If\r\n Next\r\n Else\r\n If blnDebug Then\r\n WScript.Echo &quot;No printers are mapped in this session.&quot;\r\n End If\r\n End If\r\n Else\r\n If blnDebug Then\r\n WScript.Echo &quot;The &quot; &amp; strKey &amp; &quot; registry key structure does not exist.&quot;\r\n End If\r\n End If\r\nNext\r\n\r\nset objShell = Nothing\r\nSet objNetwork = Nothing\r\nSet objPrinter = Nothing\r\n\r\nWscript.Quit(0)\r\n\r\nFunction InArray(stritem,myarray)\r\n Dim i\r\n For i=0 To UBound(myarray)\r\n If strComp(stritem,myarray(i),1) = 0 Then\r\n InArray=True\r\n Exit Function\r\n End If\r\n Next\r\n InArray=False\r\nEnd Function\r\n\r\nSub DeleteValues(strKeyPath)\r\n Dim strComputer, objReg, i, arrValueNames, arrValueTypes, return\r\n Dim strKeyRoot, HIVE\r\n CONST HKEY_LOCAL_MACHINE = &amp;H80000002\r\n CONST HKEY_CURRENT_USER = &amp;H80000001\r\n strComputer = &quot;.&quot;\r\n Set objReg = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\\\&quot; &amp;_\r\n strComputer &amp; &quot;\\root\\default:StdRegProv&quot;)\r\n If instr(1,strKeyPath,&quot;HKEY_LOCAL_MACHINE\\&quot;,1) &gt; 0 Then\r\n strKeyPath = Replace(strKeyPath,&quot;HKEY_LOCAL_MACHINE\\&quot;,&quot;&quot;)\r\n strKeyRoot = &quot;HKLM&quot;\r\n HIVE = HKEY_LOCAL_MACHINE\r\n End If\r\n If instr(1,strKeyPath,&quot;HKLM\\&quot;,1) &gt; 0 Then\r\n strKeyPath = Replace(strKeyPath,&quot;HKEY_LOCAL_MACHINE\\&quot;,&quot;&quot;)\r\n strKeyRoot = &quot;HKLM&quot;\r\n HIVE = HKEY_LOCAL_MACHINE\r\n End If\r\n If instr(1,strKeyPath,&quot;HKEY_CURRENT_USER\\&quot;,1) &gt; 0 Then\r\n strKeyPath = Replace(strKeyPath,&quot;HKEY_CURRENT_USER\\&quot;,&quot;&quot;)\r\n strKeyRoot = &quot;HKCU&quot;\r\n HIVE = HKEY_CURRENT_USER\r\n End If\r\n If instr(1,strKeyPath,&quot;HKCU\\&quot;,1) &gt; 0 Then\r\n strKeyPath = Replace(strKeyPath,&quot;HKCU\\&quot;,&quot;&quot;)\r\n strKeyRoot = &quot;HKCU&quot;\r\n HIVE = HKEY_CURRENT_USER\r\n End If\r\n return = objReg.EnumValues (HIVE, strKeyPath,_\r\n arrValueNames, arrValueTypes)\r\n If return = 0 and IsArray(arrValueNames) Then\r\n For i = 0 To UBound(arrValueNames)\r\n objReg.DeleteValue HIVE, strKeyPath, arrValueNames(i)\r\n Next\r\n End If\r\n Set objReg = Nothing\r\nEnd Sub\r\n\r\nFunction RegKeyExists(ByVal sRegKey)\r\n' Returns True or False based on the existence of a registry key.\r\n Dim sDescription, oShell\r\n Set oShell = CreateObject(&quot;WScript.Shell&quot;)\r\n RegKeyExists = True\r\n sRegKey = Trim (sRegKey)\r\n If Not Right(sRegKey, 1) = &quot;\\&quot; Then\r\n sRegKey = sRegKey &amp; &quot;\\&quot;\r\n End If\r\n On Error Resume Next\r\n oShell.RegRead &quot;HKEYNotAKey\\&quot;\r\n sDescription = Replace(Err.Description, &quot;HKEYNotAKey\\&quot;, &quot;&quot;)\r\n Err.Clear\r\n oShell.RegRead sRegKey\r\n RegKeyExists = sDescription &lt;&gt; Replace(Err.Description, sRegKey, &quot;&quot;)\r\n On Error Goto 0\r\n Set oShell = Nothing\r\nEnd Function\r\n<\/pre>\n<p>Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Having deployed a new printing solution in a large University environment, we were faced with all sorts of printing errors, slow printing, and out of memory errors on the printers themselves; specifically when printing PDFs. This is related to how the PDFs are processed, which becomes a challenge in a higher education environment where the &#8230; <a title=\"Script to set the Adobe Print As Image option\" class=\"read-more\" href=\"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/2012\/09\/12\/script-to-set-the-adobe-print-as-image-option-879\" aria-label=\"Read more about Script to set the Adobe Print As Image option\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[235,57,5],"tags":[430,237,236],"class_list":["post-879","post","type-post","status-publish","format-standard","hentry","category-adobe","category-printing","category-scripting","tag-adobe","tag-cprintasimage","tag-print-as-image"],"aioseo_notices":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts\/879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/comments?post=879"}],"version-history":[{"count":8,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts\/879\/revisions"}],"predecessor-version":[{"id":888,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts\/879\/revisions\/888"}],"wp:attachment":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/media?parent=879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/categories?post=879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/tags?post=879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}