Q&A
A customer asked how he can automatically print PDF files downloaded by WatchFTP.
WatchFTP can start a batch file after downloading so we use a script to run Foxit Reader to print the file. One extra feature was needed: he wants to print invoices on one printer and tickets on another.
Here is an example bat file you can use for this:
SET FOXCMD=C:\Program Files (x86)\Foxit Software\Foxit Reader\Foxit Reader.exe rem the printer for INV- files (printer names exactly as on your "Printers" control panel applet) SET PRINTER1=Local Printer1 rem the printer for TIC- files SET PRINTER2=\\Server\ServerPrinter 1 rem the printer for everything else SET PRINTERDEFAULT=Local Printer2 rem a log file (taskname_yyyymmdd.log) SET LOG=C:\Logs\%WF_CONFIG%_%WF_DATE%.log rem check for valid file type, only PDFs are supported IF "%WF_FILE_E%" NEQ "PDF" GOTO :Eof rem get the first 4 positions of the filename SET P4=%WF_FILE_N:~0,4% SET PRINTER=%PRINTERDEFAULT% IF /I "%P4%" EQU "INV-" ( SET PRINTER=%PRINTER1% ) IF /I "%P4%" EQU "TIC-" ( SET PRINTER=%PRINTER2% ) echo [%time%] printing %WF_FILE% to printer %PRINTER% >> "%LOG%" "%FOXCMD%" /t "%WF_FILE%" "%PRINTER%" IF %errorlevel% GEQ 1 GOTO :PrintFails echo [%time%] printed >> "%LOG%" GOTO :EOF :PrintFails echo [%time%] ERROR - FILE WAS NOT PRINTED >> "%LOG%" GOTO :EOF
No comments:
Post a Comment