Neevia Technology Sites:   www.neevia.com  |  docuPub.com  |  www.neeviaPDF.com
:: Home :: Products :: Technical Support :: About Us :: Contact Us
Technical support > Neevia docCreator code samples
Example 7: Convert an URL / HTML file into PDF from Delphi  Print Example 


procedure createPDF();
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', 'd:\');

     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;



Copyright © 1999-2016 Neevia Technology. All Rights Reserved. Home | Products | Technical Support | About Us | Contact Us