1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | procedure convertHTMLtoPDF(); var DC, IE : Variant; RVal : Integer; docToConvert, defPrinter : String; begin docToConvert := 'http:\\www.neevia.com'; try DC := CreateOleObject('Neevia.docCreator'); DC.setParameter('DocumentOutputFormat', 'PDF'); DC.setParameter('DocumentOutputName', 'testURL_Delphi'); DC.setParameter('DocumentOutputFolder', 'c:\users\public\'); RVal := DC.startPrinting; defPrinter := DC.getDefaultPrinter; if (RVal <> 0) then begin ShowMessage('Error while calling StartPrinting method!!!'); exit; end; try IE := CreateOleObject('InternetExplorer.Application'); DC.doSleep(100); IE.Visible := true; IE.navigate2(docToConvert); While (IE.ReadyState<>4) or (IE.Busy) do begin DC.doSleep(100); Application.ProcessMessages; end; DC.setDefaultPrinter(DC.newPrinterName); IE.ExecWB(6,2,emptyparam,emptyparam); RVal := DC.Create; // Create output document IE.Quit; if (RVal <> 0) then ShowMessage('Error while creating document!!! Code: '+IntToStr(RVal)) else ShowMessage('Done converting !!!'); DC.setDefaultPrinter(defPrinter); except on E: Exception do ShowMessage(E.Message); end; finally RVal := DC.stopPrinting; if (RVal <> 0) then ShowMessage('Error while calling StopPrinting method!!!'); DC := Unassigned; IE := Unassigned; end; end; |