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 1: How to create a simple PDF file from C#  Print Example 

Add a reference in your project to Neevia docCreator library.
To do this:
      a. On the Project menu, click Add Reference.
      b. On the COM tab, locate Neevia docCreator COM inteface and then click Select.
      c. Click OK in the Add References dialog box to accept your selections.
   private void prn_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
   {

     e.Graphics.DrawString("Hello from C#", new Font("Arial", 60, FontStyle.Regular), 
                           Brushes.Blue, 100, 100);

   }

   private void PrintTest()
   {

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

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

     System.Drawing.Printing.PrintDocument prn = new System.Drawing.Printing.PrintDocument();
     prn.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(prn_PrintPage);

     prn.PrinterSettings.PrinterName = "Neevia docCreator";

     String tempFile = DC.getParameter("TempDir") + DC.GUID() + ".ps";

     prn.PrinterSettings.PrintFileName = tempFile;
     prn.PrinterSettings.PrintToFile = true;

     prn.Print();

     DC.setInputDocument(tempFile, "");

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

     prn = null;
     DC = null;

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

   }



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