Inconsistent prints

If you are a Delphi developer and have any questions about using our products from Delphi here is the place to post them.
Post Reply
bongofury
Posts: 2
Joined: Fri Mar 18 2005

Inconsistent prints

Post by bongofury »

I have not had much luck with this product yet and I have try all the Dll the activeX, BatchConvert and the below code all with inconsistent results. Sometimes it works and prints all the page of the document, sometimes only half or maybe it will print just the first half of the first page. I have not been able to find any reason for why it would be doing this and need some help.
I am trying to print html pages with out any user interaction at all. I added a field on this test form for a delay thinking that there needed to be at least a minute or 2 to give it enough time to generate the .pdf but I can set it for 5 min and it still is not create the same sized pdf file each time it is ran. any help would be appreciated. Thanks

procedure TfrmTestPdf.btnStartIEClick(Sender: TObject);
const
OLECMDID_PRINT = $00000006;
OLECMDEXECOPT_DONTPROMPTUSER = $00000002;
{PRINT_WAITFORCOMPLETION = $00000002;}
var
ie, vaIn, vaOut: Variant;
pdfName : String;

begin
pdfName := extractFilePath(editHtmlFile.text) + getJobNumberFromFolder(extractFilePath(editHtmlFile.text)) + '.pdf';
if fileExists(pdfName) then
deleteFile(pdfName);


drvInit := cdintfex1.PDFDriverInit('Builder Pdf');

if chkUseFileName.Checked then
cdIntFEx1.DefaultFileName := pdfName
else
cdIntFEx1.DefaultDirectory := addBackSlash(extractFilePath(pdfName));

cdIntFEx1.FileNameOptions := 0;
if chkNoPrompt.Checked then
cdIntFEx1.FileNameOptions := cdIntFEx1.FileNameOptions + NoPrompt;
if chkUseFileName.Checked then
cdIntFEx1.FileNameOptions := cdIntFEx1.FileNameOptions + useFileName;
if chkConcatenate.Checked then
cdIntFEx1.FileNameOptions := cdIntFEx1.FileNameOptions + concatenate;

cdIntFEx1.SetDefaultPrinter;
cdIntFEx1.EnablePrinter('','');

ie := CreateOleObject('InternetExplorer.Application');
ie.Navigate(editHtmlFile.text);

ie.Visible := false;
ie.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, vaIn, vaOut);

sysDelay(strToInt(editDelay.Text));
ie.quit;
showmessage('print is complete');

end;
bongofury
Posts: 2
Joined: Fri Mar 18 2005

Inconsistent prints

Post by bongofury »

I added the following code after the call to navigate to make sure the page is loaded before trying to print it and it has helped a lot. But I would still wonder if there is a sure fire way to know when it is done printing instead of trying to guess.

sysDelay(5000);
while ie.QueryStatusWB( OLECMDID_PRINT) <> OLECMDF_SUPPORTED + OLECMDF_ENABLED do
Application.ProcessMessages;
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

There are events fired by the PDF Converter while printing. If you catch these events you can know when printing is about to start, when it starts and when it ends.

Will this help?
Post Reply