(view source code of printpdf.rex as plain text)
/* Check and parse command line arguments */
Parse Upper Arg pdflist
If pdflist = "" Then Call Syntax
If Pos( "/", pdflist ) > 0 Then Call Syntax
pdflist = Strip( Translate( pdflist, " ", "," ) )
/* Initialize RexxUtil */
Call RxFuncAdd "sysloadfuncs", "RexxUtil", "sysloadfuncs"
Call sysloadfuncs
/* Check if the specified files exist and build a file list */
pdf. = ""
pdf.0 = 0
Do Until pdflist = ""
If Left( pdflist, 1 ) = '"' Then Do
Parse Value pdflist With '"'nextspec'"'pdflist
pdflist = Strip( pdflist )
End
Else Do
Parse Value pdflist With nextspec pdflist
End
Call SysFileTree nextspec, "files.", "FO"
If files.0 > 0 Then Do i = 1 To files.0
j = pdf.0 + 1
pdf.j = files.i
pdf.0 = j
End
Else Do
Call Syntax
End
End
/* Reformat the file list */
Do i = 1 To pdf.0
pdflist = pdflist||' "'||pdf.i||'"'
End
/* Initialize W32Funcs */
Call RxFuncAdd "w32loadfuncs", "W32Util", "w32loadfuncs"
Call w32loadfuncs
/* Read default PDF print command from registry */
handle = w32RegOpenKey( "HKEY_CLASSES_ROOT", ".pdf" )
filetype = w32RegQueryValue( handle, "" )
Call w32RegCloseKey handle
handle = w32RegOpenKey( "HKEY_CLASSES_ROOT", filetype||"\shell\print\command" )
printcmd = w32RegQueryValue( handle, "" )
Call w32RegCloseKey handle
/* Check if no other (Adobe) software is used in the print command */
If Pos( "{", printcmd ) > 0 Then Do
Say
Say "This script will only work if Acrobat Reader is the default association"
Say "for PDF files."
Say "On this computer, that doesn't seem to be the case, possibly because"
Say "other Adobe software is installed."
Call Syntax
End
/* Display a message telling the user to manually close Acrobat Reader */
Say
Say "Waiting for you to close the Acrobat Reader window manually after it has sent"
Say "all files to the printer..."
/* Execute the print command for every file from the list */
Parse Value printcmd With printcmd'"%1"'printtail
printcmd = printcmd||pdflist||printtail
address SYSTEM '"'||printcmd||'"'
/* Normal program termination */
Exit 0
Syntax:
Say
Say "PrintPDF.rex, Version 1.00"
Say "Print a (list of) specified PDF file(s)"
Say
Say "Usage: <REXX> PRINTPDF.REX pdflist"
Say
say 'Where: "<REXX>" is your Rexx interpreter:'
say " - Windows: REGINA.EXE (with RexxUtil installed)"
say " - OS/2: no need to specify, just rename script to *.cmd"
Say ' "pdflist" specifies the file(s) to be printed; list format can'
Say " be wildcards, or space separated, or any combination"
Say
Say "Arguments should be enclosed in double quotes if they contain spaces"
Say
Say "Written by Rob van der Woude"
Say "http://www.robvanderwoude.com"
Exit 1
Return
page last modified: 2024-04-16; loaded in 0.0095 seconds