Does anyone know how to programm Pdfprinter from Delphi?
Best regards
Delphi
Moderator: jr
-
- Posts: 1
- Joined: Thu Mar 11, 2010 5:34 am
Re: Delphi
Yes, I have the same problem. Have you made any progress with this?
Thanks;
Thanks;
Re: Delphi
I just make different *.ini files in notepad and then copy/move them in delphi, depending on which I have to use.
It is not so elegant, but it works.
Now I have to find out how to see when making the pdf-file is finish?
It is not so elegant, but it works.
Now I have to find out how to see when making the pdf-file is finish?
-
- Posts: 1
- Joined: Wed Apr 27, 2011 6:13 pm
Re: Delphi
If you haven't imported the type library that's the first step. Once that's been done, you can use something similar to what is below:
The following fragment assumes you've created the PDFPrinterSettings as a VCL object in a datamodule or form i.e., PDFPrinterSettings1: TPDFPrinterSettings;
procedure setuppdfprinter;
var
pi : integer;
begin
try
pi := printer.Printers.IndexOf('Bullzip PDF Printer [SOA]');
printer.PrinterIndex := pi;
PDFPrinterSettings1.Connect;
PDFPrinterSettings1.SetPrinterName('Bullzip PDF Printer [SOA]');
PDFPrinterSettings1.LoadSettings(FALSE);
oppfn := '\\' + OppOutFileNodeName + '\' + JobFile.GetInstance + '$\' + ExtractFileName(UnixPathToDosPath(OppOutFileName));
PDFPrinterSettings1.SetValue('output', oppfn);
{$IFDEF WATERMARK}
if JobFile.GetInstance <> 'xxxxxxx' then
begin
PDFPrinterSettings1.SetValue('WatermarkText', 'TEST DOCUMENT');
PDFPrinterSettings1.SetValue('WatermarkTransparency', '70');
end;
{$ENDIF}
PDFPrinterSettings1.WriteSettings(TRUE);
PDFPrinterSettings1.Disconnect;
except
writeln('Error connecting to OLE');
end;
end;
Since you've selected the PDF printer as your output device it will create a PDF document when you print using begindoc/enddoc or whatever process you are using. The jobfile class is custom and unique, just make sure you specify the output filename for the pdf document. If you are multi-threaded then you will need to synchronize writing the printer settings.
I also set the document title before physically printing it. I hope this helps.
The following fragment assumes you've created the PDFPrinterSettings as a VCL object in a datamodule or form i.e., PDFPrinterSettings1: TPDFPrinterSettings;
procedure setuppdfprinter;
var
pi : integer;
begin
try
pi := printer.Printers.IndexOf('Bullzip PDF Printer [SOA]');
printer.PrinterIndex := pi;
PDFPrinterSettings1.Connect;
PDFPrinterSettings1.SetPrinterName('Bullzip PDF Printer [SOA]');
PDFPrinterSettings1.LoadSettings(FALSE);
oppfn := '\\' + OppOutFileNodeName + '\' + JobFile.GetInstance + '$\' + ExtractFileName(UnixPathToDosPath(OppOutFileName));
PDFPrinterSettings1.SetValue('output', oppfn);
{$IFDEF WATERMARK}
if JobFile.GetInstance <> 'xxxxxxx' then
begin
PDFPrinterSettings1.SetValue('WatermarkText', 'TEST DOCUMENT');
PDFPrinterSettings1.SetValue('WatermarkTransparency', '70');
end;
{$ENDIF}
PDFPrinterSettings1.WriteSettings(TRUE);
PDFPrinterSettings1.Disconnect;
except
writeln('Error connecting to OLE');
end;
end;
Since you've selected the PDF printer as your output device it will create a PDF document when you print using begindoc/enddoc or whatever process you are using. The jobfile class is custom and unique, just make sure you specify the output filename for the pdf document. If you are multi-threaded then you will need to synchronize writing the printer settings.
I also set the document title before physically printing it. I hope this helps.
Re: Delphi
Good Day,
I'm new to delphi and i tried the code above. I was wondering how to
1.) un-check the "open the document after creation" checkbox
2.) to automatically "save" without showing the "Bullzip PDF Printer - Create File" form after sending the file to print
hoping for a response, thank you in advance.
I'm new to delphi and i tried the code above. I was wondering how to
1.) un-check the "open the document after creation" checkbox
2.) to automatically "save" without showing the "Bullzip PDF Printer - Create File" form after sending the file to print
hoping for a response, thank you in advance.
Re: Delphi
ah forget about my previous post .. found it out by configuring the gui.exe