Knowledgebase

Back to Articles List

Can I use the PDF-XChange print driver from Delphi 5 to save a Quick Report as a PDF file without user intervention?

Question:

Can I use the PDF-XChange print driver from Delphi 5 to save a Quick Report as a PDF file without user intervention?

Please note that a user asked this question on the Tracker Software forum. They wanted to adjust the print driver settings programatically in order to suppress the Save As dialog box, specify a PDF filename/location and save to the file without the knowledge of the user. Additionally, they wanted to use a different print driver in order to print a hard copy for the user at the same time as the above.

The user's approach had been to print the hard copy and then programatically set the printer as the PDF printer and call the Quick Report print method. Their hope was that as they were not using the PDF-XChange APIs (such as PXC_WriteDocumentExA) it would be possible to change the print driver settings, programatically, each time a report was printed, and control how files were saved. 

Answer:

Yes - the Drivers API SDK can be used for this purpose. A sample code (in Delphi 5) is detailed below:

Sample Code:

var
iPXCC: IPXCControlEx;
iPXCP: OleVariant;
begin
iPXCC := CoCPXCControlEx.Create;
try
Key := '...';
DevCode := '...';

iPXCP := iPXCC.Get_Printer('', 'PDF-XChange 4.0', Key, DevCode);
iPXCP.Option['Saver.ShowProgress'] := 0;
iPXCP.Option['Save.SaveType'] := 'Save';
iPXCP.Option['Save.ShowSaveDialog'] := 0;
iPXCP.Option['Save.File'] := 'C:\'
iPXCP.Option['Save.WhenExists'] := 'AutoNumber';
iPXCP.Option['Save.RunApp'] := 0;

... Print QuickReport ...

finally
iPXCC := nil;
end;
end;
Was this article helpful?
Yes No Somewhat