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

PDF-XChange Drivers API (only) V4/V5
This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-XChange Printer Drivers SDK (only) - VERSION 4 & 5 - Please use the PDF-Tools SDK Forum for Library DLL assistance.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan

Post Reply
turtle_2
User
Posts: 8
Joined: Fri Feb 11, 2011 2:41 am

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

Post by turtle_2 » Tue Feb 15, 2011 6:22 am

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.

Ivan - Tracker Software
Site Admin
Posts: 3630
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 ?

Post by Ivan - Tracker Software » Tue Feb 15, 2011 5:36 pm

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.

turtle_2
User
Posts: 8
Joined: Fri Feb 11, 2011 2:41 am

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

Post by turtle_2 » Wed Feb 16, 2011 1:53 am

Thank U.

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 14154
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 ?

Post by Tracker Supp-Stefan » Wed Feb 16, 2011 12:17 pm

Kudos to Ivan :)

Best,
Stefan

Post Reply