Is PDF Parser SDK render the wrong PDF page number?

Hi,

We have encountered a bug in the PDF Parser DLL which was shipped.

Error Description:

VeryPDF_PDFParserSDK_GetHandle functions accepts parameter f and l where you can specify the first and the last page range of the report. VeryPDF returns handle id Which can be used to fetch the pages in subsequent calls.

Problem is everything works fine if the first page is 1. But if you have first page as 3 and last page as 10 it would return last 3 pages as blank (8,9,10). Similarly if you have first page as 4 and last page as 11 it returns the last 4 pages Blank.


Sample Application To Reproduce the Error:

Download The Sample application which I have created to reproduce the error.

XXXXXXXXXXXXXXXXXXXX

Steps To Reproduce the Error:

1. Enter Pages 3 and 10 and click the Load Pages Button As shown in the below Screenshot. It will populate the image box with the 3rd Page. It returns Handle which you can use to Load Pages 3 to 10.

2. Now Enter 7 below the show Page and it would correctly load the 7th Page.
3. Now Again Enter 8 page and Click Show Page. It would return Blank.Same thing would happen for pages 9,10.
4. So When you try to use the Handleid for loading last 3 pages(8,9,10) it would return Blank.

Let me know if you have any Questions.
===================================================

Could you please relate to the error as descried below?

===================================================

I have double checked your source code, it seems there has a misunderstanding in the index parameter of VeryPDF_PDFParserSDK_GetImageLength() and VeryPDF_PDFParserSDK_GetTextInfoLength() functions, you need deliver the index instead of page number to the VeryPDF_PDFParserSDK_GetImageLength() and VeryPDF_PDFParserSDK_GetTextInfoLength() functions, for example, if you render the page range "-f 3 -l 6" and if you wish display the page 3, you need deliver index "0" to VeryPDF_PDFParserSDK_GetImageLength() function, then you will get the image data of page 3, please refer to following modified source code,


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
txtFrm.Text = "3"
txtTo.Text = "6"

Dim strInPDFFile As String
strInPDFFile = Application.StartupPath() & "\tst1.pdf"
Handleid = VeryPDF_PDFParserSDK_GetHandle(strInPDFFile, "-$ XXXXXXXXXXXXX -f " & txtFrm.Text & " -l " & txtTo.Text)

Dim nImageIndex As Integer = 0
//If you wish display page 3, please set nImageIndex to 0
//If you wish display page 4, please set nImageIndex to 1
//If you wish display page 5, please set nImageIndex to 2
//If you wish display page 6, please set nImageIndex to 3
//and so on

iImageDataLen = VeryPDF_PDFParserSDK_GetImageLength(Handleid, nImageIndex)
iTextInfoLen = VeryPDF_PDFParserSDK_GetTextInfoLength(Handleid, nImageIndex)
ReDim btImgData(iImageDataLen)
ReDim btTxtData(iTextInfoLen)
VeryPDF_PDFParserSDK_GetImageData(Handleid, nImageIndex, btImgData(0), iImageDataLen)
VeryPDF_PDFParserSDK_GetTextInfoData(Handleid, nImageIndex, btTxtData(0), iTextInfoLen)
sLogMsg = System.Text.Encoding.ASCII.GetString(btTxtData)
PageMap = sLogMsg
PageImage = btImgData
PictureBox1.Image = Byte2Image(PageImage)
End Sub

Public Function Byte2Image(ByVal ByteArr() As Byte) As Image
Dim NewImage As Image = Nothing
Dim ImageStream As MemoryStream
Try
If ByteArr.GetUpperBound(0) > 0 Then
ImageStream = New MemoryStream(ByteArr)
NewImage = Image.FromStream(ImageStream)
Else
NewImage = Nothing
End If
Catch ex As Exception
NewImage = Nothing
End Try
Byte2Image = NewImage
End Function
VeryPDF
====================================================
Continuous to previous email, I have attached a new piece of source code at below, you can use following code to read all images which returned by VeryPDF_PDFParserSDK_GetHandle() function,

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

You can use VeryPDF_PDFParserSDK_GetCount() function to get the count of returned items, then you can read each item in a loop, the item index for following functions is start from "0", this item index is not equal to page number in PDF file, please notice this difference,

VeryPDF_PDFParserSDK_GetTextInfoLength()
VeryPDF_PDFParserSDK_GetImageLength()
VeryPDF_PDFParserSDK_GetImageData()
VeryPDF_PDFParserSDK_GetTextInfoData()

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

This entry was posted in VeryPDF Blog 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!