Page 1 of 1

How can I Get PDF file name after convert one doc to pdf ?

Posted: Tue Feb 15, 2011 6:22 am
by turtle_2
Hi
How can I Get PDF file name after convert one doc to pdf ?
Because the parameter Option is a Write only parameterized property. I can Set the PDF file name , but if the file exists already, and I set property Option like : FPDFPrinter.Option['Save.WhenExists'] := 'ShowWarning';
So the current PDF file name may be changed by user. How can I Get the current PDF file name ?

My code below:

procedure TcxPDFPrinter.Print;
begin
if not FileExists(FSrcFileName) then
begin
if Assigned(FOnError) then
FOnError(Self, Format(CXPDFPRINTER_ERROR_FILENOTEXISTS,[FSrcFileName]));
Exit;
end;

FDstFileName := ChangeFileExt(FSrcFileName, '.pdf');
FPDFPrinter.SetAsDefaultPrinter;
FPDFPrinter.Option['Save.RunApp'] := FIfRunPDFViewer;
FPDFPrinter.Option['Save.File'] := FDstFileName;
FPDFPrinter.Option['Save.SaveType'] := 'Save';
FPDFPrinter.Option['Save.ShowSaveDialog'] := 'No';
FPDFPrinter.Option['Save.WhenExists'] := 'ShowWarning'; // 'Overwrite'
FPDFPrinter.Option['Compression.Graphics'] := 'No';
FPDFPrinter.Option['Compression.Text'] := 'No';
FPDFPrinter.Option['Fonts.EmbedAll'] := 'No';

ShellExecute(HWND(nil), 'print', PChar(FSrcFileName), PChar('"' + FPrinterName + '"'), nil, SW_NORMAL);

// I want to get PDF file name after convert one doc to pdf. But the parameter Opention is Write only.
// FDstFileName := VarToStr(FPDFPrinter.Option['Save.File']);


FPDFPrinter.RestoreDefaultPrinter;
if Assigned(FOnAfterPrint) then
FOnAfterPrint(Self);
end;

Thank in advance.

Re: How can I Get PDF file name after convert one doc to pdf ?

Posted: Tue Feb 15, 2011 5:36 pm
by Ivan - Tracker Software
You have to handle OnFileSaved event - second parameter there is the file name of created PDF file.

Re: How can I Get PDF file name after convert one doc to pdf ?

Posted: Wed Feb 16, 2011 1:53 am
by turtle_2
Thank U.

Re: How can I Get PDF file name after convert one doc to pdf ?

Posted: Wed Feb 16, 2011 12:17 pm
by Tracker Supp-Stefan
Kudos to Ivan :)

Best,
Stefan