Neevia Technology Sites:   www.neevia.com  |  docuPub.com  |  www.neeviaPDF.com
:: Home :: Products :: Technical Support :: About Us :: Contact Us
Technical support > Neevia docuPrinter SDK code samples
Example 10: Convert an URL / HTML into PDF from C#  Print Example 

1) Add a reference in your Visual Studio project to docuPrinter library.
To do this:
  • On the Project menu, click Add Reference;
  • On the COM tab, locate docuPrinter Library and then click Select;
  • 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:
  • On the Project menu, click Add Reference.
  • On the COM tab, locate Microsoft Internet Controls and then click Select.
  • Click OK in the Add References dialog box to accept your selections.
private void button1_Click(object sender, EventArgs e)
{

   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);

   docuPrinter.SDK DPSDK = new docuPrinter.SDK();
   DPSDK.doSleep(100);

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

   DPSDK.DocumentOutputFormat = "PDF";
   DPSDK.DocumentOutputFolder = @"c:\";
   DPSDK.DocumentOutputName = "testURL";

   DPSDK.HideSaveAsWindow = true;
   DPSDK.DefaultAction = 1;
   DPSDK.ApplySettings();

   string defPrinter = DPSDK.GetDefaultPrinter();
   DPSDK.SetDefaultPrinter("docuPrinter");

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

   int RVal = DPSDK.Create(100);
   if (RVal != 0) { MessageBox.Show("Error while creating document!!!"); }

   IE.Quit();

   DPSDK.SetDefaultPrinter(defPrinter);
      
   IE = null;
   DPSDK = 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