- Acrobat Pdf Javascript
- Adobe Pdf Javascript Examples
- Adobe Pdf Javascript Silent Print
- Printing Adobe Documents
- The Adobe Acrobat User. Printers can be selected with the Acrobat Javascipt print funtion but silent printing is. And printer name is Adobe PDF and.
- Automated pdf print with embedded javascript. Browse other questions tagged javascript pdf printing.
Print PDF directly from JavaScript. Or the adobe plugin. – Rahly Oct 11 '15 at 3:43. Silent print an embedded PDF.
I'm having 2 issues when trying to print a pdf silently in C# using adobe acrobat. I'm printing the pdfs using Process.Start().
The first issue is that I cannot launch Adobe Acrobat without specifying the full path to the executable. I assume it doesn't add it to your path when you install it. Is there an easy way to launch the newest version of acrobat on a machine without specifying full path names? I'm worried that the client is going to do an update and break my code that launches this. I'm also concerned with them installing this on machines with different versions of windows (install paths are different in 64 bit environment vs. 32 bit).
My second problem is the fact that whenever I launch acrobat and print it still leaves the acrobat window open. I thought that the command line parameters I was using would suppress all of this but apparently not.
I'm trying to launch adobe acrobat from the command line with the following syntax:
C:Program Files (x86)AdobeReader 10.0Reader>AcroRd32.exe /t 'Label.pdf' 'HP4000' 'HP LaserJet 4100 Series PCL6' 'out.pdf'
It prints out fine but it still leaves the acrobat window up. Is there any other solution besides going out and killing the process programmatically?
9 Answers
I ended up bailing on Adobe Acrobat here and going with FoxIt Reader (Free pdf reader) to do my pdf printing. This is the code I'm using to print via FoxIt in C#:
The above code prints to the default printer but there are command line parameters you can use to specify file and printer. You can use the following syntax:
Foxit Reader.exe -t 'pdf filename' 'printer name'
Update:
Apparently earlier versions of acrobat do not have the problem outlined above either. If you use a much older version (4.x or something similar) it does not exhibit this problem.
Some printers do support native pdf printing as well so it's possible to send the raw pdf data to the printer and it might print it. See https://support.microsoft.com/en-us/kb/322091 for sending raw data to the printer.
Update 2
In later versions of our software we ended up using a paid product:
Cole WAcrobat Pdf Javascript
Cole WNick's answer looked good to me, so I translated it to c#. It works!
}
The following is tested in both Acrobat Reader 8.1.3 and Acrobat Pro 11.0.06, and the following functionality is confirmed:
- Locates the default Acrobat executable on the system
- Sends the file to the local printer
- Closes Acrobat, regardless of version
I've tried both Adobe Reader and Foxit without luck. The current versions of both are very fond of popping up windows and leaving processes running. Ended up using Sumatra PDF which is very unobtrusive. Here's the code I use. Not a trace of any windows and process exits nicely when it's done printing.
got another solution .. its combination of other snippets from stackOverflow. When I call CloseMainWindow, and then call Kill .. adobe closes down
Problem 1
You may be able to work your way around the registry. In HKEY_CLASSES_ROOT.pdfPersistentHandler(Default)
you should find a CLSID that points to a value found in one of two places. Either the CLSID folder of the same key, or (for 64 bit systems) one step down in Wow6432NodeCLSID
then in that CLSID's key.
Within that key you can look for LocalServer32
and find the default string value pointing to the current exe path.
I'm not 100% on any of this, but seems plausible (though you're going to have to verify on multiple environments to confirm that in-fact locates the process you're looking for).
(Here are the docs on registry keys involved regarding PersistentHandlers)
Adobe Pdf Javascript Examples
Problem 2
Probably using the CreateNoWindow of the Process StartInfo.
(only a guess however, but I'm sure a little testing will prove it to work/not work)
Brad ChristieBrad ChristieIf you use Acrobat reader 4.0 you can do things like this:'C:Program FilesAdobeAcrobat 4.0ReaderAcrord32.exe' /t /s 'U:PDF_MSSM003067K08.pdf' Planning_H2BUT if the PDF file has been created in a newer version of Acrobat an invisible window opens
You have already tried something different than Acrobat Reader, so my advice is forget about GUI apps and use 3rd party command line tool like RawFilePrinter.exe
Latest version to download: http://effisoft.pl/rawfileprinter
For Problem 2
Using /h param will open the Acrobat or Adobe Reader in minimized window.
Example:C:Program Files (x86)AdobeReader 10.0Reader>AcroRd32.exe **/h** /t 'Label.pdf' 'HP4000' 'HP LaserJet 4100 Series PCL6' 'out.pdf'
Related Documentation: https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/Acrobat_SDK_developer_faq.pdf#page=24