Hi.
Does anyone knows how to use PDFCreator com object with Delphi 2010 ?
I have already imported the type library.
I would be very glad ;-) if someone could give me an axample written in delphi.
Thanks
Costas
Hi.
Does anyone knows how to use PDFCreator com object with Delphi 2010 ?
I have already imported the type library.
I would be very glad ;-) if someone could give me an axample written in delphi.
Thanks
Costas
This procedure uses Adobe's reader COM object to print an existing PDF file, then it creates an RTF from data in a database and prints that. Both are captured by PDFCreator, then combined into one PDF.
Sorry for so little detail, I am VERRY Busy at the moment.
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DBC, CsMainForm, DB, ADODB,AcroPDFLib_TLB, PDFCreator_TLB ,StdCtrls, ExtCtrls, Printers,
ComCtrls, ucsconst;
procedure TffrmWorkingCopy.btnPrintClick(Sender: TObject);
var
sImagePDFFileName,
oPath, ScriptBaseName: String;
start: Extended;
c: Integer;
begin
start := Now();
qryRxList.Open;
oPath := IncludeTrailingPathDelimiter(txtPDFFolder.Text);
FPDFCreator := TclsPDFCreator.Create(self);
if Not assigned(fAcroPDF)then
begin
fAcroPDF := TAcroPDF.Create(Self);
fAcroPDF.Visible := False;
fAcroPDF.Parent := Panel3;
end;
fAcroPDF.setShowToolbar(False);
fAcroPDF.setPageMode('none'); // thumbs, bookmarks
FPDFCreator.cStart('/NoProcessingAtStartup', TRUE);
FPDFCreator.cOption['UseAutosave'] := 1;
FPDFCreator.cOption['UseAutosaveDirectory'] := 1;
FPDFCreator.cOption['AutosaveDirectory'] := opath;
FPDFCreator.cOption['RunProgramAfterSaving'] := 0;
FPDFCreator.cOption['AutosaveFormat'] := 0;
Printer.PrinterIndex := Printer.Printers.IndexOf('PDFCreator');
While not qryRxList.Eof do
begin
ScriptBaseName := 'WC_'+qryRxList.FieldByName('script_no').AsString+FormatDateTime('yyyy_mm_dd', now());
sImagePDFFileName := qryRxList.FieldByName('pdf').AsString;
Memo1.Lines.Add(' PDF='+sImagePDFFileName);
Memo1.Lines.Add(' FILE='+ScriptBaseName);
Memo1.Lines.Add(' PATH='+FPDFCreator.cOption['AutosaveDirectory']);
if Pos('.pdf', Lowercase(sImagePDFFileName)) = 0 then
begin
sImagePDFFileName := ExtractFilePath(ParamStr(0))+'MissingFax.pdf';
Memo1.Lines.Add(' >>>PDF='+sImagePDFFileName);
end;
FPDFCreator.cDefaultprinter := 'PDFCreator';
FPDFCreator.cClearcache;
FPDFCreator.cOption['AutosaveFilename'] := ScriptBaseName; //'';
FAcroPDF.LoadFile(sImagePDFFileName);
fAcroPDF.setShowToolbar(False);
fAcroPDF.Visible := True;
FPDFCreator.cPrinterStop := True;
FAcroPDF.PrintAll;
// Force app to wait until the PDF is spooled to the Capture queue
c:=0;
While (FPDFCreator.cCountOfPrintjobs = 0) and (c < (maxTime * 1000 / sleepTime)) Do
begin
application.ProcessMessages;
c := c + 1;
Sleep(sleepTime);
end;
BuildRTF;
rtfRx.Print(ScriptBaseName);
// Force app to wait until the RTF is spooled to the Capture queue
While (FPDFCreator.cCountOfPrintjobs < 2) and (FPDFCreator.cCountOfPrintjobs <> 0) do
WaitASec(0.5, lblTimer);
// FPDFCreator.cMovePrintjobUp(2); // this was not needed.
FPDFCreator.cCombineAll;
c := 0;
// Wait until the jobs are combined into one PDF
While (FPDFCreator.cCountOfPrintjobs > 1) and (c < (maxTime * 1000 / sleepTime)) Do
begin
application.ProcessMessages;
c := c + 1;
Sleep(sleepTime);
end;
// Now, start the PDFCreator and generate the new PDF file....
FPDFCreator.cPrinterStop := False;
c := 0;
// Force app to wait until the new PDF is created
While (FPDFCreator.cCountOfPrintjobs > 0) and (c < (maxTime * 1000 / sleepTime)) Do
begin
application.ProcessMessages;
c := c + 1;
Sleep(sleepTime);
end;
qryRxList.Next;
end;
FPDFCreator.Free;
Memo1.Lines.Add(FormatDateTime('hh:nn:ss.zzz', Now() - Start ));
if (fAutodate <> 0) or (fAutoRx <> '') then Close;
// MessageDlg('Done', mtCustom, [mbOK], 0);
end;