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
Step 1: Register doc2anyCom.exe
COM Component
- Download the Trial Package: Ensure you have downloaded the trial DOC to Any Converter SDK/COM package.
- Open Command Prompt as Administrator:
- Press
Win + X
and select "Command Prompt (Admin)" or "Windows PowerShell (Admin)".
- Press
- 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.
- Navigate to the directory where
Step 2: Add a Reference to VeryPDF.doc2anyCom
in Your C# Project
- Create or Open a C# Project:
- Open Visual Studio and create a new C# Windows Forms Application or open an existing project.
- Add COM Reference:
- In Solution Explorer, right-click on
References
and selectAdd Reference...
. - In the Reference Manager, go to
COM
tab and search forVeryPDF.doc2anyCom
. - Select it and click
OK
.
- In Solution Explorer, right-click on
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
- Setting Input and Output File Paths:
string strInFile = "D:\\downloads\\verypdf.doc"; string strOutFile = "D:\\downloads\\out.pdf";
- 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 + "\\"";
- 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);
- 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:
- How to call VeryDOC DOC to Any Converter SDK/COM (doc2anyCom.exe) from 64bit EXE application
- How can I call DOC to Any SDK from 64bit EXE application? Can help us to provide the 64bit DOC to Any Converter SDK?
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.