Code:
Procedure DoPrintToFile String sFile
String sDriver
String sDevice
String sPort
Integer iFlags
// Guarda padrão
Get DFGetCurrentDriver of WinPrintID to sDriver
Get DFGetCurrentDevice of WinPrintID to sDevice
Get DFGetCurrentPort of WinPrintID to sPort
Get DFGetPrintDialogFlags of WinPrintID to iFlags
Send DFSetSpecPrintFlag to WinPrintID DF_PRINTTOFILE
Send DFSelectPrinter to WinprintID "WinSpool" "PDF995" sFile False
Send DFPrintDoc to WinPrintID
Send DFPrintFlags to WinPrintID iFlags
// Volta padrão
Send DFSelectPrinter to WinprintID sDriver sDevice sPort True
End_Procedure
Depois usa