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.
How can I Get PDF file name after convert one doc to pdf ?
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan
- Ivan - Tracker Software
- Site Admin
- Posts: 3550
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
- Contact:
Re: How can I Get PDF file name after convert one doc to pdf ?
You have to handle OnFileSaved event - second parameter there is the file name of created PDF file.
Tracker Software (Project Director)
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
- Tracker Supp-Stefan
- Site Admin
- Posts: 17948
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How can I Get PDF file name after convert one doc to pdf ?
Kudos to Ivan
Best,
Stefan
Best,
Stefan