|
Product->Convert
PDF to Text(DLL Edition)->Tech
Document
Check the
methods exposed from the DLL here
Examples:
Download Now
FAQ'S Buy It Now
Example in
VC:
1. Copy P2TDLL.DLL to the
system folder or the folder of your project.
2. Include
P2TProcessor.h in your project.
/**
* This is the callback function. you will get the stream data here.
* Add your own process logic in the function body.
* The type of this function is DATACALLBACKFUNC, please check
* P2TProcessor.h for detail information.
*/
void ContentCallBackFunc(char* i_szStr, int i_size)
{
char tmp[800]={0};
_snprintf(tmp,i_size,"%s",i_szStr);
printf("Content: %s\n",tmp);
}
HINSTANCE hDLL; // Handle to DLL
CREATEPROCESSOR lpCreateProcessor; // Function pointer
RELEASEPROCESSOR lpReleaseProcessor;
hDLL = LoadLibrary("P2TDLL.dll");
if (hDLL != NULL)
{
lpCreateProcessor = (CREATEPROCESSOR)GetProcAddress(hDLL,
"CreateProcessor");
lpReleaseProcessor = (RELEASEPROCESSOR)GetProcAddress(hDLL,
"ReleaseProcessor");
if (!lpCreateProcessor || !lpReleaseProcessor)
{
// handle the error
MessageBox("Can't locate the function pointer.");
}
else
{
P2TProcessor* pP2TProcessor = lpCreateProcessor();
pP2TProcessor->VerifyLicense("Test Me Please",
"683690765A89C345B87135F");
pP2TProcessor->EngagePDFProcessor(0,0,"","");
pP2TProcessor->ParsePDF("C:\\test\\test.pdf", "C:\\test\\test.txt");
pP2TProcessor->ParsePDF("C:\\test\\111.pdf",ContentCallBackFunc,
200);
MessageBox("done!");
//The processor must be
released before you unload the DLL
lpReleaseProcessor(pP2TProcessor);
}
FreeLibrary(hDLL);
}
Go back to top
There's only two method exposed from the DLL.
/**
* This method get a instance of the processor
* @return P2TProcessor* The pointer of the new instance of the processor
*/
P2TProcessor* CreateProcessor();
/**
* This method release the instance created by CreateProcessor
* @param P2TProcessor* i_pP2TP The pointer created by CreateProcessor.
*
*/
void ReleaseProcessor(P2TProcessor* i_pP2TP);
Go back to top
=========>>P2TProcessor.h<<===============
////////////////////////////////////////////////////
#ifndef __P2TPROCESSOR_H_
#define __P2TPROCESSOR_H_
class P2TProcessor;
/**
* This is the log infromation callback function. if you wanna the real time
* log/output information, you need hook this function.
* @param char* i_szStr The input log information.
*
*/
typedef void(*LOGCALLBACKFUNC)(char* i_szStr);
/**
* This is the data stream callback function. you will get the stream data
here.
* Add your own process logic here to process the output data stream.
* @param const char* i_szStr The buffer pointer of the output string
* @param int i_size The size of the data(in byte)
*/
typedef void(*DATACALLBACKFUNC)(const char* i_szStr, int i_size);
/**
* This is the one of two methods exposed from the DLL
* Use this method to create a new instance of P2TProcessor
* and return the pointer of the processor, The pointer must
* be released use RleaseProcessor after converting.
*/
typedef P2TProcessor* (*CREATEPROCESSOR)();
/**
* This is the one of the two methods exposed from the DLL
* Use this method to release the processor instance created
* by CreateProcessor
*
*/
typedef void (*RELEASEPROCESSOR)(P2TProcessor* pProcessor);
/**
* P2TProcessor is the class that encapsulates all the functions related
* to PDF converting. You can get the instance of this class through
* CreateProcessor exposed from the DLL
*
*/
class P2TProcessor {
public:
/**
* This is the function that should be called first before you try to call
* any other functions, It verifies the run time license information.
* @param char* UserName The register username.
* @param char* Key The register keycode.
* @return int zero: Success. In trial version, always return zero.
* not zero: Something wrong with username/key
*/
virtual int VerifyLicense(char* UserName, char* Key) = 0;
/**
* This function pass in control information into P2TProcessor
* before it does the converting job.
* @param LOGCALLBACKFUNC pf The log
info callback function.
* @param int
i_nCntrlFlg The control flag pass into the processor.
* @param char*
i_szPageRange The output page range collection, pass in empty
* string if you don't want to output page
range.
* @param char*
i_szPageBreaker The breaker string of the page breaker.
* passin empty string if don't need page
breaker
*/
virtual void EngagePDFProcessor(LOGCALLBACKFUNC pf, int
i_nCntrlFlg, char* i_szPageRange, char* i_szPageBreaker) = 0;
/**
* This function parse pdf file and output the data into a file
* @param char* i_pdfFile The input pdf file's path and name.
* @param char* i_txtFile The output text file's path and name.
* @return int 0 Success.
* -1 Something wrong during converting, check
log callback func
*/
virtual int ParsePDF(char* i_pdfFile, char* i_txtFile) = 0;
/**
* This function parse pdf file and output the data stream into the callback
* function
* @param char* i_szPDFName: The input pdf file's path and name.
* @param DATACALLBACKFUNC i_pFunc:
The pointer of the callback function
* @param int i_nBufSize: The max buffer size that will pass to
the
* callback function.
* @return int 0 Success.
* -1 Something wrong during converting, check
log callback func
*/
virtual int ParsePDF(const char* i_szPDFName, DATACALLBACKFUNC
i_pFunc, int i_nBufSize) = 0;
};
#endif
Go back to top
|