How to Register doc2anyCom.exe COM and Add a Reference to VeryPDF.doc2anyCom in a C# Program

How to Register doc2anyCom.exe COM and Add a Reference to VeryPDF.doc2anyCom in a C# Program?

If you are using the "VeryDOC DOC to Any Converter SDK/COM Developer License" and need to integrate it into your C# application, follow the steps below to register doc2anyCom.exe and add the necessary reference to your project.

https://www.verydoc.com/doc-to-any.html

image

Step 1: Register doc2anyCom.exe COM Component

  1. Download the Trial Package: Ensure you have downloaded the trial DOC to Any Converter SDK/COM package.
  2. Open Command Prompt as Administrator:
    • Press Win + X and select "Command Prompt (Admin)" or "Windows PowerShell (Admin)".
  3. Register the COM Component:
    • Navigate to the directory where doc2anyCom.exe is located.
    • Run the following command:
      doc2anyCom.exe /regserver
    • This command registers the COM component, making it available for use in your 64-bit applications.

Step 2: Add a Reference to VeryPDF.doc2anyCom in Your C# Project

  1. Create or Open a C# Project:
    • Open Visual Studio and create a new C# Windows Forms Application or open an existing project.
  2. Add COM Reference:
    • In Solution Explorer, right-click on References and select Add Reference....
    • In the Reference Manager, go to COM tab and search for VeryPDF.doc2anyCom.
    • Select it and click OK.

Step 3: Use the VeryPDF.doc2anyCom in Your C# Code

Below is a sample C# code demonstrating how to use the VeryPDF.doc2anyCom to convert a DOC file to PDF:

using System;
using System.Windows.Forms;
using System.IO;
using VeryPDF;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string strInFile = "D:\\downloads\\verypdf.doc";
            string strOutFile = "D:\\downloads\\out.pdf";

            string strCmd = "-$ XXXX-XXXX-XXXX-XXXX -ownerpwd 123 -keylen 2 -encryption 3900";
            strCmd += " \\"" + strInFile + "\\" \\"" + strOutFile + "\\"";
            MessageBox.Show(strCmd);

            System.Type VeryPDFType = System.Type.GetTypeFromProgID("VeryPDF.doc2anyCom");
            VeryPDF.doc2anyCom VeryPDFCom = (VeryPDF.doc2anyCom)System.Activator.CreateInstance(VeryPDFType);
            string strReturn = VeryPDFCom.doc2any(strCmd);
            MessageBox.Show("Processing finished.");
        }
    }
}

Explanation of the Code

  1. Setting Input and Output File Paths:
    string strInFile = "D:\\downloads\\verypdf.doc";
    string strOutFile = "D:\\downloads\\out.pdf";
  2. Preparing the Command:

    Construct the command string with necessary options.

    string strCmd = "-$ XXXX-XXXX-XXXX-XXXX -ownerpwd 123 -keylen 2 -encryption 3900";
    strCmd += " \\"" + strInFile + "\\" \\"" + strOutFile + "\\"";
  3. Creating and Using the COM Object:

    Obtain the type from the programmatic identifier (ProgID) and create an instance. Call the doc2any method to perform the conversion.

    System.Type VeryPDFType = System.Type.GetTypeFromProgID("VeryPDF.doc2anyCom");
    VeryPDF.doc2anyCom VeryPDFCom = (VeryPDF.doc2anyCom)System.Activator.CreateInstance(VeryPDFType);
    string strReturn = VeryPDFCom.doc2any(strCmd);
  4. Displaying the Command and Result:

    Display the command string and conversion result for user confirmation.

    MessageBox.Show(strCmd);
    MessageBox.Show("Processing finished.");

Additional Resources

For more detailed information, please refer to the following links:

By following these steps, you should be able to register the doc2anyCom.exe COM component and integrate it into your C# application for converting office files to PDF files.

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!