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;
Inconsistent prints
Inconsistent prints
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;
sysDelay(5000);
while ie.QueryStatusWB( OLECMDID_PRINT) <> OLECMDF_SUPPORTED + OLECMDF_ENABLED do
Application.ProcessMessages;