I have written an application that needs to print PDF files (not create a PDF from a report output). I can do so with the code below. However, I would like to allow the user to select which printer they are sending the output to. I have used the SYS(1037) and it does send the cover reports to the selected printer, but it sends the PDF jobs to the Windows Default printer. I assume that this is because the SYS(1037) only changes where FoxPro prints but does not alter the Windows default selection. My guess is that the PDF print, since it is being done by the AcroExch call, is not controlled by the FoxPro selection. Does anyone know how to make a call to the Windows API and change the default printer or bring up a dialog box for the user to select a printer (to replace the SYS(1037) call)?
Also, note the rather cumbersome way the pages are printed with ten print commands. The reason for this is that the PrintPages command requires a start and end page number and doesn't like it if you put in a big number for the end page. Therefore I have to print one page at a time. If the page doesn't exist something flashes on the screen but nothing gets sent to the printer so it works, but there should be some way of telling it to print all pages without knowing how many pages there are. The current method limits the number of pages of the document to 10. Any ideas?
*** code for printing PDF (requires Adobe Acrobat 4.0 or 5.0 be installed on the user workstation)
if xoutput = "Preview" && preview
* Creating Objects for FDF file Creation
objAcroApp = CreateObject("AcroExch.App"
objAcroDoc = CreateObject("AcroExch.AVDoc"
objAcroApp.Show
objAcroApp.Maximize(.T.)
objAcroApp.MenuItemRemove ("ShowHideToolBar"
objAcroDoc.open(xstudentfile,"FDF Application"
else && print
objAcroApp = CreateObject("AcroExch.App"
objAcroDoc = CreateObject("AcroExch.AVDoc"
objAcroDoc.Open(xstudentfile, "FDF Application"
*objAcroDoc.Maximize (True)
do print_reset
intPrint = objAcroDoc.PrintPages(0, 0, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(1, 1, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(2, 2, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(3, 3, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(4, 4, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(5, 5, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(6, 6, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(7, 7, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(8, 8, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(9, 9, 1, .F., .F.)
do print_reset
endif
Also, note the rather cumbersome way the pages are printed with ten print commands. The reason for this is that the PrintPages command requires a start and end page number and doesn't like it if you put in a big number for the end page. Therefore I have to print one page at a time. If the page doesn't exist something flashes on the screen but nothing gets sent to the printer so it works, but there should be some way of telling it to print all pages without knowing how many pages there are. The current method limits the number of pages of the document to 10. Any ideas?
*** code for printing PDF (requires Adobe Acrobat 4.0 or 5.0 be installed on the user workstation)
if xoutput = "Preview" && preview
* Creating Objects for FDF file Creation
objAcroApp = CreateObject("AcroExch.App"
objAcroDoc = CreateObject("AcroExch.AVDoc"
objAcroApp.Show
objAcroApp.Maximize(.T.)
objAcroApp.MenuItemRemove ("ShowHideToolBar"
objAcroDoc.open(xstudentfile,"FDF Application"
else && print
objAcroApp = CreateObject("AcroExch.App"
objAcroDoc = CreateObject("AcroExch.AVDoc"
objAcroDoc.Open(xstudentfile, "FDF Application"
*objAcroDoc.Maximize (True)
do print_reset
intPrint = objAcroDoc.PrintPages(0, 0, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(1, 1, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(2, 2, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(3, 3, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(4, 4, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(5, 5, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(6, 6, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(7, 7, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(8, 8, 1, .F., .F.)
do print_reset
intPrint = objAcroDoc.PrintPages(9, 9, 1, .F., .F.)
do print_reset
endif