(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 )
EndElse Do
Parse Value pdflist With nextspec pdflist
EndCall 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 EndElse Do
Call Syntax
EndEnd/* 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 handlehandle = 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
SaySay "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 */SaySay "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:
SaySay "PrintPDF.rex, Version 1.00"
Say "Print a (list of) specified PDF file(s)"
SaySay "Usage: <REXX> PRINTPDF.REX pdflist"
Saysay '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"
SaySay "Arguments should be enclosed in double quotes if they contain spaces"
SaySay "Written by Rob van der Woude"
Say "http://www.robvanderwoude.com"
Exit 1
Returnpage last modified: 2025-10-11; loaded in 0.0077 seconds