getPagesCount method
Implementation
int getPagesCount(String path,
{String? ownerPassword,
String? userPassword,
Allocator allocator = calloc}) {
var pathC = stringToNativeInt8(path, allocator: allocator);
var _ownerPassword = ownerPassword != null
? stringToNativeInt8(ownerPassword, allocator: allocator)
: nullptr;
var _userPassword = userPassword != null
? stringToNativeInt8(userPassword, allocator: allocator)
: nullptr;
try {
var _logCallbackC = Pointer.fromFunction<Void Function(Pointer<Int8>)>(
_logCallbackGetPagesCount);
var result = pdfToTextBindings!
.getNumPages(pathC, _logCallbackC, _ownerPassword, _userPassword);
if (result == -1) {
throw Exception('Error get pages count from PDF: $_lastError');
} else {
return result;
}
} catch (e) {
rethrow;
} finally {
if (ownerPassword != null) {
allocator.free(_ownerPassword);
}
if (userPassword != null) {
allocator.free(_userPassword);
}
allocator.free(pathC);
}
}