How can I use C# to call com components of pdf2vec?

Use “VeryDOC PDF to Vector Converter”  for development.

First Add reference “PDF2VectorCOM”.

Project –> Add reference… –> COM –> PDF2VectorCOM –> OK

C# code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PDF2VectorCom;
using System.Reflection;

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

        private void PDF2VectorCOM_Click(object sender, EventArgs e)
        {
            string strStartupPath = System.Windows.Forms.Application.StartupPath + "\\";

            System.Type pdf2vecName = Type.GetTypeFromProgID("PDF2VectorCom.pdf2vec");
            if (pdf2vecName != null)
            {
                object pdf2vec = Activator.CreateInstance(pdf2vecName);
                string strPDFFile = strStartupPath + "test.pdf";
                string strOutFile = strStartupPath + "test.swf";
                string strCmd = "pdf2vec -$ XXXXXXXXXXXXXXXXXXXX \"" + strPDFFile + "\" \"" + strOutFile + "\"";

//                MessageBox.Show(strCmd);
                object[] argn = new object[1];
                argn[0] = strCmd;
                int nRet = (int)pdf2vecName.InvokeMember("com_PDF2Vector", BindingFlags.InvokeMethod, null, pdf2vec, argn);

                //int nRet = pdf2vec.com_PDF2Vector(strCmd);

                MessageBox.Show("Return Value is: " + string.Format("{0}", nRet));
            }
        }
    }
}

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

Random 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!