VeryPDF PDF to TXT Converter COM supports to be called from different programming languages like Visual Basic, C/C++, Delphi, ASP, PHP, C#, and .NET. It is helpful for application developers to develop new application in which the function of converting PDF to TXT will be realized perfectly.
In this page, you will see the main samples like ASP, C++ and VB of VeryPDF PDF to TXT Converter COM, which will enable you to use this application smoothly.
Operating Systems: all the Windows platforms, like Windows 2000, XP, Vista, 7, 8, 10, 11, Windows Server 2003, 2008, 2008 R2 and later systems, both 32 Bit and 64 Bit and so on.
The following programming languages are supported:C#, VB .NET, MS Visual Basic, Borland Delphi, VBA (MS Office products such as Access) and C++ via COM, C and C++ via native C.
<%
dim oTest
dim nRet
Set oTest = Server.CreateObject("PDF2TXT.CPDF2TXT")
Response.write "Create Object Success!"
oTest.com_SetTXTFormat 1
oTest.com_SetZoomRatio 90
oTest.com_PDF2TXTSetLicenseCode("XXXXXXXXXXXXXXXXXXXXXX")
nRet = oTest.com_Pdf2Txt("C:\sample1.pdf","C:\sample1-pdf2txt.txt")
nRet = oTest.com_Pdf2TxtEx(
"C:\sample1.pdf","C:\sample1-pdf2txtex.txt",0,0,"",""
)
Response.write "Convert Success!"
%>
void ConvertPDFBuffer2TextBuffer(char *pdffile, char *textfile)
{
int m_iFileLength = 0;
char* pdfBuffer = NULL;
FILE *file = fopen(pdffile,"rb");
if(file)
{
m_iFileLength = _filelength(fileno(file));
if(m_iFileLength <= 0)
{
fclose(file);
return;
}
pdfBuffer = new char[m_iFileLength];
if(pdfBuffer == NULL)
{
fclose(file);
return;
}
memset(pdfBuffer,0,m_iFileLength);
fread(pdfBuffer,1,m_iFileLength,file);
fclose(file);
}
if(pdfBuffer == NULL || m_iFileLength <= 0)
return;
SetPageSeparator("<<<<<<<<<********>>>>>>>>>>>>>");
SetZoomRatio(100);
SetTXTFormat(1);
SetOpenResultFile(0);
SetDeleteBlankLine(TRUE);
int textBufferSize;
const char *textbuffer = PDFBuffer2TextBuffer(
pdfBuffer, m_iFileLength, &textBufferSize
);
if(textbuffer)
printf("%s\n",textbuffer);
PDF2TextFreeBuffer(textbuffer);
LPCWSTR textbufferW = PDFBuffer2TextBufferW(
pdfBuffer, m_iFileLength, &textBufferSize
);
PDF2TextFreeBufferW(textbufferW);
textbufferW = PDFBuffer2TextBufferWEx( pdfBuffer,m_iFileLength,&textBufferSize,
0, 0,NULL,NULL,NULL,0
);
PDF2TextFreeBufferW(textbufferW);
delete []pdfBuffer;
}
Private Sub bconvert_Click()
' only PDF Files
cdialog.Filter = "PDF Files (*.PDF)|*.PDF"
' if ok
cdialog.ShowOpen
' if file specified
If cdialog.FileName <> "" Then
' Application exe path and add filename for txt
TxtFile = App.Path + "\Temp.Txt"
' Txt file exist ?
If Dir(TxtFile) <> "" Then
' ok delete it
Kill TxtFile
End If
'Register your PDF2TXT SDK by given License Code
PDF2TXTSetLicenseCode "XXXXXXXXX"
SetTXTFormat 1
SetGetDocumentSummary 0
SetPageSeparator "*****************>>>>>>>>>>>>>>>"
' convert the file
pdf2txt cdialog.FileName, TxtFile
' open notepad with textfile
ShellExecute 0, "open", TxtFile, "", "", SW_SHOW
TxtFile = App.Path + "\Temp2.Txt"
pdf2txtEx cdialog.FileName, TxtFile, 0, 0, "", ""
ShellExecute 0, "open", TxtFile, "", "", SW_SHOW
End If
End Sub
For more programming language samples, please download VeryPDF PDF to TXT Converter COM to see all its samples.