From 3eff52f7035e1f3dc91f68f60ebcda0e7d4a71dd Mon Sep 17 00:00:00 2001 From: Takashi Kawasaki Date: Wed, 6 Dec 2023 21:26:00 +0900 Subject: [PATCH] WIP --- .vscode/settings.json | 1 + lib/src/pdfium/pdfium_bindings.dart | 2574 +++++++++++++++++++++++++++ lib/src/pdfium/pdfrx_pdfium.dart | 261 ++- lib/src/pdfrx_api.dart | 121 +- lib/src/web/pdfrx_web.dart | 35 +- pubspec.yaml | 13 +- 6 files changed, 2987 insertions(+), 18 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 0b8d0e4..28838be 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -32,6 +32,7 @@ "malloc", "microtask", "nullptr", + "PAGELINK", "pdfium", "Pdfjs", "pdfrx", diff --git a/lib/src/pdfium/pdfium_bindings.dart b/lib/src/pdfium/pdfium_bindings.dart index 4a81fc8..26e41b3 100644 --- a/lib/src/pdfium/pdfium_bindings.dart +++ b/lib/src/pdfium/pdfium_bindings.dart @@ -986,6 +986,2400 @@ class pdfium { _FPDF_GetXFAPacketContentPtr.asFunction< int Function(FPDF_DOCUMENT, int, ffi.Pointer, int, ffi.Pointer)>(); + + int FPDFAnnot_IsSupportedSubtype( + int subtype, + ) { + return _FPDFAnnot_IsSupportedSubtype( + subtype, + ); + } + + late final _FPDFAnnot_IsSupportedSubtypePtr = + _lookup>( + 'FPDFAnnot_IsSupportedSubtype'); + late final _FPDFAnnot_IsSupportedSubtype = + _FPDFAnnot_IsSupportedSubtypePtr.asFunction(); + + FPDF_ANNOTATION FPDFPage_CreateAnnot( + FPDF_PAGE page, + int subtype, + ) { + return _FPDFPage_CreateAnnot( + page, + subtype, + ); + } + + late final _FPDFPage_CreateAnnotPtr = _lookup< + ffi.NativeFunction< + FPDF_ANNOTATION Function( + FPDF_PAGE, FPDF_ANNOTATION_SUBTYPE)>>('FPDFPage_CreateAnnot'); + late final _FPDFPage_CreateAnnot = _FPDFPage_CreateAnnotPtr.asFunction< + FPDF_ANNOTATION Function(FPDF_PAGE, int)>(); + + int FPDFPage_GetAnnotCount( + FPDF_PAGE page, + ) { + return _FPDFPage_GetAnnotCount( + page, + ); + } + + late final _FPDFPage_GetAnnotCountPtr = + _lookup>( + 'FPDFPage_GetAnnotCount'); + late final _FPDFPage_GetAnnotCount = + _FPDFPage_GetAnnotCountPtr.asFunction(); + + FPDF_ANNOTATION FPDFPage_GetAnnot( + FPDF_PAGE page, + int index, + ) { + return _FPDFPage_GetAnnot( + page, + index, + ); + } + + late final _FPDFPage_GetAnnotPtr = + _lookup>( + 'FPDFPage_GetAnnot'); + late final _FPDFPage_GetAnnot = _FPDFPage_GetAnnotPtr.asFunction< + FPDF_ANNOTATION Function(FPDF_PAGE, int)>(); + + int FPDFPage_GetAnnotIndex( + FPDF_PAGE page, + FPDF_ANNOTATION annot, + ) { + return _FPDFPage_GetAnnotIndex( + page, + annot, + ); + } + + late final _FPDFPage_GetAnnotIndexPtr = + _lookup>( + 'FPDFPage_GetAnnotIndex'); + late final _FPDFPage_GetAnnotIndex = _FPDFPage_GetAnnotIndexPtr.asFunction< + int Function(FPDF_PAGE, FPDF_ANNOTATION)>(); + + void FPDFPage_CloseAnnot( + FPDF_ANNOTATION annot, + ) { + return _FPDFPage_CloseAnnot( + annot, + ); + } + + late final _FPDFPage_CloseAnnotPtr = + _lookup>( + 'FPDFPage_CloseAnnot'); + late final _FPDFPage_CloseAnnot = + _FPDFPage_CloseAnnotPtr.asFunction(); + + int FPDFPage_RemoveAnnot( + FPDF_PAGE page, + int index, + ) { + return _FPDFPage_RemoveAnnot( + page, + index, + ); + } + + late final _FPDFPage_RemoveAnnotPtr = + _lookup>( + 'FPDFPage_RemoveAnnot'); + late final _FPDFPage_RemoveAnnot = + _FPDFPage_RemoveAnnotPtr.asFunction(); + + int FPDFAnnot_GetSubtype( + FPDF_ANNOTATION annot, + ) { + return _FPDFAnnot_GetSubtype( + annot, + ); + } + + late final _FPDFAnnot_GetSubtypePtr = _lookup< + ffi + .NativeFunction>( + 'FPDFAnnot_GetSubtype'); + late final _FPDFAnnot_GetSubtype = + _FPDFAnnot_GetSubtypePtr.asFunction(); + + int FPDFAnnot_IsObjectSupportedSubtype( + int subtype, + ) { + return _FPDFAnnot_IsObjectSupportedSubtype( + subtype, + ); + } + + late final _FPDFAnnot_IsObjectSupportedSubtypePtr = + _lookup>( + 'FPDFAnnot_IsObjectSupportedSubtype'); + late final _FPDFAnnot_IsObjectSupportedSubtype = + _FPDFAnnot_IsObjectSupportedSubtypePtr.asFunction(); + + int FPDFAnnot_UpdateObject( + FPDF_ANNOTATION annot, + FPDF_PAGEOBJECT obj, + ) { + return _FPDFAnnot_UpdateObject( + annot, + obj, + ); + } + + late final _FPDFAnnot_UpdateObjectPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_ANNOTATION, FPDF_PAGEOBJECT)>>('FPDFAnnot_UpdateObject'); + late final _FPDFAnnot_UpdateObject = _FPDFAnnot_UpdateObjectPtr.asFunction< + int Function(FPDF_ANNOTATION, FPDF_PAGEOBJECT)>(); + + int FPDFAnnot_AddInkStroke( + FPDF_ANNOTATION annot, + ffi.Pointer points, + int point_count, + ) { + return _FPDFAnnot_AddInkStroke( + annot, + points, + point_count, + ); + } + + late final _FPDFAnnot_AddInkStrokePtr = _lookup< + ffi.NativeFunction< + ffi.Int Function(FPDF_ANNOTATION, ffi.Pointer, + ffi.Size)>>('FPDFAnnot_AddInkStroke'); + late final _FPDFAnnot_AddInkStroke = _FPDFAnnot_AddInkStrokePtr.asFunction< + int Function(FPDF_ANNOTATION, ffi.Pointer, int)>(); + + int FPDFAnnot_RemoveInkList( + FPDF_ANNOTATION annot, + ) { + return _FPDFAnnot_RemoveInkList( + annot, + ); + } + + late final _FPDFAnnot_RemoveInkListPtr = + _lookup>( + 'FPDFAnnot_RemoveInkList'); + late final _FPDFAnnot_RemoveInkList = + _FPDFAnnot_RemoveInkListPtr.asFunction(); + + int FPDFAnnot_AppendObject( + FPDF_ANNOTATION annot, + FPDF_PAGEOBJECT obj, + ) { + return _FPDFAnnot_AppendObject( + annot, + obj, + ); + } + + late final _FPDFAnnot_AppendObjectPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_ANNOTATION, FPDF_PAGEOBJECT)>>('FPDFAnnot_AppendObject'); + late final _FPDFAnnot_AppendObject = _FPDFAnnot_AppendObjectPtr.asFunction< + int Function(FPDF_ANNOTATION, FPDF_PAGEOBJECT)>(); + + int FPDFAnnot_GetObjectCount( + FPDF_ANNOTATION annot, + ) { + return _FPDFAnnot_GetObjectCount( + annot, + ); + } + + late final _FPDFAnnot_GetObjectCountPtr = + _lookup>( + 'FPDFAnnot_GetObjectCount'); + late final _FPDFAnnot_GetObjectCount = + _FPDFAnnot_GetObjectCountPtr.asFunction(); + + FPDF_PAGEOBJECT FPDFAnnot_GetObject( + FPDF_ANNOTATION annot, + int index, + ) { + return _FPDFAnnot_GetObject( + annot, + index, + ); + } + + late final _FPDFAnnot_GetObjectPtr = _lookup< + ffi + .NativeFunction>( + 'FPDFAnnot_GetObject'); + late final _FPDFAnnot_GetObject = _FPDFAnnot_GetObjectPtr.asFunction< + FPDF_PAGEOBJECT Function(FPDF_ANNOTATION, int)>(); + + int FPDFAnnot_RemoveObject( + FPDF_ANNOTATION annot, + int index, + ) { + return _FPDFAnnot_RemoveObject( + annot, + index, + ); + } + + late final _FPDFAnnot_RemoveObjectPtr = + _lookup>( + 'FPDFAnnot_RemoveObject'); + late final _FPDFAnnot_RemoveObject = _FPDFAnnot_RemoveObjectPtr.asFunction< + int Function(FPDF_ANNOTATION, int)>(); + + int FPDFAnnot_SetColor( + FPDF_ANNOTATION annot, + int type, + int R, + int G, + int B, + int A, + ) { + return _FPDFAnnot_SetColor( + annot, + type, + R, + G, + B, + A, + ); + } + + late final _FPDFAnnot_SetColorPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_ANNOTATION, + ffi.Int32, + ffi.UnsignedInt, + ffi.UnsignedInt, + ffi.UnsignedInt, + ffi.UnsignedInt)>>('FPDFAnnot_SetColor'); + late final _FPDFAnnot_SetColor = _FPDFAnnot_SetColorPtr.asFunction< + int Function(FPDF_ANNOTATION, int, int, int, int, int)>(); + + int FPDFAnnot_GetColor( + FPDF_ANNOTATION annot, + int type, + ffi.Pointer R, + ffi.Pointer G, + ffi.Pointer B, + ffi.Pointer A, + ) { + return _FPDFAnnot_GetColor( + annot, + type, + R, + G, + B, + A, + ); + } + + late final _FPDFAnnot_GetColorPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_ANNOTATION, + ffi.Int32, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('FPDFAnnot_GetColor'); + late final _FPDFAnnot_GetColor = _FPDFAnnot_GetColorPtr.asFunction< + int Function( + FPDF_ANNOTATION, + int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + int FPDFAnnot_HasAttachmentPoints( + FPDF_ANNOTATION annot, + ) { + return _FPDFAnnot_HasAttachmentPoints( + annot, + ); + } + + late final _FPDFAnnot_HasAttachmentPointsPtr = + _lookup>( + 'FPDFAnnot_HasAttachmentPoints'); + late final _FPDFAnnot_HasAttachmentPoints = _FPDFAnnot_HasAttachmentPointsPtr + .asFunction(); + + int FPDFAnnot_SetAttachmentPoints( + FPDF_ANNOTATION annot, + int quad_index, + ffi.Pointer quad_points, + ) { + return _FPDFAnnot_SetAttachmentPoints( + annot, + quad_index, + quad_points, + ); + } + + late final _FPDFAnnot_SetAttachmentPointsPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function(FPDF_ANNOTATION, ffi.Size, + ffi.Pointer)>>('FPDFAnnot_SetAttachmentPoints'); + late final _FPDFAnnot_SetAttachmentPoints = + _FPDFAnnot_SetAttachmentPointsPtr.asFunction< + int Function(FPDF_ANNOTATION, int, ffi.Pointer)>(); + + int FPDFAnnot_AppendAttachmentPoints( + FPDF_ANNOTATION annot, + ffi.Pointer quad_points, + ) { + return _FPDFAnnot_AppendAttachmentPoints( + annot, + quad_points, + ); + } + + late final _FPDFAnnot_AppendAttachmentPointsPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_ANNOTATION, ffi.Pointer)>>( + 'FPDFAnnot_AppendAttachmentPoints'); + late final _FPDFAnnot_AppendAttachmentPoints = + _FPDFAnnot_AppendAttachmentPointsPtr.asFunction< + int Function(FPDF_ANNOTATION, ffi.Pointer)>(); + + int FPDFAnnot_CountAttachmentPoints( + FPDF_ANNOTATION annot, + ) { + return _FPDFAnnot_CountAttachmentPoints( + annot, + ); + } + + late final _FPDFAnnot_CountAttachmentPointsPtr = + _lookup>( + 'FPDFAnnot_CountAttachmentPoints'); + late final _FPDFAnnot_CountAttachmentPoints = + _FPDFAnnot_CountAttachmentPointsPtr.asFunction< + int Function(FPDF_ANNOTATION)>(); + + int FPDFAnnot_GetAttachmentPoints( + FPDF_ANNOTATION annot, + int quad_index, + ffi.Pointer quad_points, + ) { + return _FPDFAnnot_GetAttachmentPoints( + annot, + quad_index, + quad_points, + ); + } + + late final _FPDFAnnot_GetAttachmentPointsPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function(FPDF_ANNOTATION, ffi.Size, + ffi.Pointer)>>('FPDFAnnot_GetAttachmentPoints'); + late final _FPDFAnnot_GetAttachmentPoints = + _FPDFAnnot_GetAttachmentPointsPtr.asFunction< + int Function(FPDF_ANNOTATION, int, ffi.Pointer)>(); + + int FPDFAnnot_SetRect( + FPDF_ANNOTATION annot, + ffi.Pointer rect, + ) { + return _FPDFAnnot_SetRect( + annot, + rect, + ); + } + + late final _FPDFAnnot_SetRectPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_ANNOTATION, ffi.Pointer)>>('FPDFAnnot_SetRect'); + late final _FPDFAnnot_SetRect = _FPDFAnnot_SetRectPtr.asFunction< + int Function(FPDF_ANNOTATION, ffi.Pointer)>(); + + int FPDFAnnot_GetRect( + FPDF_ANNOTATION annot, + ffi.Pointer rect, + ) { + return _FPDFAnnot_GetRect( + annot, + rect, + ); + } + + late final _FPDFAnnot_GetRectPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_ANNOTATION, ffi.Pointer)>>('FPDFAnnot_GetRect'); + late final _FPDFAnnot_GetRect = _FPDFAnnot_GetRectPtr.asFunction< + int Function(FPDF_ANNOTATION, ffi.Pointer)>(); + + int FPDFAnnot_GetVertices( + FPDF_ANNOTATION annot, + ffi.Pointer buffer, + int length, + ) { + return _FPDFAnnot_GetVertices( + annot, + buffer, + length, + ); + } + + late final _FPDFAnnot_GetVerticesPtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function(FPDF_ANNOTATION, ffi.Pointer, + ffi.UnsignedLong)>>('FPDFAnnot_GetVertices'); + late final _FPDFAnnot_GetVertices = _FPDFAnnot_GetVerticesPtr.asFunction< + int Function(FPDF_ANNOTATION, ffi.Pointer, int)>(); + + int FPDFAnnot_GetInkListCount( + FPDF_ANNOTATION annot, + ) { + return _FPDFAnnot_GetInkListCount( + annot, + ); + } + + late final _FPDFAnnot_GetInkListCountPtr = + _lookup>( + 'FPDFAnnot_GetInkListCount'); + late final _FPDFAnnot_GetInkListCount = + _FPDFAnnot_GetInkListCountPtr.asFunction(); + + int FPDFAnnot_GetInkListPath( + FPDF_ANNOTATION annot, + int path_index, + ffi.Pointer buffer, + int length, + ) { + return _FPDFAnnot_GetInkListPath( + annot, + path_index, + buffer, + length, + ); + } + + late final _FPDFAnnot_GetInkListPathPtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + FPDF_ANNOTATION, + ffi.UnsignedLong, + ffi.Pointer, + ffi.UnsignedLong)>>('FPDFAnnot_GetInkListPath'); + late final _FPDFAnnot_GetInkListPath = + _FPDFAnnot_GetInkListPathPtr.asFunction< + int Function(FPDF_ANNOTATION, int, ffi.Pointer, int)>(); + + int FPDFAnnot_GetLine( + FPDF_ANNOTATION annot, + ffi.Pointer start, + ffi.Pointer end, + ) { + return _FPDFAnnot_GetLine( + annot, + start, + end, + ); + } + + late final _FPDFAnnot_GetLinePtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function(FPDF_ANNOTATION, ffi.Pointer, + ffi.Pointer)>>('FPDFAnnot_GetLine'); + late final _FPDFAnnot_GetLine = _FPDFAnnot_GetLinePtr.asFunction< + int Function( + FPDF_ANNOTATION, ffi.Pointer, ffi.Pointer)>(); + + int FPDFAnnot_SetBorder( + FPDF_ANNOTATION annot, + double horizontal_radius, + double vertical_radius, + double border_width, + ) { + return _FPDFAnnot_SetBorder( + annot, + horizontal_radius, + vertical_radius, + border_width, + ); + } + + late final _FPDFAnnot_SetBorderPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function(FPDF_ANNOTATION, ffi.Float, ffi.Float, + ffi.Float)>>('FPDFAnnot_SetBorder'); + late final _FPDFAnnot_SetBorder = _FPDFAnnot_SetBorderPtr.asFunction< + int Function(FPDF_ANNOTATION, double, double, double)>(); + + int FPDFAnnot_GetBorder( + FPDF_ANNOTATION annot, + ffi.Pointer horizontal_radius, + ffi.Pointer vertical_radius, + ffi.Pointer border_width, + ) { + return _FPDFAnnot_GetBorder( + annot, + horizontal_radius, + vertical_radius, + border_width, + ); + } + + late final _FPDFAnnot_GetBorderPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_ANNOTATION, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('FPDFAnnot_GetBorder'); + late final _FPDFAnnot_GetBorder = _FPDFAnnot_GetBorderPtr.asFunction< + int Function(FPDF_ANNOTATION, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>(); + + int FPDFAnnot_GetFormAdditionalActionJavaScript( + FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + int event, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDFAnnot_GetFormAdditionalActionJavaScript( + hHandle, + annot, + event, + buffer, + buflen, + ); + } + + late final _FPDFAnnot_GetFormAdditionalActionJavaScriptPtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function(FPDF_FORMHANDLE, FPDF_ANNOTATION, + ffi.Int, ffi.Pointer, ffi.UnsignedLong)>>( + 'FPDFAnnot_GetFormAdditionalActionJavaScript'); + late final _FPDFAnnot_GetFormAdditionalActionJavaScript = + _FPDFAnnot_GetFormAdditionalActionJavaScriptPtr.asFunction< + int Function(FPDF_FORMHANDLE, FPDF_ANNOTATION, int, + ffi.Pointer, int)>(); + + int FPDFAnnot_HasKey( + FPDF_ANNOTATION annot, + FPDF_BYTESTRING key, + ) { + return _FPDFAnnot_HasKey( + annot, + key, + ); + } + + late final _FPDFAnnot_HasKeyPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_ANNOTATION, FPDF_BYTESTRING)>>('FPDFAnnot_HasKey'); + late final _FPDFAnnot_HasKey = _FPDFAnnot_HasKeyPtr.asFunction< + int Function(FPDF_ANNOTATION, FPDF_BYTESTRING)>(); + + int FPDFAnnot_GetValueType( + FPDF_ANNOTATION annot, + FPDF_BYTESTRING key, + ) { + return _FPDFAnnot_GetValueType( + annot, + key, + ); + } + + late final _FPDFAnnot_GetValueTypePtr = _lookup< + ffi.NativeFunction< + FPDF_OBJECT_TYPE Function( + FPDF_ANNOTATION, FPDF_BYTESTRING)>>('FPDFAnnot_GetValueType'); + late final _FPDFAnnot_GetValueType = _FPDFAnnot_GetValueTypePtr.asFunction< + int Function(FPDF_ANNOTATION, FPDF_BYTESTRING)>(); + + int FPDFAnnot_SetStringValue( + FPDF_ANNOTATION annot, + FPDF_BYTESTRING key, + FPDF_WIDESTRING value, + ) { + return _FPDFAnnot_SetStringValue( + annot, + key, + value, + ); + } + + late final _FPDFAnnot_SetStringValuePtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function(FPDF_ANNOTATION, FPDF_BYTESTRING, + FPDF_WIDESTRING)>>('FPDFAnnot_SetStringValue'); + late final _FPDFAnnot_SetStringValue = + _FPDFAnnot_SetStringValuePtr.asFunction< + int Function(FPDF_ANNOTATION, FPDF_BYTESTRING, FPDF_WIDESTRING)>(); + + int FPDFAnnot_GetStringValue( + FPDF_ANNOTATION annot, + FPDF_BYTESTRING key, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDFAnnot_GetStringValue( + annot, + key, + buffer, + buflen, + ); + } + + late final _FPDFAnnot_GetStringValuePtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + FPDF_ANNOTATION, + FPDF_BYTESTRING, + ffi.Pointer, + ffi.UnsignedLong)>>('FPDFAnnot_GetStringValue'); + late final _FPDFAnnot_GetStringValue = + _FPDFAnnot_GetStringValuePtr.asFunction< + int Function(FPDF_ANNOTATION, FPDF_BYTESTRING, + ffi.Pointer, int)>(); + + int FPDFAnnot_GetNumberValue( + FPDF_ANNOTATION annot, + FPDF_BYTESTRING key, + ffi.Pointer value, + ) { + return _FPDFAnnot_GetNumberValue( + annot, + key, + value, + ); + } + + late final _FPDFAnnot_GetNumberValuePtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function(FPDF_ANNOTATION, FPDF_BYTESTRING, + ffi.Pointer)>>('FPDFAnnot_GetNumberValue'); + late final _FPDFAnnot_GetNumberValue = + _FPDFAnnot_GetNumberValuePtr.asFunction< + int Function( + FPDF_ANNOTATION, FPDF_BYTESTRING, ffi.Pointer)>(); + + int FPDFAnnot_SetAP( + FPDF_ANNOTATION annot, + int appearanceMode, + FPDF_WIDESTRING value, + ) { + return _FPDFAnnot_SetAP( + annot, + appearanceMode, + value, + ); + } + + late final _FPDFAnnot_SetAPPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function(FPDF_ANNOTATION, FPDF_ANNOT_APPEARANCEMODE, + FPDF_WIDESTRING)>>('FPDFAnnot_SetAP'); + late final _FPDFAnnot_SetAP = _FPDFAnnot_SetAPPtr.asFunction< + int Function(FPDF_ANNOTATION, int, FPDF_WIDESTRING)>(); + + int FPDFAnnot_GetAP( + FPDF_ANNOTATION annot, + int appearanceMode, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDFAnnot_GetAP( + annot, + appearanceMode, + buffer, + buflen, + ); + } + + late final _FPDFAnnot_GetAPPtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function(FPDF_ANNOTATION, FPDF_ANNOT_APPEARANCEMODE, + ffi.Pointer, ffi.UnsignedLong)>>('FPDFAnnot_GetAP'); + late final _FPDFAnnot_GetAP = _FPDFAnnot_GetAPPtr.asFunction< + int Function(FPDF_ANNOTATION, int, ffi.Pointer, int)>(); + + FPDF_ANNOTATION FPDFAnnot_GetLinkedAnnot( + FPDF_ANNOTATION annot, + FPDF_BYTESTRING key, + ) { + return _FPDFAnnot_GetLinkedAnnot( + annot, + key, + ); + } + + late final _FPDFAnnot_GetLinkedAnnotPtr = _lookup< + ffi.NativeFunction< + FPDF_ANNOTATION Function( + FPDF_ANNOTATION, FPDF_BYTESTRING)>>('FPDFAnnot_GetLinkedAnnot'); + late final _FPDFAnnot_GetLinkedAnnot = _FPDFAnnot_GetLinkedAnnotPtr + .asFunction(); + + int FPDFAnnot_GetFlags( + FPDF_ANNOTATION annot, + ) { + return _FPDFAnnot_GetFlags( + annot, + ); + } + + late final _FPDFAnnot_GetFlagsPtr = + _lookup>( + 'FPDFAnnot_GetFlags'); + late final _FPDFAnnot_GetFlags = + _FPDFAnnot_GetFlagsPtr.asFunction(); + + int FPDFAnnot_SetFlags( + FPDF_ANNOTATION annot, + int flags, + ) { + return _FPDFAnnot_SetFlags( + annot, + flags, + ); + } + + late final _FPDFAnnot_SetFlagsPtr = + _lookup>( + 'FPDFAnnot_SetFlags'); + late final _FPDFAnnot_SetFlags = + _FPDFAnnot_SetFlagsPtr.asFunction(); + + int FPDFAnnot_GetFormFieldFlags( + FPDF_FORMHANDLE handle, + FPDF_ANNOTATION annot, + ) { + return _FPDFAnnot_GetFormFieldFlags( + handle, + annot, + ); + } + + late final _FPDFAnnot_GetFormFieldFlagsPtr = _lookup< + ffi + .NativeFunction>( + 'FPDFAnnot_GetFormFieldFlags'); + late final _FPDFAnnot_GetFormFieldFlags = _FPDFAnnot_GetFormFieldFlagsPtr + .asFunction(); + + FPDF_ANNOTATION FPDFAnnot_GetFormFieldAtPoint( + FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + ffi.Pointer point, + ) { + return _FPDFAnnot_GetFormFieldAtPoint( + hHandle, + page, + point, + ); + } + + late final _FPDFAnnot_GetFormFieldAtPointPtr = _lookup< + ffi.NativeFunction< + FPDF_ANNOTATION Function(FPDF_FORMHANDLE, FPDF_PAGE, + ffi.Pointer)>>('FPDFAnnot_GetFormFieldAtPoint'); + late final _FPDFAnnot_GetFormFieldAtPoint = + _FPDFAnnot_GetFormFieldAtPointPtr.asFunction< + FPDF_ANNOTATION Function( + FPDF_FORMHANDLE, FPDF_PAGE, ffi.Pointer)>(); + + int FPDFAnnot_GetFormFieldName( + FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDFAnnot_GetFormFieldName( + hHandle, + annot, + buffer, + buflen, + ); + } + + late final _FPDFAnnot_GetFormFieldNamePtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + FPDF_FORMHANDLE, + FPDF_ANNOTATION, + ffi.Pointer, + ffi.UnsignedLong)>>('FPDFAnnot_GetFormFieldName'); + late final _FPDFAnnot_GetFormFieldName = + _FPDFAnnot_GetFormFieldNamePtr.asFunction< + int Function(FPDF_FORMHANDLE, FPDF_ANNOTATION, + ffi.Pointer, int)>(); + + int FPDFAnnot_GetFormFieldAlternateName( + FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDFAnnot_GetFormFieldAlternateName( + hHandle, + annot, + buffer, + buflen, + ); + } + + late final _FPDFAnnot_GetFormFieldAlternateNamePtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + FPDF_FORMHANDLE, + FPDF_ANNOTATION, + ffi.Pointer, + ffi.UnsignedLong)>>('FPDFAnnot_GetFormFieldAlternateName'); + late final _FPDFAnnot_GetFormFieldAlternateName = + _FPDFAnnot_GetFormFieldAlternateNamePtr.asFunction< + int Function(FPDF_FORMHANDLE, FPDF_ANNOTATION, + ffi.Pointer, int)>(); + + int FPDFAnnot_GetFormFieldType( + FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + ) { + return _FPDFAnnot_GetFormFieldType( + hHandle, + annot, + ); + } + + late final _FPDFAnnot_GetFormFieldTypePtr = _lookup< + ffi + .NativeFunction>( + 'FPDFAnnot_GetFormFieldType'); + late final _FPDFAnnot_GetFormFieldType = _FPDFAnnot_GetFormFieldTypePtr + .asFunction(); + + int FPDFAnnot_GetFormFieldValue( + FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDFAnnot_GetFormFieldValue( + hHandle, + annot, + buffer, + buflen, + ); + } + + late final _FPDFAnnot_GetFormFieldValuePtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + FPDF_FORMHANDLE, + FPDF_ANNOTATION, + ffi.Pointer, + ffi.UnsignedLong)>>('FPDFAnnot_GetFormFieldValue'); + late final _FPDFAnnot_GetFormFieldValue = + _FPDFAnnot_GetFormFieldValuePtr.asFunction< + int Function(FPDF_FORMHANDLE, FPDF_ANNOTATION, + ffi.Pointer, int)>(); + + int FPDFAnnot_GetOptionCount( + FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + ) { + return _FPDFAnnot_GetOptionCount( + hHandle, + annot, + ); + } + + late final _FPDFAnnot_GetOptionCountPtr = _lookup< + ffi + .NativeFunction>( + 'FPDFAnnot_GetOptionCount'); + late final _FPDFAnnot_GetOptionCount = _FPDFAnnot_GetOptionCountPtr + .asFunction(); + + int FPDFAnnot_GetOptionLabel( + FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + int index, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDFAnnot_GetOptionLabel( + hHandle, + annot, + index, + buffer, + buflen, + ); + } + + late final _FPDFAnnot_GetOptionLabelPtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + FPDF_FORMHANDLE, + FPDF_ANNOTATION, + ffi.Int, + ffi.Pointer, + ffi.UnsignedLong)>>('FPDFAnnot_GetOptionLabel'); + late final _FPDFAnnot_GetOptionLabel = + _FPDFAnnot_GetOptionLabelPtr.asFunction< + int Function(FPDF_FORMHANDLE, FPDF_ANNOTATION, int, + ffi.Pointer, int)>(); + + int FPDFAnnot_IsOptionSelected( + FPDF_FORMHANDLE handle, + FPDF_ANNOTATION annot, + int index, + ) { + return _FPDFAnnot_IsOptionSelected( + handle, + annot, + index, + ); + } + + late final _FPDFAnnot_IsOptionSelectedPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function(FPDF_FORMHANDLE, FPDF_ANNOTATION, + ffi.Int)>>('FPDFAnnot_IsOptionSelected'); + late final _FPDFAnnot_IsOptionSelected = _FPDFAnnot_IsOptionSelectedPtr + .asFunction(); + + int FPDFAnnot_GetFontSize( + FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + ffi.Pointer value, + ) { + return _FPDFAnnot_GetFontSize( + hHandle, + annot, + value, + ); + } + + late final _FPDFAnnot_GetFontSizePtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function(FPDF_FORMHANDLE, FPDF_ANNOTATION, + ffi.Pointer)>>('FPDFAnnot_GetFontSize'); + late final _FPDFAnnot_GetFontSize = _FPDFAnnot_GetFontSizePtr.asFunction< + int Function(FPDF_FORMHANDLE, FPDF_ANNOTATION, ffi.Pointer)>(); + + int FPDFAnnot_IsChecked( + FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + ) { + return _FPDFAnnot_IsChecked( + hHandle, + annot, + ); + } + + late final _FPDFAnnot_IsCheckedPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_FORMHANDLE, FPDF_ANNOTATION)>>('FPDFAnnot_IsChecked'); + late final _FPDFAnnot_IsChecked = _FPDFAnnot_IsCheckedPtr.asFunction< + int Function(FPDF_FORMHANDLE, FPDF_ANNOTATION)>(); + + int FPDFAnnot_SetFocusableSubtypes( + FPDF_FORMHANDLE hHandle, + ffi.Pointer subtypes, + int count, + ) { + return _FPDFAnnot_SetFocusableSubtypes( + hHandle, + subtypes, + count, + ); + } + + late final _FPDFAnnot_SetFocusableSubtypesPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_FORMHANDLE, + ffi.Pointer, + ffi.Size)>>('FPDFAnnot_SetFocusableSubtypes'); + late final _FPDFAnnot_SetFocusableSubtypes = + _FPDFAnnot_SetFocusableSubtypesPtr.asFunction< + int Function( + FPDF_FORMHANDLE, ffi.Pointer, int)>(); + + int FPDFAnnot_GetFocusableSubtypesCount( + FPDF_FORMHANDLE hHandle, + ) { + return _FPDFAnnot_GetFocusableSubtypesCount( + hHandle, + ); + } + + late final _FPDFAnnot_GetFocusableSubtypesCountPtr = + _lookup>( + 'FPDFAnnot_GetFocusableSubtypesCount'); + late final _FPDFAnnot_GetFocusableSubtypesCount = + _FPDFAnnot_GetFocusableSubtypesCountPtr.asFunction< + int Function(FPDF_FORMHANDLE)>(); + + int FPDFAnnot_GetFocusableSubtypes( + FPDF_FORMHANDLE hHandle, + ffi.Pointer subtypes, + int count, + ) { + return _FPDFAnnot_GetFocusableSubtypes( + hHandle, + subtypes, + count, + ); + } + + late final _FPDFAnnot_GetFocusableSubtypesPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_FORMHANDLE, + ffi.Pointer, + ffi.Size)>>('FPDFAnnot_GetFocusableSubtypes'); + late final _FPDFAnnot_GetFocusableSubtypes = + _FPDFAnnot_GetFocusableSubtypesPtr.asFunction< + int Function( + FPDF_FORMHANDLE, ffi.Pointer, int)>(); + + FPDF_LINK FPDFAnnot_GetLink( + FPDF_ANNOTATION annot, + ) { + return _FPDFAnnot_GetLink( + annot, + ); + } + + late final _FPDFAnnot_GetLinkPtr = + _lookup>( + 'FPDFAnnot_GetLink'); + late final _FPDFAnnot_GetLink = + _FPDFAnnot_GetLinkPtr.asFunction(); + + int FPDFAnnot_GetFormControlCount( + FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + ) { + return _FPDFAnnot_GetFormControlCount( + hHandle, + annot, + ); + } + + late final _FPDFAnnot_GetFormControlCountPtr = _lookup< + ffi + .NativeFunction>( + 'FPDFAnnot_GetFormControlCount'); + late final _FPDFAnnot_GetFormControlCount = _FPDFAnnot_GetFormControlCountPtr + .asFunction(); + + int FPDFAnnot_GetFormControlIndex( + FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + ) { + return _FPDFAnnot_GetFormControlIndex( + hHandle, + annot, + ); + } + + late final _FPDFAnnot_GetFormControlIndexPtr = _lookup< + ffi + .NativeFunction>( + 'FPDFAnnot_GetFormControlIndex'); + late final _FPDFAnnot_GetFormControlIndex = _FPDFAnnot_GetFormControlIndexPtr + .asFunction(); + + int FPDFAnnot_GetFormFieldExportValue( + FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDFAnnot_GetFormFieldExportValue( + hHandle, + annot, + buffer, + buflen, + ); + } + + late final _FPDFAnnot_GetFormFieldExportValuePtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + FPDF_FORMHANDLE, + FPDF_ANNOTATION, + ffi.Pointer, + ffi.UnsignedLong)>>('FPDFAnnot_GetFormFieldExportValue'); + late final _FPDFAnnot_GetFormFieldExportValue = + _FPDFAnnot_GetFormFieldExportValuePtr.asFunction< + int Function(FPDF_FORMHANDLE, FPDF_ANNOTATION, + ffi.Pointer, int)>(); + + int FPDFAnnot_SetURI( + FPDF_ANNOTATION annot, + ffi.Pointer uri, + ) { + return _FPDFAnnot_SetURI( + annot, + uri, + ); + } + + late final _FPDFAnnot_SetURIPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_ANNOTATION, ffi.Pointer)>>('FPDFAnnot_SetURI'); + late final _FPDFAnnot_SetURI = _FPDFAnnot_SetURIPtr.asFunction< + int Function(FPDF_ANNOTATION, ffi.Pointer)>(); + + FPDF_TEXTPAGE FPDFText_LoadPage( + FPDF_PAGE page, + ) { + return _FPDFText_LoadPage( + page, + ); + } + + late final _FPDFText_LoadPagePtr = + _lookup>( + 'FPDFText_LoadPage'); + late final _FPDFText_LoadPage = + _FPDFText_LoadPagePtr.asFunction(); + + void FPDFText_ClosePage( + FPDF_TEXTPAGE text_page, + ) { + return _FPDFText_ClosePage( + text_page, + ); + } + + late final _FPDFText_ClosePagePtr = + _lookup>( + 'FPDFText_ClosePage'); + late final _FPDFText_ClosePage = + _FPDFText_ClosePagePtr.asFunction(); + + int FPDFText_CountChars( + FPDF_TEXTPAGE text_page, + ) { + return _FPDFText_CountChars( + text_page, + ); + } + + late final _FPDFText_CountCharsPtr = + _lookup>( + 'FPDFText_CountChars'); + late final _FPDFText_CountChars = + _FPDFText_CountCharsPtr.asFunction(); + + int FPDFText_GetUnicode( + FPDF_TEXTPAGE text_page, + int index, + ) { + return _FPDFText_GetUnicode( + text_page, + index, + ); + } + + late final _FPDFText_GetUnicodePtr = _lookup< + ffi.NativeFunction>( + 'FPDFText_GetUnicode'); + late final _FPDFText_GetUnicode = + _FPDFText_GetUnicodePtr.asFunction(); + + int FPDFText_IsGenerated( + FPDF_TEXTPAGE text_page, + int index, + ) { + return _FPDFText_IsGenerated( + text_page, + index, + ); + } + + late final _FPDFText_IsGeneratedPtr = + _lookup>( + 'FPDFText_IsGenerated'); + late final _FPDFText_IsGenerated = + _FPDFText_IsGeneratedPtr.asFunction(); + + int FPDFText_IsHyphen( + FPDF_TEXTPAGE text_page, + int index, + ) { + return _FPDFText_IsHyphen( + text_page, + index, + ); + } + + late final _FPDFText_IsHyphenPtr = + _lookup>( + 'FPDFText_IsHyphen'); + late final _FPDFText_IsHyphen = + _FPDFText_IsHyphenPtr.asFunction(); + + int FPDFText_HasUnicodeMapError( + FPDF_TEXTPAGE text_page, + int index, + ) { + return _FPDFText_HasUnicodeMapError( + text_page, + index, + ); + } + + late final _FPDFText_HasUnicodeMapErrorPtr = + _lookup>( + 'FPDFText_HasUnicodeMapError'); + late final _FPDFText_HasUnicodeMapError = _FPDFText_HasUnicodeMapErrorPtr + .asFunction(); + + double FPDFText_GetFontSize( + FPDF_TEXTPAGE text_page, + int index, + ) { + return _FPDFText_GetFontSize( + text_page, + index, + ); + } + + late final _FPDFText_GetFontSizePtr = + _lookup>( + 'FPDFText_GetFontSize'); + late final _FPDFText_GetFontSize = _FPDFText_GetFontSizePtr.asFunction< + double Function(FPDF_TEXTPAGE, int)>(); + + int FPDFText_GetFontInfo( + FPDF_TEXTPAGE text_page, + int index, + ffi.Pointer buffer, + int buflen, + ffi.Pointer flags, + ) { + return _FPDFText_GetFontInfo( + text_page, + index, + buffer, + buflen, + flags, + ); + } + + late final _FPDFText_GetFontInfoPtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + FPDF_TEXTPAGE, + ffi.Int, + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer)>>('FPDFText_GetFontInfo'); + late final _FPDFText_GetFontInfo = _FPDFText_GetFontInfoPtr.asFunction< + int Function(FPDF_TEXTPAGE, int, ffi.Pointer, int, + ffi.Pointer)>(); + + int FPDFText_GetFontWeight( + FPDF_TEXTPAGE text_page, + int index, + ) { + return _FPDFText_GetFontWeight( + text_page, + index, + ); + } + + late final _FPDFText_GetFontWeightPtr = + _lookup>( + 'FPDFText_GetFontWeight'); + late final _FPDFText_GetFontWeight = + _FPDFText_GetFontWeightPtr.asFunction(); + + int FPDFText_GetTextRenderMode( + FPDF_TEXTPAGE text_page, + int index, + ) { + return _FPDFText_GetTextRenderMode( + text_page, + index, + ); + } + + late final _FPDFText_GetTextRenderModePtr = + _lookup>( + 'FPDFText_GetTextRenderMode'); + late final _FPDFText_GetTextRenderMode = _FPDFText_GetTextRenderModePtr + .asFunction(); + + int FPDFText_GetFillColor( + FPDF_TEXTPAGE text_page, + int index, + ffi.Pointer R, + ffi.Pointer G, + ffi.Pointer B, + ffi.Pointer A, + ) { + return _FPDFText_GetFillColor( + text_page, + index, + R, + G, + B, + A, + ); + } + + late final _FPDFText_GetFillColorPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_TEXTPAGE, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('FPDFText_GetFillColor'); + late final _FPDFText_GetFillColor = _FPDFText_GetFillColorPtr.asFunction< + int Function( + FPDF_TEXTPAGE, + int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + int FPDFText_GetStrokeColor( + FPDF_TEXTPAGE text_page, + int index, + ffi.Pointer R, + ffi.Pointer G, + ffi.Pointer B, + ffi.Pointer A, + ) { + return _FPDFText_GetStrokeColor( + text_page, + index, + R, + G, + B, + A, + ); + } + + late final _FPDFText_GetStrokeColorPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_TEXTPAGE, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('FPDFText_GetStrokeColor'); + late final _FPDFText_GetStrokeColor = _FPDFText_GetStrokeColorPtr.asFunction< + int Function( + FPDF_TEXTPAGE, + int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + double FPDFText_GetCharAngle( + FPDF_TEXTPAGE text_page, + int index, + ) { + return _FPDFText_GetCharAngle( + text_page, + index, + ); + } + + late final _FPDFText_GetCharAnglePtr = + _lookup>( + 'FPDFText_GetCharAngle'); + late final _FPDFText_GetCharAngle = _FPDFText_GetCharAnglePtr.asFunction< + double Function(FPDF_TEXTPAGE, int)>(); + + int FPDFText_GetCharBox( + FPDF_TEXTPAGE text_page, + int index, + ffi.Pointer left, + ffi.Pointer right, + ffi.Pointer bottom, + ffi.Pointer top, + ) { + return _FPDFText_GetCharBox( + text_page, + index, + left, + right, + bottom, + top, + ); + } + + late final _FPDFText_GetCharBoxPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_TEXTPAGE, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('FPDFText_GetCharBox'); + late final _FPDFText_GetCharBox = _FPDFText_GetCharBoxPtr.asFunction< + int Function( + FPDF_TEXTPAGE, + int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + int FPDFText_GetLooseCharBox( + FPDF_TEXTPAGE text_page, + int index, + ffi.Pointer rect, + ) { + return _FPDFText_GetLooseCharBox( + text_page, + index, + rect, + ); + } + + late final _FPDFText_GetLooseCharBoxPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function(FPDF_TEXTPAGE, ffi.Int, + ffi.Pointer)>>('FPDFText_GetLooseCharBox'); + late final _FPDFText_GetLooseCharBox = _FPDFText_GetLooseCharBoxPtr + .asFunction)>(); + + int FPDFText_GetMatrix( + FPDF_TEXTPAGE text_page, + int index, + ffi.Pointer matrix, + ) { + return _FPDFText_GetMatrix( + text_page, + index, + matrix, + ); + } + + late final _FPDFText_GetMatrixPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function(FPDF_TEXTPAGE, ffi.Int, + ffi.Pointer)>>('FPDFText_GetMatrix'); + late final _FPDFText_GetMatrix = _FPDFText_GetMatrixPtr.asFunction< + int Function(FPDF_TEXTPAGE, int, ffi.Pointer)>(); + + int FPDFText_GetCharOrigin( + FPDF_TEXTPAGE text_page, + int index, + ffi.Pointer x, + ffi.Pointer y, + ) { + return _FPDFText_GetCharOrigin( + text_page, + index, + x, + y, + ); + } + + late final _FPDFText_GetCharOriginPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function(FPDF_TEXTPAGE, ffi.Int, ffi.Pointer, + ffi.Pointer)>>('FPDFText_GetCharOrigin'); + late final _FPDFText_GetCharOrigin = _FPDFText_GetCharOriginPtr.asFunction< + int Function(FPDF_TEXTPAGE, int, ffi.Pointer, + ffi.Pointer)>(); + + int FPDFText_GetCharIndexAtPos( + FPDF_TEXTPAGE text_page, + double x, + double y, + double xTolerance, + double yTolerance, + ) { + return _FPDFText_GetCharIndexAtPos( + text_page, + x, + y, + xTolerance, + yTolerance, + ); + } + + late final _FPDFText_GetCharIndexAtPosPtr = _lookup< + ffi.NativeFunction< + ffi.Int Function(FPDF_TEXTPAGE, ffi.Double, ffi.Double, ffi.Double, + ffi.Double)>>('FPDFText_GetCharIndexAtPos'); + late final _FPDFText_GetCharIndexAtPos = + _FPDFText_GetCharIndexAtPosPtr.asFunction< + int Function(FPDF_TEXTPAGE, double, double, double, double)>(); + + int FPDFText_GetText( + FPDF_TEXTPAGE text_page, + int start_index, + int count, + ffi.Pointer result, + ) { + return _FPDFText_GetText( + text_page, + start_index, + count, + result, + ); + } + + late final _FPDFText_GetTextPtr = _lookup< + ffi.NativeFunction< + ffi.Int Function(FPDF_TEXTPAGE, ffi.Int, ffi.Int, + ffi.Pointer)>>('FPDFText_GetText'); + late final _FPDFText_GetText = _FPDFText_GetTextPtr.asFunction< + int Function(FPDF_TEXTPAGE, int, int, ffi.Pointer)>(); + + int FPDFText_CountRects( + FPDF_TEXTPAGE text_page, + int start_index, + int count, + ) { + return _FPDFText_CountRects( + text_page, + start_index, + count, + ); + } + + late final _FPDFText_CountRectsPtr = _lookup< + ffi + .NativeFunction>( + 'FPDFText_CountRects'); + late final _FPDFText_CountRects = _FPDFText_CountRectsPtr.asFunction< + int Function(FPDF_TEXTPAGE, int, int)>(); + + int FPDFText_GetRect( + FPDF_TEXTPAGE text_page, + int rect_index, + ffi.Pointer left, + ffi.Pointer top, + ffi.Pointer right, + ffi.Pointer bottom, + ) { + return _FPDFText_GetRect( + text_page, + rect_index, + left, + top, + right, + bottom, + ); + } + + late final _FPDFText_GetRectPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_TEXTPAGE, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('FPDFText_GetRect'); + late final _FPDFText_GetRect = _FPDFText_GetRectPtr.asFunction< + int Function( + FPDF_TEXTPAGE, + int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + int FPDFText_GetBoundedText( + FPDF_TEXTPAGE text_page, + double left, + double top, + double right, + double bottom, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDFText_GetBoundedText( + text_page, + left, + top, + right, + bottom, + buffer, + buflen, + ); + } + + late final _FPDFText_GetBoundedTextPtr = _lookup< + ffi.NativeFunction< + ffi.Int Function( + FPDF_TEXTPAGE, + ffi.Double, + ffi.Double, + ffi.Double, + ffi.Double, + ffi.Pointer, + ffi.Int)>>('FPDFText_GetBoundedText'); + late final _FPDFText_GetBoundedText = _FPDFText_GetBoundedTextPtr.asFunction< + int Function(FPDF_TEXTPAGE, double, double, double, double, + ffi.Pointer, int)>(); + + FPDF_SCHHANDLE FPDFText_FindStart( + FPDF_TEXTPAGE text_page, + FPDF_WIDESTRING findwhat, + int flags, + int start_index, + ) { + return _FPDFText_FindStart( + text_page, + findwhat, + flags, + start_index, + ); + } + + late final _FPDFText_FindStartPtr = _lookup< + ffi.NativeFunction< + FPDF_SCHHANDLE Function(FPDF_TEXTPAGE, FPDF_WIDESTRING, + ffi.UnsignedLong, ffi.Int)>>('FPDFText_FindStart'); + late final _FPDFText_FindStart = _FPDFText_FindStartPtr.asFunction< + FPDF_SCHHANDLE Function(FPDF_TEXTPAGE, FPDF_WIDESTRING, int, int)>(); + + int FPDFText_FindNext( + FPDF_SCHHANDLE handle, + ) { + return _FPDFText_FindNext( + handle, + ); + } + + late final _FPDFText_FindNextPtr = + _lookup>( + 'FPDFText_FindNext'); + late final _FPDFText_FindNext = + _FPDFText_FindNextPtr.asFunction(); + + int FPDFText_FindPrev( + FPDF_SCHHANDLE handle, + ) { + return _FPDFText_FindPrev( + handle, + ); + } + + late final _FPDFText_FindPrevPtr = + _lookup>( + 'FPDFText_FindPrev'); + late final _FPDFText_FindPrev = + _FPDFText_FindPrevPtr.asFunction(); + + int FPDFText_GetSchResultIndex( + FPDF_SCHHANDLE handle, + ) { + return _FPDFText_GetSchResultIndex( + handle, + ); + } + + late final _FPDFText_GetSchResultIndexPtr = + _lookup>( + 'FPDFText_GetSchResultIndex'); + late final _FPDFText_GetSchResultIndex = + _FPDFText_GetSchResultIndexPtr.asFunction(); + + int FPDFText_GetSchCount( + FPDF_SCHHANDLE handle, + ) { + return _FPDFText_GetSchCount( + handle, + ); + } + + late final _FPDFText_GetSchCountPtr = + _lookup>( + 'FPDFText_GetSchCount'); + late final _FPDFText_GetSchCount = + _FPDFText_GetSchCountPtr.asFunction(); + + void FPDFText_FindClose( + FPDF_SCHHANDLE handle, + ) { + return _FPDFText_FindClose( + handle, + ); + } + + late final _FPDFText_FindClosePtr = + _lookup>( + 'FPDFText_FindClose'); + late final _FPDFText_FindClose = + _FPDFText_FindClosePtr.asFunction(); + + FPDF_PAGELINK FPDFLink_LoadWebLinks( + FPDF_TEXTPAGE text_page, + ) { + return _FPDFLink_LoadWebLinks( + text_page, + ); + } + + late final _FPDFLink_LoadWebLinksPtr = + _lookup>( + 'FPDFLink_LoadWebLinks'); + late final _FPDFLink_LoadWebLinks = _FPDFLink_LoadWebLinksPtr.asFunction< + FPDF_PAGELINK Function(FPDF_TEXTPAGE)>(); + + int FPDFLink_CountWebLinks( + FPDF_PAGELINK link_page, + ) { + return _FPDFLink_CountWebLinks( + link_page, + ); + } + + late final _FPDFLink_CountWebLinksPtr = + _lookup>( + 'FPDFLink_CountWebLinks'); + late final _FPDFLink_CountWebLinks = + _FPDFLink_CountWebLinksPtr.asFunction(); + + int FPDFLink_GetURL( + FPDF_PAGELINK link_page, + int link_index, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDFLink_GetURL( + link_page, + link_index, + buffer, + buflen, + ); + } + + late final _FPDFLink_GetURLPtr = _lookup< + ffi.NativeFunction< + ffi.Int Function(FPDF_PAGELINK, ffi.Int, + ffi.Pointer, ffi.Int)>>('FPDFLink_GetURL'); + late final _FPDFLink_GetURL = _FPDFLink_GetURLPtr.asFunction< + int Function(FPDF_PAGELINK, int, ffi.Pointer, int)>(); + + int FPDFLink_CountRects( + FPDF_PAGELINK link_page, + int link_index, + ) { + return _FPDFLink_CountRects( + link_page, + link_index, + ); + } + + late final _FPDFLink_CountRectsPtr = + _lookup>( + 'FPDFLink_CountRects'); + late final _FPDFLink_CountRects = + _FPDFLink_CountRectsPtr.asFunction(); + + int FPDFLink_GetRect( + FPDF_PAGELINK link_page, + int link_index, + int rect_index, + ffi.Pointer left, + ffi.Pointer top, + ffi.Pointer right, + ffi.Pointer bottom, + ) { + return _FPDFLink_GetRect( + link_page, + link_index, + rect_index, + left, + top, + right, + bottom, + ); + } + + late final _FPDFLink_GetRectPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_PAGELINK, + ffi.Int, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('FPDFLink_GetRect'); + late final _FPDFLink_GetRect = _FPDFLink_GetRectPtr.asFunction< + int Function( + FPDF_PAGELINK, + int, + int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + int FPDFLink_GetTextRange( + FPDF_PAGELINK link_page, + int link_index, + ffi.Pointer start_char_index, + ffi.Pointer char_count, + ) { + return _FPDFLink_GetTextRange( + link_page, + link_index, + start_char_index, + char_count, + ); + } + + late final _FPDFLink_GetTextRangePtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function(FPDF_PAGELINK, ffi.Int, ffi.Pointer, + ffi.Pointer)>>('FPDFLink_GetTextRange'); + late final _FPDFLink_GetTextRange = _FPDFLink_GetTextRangePtr.asFunction< + int Function( + FPDF_PAGELINK, int, ffi.Pointer, ffi.Pointer)>(); + + void FPDFLink_CloseWebLinks( + FPDF_PAGELINK link_page, + ) { + return _FPDFLink_CloseWebLinks( + link_page, + ); + } + + late final _FPDFLink_CloseWebLinksPtr = + _lookup>( + 'FPDFLink_CloseWebLinks'); + late final _FPDFLink_CloseWebLinks = + _FPDFLink_CloseWebLinksPtr.asFunction(); + + FPDF_BOOKMARK FPDFBookmark_GetFirstChild( + FPDF_DOCUMENT document, + FPDF_BOOKMARK bookmark, + ) { + return _FPDFBookmark_GetFirstChild( + document, + bookmark, + ); + } + + late final _FPDFBookmark_GetFirstChildPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOKMARK Function( + FPDF_DOCUMENT, FPDF_BOOKMARK)>>('FPDFBookmark_GetFirstChild'); + late final _FPDFBookmark_GetFirstChild = _FPDFBookmark_GetFirstChildPtr + .asFunction(); + + FPDF_BOOKMARK FPDFBookmark_GetNextSibling( + FPDF_DOCUMENT document, + FPDF_BOOKMARK bookmark, + ) { + return _FPDFBookmark_GetNextSibling( + document, + bookmark, + ); + } + + late final _FPDFBookmark_GetNextSiblingPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOKMARK Function( + FPDF_DOCUMENT, FPDF_BOOKMARK)>>('FPDFBookmark_GetNextSibling'); + late final _FPDFBookmark_GetNextSibling = _FPDFBookmark_GetNextSiblingPtr + .asFunction(); + + int FPDFBookmark_GetTitle( + FPDF_BOOKMARK bookmark, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDFBookmark_GetTitle( + bookmark, + buffer, + buflen, + ); + } + + late final _FPDFBookmark_GetTitlePtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function(FPDF_BOOKMARK, ffi.Pointer, + ffi.UnsignedLong)>>('FPDFBookmark_GetTitle'); + late final _FPDFBookmark_GetTitle = _FPDFBookmark_GetTitlePtr.asFunction< + int Function(FPDF_BOOKMARK, ffi.Pointer, int)>(); + + int FPDFBookmark_GetCount( + FPDF_BOOKMARK bookmark, + ) { + return _FPDFBookmark_GetCount( + bookmark, + ); + } + + late final _FPDFBookmark_GetCountPtr = + _lookup>( + 'FPDFBookmark_GetCount'); + late final _FPDFBookmark_GetCount = + _FPDFBookmark_GetCountPtr.asFunction(); + + FPDF_BOOKMARK FPDFBookmark_Find( + FPDF_DOCUMENT document, + FPDF_WIDESTRING title, + ) { + return _FPDFBookmark_Find( + document, + title, + ); + } + + late final _FPDFBookmark_FindPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOKMARK Function( + FPDF_DOCUMENT, FPDF_WIDESTRING)>>('FPDFBookmark_Find'); + late final _FPDFBookmark_Find = _FPDFBookmark_FindPtr.asFunction< + FPDF_BOOKMARK Function(FPDF_DOCUMENT, FPDF_WIDESTRING)>(); + + FPDF_DEST FPDFBookmark_GetDest( + FPDF_DOCUMENT document, + FPDF_BOOKMARK bookmark, + ) { + return _FPDFBookmark_GetDest( + document, + bookmark, + ); + } + + late final _FPDFBookmark_GetDestPtr = _lookup< + ffi.NativeFunction>( + 'FPDFBookmark_GetDest'); + late final _FPDFBookmark_GetDest = _FPDFBookmark_GetDestPtr.asFunction< + FPDF_DEST Function(FPDF_DOCUMENT, FPDF_BOOKMARK)>(); + + FPDF_ACTION FPDFBookmark_GetAction( + FPDF_BOOKMARK bookmark, + ) { + return _FPDFBookmark_GetAction( + bookmark, + ); + } + + late final _FPDFBookmark_GetActionPtr = + _lookup>( + 'FPDFBookmark_GetAction'); + late final _FPDFBookmark_GetAction = _FPDFBookmark_GetActionPtr.asFunction< + FPDF_ACTION Function(FPDF_BOOKMARK)>(); + + int FPDFAction_GetType( + FPDF_ACTION action, + ) { + return _FPDFAction_GetType( + action, + ); + } + + late final _FPDFAction_GetTypePtr = + _lookup>( + 'FPDFAction_GetType'); + late final _FPDFAction_GetType = + _FPDFAction_GetTypePtr.asFunction(); + + FPDF_DEST FPDFAction_GetDest( + FPDF_DOCUMENT document, + FPDF_ACTION action, + ) { + return _FPDFAction_GetDest( + document, + action, + ); + } + + late final _FPDFAction_GetDestPtr = _lookup< + ffi.NativeFunction>( + 'FPDFAction_GetDest'); + late final _FPDFAction_GetDest = _FPDFAction_GetDestPtr.asFunction< + FPDF_DEST Function(FPDF_DOCUMENT, FPDF_ACTION)>(); + + int FPDFAction_GetFilePath( + FPDF_ACTION action, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDFAction_GetFilePath( + action, + buffer, + buflen, + ); + } + + late final _FPDFAction_GetFilePathPtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function(FPDF_ACTION, ffi.Pointer, + ffi.UnsignedLong)>>('FPDFAction_GetFilePath'); + late final _FPDFAction_GetFilePath = _FPDFAction_GetFilePathPtr.asFunction< + int Function(FPDF_ACTION, ffi.Pointer, int)>(); + + int FPDFAction_GetURIPath( + FPDF_DOCUMENT document, + FPDF_ACTION action, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDFAction_GetURIPath( + document, + action, + buffer, + buflen, + ); + } + + late final _FPDFAction_GetURIPathPtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + FPDF_DOCUMENT, + FPDF_ACTION, + ffi.Pointer, + ffi.UnsignedLong)>>('FPDFAction_GetURIPath'); + late final _FPDFAction_GetURIPath = _FPDFAction_GetURIPathPtr.asFunction< + int Function(FPDF_DOCUMENT, FPDF_ACTION, ffi.Pointer, int)>(); + + int FPDFDest_GetDestPageIndex( + FPDF_DOCUMENT document, + FPDF_DEST dest, + ) { + return _FPDFDest_GetDestPageIndex( + document, + dest, + ); + } + + late final _FPDFDest_GetDestPageIndexPtr = + _lookup>( + 'FPDFDest_GetDestPageIndex'); + late final _FPDFDest_GetDestPageIndex = _FPDFDest_GetDestPageIndexPtr + .asFunction(); + + int FPDFDest_GetView( + FPDF_DEST dest, + ffi.Pointer pNumParams, + ffi.Pointer pParams, + ) { + return _FPDFDest_GetView( + dest, + pNumParams, + pParams, + ); + } + + late final _FPDFDest_GetViewPtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function(FPDF_DEST, ffi.Pointer, + ffi.Pointer)>>('FPDFDest_GetView'); + late final _FPDFDest_GetView = _FPDFDest_GetViewPtr.asFunction< + int Function( + FPDF_DEST, ffi.Pointer, ffi.Pointer)>(); + + int FPDFDest_GetLocationInPage( + FPDF_DEST dest, + ffi.Pointer hasXVal, + ffi.Pointer hasYVal, + ffi.Pointer hasZoomVal, + ffi.Pointer x, + ffi.Pointer y, + ffi.Pointer zoom, + ) { + return _FPDFDest_GetLocationInPage( + dest, + hasXVal, + hasYVal, + hasZoomVal, + x, + y, + zoom, + ); + } + + late final _FPDFDest_GetLocationInPagePtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_DEST, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>>('FPDFDest_GetLocationInPage'); + late final _FPDFDest_GetLocationInPage = + _FPDFDest_GetLocationInPagePtr.asFunction< + int Function( + FPDF_DEST, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>(); + + FPDF_LINK FPDFLink_GetLinkAtPoint( + FPDF_PAGE page, + double x, + double y, + ) { + return _FPDFLink_GetLinkAtPoint( + page, + x, + y, + ); + } + + late final _FPDFLink_GetLinkAtPointPtr = _lookup< + ffi.NativeFunction< + FPDF_LINK Function( + FPDF_PAGE, ffi.Double, ffi.Double)>>('FPDFLink_GetLinkAtPoint'); + late final _FPDFLink_GetLinkAtPoint = _FPDFLink_GetLinkAtPointPtr.asFunction< + FPDF_LINK Function(FPDF_PAGE, double, double)>(); + + int FPDFLink_GetLinkZOrderAtPoint( + FPDF_PAGE page, + double x, + double y, + ) { + return _FPDFLink_GetLinkZOrderAtPoint( + page, + x, + y, + ); + } + + late final _FPDFLink_GetLinkZOrderAtPointPtr = _lookup< + ffi + .NativeFunction>( + 'FPDFLink_GetLinkZOrderAtPoint'); + late final _FPDFLink_GetLinkZOrderAtPoint = _FPDFLink_GetLinkZOrderAtPointPtr + .asFunction(); + + FPDF_DEST FPDFLink_GetDest( + FPDF_DOCUMENT document, + FPDF_LINK link, + ) { + return _FPDFLink_GetDest( + document, + link, + ); + } + + late final _FPDFLink_GetDestPtr = + _lookup>( + 'FPDFLink_GetDest'); + late final _FPDFLink_GetDest = _FPDFLink_GetDestPtr.asFunction< + FPDF_DEST Function(FPDF_DOCUMENT, FPDF_LINK)>(); + + FPDF_ACTION FPDFLink_GetAction( + FPDF_LINK link, + ) { + return _FPDFLink_GetAction( + link, + ); + } + + late final _FPDFLink_GetActionPtr = + _lookup>( + 'FPDFLink_GetAction'); + late final _FPDFLink_GetAction = + _FPDFLink_GetActionPtr.asFunction(); + + int FPDFLink_Enumerate( + FPDF_PAGE page, + ffi.Pointer start_pos, + ffi.Pointer link_annot, + ) { + return _FPDFLink_Enumerate( + page, + start_pos, + link_annot, + ); + } + + late final _FPDFLink_EnumeratePtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function(FPDF_PAGE, ffi.Pointer, + ffi.Pointer)>>('FPDFLink_Enumerate'); + late final _FPDFLink_Enumerate = _FPDFLink_EnumeratePtr.asFunction< + int Function(FPDF_PAGE, ffi.Pointer, ffi.Pointer)>(); + + FPDF_ANNOTATION FPDFLink_GetAnnot( + FPDF_PAGE page, + FPDF_LINK link_annot, + ) { + return _FPDFLink_GetAnnot( + page, + link_annot, + ); + } + + late final _FPDFLink_GetAnnotPtr = _lookup< + ffi.NativeFunction>( + 'FPDFLink_GetAnnot'); + late final _FPDFLink_GetAnnot = _FPDFLink_GetAnnotPtr.asFunction< + FPDF_ANNOTATION Function(FPDF_PAGE, FPDF_LINK)>(); + + int FPDFLink_GetAnnotRect( + FPDF_LINK link_annot, + ffi.Pointer rect, + ) { + return _FPDFLink_GetAnnotRect( + link_annot, + rect, + ); + } + + late final _FPDFLink_GetAnnotRectPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function( + FPDF_LINK, ffi.Pointer)>>('FPDFLink_GetAnnotRect'); + late final _FPDFLink_GetAnnotRect = _FPDFLink_GetAnnotRectPtr.asFunction< + int Function(FPDF_LINK, ffi.Pointer)>(); + + int FPDFLink_CountQuadPoints( + FPDF_LINK link_annot, + ) { + return _FPDFLink_CountQuadPoints( + link_annot, + ); + } + + late final _FPDFLink_CountQuadPointsPtr = + _lookup>( + 'FPDFLink_CountQuadPoints'); + late final _FPDFLink_CountQuadPoints = + _FPDFLink_CountQuadPointsPtr.asFunction(); + + int FPDFLink_GetQuadPoints( + FPDF_LINK link_annot, + int quad_index, + ffi.Pointer quad_points, + ) { + return _FPDFLink_GetQuadPoints( + link_annot, + quad_index, + quad_points, + ); + } + + late final _FPDFLink_GetQuadPointsPtr = _lookup< + ffi.NativeFunction< + FPDF_BOOL Function(FPDF_LINK, ffi.Int, + ffi.Pointer)>>('FPDFLink_GetQuadPoints'); + late final _FPDFLink_GetQuadPoints = _FPDFLink_GetQuadPointsPtr.asFunction< + int Function(FPDF_LINK, int, ffi.Pointer)>(); + + FPDF_ACTION FPDF_GetPageAAction( + FPDF_PAGE page, + int aa_type, + ) { + return _FPDF_GetPageAAction( + page, + aa_type, + ); + } + + late final _FPDF_GetPageAActionPtr = + _lookup>( + 'FPDF_GetPageAAction'); + late final _FPDF_GetPageAAction = _FPDF_GetPageAActionPtr.asFunction< + FPDF_ACTION Function(FPDF_PAGE, int)>(); + + int FPDF_GetFileIdentifier( + FPDF_DOCUMENT document, + int id_type, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDF_GetFileIdentifier( + document, + id_type, + buffer, + buflen, + ); + } + + late final _FPDF_GetFileIdentifierPtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function( + FPDF_DOCUMENT, + ffi.Int32, + ffi.Pointer, + ffi.UnsignedLong)>>('FPDF_GetFileIdentifier'); + late final _FPDF_GetFileIdentifier = _FPDF_GetFileIdentifierPtr.asFunction< + int Function(FPDF_DOCUMENT, int, ffi.Pointer, int)>(); + + int FPDF_GetMetaText( + FPDF_DOCUMENT document, + FPDF_BYTESTRING tag, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDF_GetMetaText( + document, + tag, + buffer, + buflen, + ); + } + + late final _FPDF_GetMetaTextPtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function(FPDF_DOCUMENT, FPDF_BYTESTRING, + ffi.Pointer, ffi.UnsignedLong)>>('FPDF_GetMetaText'); + late final _FPDF_GetMetaText = _FPDF_GetMetaTextPtr.asFunction< + int Function( + FPDF_DOCUMENT, FPDF_BYTESTRING, ffi.Pointer, int)>(); + + int FPDF_GetPageLabel( + FPDF_DOCUMENT document, + int page_index, + ffi.Pointer buffer, + int buflen, + ) { + return _FPDF_GetPageLabel( + document, + page_index, + buffer, + buflen, + ); + } + + late final _FPDF_GetPageLabelPtr = _lookup< + ffi.NativeFunction< + ffi.UnsignedLong Function(FPDF_DOCUMENT, ffi.Int, + ffi.Pointer, ffi.UnsignedLong)>>('FPDF_GetPageLabel'); + late final _FPDF_GetPageLabel = _FPDF_GetPageLabelPtr.asFunction< + int Function(FPDF_DOCUMENT, int, ffi.Pointer, int)>(); } abstract class FPDF_TEXT_RENDERMODE { @@ -1266,6 +3660,38 @@ typedef FS_MATRIX = _FS_MATRIX_; typedef FPDF_PAGERANGE = ffi.Pointer; typedef FPDF_DEST = ffi.Pointer; +abstract class FPDFANNOT_COLORTYPE { + static const int FPDFANNOT_COLORTYPE_Color = 0; + static const int FPDFANNOT_COLORTYPE_InteriorColor = 1; +} + +typedef FPDF_ANNOTATION_SUBTYPE = ffi.Int; +typedef DartFPDF_ANNOTATION_SUBTYPE = int; +typedef FPDF_ANNOTATION = ffi.Pointer; +typedef FPDF_PAGEOBJECT = ffi.Pointer; +typedef FS_POINTF = FS_POINTF_; +typedef FS_QUADPOINTSF = _FS_QUADPOINTSF; +typedef FPDF_FORMHANDLE = ffi.Pointer; +typedef FPDF_WCHAR = ffi.UnsignedShort; +typedef DartFPDF_WCHAR = int; +typedef FPDF_OBJECT_TYPE = ffi.Int; +typedef DartFPDF_OBJECT_TYPE = int; +typedef FPDF_WIDESTRING = ffi.Pointer; +typedef FPDF_ANNOT_APPEARANCEMODE = ffi.Int; +typedef DartFPDF_ANNOT_APPEARANCEMODE = int; +typedef FPDF_LINK = ffi.Pointer; +typedef FPDF_TEXTPAGE = ffi.Pointer; +typedef FPDF_SCHHANDLE = ffi.Pointer; +typedef FPDF_PAGELINK = ffi.Pointer; + +abstract class FPDF_FILEIDTYPE { + static const int FILEIDTYPE_PERMANENT = 0; + static const int FILEIDTYPE_CHANGING = 1; +} + +typedef FPDF_BOOKMARK = ffi.Pointer; +typedef FPDF_ACTION = ffi.Pointer; + const int FPDF_OBJECT_UNKNOWN = 0; const int FPDF_OBJECT_BOOLEAN = 1; @@ -1339,3 +3765,151 @@ const int FPDFBitmap_BGR = 2; const int FPDFBitmap_BGRx = 3; const int FPDFBitmap_BGRA = 4; + +const int FPDF_ANNOT_UNKNOWN = 0; + +const int FPDF_ANNOT_TEXT = 1; + +const int FPDF_ANNOT_LINK = 2; + +const int FPDF_ANNOT_FREETEXT = 3; + +const int FPDF_ANNOT_LINE = 4; + +const int FPDF_ANNOT_SQUARE = 5; + +const int FPDF_ANNOT_CIRCLE = 6; + +const int FPDF_ANNOT_POLYGON = 7; + +const int FPDF_ANNOT_POLYLINE = 8; + +const int FPDF_ANNOT_HIGHLIGHT = 9; + +const int FPDF_ANNOT_UNDERLINE = 10; + +const int FPDF_ANNOT_SQUIGGLY = 11; + +const int FPDF_ANNOT_STRIKEOUT = 12; + +const int FPDF_ANNOT_STAMP = 13; + +const int FPDF_ANNOT_CARET = 14; + +const int FPDF_ANNOT_INK = 15; + +const int FPDF_ANNOT_POPUP = 16; + +const int FPDF_ANNOT_FILEATTACHMENT = 17; + +const int FPDF_ANNOT_SOUND = 18; + +const int FPDF_ANNOT_MOVIE = 19; + +const int FPDF_ANNOT_WIDGET = 20; + +const int FPDF_ANNOT_SCREEN = 21; + +const int FPDF_ANNOT_PRINTERMARK = 22; + +const int FPDF_ANNOT_TRAPNET = 23; + +const int FPDF_ANNOT_WATERMARK = 24; + +const int FPDF_ANNOT_THREED = 25; + +const int FPDF_ANNOT_RICHMEDIA = 26; + +const int FPDF_ANNOT_XFAWIDGET = 27; + +const int FPDF_ANNOT_REDACT = 28; + +const int FPDF_ANNOT_FLAG_NONE = 0; + +const int FPDF_ANNOT_FLAG_INVISIBLE = 1; + +const int FPDF_ANNOT_FLAG_HIDDEN = 2; + +const int FPDF_ANNOT_FLAG_PRINT = 4; + +const int FPDF_ANNOT_FLAG_NOZOOM = 8; + +const int FPDF_ANNOT_FLAG_NOROTATE = 16; + +const int FPDF_ANNOT_FLAG_NOVIEW = 32; + +const int FPDF_ANNOT_FLAG_READONLY = 64; + +const int FPDF_ANNOT_FLAG_LOCKED = 128; + +const int FPDF_ANNOT_FLAG_TOGGLENOVIEW = 256; + +const int FPDF_ANNOT_APPEARANCEMODE_NORMAL = 0; + +const int FPDF_ANNOT_APPEARANCEMODE_ROLLOVER = 1; + +const int FPDF_ANNOT_APPEARANCEMODE_DOWN = 2; + +const int FPDF_ANNOT_APPEARANCEMODE_COUNT = 3; + +const int FPDF_FORMFLAG_NONE = 0; + +const int FPDF_FORMFLAG_READONLY = 1; + +const int FPDF_FORMFLAG_REQUIRED = 2; + +const int FPDF_FORMFLAG_NOEXPORT = 4; + +const int FPDF_FORMFLAG_TEXT_MULTILINE = 4096; + +const int FPDF_FORMFLAG_TEXT_PASSWORD = 8192; + +const int FPDF_FORMFLAG_CHOICE_COMBO = 131072; + +const int FPDF_FORMFLAG_CHOICE_EDIT = 262144; + +const int FPDF_FORMFLAG_CHOICE_MULTI_SELECT = 2097152; + +const int FPDF_ANNOT_AACTION_KEY_STROKE = 12; + +const int FPDF_ANNOT_AACTION_FORMAT = 13; + +const int FPDF_ANNOT_AACTION_VALIDATE = 14; + +const int FPDF_ANNOT_AACTION_CALCULATE = 15; + +const int FPDF_MATCHCASE = 1; + +const int FPDF_MATCHWHOLEWORD = 2; + +const int FPDF_CONSECUTIVE = 4; + +const int PDFACTION_UNSUPPORTED = 0; + +const int PDFACTION_GOTO = 1; + +const int PDFACTION_REMOTEGOTO = 2; + +const int PDFACTION_URI = 3; + +const int PDFACTION_LAUNCH = 4; + +const int PDFACTION_EMBEDDEDGOTO = 5; + +const int PDFDEST_VIEW_UNKNOWN_MODE = 0; + +const int PDFDEST_VIEW_XYZ = 1; + +const int PDFDEST_VIEW_FIT = 2; + +const int PDFDEST_VIEW_FITH = 3; + +const int PDFDEST_VIEW_FITV = 4; + +const int PDFDEST_VIEW_FITR = 5; + +const int PDFDEST_VIEW_FITB = 6; + +const int PDFDEST_VIEW_FITBH = 7; + +const int PDFDEST_VIEW_FITBV = 8; diff --git a/lib/src/pdfium/pdfrx_pdfium.dart b/lib/src/pdfium/pdfrx_pdfium.dart index 52fa6f8..776e305 100644 --- a/lib/src/pdfium/pdfrx_pdfium.dart +++ b/lib/src/pdfium/pdfrx_pdfium.dart @@ -56,10 +56,16 @@ class PdfDocumentFactoryImpl extends PdfDocumentFactory { } @override - Future openData(Uint8List data, {String? password}) => _openData( + Future openData( + Uint8List data, { + String? password, + void Function()? onDispose, + }) => + _openData( data, 'memory-${data.hashCode}', password: password, + onDispose: onDispose, ); @override @@ -79,6 +85,7 @@ class PdfDocumentFactoryImpl extends PdfDocumentFactory { String sourceName, { String? password, int? maxSizeToCacheOnMemory, + void Function()? onDispose, }) async { _init(); return openCustom( @@ -94,7 +101,9 @@ class PdfDocumentFactoryImpl extends PdfDocumentFactory { }, fileSize: data.length, sourceName: sourceName, + password: password, maxSizeToCacheOnMemory: maxSizeToCacheOnMemory, + onDispose: onDispose, ); } @@ -106,6 +115,7 @@ class PdfDocumentFactoryImpl extends PdfDocumentFactory { required String sourceName, String? password, int? maxSizeToCacheOnMemory, + void Function()? onDispose, }) async { _init(); @@ -123,7 +133,10 @@ class PdfDocumentFactoryImpl extends PdfDocumentFactory { password?.toUtf8(arena) ?? nullptr, ), sourceName: sourceName, - disposeCallback: () => calloc.free(buffer), + disposeCallback: () { + calloc.free(buffer); + onDispose?.call(); + }, ); }); } @@ -146,7 +159,10 @@ class PdfDocumentFactoryImpl extends PdfDocumentFactory { return PdfDocumentPdfium.fromPdfDocument( pdfium_bindings.FPDF_DOCUMENT.fromAddress(doc), sourceName: sourceName, - disposeCallback: () => fa.dispose(), + disposeCallback: () { + fa.dispose(); + onDispose?.call(); + }, ); } } @@ -340,6 +356,21 @@ class PdfPagePdfium extends PdfPage { buffer: buffer, ); } + + @override + Future loadText() async { + return await document.synchronized(() { + final textPage = pdfium.FPDFText_LoadPage(page); + final charCount = pdfium.FPDFText_CountChars(textPage); + return textPage.address == 0 + ? null + : PdfPageTextPdfium( + page: this, + textPage: textPage, + charCount: charCount, + ); + }); + } } class PdfImagePdfium extends PdfImage { @@ -365,3 +396,227 @@ class PdfImagePdfium extends PdfImage { calloc.free(_buffer); } } + +class PdfPageTextPdfium extends PdfPageText { + final PdfPagePdfium page; + final pdfium_bindings.FPDF_TEXTPAGE textPage; + + PdfPageTextPdfium({ + required this.page, + required this.textPage, + required this.charCount, + }); + + @override + Future dispose() { + return page.document + .synchronized(() => pdfium.FPDFText_ClosePage(textPage)); + } + + @override + final int charCount; + + @override + Future getChars({PdfPageTextRange? range}) { + range ??= fullRange; + return page.document.synchronized( + () => using( + (arena) { + final buffer = arena.allocate(range!.count * 2); + pdfium.FPDFText_GetText( + textPage, range.start, range.count, buffer.cast()); + return String.fromCharCodes(buffer.asTypedList(range.count)); + }, + ), + ); + } + + /// Get the font size of the text in the specified range. + /// The font size of the particular character, measured in points (about 1/72 inch). + /// This is the typographic size of the font (so called "em size"). + Future> getFontSizes({PdfPageTextRange? range}) { + range ??= fullRange; + return page.document.synchronized(() => List.generate( + range!.count, + (index) => + pdfium.FPDFText_GetFontSize(textPage, range!.start + index))); + } + + @override + Future> getCharBoxes({PdfPageTextRange? range}) { + range ??= fullRange; + return page.document.synchronized( + () => using( + (arena) { + final buffer = arena.allocate(4 * 8); + return List.generate( + range!.count, + (index) { + pdfium.FPDFText_GetCharBox( + textPage, + range!.start + index, + buffer, + buffer.offset(8), + buffer.offset(16), + buffer.offset(24), + ); + return _rectFromPointer(buffer); + }, + ); + }, + ), + ); + } + + @override + Future getRectCount({PdfPageTextRange? range}) { + range ??= fullRange; + return page.document.synchronized( + () => pdfium.FPDFText_CountRects(textPage, range!.start, range.count)); + } + + @override + Future> getRects({PdfPageTextRange? range}) { + range ??= fullRange; + return page.document.synchronized( + () => using( + (arena) { + final rectBuffer = arena.allocate(4 * 8); + return List.generate( + range!.count, + (index) { + pdfium.FPDFText_GetRect( + textPage, + range!.start + index, + rectBuffer, + rectBuffer.offset(8), + rectBuffer.offset(16), + rectBuffer.offset(24), + ); + return _rectFromPointer(rectBuffer); + }, + ); + }, + ), + ); + } + + @override + Future getBoundedText(PdfRect rect) => page.document.synchronized( + () => using( + (arena) { + final count = pdfium.FPDFText_GetBoundedText( + textPage, + rect.left, + rect.bottom, + rect.right, + rect.top, + nullptr, + 0, + ); + + final buffer = arena.allocate(count * 2); + pdfium.FPDFText_GetBoundedText( + textPage, + rect.left, + rect.bottom, + rect.right, + rect.top, + buffer, + count, + ); + return String.fromCharCodes( + buffer.cast().asTypedList(count)); + }, + ), + ); + + @override + Future> getLinks() async { + return await page.document.synchronized(() { + final linkPage = pdfium.FPDFLink_LoadWebLinks(textPage); + try { + return using((arena) { + final rectBuffer = arena.allocate(4 * 8); + return List.generate( + pdfium.FPDFLink_CountWebLinks(linkPage), + (index) { + return PdfLink( + _getLinkUrl(arena, linkPage, index), + List.generate( + pdfium.FPDFLink_CountRects(linkPage, index), + (rectIndex) { + pdfium.FPDFLink_GetRect( + linkPage, + index, + rectIndex, + rectBuffer, + rectBuffer.offset(8), + rectBuffer.offset(16), + rectBuffer.offset(24), + ); + return _rectFromPointer(rectBuffer); + }, + ), + ); + }, + ); + }); + } finally { + pdfium.FPDFLink_CloseWebLinks(linkPage); + } + }); + } + + String _getLinkUrl( + Allocator alloc, pdfium_bindings.FPDF_PAGELINK linkPage, int linkIndex) { + final urlLength = pdfium.FPDFLink_GetURL(linkPage, linkIndex, nullptr, 0); + final urlBuffer = alloc.allocate(urlLength * 2); + pdfium.FPDFLink_GetURL(linkPage, linkIndex, urlBuffer, urlLength); + return String.fromCharCodes( + urlBuffer.cast().asTypedList(urlLength)); + } + + @override + Future> findText( + String text, { + bool matchCase = false, + bool wholeWord = false, + }) => + page.document.synchronized( + () { + return using( + (arena) { + final search = pdfium.FPDFText_FindStart( + textPage, + text.toNativeUtf16(allocator: arena).cast(), + (matchCase ? 1 : 0) | (wholeWord ? 2 : 0), + 0, + ); + try { + final matches = []; + do { + matches.add( + PdfPageTextRange( + pdfium.FPDFText_GetSchResultIndex(search), + pdfium.FPDFText_GetSchCount(search), + ), + ); + } while (pdfium.FPDFText_FindNext(search) != 0); + return matches; + } finally { + pdfium.FPDFText_FindClose(search); + } + }, + ); + }, + ); +} + +PdfRect _rectFromPointer(Pointer buffer) => + PdfRect(buffer[0], buffer[3], buffer[2], buffer[3]); + +extension _PointerExt on Pointer { + Pointer offset(int offsetInBytes) => + Pointer.fromAddress(address + offsetInBytes); +} diff --git a/lib/src/pdfrx_api.dart b/lib/src/pdfrx_api.dart index ee88a28..121e21a 100644 --- a/lib/src/pdfrx_api.dart +++ b/lib/src/pdfrx_api.dart @@ -9,7 +9,11 @@ import 'pdfium/pdfrx_pdfium.dart' if (dart.library.js) 'web/pdfrx_web.dart'; /// For platform abstraction purpose; use [PdfDocument] instead. abstract class PdfDocumentFactory { Future openAsset(String name, {String? password}); - Future openData(Uint8List data, {String? password}); + Future openData( + Uint8List data, { + String? password, + void Function()? onDispose, + }); Future openFile(String filePath, {String? password}); Future openCustom({ required FutureOr Function(Uint8List buffer, int position, int size) @@ -18,6 +22,7 @@ abstract class PdfDocumentFactory { required String sourceName, String? password, int? maxSizeToCacheOnMemory, + void Function()? onDispose, }); static PdfDocumentFactory instance = PdfDocumentFactoryImpl(); @@ -60,8 +65,16 @@ abstract class PdfDocument { PdfDocumentFactory.instance.openAsset(name, password: password); /// Opening the PDF on memory. - static Future openData(Uint8List data, {String? password}) => - PdfDocumentFactory.instance.openData(data, password: password); + static Future openData( + Uint8List data, { + String? password, + void Function()? onDispose, + }) => + PdfDocumentFactory.instance.openData( + data, + password: password, + onDispose: onDispose, + ); /// Opening the PDF from custom source. /// [maxSizeToCacheOnMemory] is the maximum size of the PDF to cache on memory in bytes; the custom loading process @@ -74,12 +87,15 @@ abstract class PdfDocument { required String sourceName, String? password, int? maxSizeToCacheOnMemory, + void Function()? onDispose, }) => PdfDocumentFactory.instance.openCustom( read: read, fileSize: fileSize, sourceName: sourceName, password: password, + maxSizeToCacheOnMemory: maxSizeToCacheOnMemory, + onDispose: onDispose, ); /// Get page object. The first page is 1. @@ -116,6 +132,10 @@ abstract class PdfPage { double? fullHeight, Color? backgroundColor, }); + + /// Create Text object to extract text from the page. + /// The returned object should be disposed after use. + Future loadText(); } /// Image rendered from PDF page. @@ -143,3 +163,98 @@ abstract class PdfImage { return comp.future; } } + +abstract class PdfPageText { + /// Dispose the text object. + Future dispose(); + + /// Get number of characters in the page. + int get charCount; + + /// Get full character index range of the text. + PdfPageTextRange get fullRange => PdfPageTextRange(0, charCount); + + /// Get UTF-16 code units of the text in the specified range. + Future getChars({PdfPageTextRange? range}); + + /// Get bounding box of the text in the specified range. + /// All positions are measured in PDF "user space". + Future> getCharBoxes({PdfPageTextRange? range}); + + /// Count number of rectangular areas occupied by a segment of texts. + /// This function, along with FPDFText_GetRect can be used by applications + /// to detect the position on the page for a text segment, so proper areas + /// can be highlighted or something. It will automatically merge small + /// character boxes into bigger one if those characters are on the same + /// line and use same font settings. + Future getRectCount({PdfPageTextRange? range}); + + /// Extract unicode text within a rectangular boundary on the page. + Future> getRects({PdfPageTextRange? range}); + + /// Extract unicode text within a rectangular boundary on the page. + Future getBoundedText(PdfRect rect); + + /// Get links in the page. + Future> getLinks(); + + /// Find text in the page. + Future> findText( + String text, { + bool matchCase = false, + bool wholeWord = false, + }); +} + +@immutable +class PdfPageTextRange { + const PdfPageTextRange(this.start, this.count); + final int start; + final int count; + + int get end => start + count; +} + +@immutable +class PdfRect { + const PdfRect(this.left, this.top, this.right, this.bottom); + final double left; + final double top; + final double right; + final double bottom; + + bool get isEmpty => left == right || top == bottom; + bool get isNotEmpty => !isEmpty; + + PdfRect merge(PdfRect other) { + return PdfRect( + left < other.left ? left : other.left, + top < other.top ? top : other.top, + right > other.right ? right : other.right, + bottom > other.bottom ? bottom : other.bottom, + ); + } + + static const empty = PdfRect(0, 0, 0, 0); +} + +extension PdfRectsExt on Iterable { + PdfRect boundingRect() { + final it = iterator; + if (!it.moveNext()) { + return PdfRect.empty; + } + var rect = it.current; + while (it.moveNext()) { + rect = rect.merge(it.current); + } + return rect; + } +} + +@immutable +class PdfLink { + const PdfLink(this.url, this.rects); + final String url; + final List rects; +} diff --git a/lib/src/web/pdfrx_web.dart b/lib/src/web/pdfrx_web.dart index d6f0fe1..83a8372 100644 --- a/lib/src/web/pdfrx_web.dart +++ b/lib/src/web/pdfrx_web.dart @@ -23,13 +23,15 @@ class PdfDocumentFactoryImpl extends PdfDocumentFactory { } @override - Future openCustom( - {required FutureOr Function(Uint8List buffer, int position, int size) - read, - required int fileSize, - required String sourceName, - String? password, - int? maxSizeToCacheOnMemory}) async { + Future openCustom({ + required FutureOr Function(Uint8List buffer, int position, int size) + read, + required int fileSize, + required String sourceName, + String? password, + int? maxSizeToCacheOnMemory, + void Function()? onDispose, + }) async { final buffer = Uint8List(fileSize); await read(buffer, 0, fileSize); return await PdfDocumentWeb.fromDocument( @@ -38,17 +40,23 @@ class PdfDocumentFactoryImpl extends PdfDocumentFactory { password: password, ), sourceName: sourceName, + onDispose: onDispose, ); } @override - Future openData(Uint8List data, {String? password}) async { + Future openData( + Uint8List data, { + String? password, + void Function()? onDispose, + }) async { return await PdfDocumentWeb.fromDocument( await pdfjsGetDocumentFromData( data.buffer, password: password, ), sourceName: 'memory', + onDispose: onDispose, ); } @@ -72,13 +80,16 @@ class PdfDocumentWeb extends PdfDocument { required super.isEncrypted, required super.allowsCopying, required super.allowsPrinting, + this.onDispose, }); final PdfjsDocument _document; + final void Function()? onDispose; static Future fromDocument( PdfjsDocument document, { required String sourceName, + void Function()? onDispose, }) async { final perms = await js_util.promiseToFuture?>(document.getPermissions()); @@ -90,12 +101,14 @@ class PdfDocumentWeb extends PdfDocument { isEncrypted: perms != null, allowsCopying: perms == null, allowsPrinting: perms == null, + onDispose: onDispose, ); } @override Future dispose() async { _document.destroy(); + onDispose?.call(); } @override @@ -207,6 +220,12 @@ class PdfPageWeb extends PdfPage { .asUint8List(); return src; } + + @override + Future loadText() { + // TODO: implement loadText + throw UnimplementedError(); + } } class PdfImageWeb extends PdfImage { diff --git a/pubspec.yaml b/pubspec.yaml index 503cf5f..f07bcac 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,7 +21,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^3.0.0 + flutter_lints: ^3.0.1 ffigen: ^10.0.0 flutter: @@ -44,12 +44,17 @@ flutter: package: jp.espresso3389.pdfrx pluginClass: PdfrxPlugin sharedDarwinSource: true + +# dart run ffigen ffigen: output: - bindings: 'lib/src/pdfium_bindings.dart' + bindings: 'lib/src/pdfium/pdfium_bindings.dart' headers: entry-points: - - '../pdfrx/android/.lib/include/fpdfview.h' + - '../../pdfrx/windows/.lib/include/fpdfview.h' + - '../../pdfrx/windows/.lib/include/fpdf_annot.h' + - '../../pdfrx/windows/.lib/include/fpdf_text.h' + - '../../pdfrx/windows/.lib/include/fpdf_doc.h' include-directives: - - '../pdfrx/android/.lib/include/**' + - '../../pdfrx/windows/.lib/include/**' name: 'pdfium'