VC++ source code for EMF to Text Converter, Text Extraction from EMF and PDF formats

#include <windows.h>

#include <stdio.h>

#include <string>

using namespace std;

 

typedef BOOL  (__stdcall *EMF2TXTFunc)(LPCTSTR lpEMFFile, LPCTSTR lpTextFile, BOOL bAppend);

typedef BOOL  (__stdcall *PDF2TXTFunc)(LPCTSTR lpPDFFile, LPCTSTR lpTextFile);

typedef BOOL  (__stdcall *EMF2TXTWFunc)(LPCWSTR lpEMFFile, LPCWSTR lpTextFile, BOOL bAppend);

typedef BOOL  (__stdcall *PDF2TXTWFunc)(LPCWSTR lpPDFFile, LPCWSTR lpTextFile);

 

EMF2TXTFunc      VeryPDF_EMF2TXT = NULL;

PDF2TXTFunc      VeryPDF_PDF2TXT = NULL;

EMF2TXTWFunc     VeryPDF_EMF2TXTW = NULL;

PDF2TXTWFunc     VeryPDF_PDF2TXTW = NULL;

 

void GetModulePath(char *out_path,char *in_name)

{

      char *p;

      GetModuleFileName(NULL,out_path,256);

      p =strrchr(out_path,'\\');

      p[1]=0;

      strcat(out_path,in_name);

}

 

string GetFullPath(char *in_name)

{

      char szFileName[2000] = {0};

      GetModuleFileName(NULL,szFileName,sizeof(szFileName));

      char *p = strrchr(szFileName, '\\');

      if(p)

           p[1] = 0;

      strcat(szFileName, in_name);

      return szFileName;

}

 

wstring GetFullPath(wchar_t *in_name)

{

      wchar_t wszFileName[2000] = {0};

      GetModuleFileNameW(NULL, wszFileName, sizeof(wszFileName));

      wchar_t *p = wcsrchr(wszFileName, '\\');

      if(p)

           p[1] = 0;

      wcscat(wszFileName, in_name);

      return wszFileName;

}

 

HMODULE LoadDLLLibrary()

{

      BOOL bRet = FALSE;

      char szLibPath[_MAX_PATH];

#if _WIN64

      GetModulePath(szLibPath, "txtsdk64.dll");

#else

      GetModulePath(szLibPath, "txtsdk32.dll");

#endif

      HMODULE dll_handle = LoadLibrary(szLibPath);

      if(dll_handle == NULL)

           return FALSE;

      VeryPDF_EMF2TXT = (EMF2TXTFunc)GetProcAddress(dll_handle, "EMF2TXT");

      if(VeryPDF_EMF2TXT == NULL)

           goto _failed;

      VeryPDF_PDF2TXT = (PDF2TXTFunc)GetProcAddress(dll_handle, "PDF2TXT");

      if(VeryPDF_PDF2TXT == NULL)

           goto _failed;

      VeryPDF_EMF2TXTW = (EMF2TXTWFunc)GetProcAddress(dll_handle, "EMF2TXTW");

      if(VeryPDF_EMF2TXTW == NULL)

           goto _failed;

      VeryPDF_PDF2TXTW = (PDF2TXTWFunc)GetProcAddress(dll_handle, "PDF2TXTW");

      if(VeryPDF_PDF2TXTW == NULL)

           goto _failed;

 

      return dll_handle;

_failed:

      FreeLibrary(dll_handle);

      return NULL;

}

 

int main(int argc, char* argv[])

{

      HMODULE dll_handle = LoadDLLLibrary();

      if(dll_handle == NULL)

           return 0;

 

      VeryPDF_EMF2TXT(GetFullPath("14214580-0001.emf").c_str(),
           GetFullPath(
"emf2txt.txt").c_str(), TRUE);

      VeryPDF_EMF2TXT(GetFullPath("14214580-0002.emf").c_str(),          

           GetFullPath("emf2txt.txt").c_str(), TRUE);

      VeryPDF_EMF2TXT(GetFullPath("14214580-0003.emf").c_str(),
           GetFullPath(
"emf2txt.txt").c_str(), TRUE);

      VeryPDF_EMF2TXT(GetFullPath("14214580-0004.emf").c_str(),
           GetFullPath(
"emf2txt.txt").c_str(), TRUE);

      VeryPDF_EMF2TXT(GetFullPath("14214580-0005.emf").c_str(),
           GetFullPath(
"emf2txt.txt").c_str(), TRUE);

      VeryPDF_EMF2TXT(GetFullPath("14214580-0006.emf").c_str(),
           GetFullPath(
"emf2txt.txt").c_str(), TRUE);

      VeryPDF_EMF2TXT(GetFullPath("14214580-0007.emf").c_str(),
           GetFullPath(
"emf2txt.txt").c_str(), TRUE);

      VeryPDF_EMF2TXT(GetFullPath("14214580-0008.emf").c_str(),
           GetFullPath(
"emf2txt.txt").c_str(), TRUE);

      VeryPDF_EMF2TXT(GetFullPath("14214580-0009.emf").c_str(),
           GetFullPath(
"emf2txt.txt").c_str(), TRUE);

      VeryPDF_EMF2TXT(GetFullPath("14214580-0010.emf").c_str(),
           GetFullPath(
"emf2txt.txt").c_str(), TRUE);

 

      VeryPDF_PDF2TXT(GetFullPath("testreport.pdf").c_str(),
           GetFullPath(
"pdf2txt.txt").c_str());

 

      VeryPDF_EMF2TXTW(GetFullPath(L"14214580-0001.emf").c_str(),
           GetFullPath(L
"emf2txtW.txt").c_str(), TRUE);

      VeryPDF_EMF2TXTW(GetFullPath(L"14214580-0002.emf").c_str(),
           GetFullPath(L
"emf2txtW.txt").c_str(), TRUE);

      VeryPDF_EMF2TXTW(GetFullPath(L"14214580-0003.emf").c_str(),
           GetFullPath(L
"emf2txtW.txt").c_str(), TRUE);

      VeryPDF_EMF2TXTW(GetFullPath(L"14214580-0004.emf").c_str(),
           GetFullPath(L
"emf2txtW.txt").c_str(), TRUE);

      VeryPDF_EMF2TXTW(GetFullPath(L"14214580-0005.emf").c_str(),
           GetFullPath(L
"emf2txtW.txt").c_str(), TRUE);

      VeryPDF_EMF2TXTW(GetFullPath(L"14214580-0006.emf").c_str(),
           GetFullPath(L
"emf2txtW.txt").c_str(), TRUE);

      VeryPDF_EMF2TXTW(GetFullPath(L"14214580-0007.emf").c_str(),
           GetFullPath(L
"emf2txtW.txt").c_str(), TRUE);

      VeryPDF_EMF2TXTW(GetFullPath(L"14214580-0008.emf").c_str(),
           GetFullPath(L
"emf2txtW.txt").c_str(), TRUE);

      VeryPDF_EMF2TXTW(GetFullPath(L"14214580-0009.emf").c_str(),
           GetFullPath(L
"emf2txtW.txt").c_str(), TRUE);

      VeryPDF_EMF2TXTW(GetFullPath(L"14214580-0010.emf").c_str(),
           GetFullPath(L
"emf2txtW.txt").c_str(), TRUE);

     

      VeryPDF_PDF2TXTW(GetFullPath(L"testreport.pdf").c_str(),
           GetFullPath(L
"pdf2txtW.txt").c_str());

 

      FreeLibrary(dll_handle);

      return 0;

}

 

This is original EMF file,

image

 

The converted text file,image

 

Please feel free contact to VeryPDF if you wish to evaluate this EMF to Text Converter SDK,

 

http://support.verypdf.com/open.php

 

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

This entry was posted in VeryPDF SDK & COM and tagged , . Bookmark the permalink.

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!