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


procedure createPDF();
var
  RVal : Integer;

  DC,
  MSWord,
  NewDoc,
  MSWordDialog : Variant;

  tempFile,
  docToConvert : String;
begin
   docToConvert := 'd:\test.doc';

   try
     DC := CreateOleObject('Neevia.docCreator');

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

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

     try
       MSWord := CreateOleObject('Word.Application');
       MSWord.DisplayAlerts:= False;
       NewDoc := MSWord.Documents.Open(docToConvert, false, true);

       MSWordDialog := MSWord.Dialogs.Item(97);
       MSWordDialog.Printer := 'Neevia docCreator';
       MSWordDialog.DoNotSetAsSysDefault := 1;
       MSWordDialog.Execute;

       NewDoc.PrintOut(false,emptyparam,emptyparam,tempFile,
                       emptyparam,emptyparam,emptyparam,
                       emptyparam,emptyparam,emptyparam,true);

       NewDoc.Close(False);
       MSWord.Quit(False);

       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;
     MSWord := Unassigned;
   end;  
end;



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