PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Printing PDF files using Windows system help  (Read 1241 times)

PxPlus

  • Administrator
  • Diamond Member
  • *****
  • Posts: 1091
    • View Profile
Printing PDF files using Windows system help
« on: May 31, 2018, 09:59:10 AM »
If you want to print a PDF file when running under Windows (or via Windx), one of the easiest techniques is to use the Windows Shell to determine how to print the file.

The following program invokes the Windows shell to print all PDF files in a directory using Adobe:

0010 ! Utility to print all PDF's in a directory
0020 ! Developed by PVX Plus Technologies
0030 ! Written by: Mike King - Nov 2005
0040 !
0050 SELECT F$ FROM "." WHERE LCS(MID(F$,-4))=".pdf"
0060 LET TRU_PATH$=LWD+DLM+F$+$00$
0070 LET A=DLL("SHELL32.DLL","ShellExecuteA",0,"print"+$00$,TRU_PATH$,0,0,0)
0080 WAIT 1
0090 NEXT RECORD
0100 !
0110 ! Find Adobe and terminate it
0120 !
0130 LET WINAPI=NEW("*obj/winapi")
0140 !
0150 FOR I=1 TO 20
0160 WAIT 1 ! give it a second to complete
0170 LET WDWHDL=WINAPI'FINDWINDOW("Adobe Reader"+$00$,"")
0180 IF WDWHDL<>0 THEN WINAPI'SENDMESSAGE(WDWHDL,16,0,0); BREAK
0190 NEXT
0200 !
0210 DROP OBJECT WINAPI
0220 END

The logic consists of passing the full pathname of each PDF file to the Shell and asking it to print. Once done, the system looks for a window titled "Adobe Reader" and if found sends it a Window Close request.