Sending pdf files directly to a network printer, using Windows command line

16,013

Solution 1

Most printers cannot print PDFs directly. Some can, but nearly every one of those requires the PDF to be sent to the printer via some special, printer-specifc command. In the case of the Kyocera the command is "KYOCERA Net Direct Print". Note that only Windows versions are available.

The only other way to send a PDF to a printer from the command line is to use a PDF reader with suitable command line options. Old versions of Adobe Acrobat Reader had this capability, but this is no longer supported. However, some other PDF readers like Foxit Reader still do. This should be significantly faster than GSprint. To print a PDF with Foxit, use the following command:

Foxit Reader.exe" /t "FileName

Solution 2

For windows, in cmd just copy to printer share with parameter /B (binary):

COPY /B  File.pdf \\PrintServerComputername\PrinterShareName

Be aware ACL.

Before PrintServerComputername must be two backslash characters. It looks they are converted to one while posting.

Solution 3

LibreOffice has this capability, too. Found out after asking around and simply trying to open a PDF with LibreOffice :) Works without showing a GUI.

Command Line Reference for LibreOffice

"\Program Files\LibreOffice\program\soffice.exe" -p <pdffile>

or

"\Program Files\LibreOffice\program\soffice.exe" -pt <"Printer name"> <pdffile>
Share:
16,013

Related videos on Youtube

Martin Zaske
Author by

Martin Zaske

Updated on September 18, 2022

Comments

  • Martin Zaske
    Martin Zaske over 1 year

    I have network printers. The new one is a Kyocera P2135dn and can handle PDF documents directly: When I pull a pdf-file into the print-spool-window, the file gets printed properly and no driver dialog window pops up, no Adobe tools involved, I believe. If I take the same pdf-file to the printer via usb-flash-drive, it also prints fine.

    Now I have got several hundred pdf-files (all nicely named like 0001.pdf etc.) in one folder and I want to send them to the printer via the windows command line.

    (Background: In the next step, I want to wrap hundreds of those commands in a Phyton script, but first I want to learn and test this "manually".)

    In the past we have used GSprint from the GSview tool. It is still working, but is internally creating huge bitmap files and is slow to render and also slow over the network (even though the printer has got a fast connection). Typically I can only print about four pages per minute, and I have got hundreds to print. (The new GSview from Artifex does not include any GSprint. So we want to figure out a new workflow.)

    I am just looking for the right command to send my pdf to the printer, which is properly configured via standard TCP/IP-port. I am working on Windows 10 pro, 64bit.

    I managed to activate lpr on my windows and tried (just in cases) to send the file, and got it sent; but it does not get reckognized as a valid pdf (no surprise) and the printer is just printing lots of gibberish.

    So please just tell me what command is needed to send a "binary" accross the network to my printer. And I will read up on it and hopefully figure out the syntax. I believe command line is best - to later integrate into a Phyton script. But Power Shell command might also help me.

    (If you want to send examples, that would be awesome, but is optional.)

    File is this, for example: C:\Users\martin\MyDocument.pdf

    Printer port is called "192.168.0.200" (this is its name, no typo)

    Thank you.

    • hdhondt
      hdhondt over 6 years
      You can use Foxit Reader to print from the command line, e.g. "Foxit Reader.exe" /t "FileName" "PrinterName"
    • Martin Zaske
      Martin Zaske over 6 years
      @hdhondt Thank you. Are you saying indirectly that what I want cannot be done? When I am already on the command line, why would I employ a rather massive tool to send a ready pdf to a printer who can handle it "as is"? I had hoped for something "native" to the command line. If nothing else comes up as answers, I will try your idea and time it versus our old GSprint workflow. Will let you know.
    • hdhondt
      hdhondt over 6 years
      Very few printers can handle a PDF directly. Of those that do, most require the PDF to be sent via a special utility or some other specific way. For your printer, that's "KYOCERA Net Direct Print".
    • Martin Zaske
      Martin Zaske over 6 years
      @hdhondt I had made certain assumptions. Our printer has got an USB-slot and can print PDF documents directly from a normal USB-memory-stick (which does not provide any logic as far as I know). So I assume that our printer can indeed handle PDF files directly. Would be a shame, if file-coming-via-the-network-rather-than-from-local-USB would somehow prevent the printer from its own competence. Still thank you for all input.
  • Martin Zaske
    Martin Zaske over 6 years
    I just installed the tool Kyo Net Direct Print and I managed to make it run via command line: The first "option" (path to a pdf file) that I pass after the program call, gets printed. Now I am searching please, how to either change the default settings or how to call one of those "User Printer Settings" via the command line. I saved settings as a .bin file and passed it, but that ended up in the print spool. If you got experience with this tool, please advise. I need special settings like "print first page only".
  • Martin Zaske
    Martin Zaske over 6 years
    I am testing it, and it is much faster than our old GSprint, so we are getting close to a solution. But it will only work, if I find a way to apply our special settings (full size, first page only, recto only, ...) which are not what the inbuilt defaults are.
  • hdhondt
    hdhondt over 6 years
    If you apply your settings on the printer itself (via its web i/f or the front panel menu) they should be applied here. The Windows driver settings will override those settings, so normal printing will still work as usual.
  • Scott - Слава Україні
    Scott - Слава Україні about 6 years
    Please elaborate on what you mean by “Set printer before save settings (.bin-file)”. Please do not respond in comments; edit your answer to make it clearer and more complete.
  • Martin Zaske
    Martin Zaske almost 4 years
    Good idea, thank you. The syntax did not work at all in the power shell. When I switched to a cmd window it worked like you wrote: the pdf-file got sent to our printer. Sadly our Kyocera prints the file fine from an USB-drive but not this way via the network.It prints binary data as I would see in a hex-editor. And same if I omit the /B option. Still I give you a tick for your help, it might work on certain printers.
  • Aaron Cicali
    Aaron Cicali over 3 years
    I recommend SumatraPDF instead of Foxit. Sumatra supports CLI printing, is small and portable, and doesn't bundle malware with its installer like Foxit does.
  • Essej
    Essej over 3 years
    This works: "C:\Program Files\LibreOffice\program\soffice.exe" --pt "Microsoft Print to PDF" "PathToPdf.pdf" but it does show a dialog box prompting the user to save the file.