Code Samples - Neevia docCreator

Example 1: How to create a simple PDF file - C# Copy 

Add a reference in your Visual Studio project to docCreator library.
To do this:
        a. On the Project menu, click Add Reference;
        b. On the COM tab, locate Neevia docCreator COM interface and then click Select;
        c. Click OK in the Add References dialog box to accept your selections.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
   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", @"c:\users\public\");

     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 !!!");
     }

   }