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 4: Convert a PowerPoint document into PDF from C#  Print Example 

1) Add a reference in your project to docCreator library.
To do this:
      a. On the Project menu, click Add Reference.
      b. On the COM tab, locate docCreator Library and then click Select.
      c. Click OK in the Add References dialog box to accept your selections.

2) Add a reference in your project to Microsoft PowerPoint.
To do this:
      a. On the Project menu, click Add Reference.
      b. On the COM tab, locate Microsoft PowerPoint and then click Select.
      c. Click OK in the Add References dialog box to accept your selections.
   string fileToConvert = @"d:\test.ppt";

   Neevia.docCreator DC = new Neevia.docCreator();

   DC.setParameter("DocumentOutputFormat", "PDF");
   DC.setParameter("DocumentOutputName", "testPPT_CSHARP");
   DC.setParameter("DocumentOutputFolder", @"d:\");
   DC.setParameter("PDFAutoRotatePage", "All");

   // This works only with MS Office 2003
   Microsoft.Office.Interop.PowerPoint.Application MSPowerPoint =
     new Microsoft.Office.Interop.PowerPoint.Application();
   Microsoft.Office.Interop.PowerPoint.Presentation PPTDoc;
   PPTDoc = MSPowerPoint.Presentations.Open(fileToConvert,
              Microsoft.Office.Core.MsoTriState.msoFalse, 0, 0);

   // This works only with MS Office 2000 and XP
   // PowerPoint._Application MSPowerPoint = new PowerPoint.Application();
   // PowerPoint._Presentation PPTDoc;
   // PPTDoc = MSPowerPoint.Presentations.Open(fileToConvert,0, 0, 0);
                        
   string tempFile = DC.getParameter("TempDir") + DC.GUID() + ".ps";

   PPTDoc.PrintOptions.PrintInBackground = 0;
   PPTDoc.PrintOptions.ActivePrinter = "Neevia docCreator";
   PPTDoc.PrintOut(0, 9999, tempFile, 1, 0);
   PPTDoc.Close();
   MSPowerPoint.Quit();
   MSPowerPoint = null;

   DC.setInputDocument(tempFile, "");

   int RVal = DC.create();
   DC.fileDelete(tempFile);

   DC = null;

   if (RVal != 0)
   {
      MessageBox.Show("Error while creating document!!!");
   }
   else
   {
      MessageBox.Show("Done converting !!!");
   }



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