print pdf silently

I wish to print pdf files from my program in a silent fashion without opening Acrobat or
a printer dialog box.  I have tried a product called ppdf, but the Acrobat window still opens.
I have my old versions of Acrobat 5.0 and 3.0 besides my current 9.0 version.  Nothing in the knowledgebase seems useful.  Essentially I need a command line method of printing.
beach3961Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

for_yanCommented:



If you use java then
Use com.lowagie.tools.Executable.printDocumentSilent(fileName);
within iText package
http://itextpdf.com/

It sghould print PDF file silently.


0
for_yanCommented:
Other suggestions which I saw where to print through ghostscript and xpdf
0
for_yanCommented:
No this actually does not work, requires acrord32, so doesn't look it is something usable:
com.lowagie.tools.Executable.printDocumentSilent(fileName);

However what worked for me was java application called PDFBox:
I dwonloaded pdfbox-app-1.6.0.jar  from here:
http://www.apache.org/dyn/closer.cgi/pdfbox/1.6.0/pdfbox-app-1.6.0.jar

and at the dos command prompt :

C:\pdfbox>java -jar pdfbox-app-1.6.0.jar PrintPDF -silentPrint test.pdf

Oct 21, 2011 4:28:01 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
INFO: unsupported/disabled operation: i
Oct 21, 2011 4:28:01 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
INFO: unsupported/disabled operation: i

Open in new window


it nicely and without opening any windows printed for me pdf file
Don't know if it would do it on all printers and perhaps there may be problems with more
sophisticated PDFs (mine was rather simple) but on my default  HP LaserJet 4050 TN printer it had no problems at all.
and I have java version 1.6.0_19
(if you don't have it, you can install it from here
http://javadl.sun.com/webapps/download/AutoDL?BundleId=57240)

 





0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

for_yanCommented:

and this is the whole article about printing PDF silently (maybe you'll find something better there):
https://vineetreynolds.wordpress.com/2005/12/12/silent-print-a-pdf-print-pdf-programmatically/
0
arnoldCommented:
You did not specify which OS you have,
http://orion.math.iastate.edu/burkardt/g_src/pdf2ps/pdf2ps.html requires ghostscript which for_yan referenced.
The PS output is then sent to the printer which you would need to have.

You have to know what format the printer supports and then look at a pdf to that format conversion option.
0
Steve KnightIT ConsultancyCommented:
Do you have the Print option on right click within explorer?

Unless I am missing something in this Q, a PDF can be printed with that, or rather the code that the right click runs, i.e. along these lines;

"C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe" /p /h "%1"

Where %1 is the path and filename to the pdf to print

Obviously you can code the filename in directly or use other batch commands as needed to get it.

Same goes for the Acrobat file, e.g. the batch below searches the program files dir to look for AcroR32 and tells you if not found:


Steve


@echo off

set Acro=
for /f "delims=" %%A in ('dir "%programfiles%\adobe\acrord32.exe" /s /b 2^>NUL') do set Acro=%%A
if "%Acro%"=="" for /f "delims=" %%A in ('dir "%programfiles(x86)%\adobe\acrord32.exe"/s /b 2^>NUL') do set Acro=%%A

if "%Acro%"=="" (
  echo Unable to find Acrobat Reader
  pause
  exit /b
)

if "%~1"=="" (
  cls
  echo Print one or multiple PDF from the command line or dragged onto this as shortcut
  echo Steve Knight [dragon-it] EE question # 27407319
  echo.
  echo No PDF has been specified on the command line
  echo.
  echo Usage: %~nx0 "somefile.pdf" "anotherfile.pdf" etc.
  pause
  exit /b
)

:loop

  REM Shift through each PDF file on command line and print each one by one using found AcroRd32.exe
  echo Printing "%~1"
  START "Printing %~1" "%Acro%" /p /h "%~1"
  shift
if not "%~1"=="" goto loop

echo All completed.  Closing Acrobat reader after short pause
ping 127.0.0.1 -n 5
taskkill /FI "IMAGENAME eq acrord32.exe"
exit /b

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
beach3961Author Commented:
I just tried this in a batch file and it works, therefore I am confident I can integrate it into my program.
I was hoping to avoid having the Acrobat window open but if that is not possible, I can live with it.
Thank you.
0
for_yanCommented:
Try it with java like in http://#37009693  - it prints silently without opening the window.

I went through that option when I was investigationg it of course:
AcroRd32.exe /p /h filename
but you  were stressing silently - and it was always opening that acrobat window for me.

Don't know, maybe some sophisticated pdf will not work but try it with your example.
It is really easy to install - and nowadays all folks have java on their PCs.
0
beach3961Author Commented:
I hadn't tried the Java beause I didn't understand it and I am not doing this from a web page.
But I just tried it from the command line and it did everything I needed.
I am going to try it calling it from my program.  My only concern is the warning messages
about "Changing fonts" from the application.  I need to research and see if there is a way to suppress
warning messages or how those warnings will display when the process is ececuted from my program.
Thank you,
Alan
0
for_yanCommented:
Sorry, I didn't understadn form your post, so you did try java method or you were talking about acrobat method?

This java method has nothing to do with any web - it is just form comman line.

So, please explain - were the font message s from java or from the "arboat based " method.
If they were from java - post them we'll think about it.
0
beach3961Author Commented:
With the java method, it outputs messages relating to the processing.  Attached is a jpg of the stream messages I got from a test. java messages
0
for_yanCommented:
One simple way to try is to try to redirect them to NUL


java -jar pdfbox... PrintPdf -silentPrint log.pdf > NUL

I hope they should disappear this way.

another option to try:

java -jar pdfbox... PrintPdf -silentPrint log.pdf  2> NUL

because 2> redirects the error stream



I didn't find how to suppress these warinings altogether, howvere one my guess is that they may be java version dependent
check
java -version
 maybe newer java which you can easily install will not have that.
I think I used to see such waernings a fww years ago when I had java 1.4 or something. Now that I have java 1.6
I dont recall seeing them (though t may of course depend on the task) .

If not let me know what version of java do you have



0
beach3961Author Commented:
2> NULL worked to supress the messages
I have java version 1.6.0_25-b06
Thank you
Alan
0
for_yanCommented:
1.6.0_25 is OK, but if NULL worked that is fine.
Only check if you have different tuypes of PDF's say with pictures, etc
check if they print it OK. After all this is quite different printing not through
Acrobat and not written by Adbe; I would not be surprised if in some special
cases they might do something not exactly as it should be done.
But for motsly conventioanl pdf's I expect it shoul be doing a normal job.
0
Steve KnightIT ConsultancyCommented:
BTW using NULL will create a file called NULL.  NUL is what you want :-) or both together

>NUL 2>&1

to redirect std ouput to nul and std error output to stream 1 (std out) and into nul too!


Thanks for the points / answer.  Will give java method a go myself for one I need to look at' have always just called acrobat reader in the past...
0
for_yanCommented:
Yes, it is true - that's what it is called in woindows NUL (for some reason without second L); this analog of /dev/null in Unix.
0
beach3961Author Commented:
You said there might be a problems printing images.  Definitely.
The java method does not handle images at all.
0
for_yanCommented:
well, I was expecting it will not handle everything as Adobe
Myabe there is some information on that PdfBox project  site
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Acrobat

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.