Partners Contact US Site Map Blog
A professional PDF Converter, PDF Writer, PDF Creator, PDF Editor, HTML Converter, Postscript Converter, AutoCAD DWG Converter, as well as PCL Converter, etc.  

VeryDOC PDF Parser SDK Examples

Download and purchase PDF Parser SDK
 
PDF Parser SDK Functions:
/////////////////////////////////////
//Function:
// 
VeryPDF_PDFParserSDK(string lpPDFFile, string lpOutFile, string lpOptions)
//
//Description:
//  Render PDF file to image file and HTML data.
//
//Parameters:
// 
lpPDFFile: input PDF file name
//  lpOutFile: output image or html file name

//  lpOptions: set options to render PDF pages, "lpOptions" parameter supports
//             following options:
//
//  -f <int> : first page to convert
//  -l <int> : last page to convert
//  -r <int> : set resolution to render PDF pages
//  -opw <string> : set owner password for encrypted file
//  -upw <string> : set user password for encrypted file
//  -html    : output text information in HTML format instead of CSV format
//
//Return values:
//  0 is successful and other values are indicate an error occurred during
//  conversion.
/////////////////////////////////////
[DllImport("pdfparsersdk2.dll")]
private static extern int VeryPDF_PDFParserSDK(string lpPDFFile, string lpOutFile, string lpOptions);

[DllImport("pdfparsersdk2.dll")]
private static extern int VeryPDF_PDFParserSDKFromMemory(ref byte lpPDFData, int nDataLen, string lpOutFile, string lpOptions);

[DllImport("pdfparsersdk2.dll")]
private static extern int VeryPDF_PDFParserSDK_GetHandle(string lpPDFFile, string lpOptions);

[DllImport("pdfparsersdk2.dll")]
private
static extern int VeryPDF_PDFParserSDK_GetCount(int hPDFParserData);

[DllImport("pdfparsersdk2.dll")]
private
static extern int VeryPDF_PDFParserSDK_GetImageLength(int hPDFParserData, int nIndex);

[DllImport("pdfparsersdk2.dll")]
private
static extern int VeryPDF_PDFParserSDK_GetImageData(int hPDFParserData, int nIndex, [MarshalAs(UnmanagedType.LPArray)] byte[] lpData, int nBufLen);

[DllImport("pdfparsersdk2.dll")]
private
static extern int VeryPDF_PDFParserSDK_GetTextInfoLength(int hPDFParserData, int nIndex);

[DllImport("pdfparsersdk2.dll")]
private
static extern int VeryPDF_PDFParserSDK_GetTextInfoData(int hPDFParserData, int nIndex, [MarshalAs(UnmanagedType.LPArray)] byte[] lpData, int nBufLen);

[DllImport("pdfparsersdk2.dll")]
private
static extern int VeryPDF_PDFParserSDK_Free(int hPDFParserData);

[DllImport("pdfparsersdk2.dll")]
private static extern int VeryPDF_PDFParserSDK_GetPageCount(string lpPDFFile);

[DllImport("pdfparsersdk2.dll")]
private static extern int VeryPDF_PDFParserSDK_GetAllPagesCount(int hPDFParserData);

 
1. C# Example:
1.1. Convert PDF file to PNG image and HTML file on disk
private void DiskFile_Click(object sender, EventArgs e)
{

    string
appPath = Path.GetDirectoryName(Application.ExecutablePath);
    int
nRet;
    string
strOptions;
    string
strInPDFFile;
    string
strOutFile;
    string
strLogMsg;
    strInPDFFile = (appPath + "\\example1.pdf");
    strOutFile = (appPath + "\\out.png");
    strOptions = "-$ XXXXXXXXXXXXXXXXXXXX";
    nRet = VeryPDF_PDFParserSDK(strInPDFFile, strOutFile, strOptions);
    strLogMsg = (strInPDFFile + ("\r\n"
        + (strOutFile + ("\r\n"
        + (strOptions + ("\r\n" + ("nRet = " + (nRet.ToString()))))))));
    MessageBox.Show(strLogMsg);
}
 
1.2. Convert PDF file to PNG image and HTML data in memory
private void Memory_Click(object sender, EventArgs e)
{

    int
nRet;
    string
strOptions;
    string
strInPDFFile;
    string
strOutFile;
    int
nPDFSDKLib;
    int
nCount;
    int
nItem;
    byte
[] vecImgData = null;
    byte
[] vecTxtData = null;
    int
nImageDataLen;
    int
nTextInfoLen;
    string
strLogMsg;
    string
appPath = Path.GetDirectoryName(Application.ExecutablePath);
    strInPDFFile = (appPath + "\\example1.pdf");
    strOptions = "-$ XXXXXXXXXXXXXXXXXXXX";
    nPDFSDKLib = VeryPDF_PDFParserSDK_GetHandle(strInPDFFile, strOptions);
    nCount = VeryPDF_PDFParserSDK_GetCount(nPDFSDKLib);
    for
(nItem = 0; (nItem <= (nCount - 1)); nItem++)
    {
        nImageDataLen = VeryPDF_PDFParserSDK_GetImageLength(nPDFSDKLib, nItem);
        nTextInfoLen = VeryPDF_PDFParserSDK_GetTextInfoLength(nPDFSDKLib, nItem);
        vecImgData = new byte[nImageDataLen];
        vecTxtData = new byte[nTextInfoLen];
        VeryPDF_PDFParserSDK_GetImageData(nPDFSDKLib, nItem, vecImgData,
            nImageDataLen);
        VeryPDF_PDFParserSDK_GetTextInfoData(nPDFSDKLib, nItem, vecTxtData,
            nTextInfoLen);
        strLogMsg = System.Text.Encoding.ASCII.GetString(vecTxtData);
        MessageBox.Show(strLogMsg.Substring(0, 300));
    }
    VeryPDF_PDFParserSDK_Free(nPDFSDKLib);
    nPDFSDKLib = 0;
}
 
2. VB.NET Example
2.1. Convert PDF file to PNG image and HTML file on disk
Private Sub DiskFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DiskFile.Click

    Dim nRet As Integer
    Dim
strOptions As String
    Dim
strInPDFFile As String
    Dim
strOutFile As String
    Dim
strLogMsg As String
    strInPDFFile = Application.StartupPath() & "\example1.pdf"
    strOutFile = Application.StartupPath() & "\out.png"
    strOptions = "-$ XXXXXXXXXXXXXXXXXXXX"
    nRet = VeryPDF_PDFParserSDK(strInPDFFile, strOutFile, strOptions)
    strLogMsg = strInPDFFile & vbCrLf & strOutFile & vbCrLf & strOptions
        & vbCrLf &
"nRet = " & Str(nRet)
    MsgBox(strLogMsg)

End Sub

 
2.2. Convert PDF file to PNG image and HTML data in memory
Private Sub Memory_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Memory.Click

    Dim nRet As Integer
    Dim
strOptions As String
    Dim
strInPDFFile As String
    Dim
strOutFile As String
    Dim
nPDFSDKLib As Integer
    Dim
nCount As Integer
    Dim
nItem As Integer
    Dim
vecImgData() As Byte = Nothing
    Dim
vecTxtData() As Byte = Nothing
    Dim
nImageDataLen As Integer
    Dim
nTextInfoLen As Integer
    Dim
strLogMsg As String
   
    strInPDFFile = Application.StartupPath() & "\example1.pdf"
    strOptions = "-$ XXXXXXXXXXXXXXXXXXXX"
    nPDFSDKLib = VeryPDF_PDFParserSDK_GetHandle(strInPDFFile, strOptions)
    nCount = VeryPDF_PDFParserSDK_GetCount(nPDFSDKLib)
    For nItem = 0 To nCount - 1
        nImageDataLen = VeryPDF_PDFParserSDK_GetImageLength(nPDFSDKLib, nItem)
        nTextInfoLen = VeryPDF_PDFParserSDK_GetTextInfoLength(nPDFSDKLib, nItem)
        ReDim vecImgData(nImageDataLen)
        ReDim vecTxtData(nTextInfoLen)
        VeryPDF_PDFParserSDK_GetImageData(nPDFSDKLib, nItem, vecImgData(0),
            nImageDataLen)
        VeryPDF_PDFParserSDK_GetTextInfoData(nPDFSDKLib, nItem, vecTxtData(0),
            nTextInfoLen)
        strLogMsg = System.Text.Encoding.ASCII.GetString(vecTxtData)
        MsgBox(strLogMsg.Substring(0, 300))
    Next nItem
    VeryPDF_PDFParserSDK_Free(nPDFSDKLib)
    nPDFSDKLib = Nothing

End
Sub

 
2.3. Get page count from PDF file
Private Sub GetPageCount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetPageCount.Click

    Dim strOptions As String
    Dim
strInPDFFile As String
    Dim
HandleId As Integer
    Dim
strLogMsg As String
    strInPDFFile = Application.StartupPath() & "\example3_tst1.pdf"
    strOptions = "-$ XXXXXXXXXXXXXXXXX -f 1 -l 78"
    ' strOptions = strOptions & " -noimg"
    HandleId = VeryPDF_PDFParserSDK_GetHandle(strInPDFFile, strOptions)
    Dim
cnt As Integer = VeryPDF_PDFParserSDK_GetAllPagesCount(HandleId)
    strLogMsg = "PageCount of """ + strInPDFFile + """ file is:" + vbCrLf
    strLogMsg = strLogMsg + "VeryPDF_PDFParserSDK_GetAllPagesCount() return:"
        + Str(cnt) + vbCrLf
    Dim nPageCount As Integer = VeryPDF_PDFParserSDK_GetPageCount(strInPDFFile)
    strLogMsg = strLogMsg + "VeryPDF_PDFParserSDK_GetPageCount() return:"
        + Str(nPageCount)
    MsgBox(strLogMsg)

End
Sub
 
3. C/C++ Example
3.1. Convert PDF file to PNG image and HTML file on disk
int nRet = VeryPDF_PDFParserSDK("C:\\test.pdf", "C:\\out.png", "-html");
 
3.2. Convert PDF file to PNG image and HTML data in memory
int Test_PDFParserSDK_3(char *pdf_filename, char *out_filename)
{

    int
nRet = 0;
    HANDLE hPDFSDK = PDFParserSDK_GetHandle(pdf_filename, NULL);
    if
(hPDFSDK == NULL)
        return
nRet;
    int
nCount = PDFParserSDK_GetCount(hPDFSDK);
    for
(int i = 0; i < nCount; i++)
    {
        int
nImageDataLen = PDFParserSDK_GetImageLength(hPDFSDK, i);
        int
nTextInfoLen = PDFParserSDK_GetTextInfoLength(hPDFSDK, i);
        vector<BYTE> vecImgData;
        vector<BYTE> vecTxtData;
        vecImgData.resize(nImageDataLen);
        vecTxtData.resize(nTextInfoLen);
        PDFParserSDK_GetImageData(hPDFSDK, i, vecImgData.begin(),
            vecImgData.size());
        PDFParserSDK_GetTextInfoData(hPDFSDK, i, vecTxtData.begin(),
            vecTxtData.size());
    }
    PDFParserSDK_Free(hPDFSDK);
    hPDFSDK = NULL;
    return
nRet;
}
 
Download and purchase PDF Parser SDK
 
Correlative Links:
PDF to Image Converter SDK: Render PDF pages to image files.
PDF to XML Converter SDK: Render PDF pages to XML, plain text and image files.
PDFEditor OCX: View and Edit PDF files.
PDFPrint: Print PDF files to Windows Printer without depend on Adobe Reader.
PDF to HTML Converter: Convert PDF files to HTML documents.
PDF to Text Converter: Convert PDF files to plain text files.
PDF to Vector Converter: Convert PDF files to PS, EPS, WMF, EMF, XPS, PCL, HPGL, SWF, SVG, etc. vector files.
PDF to Image Converter: Convert PDF files to TIF, TIFF, JPG, GIF, PNG, BMP, EMF, PCX, TGA formats.
DocConverter COM Component (+HTML2PDF.exe): Convert HTML, DOC, RTF, XLS, PPT, TXT etc. files to PDF files, it is depend on PDFcamp Printer product.
Image to PDF Converter: Convert 40+ image formats to PDF files.
HTML Converter: Convert HTML files to TIF, TIFF, JPG, JPEG, GIF, PNG, BMP, PCX, TGA, JP2 (JPEG2000), PNM, etc. formats.
PDF to Word Converter: Convert PDF files to MS Word documents.
More PDF Products
 
See Also:
PDF to Image Converter :: PDF Extract TIFF :: HTML Converter :: PDFcamp Printer :: DocConverter COM :: PDF to Word Converter :: PDF to Text Converter :: Image to PDF Converter :: Image to PDF OCR :: PDF to HTML Converter :: AutoCAD DWG and DXF to PDF Converter :: PCL to PDF Converter :: Document Printer (docPrint) :: VeryPDF PDF Editor :: PDF Password Remover :: Encrypt PDF :: PDF Split-Merge :: PDF Stamper :: VeryPDF PDFPrint :: Advanced PDF Tools :: PDF Editor Toolkit :: Text to PDF Converter :: PowerPoint to Flash :: PowerPoint Converter


Home | Site Map | VeryPDF.com | VeryPCL.com | Contact | Blog

Copyright © 2002- VeryDOC.com Company. All Rights Reserved.