Announcement

Collapse
No announcement yet.

Get printer spool string for Ghostscript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get printer spool string for Ghostscript

    After trial and error the following Sub (I think gets the -sOutputfile string needed to send a PDF directly to the printer without any printer dialog using Ghostscript.

    I need a couple of people to test for me if possible.
    Steps:
    1. Set a local default printer and run
    2. Set a network printer as the default and run

    My tests were with

    HPLJ5S for the local printer
    Code returned \\spool\HPLJ5S
    HPLJ5P on BOBM-HWA (from BOB-PC) for the network printer
    Code returned \\spool\\\BOBM-HWA\HPLJ5P

    Code:
    SUB GetDefPrt
     LOCAL zPrinterDefault AS ASCIIZ * 255
     LOCAL sPrinterDefault AS STRING
     GetProfileString "WINDOWS", "DEVICE", ",,,", zPrinterDefault, SIZEOF(zPrinterDefault)
     sPrinterDefault = TRIM$(zPrinterDefault)
     sPrinterDefault = PARSE$(sPrinterDefault,",",1)
     IF INSTR(sPrinterDefault," on ") > 0 THEN
       sPrinterDefault = "\\spool\\\" + PARSE$(sPrinterDefault," ",3) + "\" + PARSE$(sPrinterDefault," ",1)
     ELSE
       sPrinterDefault = "\\spool\" + PARSE$(sPrinterDefault," ",1)
     END IF
     MSGBOX(sPrinterDefault)
    END SUB
    The actual command line for the network printer. The %1 would be replaced with the PDF name.

    gswin32c -q -sDEVICE=mswinpr2 -sOutputFile="\\spool\\\BOBM-HWA\HPLJ5P" -dNOPAUSE -dBATCH %1

    I'm hoping this will work in default situations of network printer setups. Any advice would be valuable.

    Thanks,

    Bob Mechler

  • #2
    Code:
    GLOBAL sPrinterDefault AS STRING
    SUB GetDefPrt
     LOCAL zPrinterDefault AS ASCIIZ * 255
     GetProfileString "WINDOWS", "DEVICE", ",,,", zPrinterDefault, SIZEOF(zPrinterDefault)
     sPrinterDefault = TRIM$(zPrinterDefault)
     sPrinterDefault = "\\spool\" + PARSE$(sPrinterDefault,",",1) 
    END SUB
    Works with less code.

    Bob Mechler

    Comment

    Working...
    X