Page 1 of 1

Sending Printjobs to network printers

Posted: Wed Jul 08, 2020 1:35 pm
by bkromer
Hey there,

I am currently testing the PDFPrinter APP we found at the Enfocus Appstore.
The goal is to send incoming files to network printers. Office and Label printers.

The Flow with the app looks like this:
Bildschirmfoto 2020-07-08 um 13.29.00.png
Bildschirmfoto 2020-07-08 um 13.29.00.png (154.02 KiB) Viewed 10556 times
For some printers it works very well for some not, Switch brings up an Error Message that some ScriptExecuter....exe crashed.

Is there any other solution for this use-case.

Re: Sending Printjobs to network printers

Posted: Wed Jul 08, 2020 1:39 pm
by jan_suhr
I suggest that you contact the App-creator for support.
https://www.apagoinc.com/

Re: Sending Printjobs to network printers

Posted: Wed Jul 08, 2020 1:45 pm
by bkromer
jan_suhr wrote: Wed Jul 08, 2020 1:39 pm I suggest that you contact the App-creator for support.
https://www.apagoinc.com/
I did thanks.

Re: Sending Printjobs to network printers

Posted: Thu Jul 09, 2020 9:40 am
by ThomasDeschamps
An easy alternative if you are operating on windows is a small batch file and Foxit Reader or similar PDF tool :

Code: Select all

setlocal enabledelayedexpansion
set mypath=C:\SCRUT\pdfa4
set myprinter=Brother_A4
echo "starting hotfolder scan in %mypath%"
:loop
for %%f in (%mypath%\*.pdf) do (
  echo printing %%f
  %mypath%\..\PGM\Foxit_Reader.exe /t "%%f" %myprinter%
  echo on printer %myprinter%
  move "%%f" "%mypath%\ARCHIVES"
  echo moving %%f in Archive

)
timeout /t 2
You need to create the folder "mypath" and use the windows name of your printer. the preset default printing option will be used.
if needed, you can put this batch file in the starting folder

Re: Sending Printjobs to network printers

Posted: Tue Jul 21, 2020 12:24 pm
by w3gmbh
Benjamin,

a nice and fast option for me was to use gsprint, a part of ghostview, extremely fast and configurable (just change your printer config).

see: http://www.ghostgum.com.au/software/gsview.htm

Switch Setup:
Application: C:/Program Files/Ghostgum/gsview/gsprint.exe
Parameters: -noquery -color -all -printer "MyWindowsPrinter" "%1"

Ralf.

Re: Sending Printjobs to network printers

Posted: Wed Jul 22, 2020 8:59 am
by bkromer
w3gmbh wrote: Tue Jul 21, 2020 12:24 pm ...

Switch Setup:
Application: C:/Program Files/Ghostgum/gsview/gsprint.exe
Parameters: -noquery -color -all -printer "MyWindowsPrinter" "%1"
...
Hey Ralf, can you describe that a little further.
Are you starting the gsprint.exe from within Switch?
ThomasDeschamps wrote: Thu Jul 09, 2020 9:40 am An easy alternative if you are operating on windows is a small batch file and Foxit Reader or similar PDF tool :
...
Thanks Thomas this is so cool. I dont know batch this well, but inspired by your script
I wrote myself a python2 script. It works like a hotfolder. PDF-Files need to have the printers name at the end like _BP730i.pdf
The only downside I see is that the scripts open´s the standard APP for PDF Files and sends it to the printer. After that, it closes the APP immediately.
So you won't run this script on your switch server as it would be very disturbing having pdf readers popping up all the time some printjob comes in. :/

Code: Select all

import win32api
import win32print
import os
import time
import shutil
import re
from datetime import datetime

now = datetime.now()
t = now.strftime("%d.%m.%Y, %H:%M:%S")

#all_printers = win32print.EnumPrinters(2)

pdf_dir = "Y:\\HOTFOLDER_DRUCK\\INPUT\\"
archiv = "Y:\\HOTFOLDER_DRUCK\\ARCHIV\\"

while True:
    time.sleep(1)
    files = os.listdir(pdf_dir)
    if files > 0:
        time.sleep(6) # WARTEN BIS SWITCH DEN PREFIX ENTFERNT HAT 
        files = os.listdir(pdf_dir) # ANSCHLIESSEND ORDNER NEU EINLESEN
        for f in files:
            pattern = re.compile('\_([a-zA-Z0-9]+)\.pdf')
            match = pattern.search(f)
            printer = match.group(1)
            defaultPrinter = win32print.GetDefaultPrinter()
            if defaultPrinter != printer:
                win32print.SetDefaultPrinter(printer)
            print t+" printing file "+ str(pdf_dir+f) +" on "+str(printer) #str(win32print.GetDefaultPrinter())
            time.sleep(1)
            win32api.ShellExecute(0, "print", os.path.join(pdf_dir,f), None,  ".",  0)
            time.sleep(6)
            shutil.copy(os.path.join(pdf_dir,f),os.path.join(archiv,f))
            os.remove(os.path.join(pdf_dir,f))

Re: Sending Printjobs to network printers

Posted: Wed Jul 22, 2020 9:33 am
by jan_suhr
What Ralf suggests uses the Execute Command element in Switch.

You'll see when you add it to the flow.

Re: Sending Printjobs to network printers

Posted: Wed Jul 22, 2020 10:29 am
by bkromer
Great thx.
I also found a similar tool to ghostgum its called pdftoprinter http://www.columbia.edu/~em36/pdftoprinter.html.

Sending print jobs to a printer via cmd is easy, there is no pdfreader poping up now its completely silent.
But its also possible to define the amount of copies to print, the printer and the file as variables. But how can I build this in execute command?
My files are named like YB27_bkromer_copies_2_BP730i.pdf and the command should look like

Code: Select all

c://pdftoprinter.exe c://hotfolder/input/YB27_bkromer_copies_2_BP730i.pdf  "BP730i" copies=2
So I need the variable [Job.Name:After="copies_",Before="_"] for the amount of copies, the [Job.Name:After="_",Before=".pdf"] for the printer name and the [Job.Name] for the pdf file to print.
Is there a way to make this work?
Bildschirmfoto 2020-07-22 um 10.24.33.png
Bildschirmfoto 2020-07-22 um 10.24.33.png (66.38 KiB) Viewed 10406 times
If this works, this would be the perfect solution.

Re: Sending Printjobs to network printers

Posted: Wed Jul 22, 2020 10:34 am
by jan_suhr
You could probably do it with a .BAT or Shellscript file. Use the App Execute Command Friend to create such a file and then let Execute Command run it. With that app you could build up your command with Switch variables.

https://www.enfocus.com/en/appstore/pro ... and-friend

Re: Sending Printjobs to network printers

Posted: Wed Jul 22, 2020 12:55 pm
by w3gmbh
when using gsprint (blazing fast, no size mismatches) you can use all those switches (including copies):

http://www.ccp14.ac.uk/ccp/web-mirrors/ ... sprint.htm

Simple implementation screenshot:
gsprint.PNG
gsprint.PNG (11.85 KiB) Viewed 10399 times
Cheers,

Ralf