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 3: Convert a MS Excel document into PDF from Delphi  Print Example 


procedure createPDF();
var
  DC,
  MSExcel,
  XLDoc : Variant;

  docToConvert,
  tempFile : String;
  RVal : Integer; 
begin
  docToConvert := 'd:\test.xls';
  try
    DC := CreateOleObject('Neevia.docCreator');

    DC.setParameter('DocumentOutputFormat', 'PDF');
    DC.setParameter('DocumentOutputName', 'testXLS_Delphi');
    DC.setParameter('DocumentOutputFolder', 'd:\');

    tempFile := DC.getParameter('TempDir') + DC.GUID + '.ps';

    try
      MSExcel := CreateOleObject('Excel.Application');
      MSExcel.DisplayAlerts := false;
      XLDoc := MSExcel.Workbooks.Open(docToConvert, 0, true);

      XLDoc.Activate;
      XLDoc.PrintOut(emptyparam,emptyparam,
                     emptyparam, false, 'Neevia docCreator', true, 0, tempFile);
      XLDoc.Saved := true;
      XLDoc.Close;
      MSExcel.Quit;

      DC.setInputDocument(tempFile);
      RVal := DC.create; // Create output document
      if (RVal <> 0) then
        ShowMessage('Error while creating document!!! Code: '+IntToStr(RVal))
      else
        ShowMessage('Document Created !!!');
    except
     on E: Exception do
       ShowMessage(E.Message);
    end
  finally
    DC := Unassigned;
    MSExcel := Unassigned;
  end;
end;



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