I tried to convert a two pages PDF into two PNG.
It worked when I converted only one page(either first or second page) from the PDF.
The program crash when reaching the call to gflSaveBitmapIntoHandle(VarPtr(SData), GflBitmap, GflSaveParams) for the second images (see code below).
Anyone can help?
Thanks
Code:
'-------------------
Private Sub Form_Load()
Dim GflBitmap As GFL_BITMAP
Dim PtrBitmap As Long
Dim GflLoadParams As GFL_LOAD_PARAMS
Dim GflSaveParams As GFL_SAVE_PARAMS
Dim GflInfo As GFL_FILE_INFORMATION
Dim Error As Integer
gflLibraryInit 'Initialize the library
gflGetDefaultLoadParams GflLoadParams 'Gets default parameters for loading
gflGetDefaultSaveParams GflSaveParams 'Gets default parameters for saving
Error = gflLoadBitmap(App.Path & "\ae.pdf", PtrBitmap, GflLoadParams, GflInfo) 'Load bitmap in memory
If Error = GFL_NO_ERROR Then 'Si aucune erreur
extGetGflBitmapFromPtr PtrBitmap, GflBitmap 'Get the picture data
With GflSaveParams.Callbacks
.Write = extFarProc(AddressOf WRITE_WriteFunction) 'Set the CallBacks
.Tell = extFarProc(AddressOf WRITE_TellFunction)
.Seek = extFarProc(AddressOf WRITE_SeekFunction)
End With
GflSaveParams.FormatIndex = gflGetFormatIndexByName("png") 'Set the writing format
Error = gflSaveBitmapIntoHandle(VarPtr(SData), GflBitmap, GflSaveParams) 'Write the file in memory using the SData strucutre (copy of SAVE_DATA)
If Error = GFL_NO_ERROR Then
extSaveFile App.Path & "\ae1.png", SData 'If no error, save the picture
Text1.text = "image 1 saved !"
gflMemoryFree SData.Data 'Free SData
End If
gflFreeBitmapData GflBitmap 'Free bitmap
End If
If Error <> GFL_NO_ERROR Then MsgBox "Error : " & extGetStr(gflGetErrorString(Error)) & " (" & Error & ")" 'If no error, display it
gflGetDefaultLoadParams GflLoadParams 'Gets default parameters for loading
gflGetDefaultSaveParams GflSaveParams 'Gets default parameters for saving
GflLoadParams.ImageWanted = 1 'set to second page of the PDF
Error = gflLoadBitmap(App.Path & "\ae.pdf", PtrBitmap, GflLoadParams, GflInfo) 'Load bitmap in memory
If Error = GFL_NO_ERROR Then 'Si aucune erreur
extGetGflBitmapFromPtr PtrBitmap, GflBitmap 'Get the picture data
With GflSaveParams.Callbacks
.Write = extFarProc(AddressOf WRITE_WriteFunction) 'Set the CallBacks
.Tell = extFarProc(AddressOf WRITE_TellFunction)
.Seek = extFarProc(AddressOf WRITE_SeekFunction)
End With
GflSaveParams.FormatIndex = gflGetFormatIndexByName("png") 'Set the writing format
'CRASH HERE
Error = gflSaveBitmapIntoHandle(VarPtr(SData), GflBitmap, GflSaveParams) 'Write the file in memory using the SData strucutre (copy of SAVE_DATA)
If Error = GFL_NO_ERROR Then
extSaveFile App.Path & "\ae2.png", SData 'If no error, save the picture
Text1.text = "image 2 saved !"
gflMemoryFree SData.Data 'Free SData
End If
gflFreeBitmapData GflBitmap 'Free bitmap
End If
If Error <> GFL_NO_ERROR Then MsgBox "Error : " & extGetStr(gflGetErrorString(Error)) & " (" & Error & ")" 'If no error, display it
gflLibraryExit 'Quit library
End Sub
Program crashed when converting the second page of a pdf
Moderators: helmut, XnTriq, xnview
Re: Program crashed when converting the second page of a pdf
Could you send me the PDF file?zliang68 wrote:I tried to convert a two pages PDF into two PNG.
It worked when I converted only one page(either first or second page) from the PDF.
The program crash when reaching the call to gflSaveBitmapIntoHandle(VarPtr(SData), GflBitmap, GflSaveParams) for the second images (see code below).
Anyone can help?
Thanks
Pierre.