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 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 Internet Controls.
To do this:
      a. On the Project menu, click Add Reference.
      b. On the COM tab, locate Microsoft Internet Controls and then click Select.
      c. Click OK in the Add References dialog box to accept your selections.
   SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
   IE.Visible = true;

   object RN = System.Reflection.Missing.Value;
   object URL = @"http:\\www.neevia.com";
   IE.Navigate2(ref URL, ref RN, ref RN, ref RN, ref RN);

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

   while ((IE.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
            || (IE.Busy == true))
   {
      DC.doSleep(100);
   }

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

   int RVal = DC.startPrinting();
   if (RVal != 0)
   {
      MessageBox.Show("Error while creating the virtual printer!!!");
   }

   string defPrinter = DC.getDefaultPrinter();
   DC.setDefaultPrinter(DC.newPrinterName());

   IE.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT,
             SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,
             ref RN, ref RN);

   RVal = DC.create();
   if (RVal != 0) { MessageBox.Show("Error while creating document!!!"); }

   IE.Quit();

   DC.setDefaultPrinter(defPrinter);
   RVal = DC.stopPrinting();

   IE = null;
   DC = null;

   if (RVal != 0)
   {
     MessageBox.Show("Error while deleting the virtual printer!!!");
   }
   else
   {
     MessageBox.Show("Done converting !!!");
   }



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