LPARAMETERS tcFRXname, tcFor LOCAL lcDefaultPrinter, lcPrinter, lcDestFileName, loObj, lnLen, lnRetVal *** Make sure the passed parameter has an extension of frx tcFRXname = FORCEEXT( tcFRXname, 'FRX' ) *********************************************************************** *** Changed By.: Marcia G. Akins on 07 October 2009 *** Reason.....: Get the windows default printer so we can and set it as *** .....................: the VFP default printer after the PDF is created *********************************************************************** lcDefaultPrinter = SPACE( 254 ) lnLen = 254 DECLARE INTEGER GetDefaultPrinter IN winspool.drv STRING @lcDefaultPrinter, INTEGER @lnLen lnRetVal = GetDefaultPrinter( @lcDefaultPrinter, @lnLen ) *** a return value of zero means that an error occurred IF lnRetVal > 0 lcDefaultPrinter = LEFT( lcDefaultPrinter, lnLen ) ENDIF lcPrinter = "Bullzip PDF Printer" *** Lookup the destination location in the PDFcontrol table IF NOT USED( 'PDFcontrol' ) USE PDFcontrol IN 0 ENDIF && NOT USED( 'PDFcontrol' ) IF SEEK( UPPER( ALLTRIM( tcFRXname ) ), 'PDFcontrol', 'FRXname' ) *** construct the pdf name to be the same as the report with the date and time added lcDestFileName = ADDBS(ALLTRIM( PDFcontrol.PDFloc ) ) + JUSTSTEM( tcFRXname ) + TTOC( DATETIME(), 1 ) + '.pdf' ELSE RETURN ENDIF && SEEK( UPPER( ALLTRIM( tcFRXname ) ), 'PDFcontrol', 'FRXname' ) IF FILE(lcDestFileName) DELETE FILE ( lcDestFileName ) ENDIF *** Create the COM object to control the printer. loObj = CreateObject("BullZIP.PDFPrinterSettings") loObj.SetValue("Output",lcDestFileName) loObj.SetValue("ShowSettings" ,"never") loObj.SetValue("ShowPDF" ,"no") loObj.WriteSettings(.T.) SET PRINTER TO NAME ( lcprinter ) *** Check for a 'For' condition IF NOT EMPTY( tcFor ) REPORT FORM ( tcFRXname ) FOR &tcFor TO PRINTER NOCONSOLE ELSE && NOT EMPTY( tcFor ) REPORT FORM ( tcFRXname ) TO PRINTER NOCONSOLE ENDIF && NOT EMPTY( tcFor ) SET PRINTER TO NAME ( lcDefaultPrinter )