Printing PDFs from Windows Command Line

后端 未结 11 469
我寻月下人不归
我寻月下人不归 2020-11-30 01:06

I\'m trying to print all pdfs in current dir. When I call this bash script in cmd (singlepdf.sh): \'\"C:\\Program Files (x86)\\Adobe\\Reader 10.0\\Reader

相关标签:
11条回答
  • 2020-11-30 01:42

    Another solution "out of the box"

    FOR %X in ("*.pdf") DO (C:\Windows\System32\print.exe /d:"\\printername" "%X.pdf")

    Edit : As mentionned by "huysentruitw", this only works for txt files ! Sorry !

    When I double checked i realized I'm using GhostScript, as "Multiverse IT" proposed. It looks like so :

    "C:\Program Files (x86)\gs\gs\bin\gswin32c.exe" -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=1 -sDEVICE=mswinpr2 -sOutputFile="%printer%My-Printer-Name" "c:\My-Pdf-File.pdf"
    
    0 讨论(0)
  • 2020-11-30 01:43

    Using Acrobat reader is not a good solution, especially command line attributes are not documented. Additionally Acrobat reader's window stays open after printing process. PDF files are well known by printer drivers, so you may find better tools, like 2Printer.exe or RawFilePrinter.exe. In my opinion RawFilePrinter has better support and clear licencing process (you pay donation once and you can redistribute RawFilePrinter in many project you like - even new versions work with previously purchased license)

    RawFilePrinter.exe -p "c:\Users\Me\Desktop\mypdffile.pdf" "Canon Printer" 
    IF %ERRORLEVEL% 1(
        echo "Error!"
    )
    

    Latest version to download: http://bigdotsoftware.pl/index.php/rawfileprinter

    0 讨论(0)
  • 2020-11-30 01:44

    First response - wanted to finally give back to a helpful community...

    Wanted to add this to the responses for people still looking for simple a solution. I'm using a free product by Foxit Software - FoxItReader.
    Here is the link to the version that works with the silent print - newer versions the silent print feature is still not working. FoxitReader623.815_Setup

    FOR %%f IN (*.pdf) DO ("C:\Program Files (x86)\Foxit Software\Foxit Reader\FoxitReader.exe" /t %%f "SPST-SMPICK" %%f & del %%f) 
    

    I simply created a command to loop through the directory and for each pdf file (FOR %%f IN *.pdf) open the reader silently (/t) get the next PDF (%%f) and send it to the print queue (SPST-SMPICK), then delete each PDF after I send it to the print queue (del%%f). Shashank showed an example of moving the files to another directory if that what you need to do

    FOR %%X in ("%dir1%*.pdf") DO (move "%%~dpnX.pdf" p/)
    
    0 讨论(0)
  • 2020-11-30 01:47

    I had two problems with using Acrobat Reader for this task.

    1. The command line API is not officially supported, so it could change or be removed without warning.
    2. Send a print command to Reader loads up the GUI, with seemingly no way to prevent it. I needed the process to be transparent to the user.

    I stumbled across this blog, that suggests using Foxit Reader. Foxit Reader is free, the API is almost identical to Acrobat Reader, but crucially is documented and does not load the GUI for print jobs.

    A word of warning, don't just click through the install process without paying attention, it tries to install unrelated software as well. Why are software vendors still doing this???

    0 讨论(0)
  • 2020-11-30 01:50
    @ECHO off set "dir1=C:\TicketDownload" 
    FOR %%X in ("%dir1%*.pdf") DO ( "C:\Program Files (x86)\Adobe\Reader 9.0\Reader\AcroRd32.exe" /t "%%~dpnX.pdf" "Microsoft XPS Document Writer" ) 
    FOR %%X in ("%dir1%*.pdf") DO (move "%%~dpnX.pdf" p/)
    

    Try this..May be u have some other version of Reader so that is the problem..

    0 讨论(0)
  • 2020-11-30 01:53

    I had the similar problem with printing multiple PDF files in a row and found only workaround by using 2Printer software. Command line example to print PDF files:

    2Printer.exe -s "C:\In\*.PDF" -prn "HP LasetJet 1100"
    

    It is free for non-commercial use at http://doc2prn.com/

    0 讨论(0)
提交回复
热议问题