How to convert from PDF files to text files from my C# application?

Hello. We have purchased the PDF2TXT COM server version and I have tried to integrate into a website that has a C# backend but none of the .dlls can be used. They throw different errors when I try to add them as references in the project. I also tried to apply what the readme file says about registering the the libraries in Windows, without any luck, getting errors again. I used Visual Studio 2017, tried on both Windows 10 and Windows server 2012 R2.

How do we proceed to make the tool work in our application?

Thank you for your time.
Customer
------------------------------------

image
Thanks for your message, please download latest version of PDF2TXT SDK from following URL,

http://www.verypdf.com/app/pdf-to-txt-converter/index.html
http://www.verypdf.com/pdf2txt/sdk/pdf2txt_trial_version.zip

this version does include a PDF2TXTCOM.exe file, please by following steps to use this PDF2TXT COM from your both 32bit and 64bit applications,

1. Please use administrator privilege to run following command line to register PDF2TXTCOM.exe into your system first,

PDF2TXTCOM.exe /regserver

2. You can run following VBS (VB Script) to call PDF2TXTCOM.exe from your 64bit application,

=============================
Dim oTest
dim nRet

Set fso = CreateObject("Scripting.FileSystemObject")
strFolder = fso.GetParentFolderName(wscript.ScriptFullName)
destiantionPath = strFolder& "\verypdf.pdf"

Set oTest = CreateObject("PDF2TXTCOM.PDF2TXT")
oTest.com_SetTXTFormat 1
oTest.com_SetZoomRatio 90
oTest.com_PDF2TXTSetLicenseCode("XXXXXXXXXXXXXXXXXXXXXX")
nRet = oTest.com_Pdf2Txt(strFolder& "\sample1.pdf", strFolder& "\sample1-pdf2txt.txt")
nRet = oTest.com_Pdf2TxtEx(strFolder& "\sample1.pdf", strFolder& "\sample1-pdf2txtEx.txt",0,0,"","")
MsgBox "Convert Success!"
=============================

3. If you wish integrate "PDF2TXTCOM.PDF2TXT" into your C# project, you may add add a reference to "PDF2TXTCOM" from your C# project, then you can use following sample C# code to call "PDF2TXTCOM.PDF2TXT" to convert from PDF files to text files,

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 PDF2TXTCOM;
using System.IO;

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

        private void button1_Click(object sender, EventArgs e)
        {
            string appPath = Path.GetDirectoryName(Application.ExecutablePath);
            string strPDFFile = appPath + "\\sample1.pdf";
            string strOutFile = appPath + "\\_sample1.txt";

            System.Type VeryPDFType = System.Type.GetTypeFromProgID
                           ("PDF2TXTCOM.PDF2TXT");
            PDF2TXTCOM.PDF2TXT VeryPDFCom = (PDF2TXTCOM.PDF2TXT)
                           System.Activator.CreateInstance(VeryPDFType);
            VeryPDFCom.com_PDF2TXTSetLicenseCode
                           ("XXXXXXXXXXXXXXXXXXXXXX");
            int nReturn = VeryPDFCom.com_PDF2TXTEx(strPDFFile, strOutFile, 0, 0, "", "");
            MessageBox.Show("Converter finished.");
        }
    }
}

VeryPDF

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!