Code Samples - Neevia docuPrinter SDK

Example 8: Convert a WordPerfect document into PDF - C# Copy 

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

2) Add a reference in your Visual Studio project to Corel WordPerfect.
To do this:
        a. On the Project menu, click Add Reference;
        b. On the COM tab, locate Corel WordPerfect 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
   private void button1_Click(object sender, EventArgs e)
   {

      string docToConvert = @"c:\users\public\test.wpd";

      WordPerfect.PerfectScript objWordPerfect = new WordPerfect.PerfectScript();
      objWordPerfect.AppMaximize();
      objWordPerfect.Backup(0);
      objWordPerfect.BackupOriginalDoc(0);
      objWordPerfect.PerfectExpert(0);

      object RN = System.Reflection.Missing.Value;
      objWordPerfect.FileOpen(docToConvert,
      WordPerfect._FileOpen_Format_enum.WordPerfect_CompoundFile_FileOpen_Format);

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

      DPSDK.DocumentOutputFormat = "PDF";
      DPSDK.DocumentOutputFolder = @"c:\users\public\";
      DPSDK.DocumentOutputName = "demoWP";

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

      objWordPerfect.PrintTo(docToConvert, "docuPrinter", "", "");

      objWordPerfect.CloseNoSave(0);
      objWordPerfect.ExitWordPerfect();
      objWordPerfect = null;

      int RVal = DPSDK.Create(100);            
      DPSDK = null;

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

   }