Hi everyone,
I have a process that allows the user to print. But every time the user prints, the saveas dialog box keeps on prompting and asking you to supply filename. Below are my scripts.
I do this kind of printing because with that, I can successfully print image with pdf format and I use filecopy to copy the saved pdf file from local to server or any path that I need.
s_newfilename = s_cppath1 + s_name + ".pdf"
s_newfilename2 = s_cppath2 + s_name + ".pdf"
s_newfilename3 = s_cppath3 + s_name + ".pdf"
dw_printer.Object.DataWindow.Print.PrinterName = "Microsoft Print to PDF"
dw_printer.Object.DataWindow.Print.FileName = s_newfilename3
dw_printer.Print(false, false)
If dw_printer.rowcount() > 0 then
if dw_printer.Print() < 1 then
dw_printer.PrintCancel()
end if
end if
s_copypath = "c:/path/"+s_newfilename3
//Messagebox("",s_copypath)
li_FileNum = FileCopy (s_copypath, &
s_newfilename, True )
li_FileNum2 = FileCopy (s_copypath, &
s_newfilename2, True )
li_FileNum3 = FileCopy (s_copypath, &
s_newfilename3, True )
iRetVal = ShellExecute(0, "print", s_newfilename3, "", "", 1)
IF iRetVal <= 32 THEN
// Capture the error message
string ls_errorMessage
ls_errorMessage = "Failed to print PDF file. Error code: " + String(iRetVal)
// Display the error message in a messagebox
MessageBox("System Error", ls_errorMessage, StopSign!)
ELSE
MessageBox("Success", "Printing PDF file...")
END IF
and in my global external function I have this:
Function long ShellExecute( long hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, integer nShowCmd ) Library "shell32.dll" alias for "ShellExecuteW"
I'm having problem also with re-print. When the document got reprinted or already existing in the server, the newly copied file got corrupted.
By the way Im using Powerbuilder Claasic 12.5
Please help. TIA.