the latest version PDFium 128.0.6611.0
windows x64
Public Declare PtrSafe Function FPDF_LoadDocument Lib "pdfium" (ByVal file_path As String, Optional ByVal Password As String) As LongPtr
Public Declare PtrSafe Sub FPDF_CloseDocument Lib "pdfium" (ByVal hPDF As LongPtr)
Public Declare PtrSafe Function FPDF_GetPageCount Lib "pdfium" (ByVal hPDF As LongPtr) As Long
Public Declare PtrSafe Sub FPDF_InitLibrary Lib "pdfium" ()
Public Declare PtrSafe Sub FPDF_DestroyLibrary Lib "pdfium" ()
Public Function pdfium_GetPages(ByVal sPath As String) As Long
Dim hPDF As LongPtr
Dim bytBuff() As Byte
StrToUTF8 sPath, bytBuff 'convert sPath to UTF8 array
FPDF_InitLibrary
hPDF = FPDF_LoadDocument(bytBuff(0))
If hPDF Then
pdfium_GetPages = FPDF_GetPageCount(hPDF)
FPDF_CloseDocument hPDF 'Excel crashs here
End If
FPDF_DestroyLibrary
End Function
the latest version PDFium 128.0.6611.0 windows x64 Public Declare PtrSafe Function FPDF_LoadDocument Lib "pdfium" (ByVal file_path As String, Optional ByVal Password As String) As LongPtr Public Declare PtrSafe Sub FPDF_CloseDocument Lib "pdfium" (ByVal hPDF As LongPtr) Public Declare PtrSafe Function FPDF_GetPageCount Lib "pdfium" (ByVal hPDF As LongPtr) As Long Public Declare PtrSafe Sub FPDF_InitLibrary Lib "pdfium" () Public Declare PtrSafe Sub FPDF_DestroyLibrary Lib "pdfium" ()
Public Function pdfium_GetPages(ByVal sPath As String) As Long Dim hPDF As LongPtr Dim bytBuff() As Byte StrToUTF8 sPath, bytBuff 'convert sPath to UTF8 array FPDF_InitLibrary hPDF = FPDF_LoadDocument(bytBuff(0)) If hPDF Then pdfium_GetPages = FPDF_GetPageCount(hPDF) FPDF_CloseDocument hPDF 'Excel crashs here End If FPDF_DestroyLibrary End Function