Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions PdfiumAndroid/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ find_library( # Sets the name of the path variable.
target_link_libraries( # Specifies the target library.
pdfiumandroid

libabsl
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you changing these dependencies? Its not necessarily a dead-breaker, but it needs to be clearly justified.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because, libpdfium.so, already contains all required dependencies

libc++_chrome
libchrome_zlib
libicuuc
libpartition_alloc
libpdfium

# Links the target library to the log library
Expand All @@ -72,16 +67,6 @@ target_link_libraries( # Specifies the target library.
)


add_library( libabsl SHARED IMPORTED )
add_library( libc++_chrome SHARED IMPORTED )
add_library( libchrome_zlib SHARED IMPORTED )
add_library( libicuuc SHARED IMPORTED )
add_library( libpartition_alloc SHARED IMPORTED )
add_library( libpdfium SHARED IMPORTED )

set_target_properties( libabsl PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libabsl.cr.so)
set_target_properties( libc++_chrome PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libc++_chrome.cr.so)
set_target_properties( libchrome_zlib PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libchrome_zlib.cr.so)
set_target_properties( libicuuc PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libicuuc.cr.so)
set_target_properties( libpartition_alloc PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libpartition_alloc.cr.so)
set_target_properties( libpdfium PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libpdfium.cr.so)
set_target_properties( libpdfium PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libpdfium.so)
2 changes: 2 additions & 0 deletions PdfiumAndroid/src/main/cpp/include/fpdf_doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ typedef enum {
//
// Returns a handle to the first child of |bookmark| or the first top-level
// bookmark item. NULL if no child or top-level bookmark found.
// Note that another name for the bookmarks is the document outline, as
// described in ISO 32000-1:2008, section 12.3.3.
FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV
FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark);

Expand Down
45 changes: 45 additions & 0 deletions PdfiumAndroid/src/main/cpp/include/fpdf_edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,38 @@ FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDFPage_New(FPDF_DOCUMENT document,
FPDF_EXPORT void FPDF_CALLCONV FPDFPage_Delete(FPDF_DOCUMENT document,
int page_index);

// Experimental API.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these just due to the new version of pdfium?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

// Move the given pages to a new index position.
//
// page_indices - the ordered list of pages to move. No duplicates allowed.
// page_indices_len - the number of elements in |page_indices|
// dest_page_index - the new index position to which the pages in
// |page_indices| are moved.
//
// Returns TRUE on success. If it returns FALSE, the document may be left in an
// indeterminate state.
//
// Example: The PDF document starts out with pages [A, B, C, D], with indices
// [0, 1, 2, 3].
//
// > Move(doc, [3, 2], 2, 1); // returns true
// > // The document has pages [A, D, C, B].
// >
// > Move(doc, [0, 4, 3], 3, 1); // returns false
// > // Returned false because index 4 is out of range.
// >
// > Move(doc, [0, 3, 1], 3, 2); // returns false
// > // Returned false because index 2 is out of range for 3 page indices.
// >
// > Move(doc, [2, 2], 2, 0); // returns false
// > // Returned false because [2, 2] contains duplicates.
//
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDF_MovePages(FPDF_DOCUMENT document,
const int* page_indices,
unsigned long page_indices_len,
int dest_page_index);

// Get the rotation of |page|.
//
// page - handle to a page
Expand Down Expand Up @@ -731,6 +763,19 @@ FPDFImageObj_GetImageMetadata(FPDF_PAGEOBJECT image_object,
FPDF_PAGE page,
FPDF_IMAGEOBJ_METADATA* metadata);

// Experimental API.
// Get the image size in pixels. Faster method to get only image size.
//
// image_object - handle to an image object.
// width - receives the image width in pixels; must not be NULL.
// height - receives the image height in pixels; must not be NULL.
//
// Returns true if successful.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFImageObj_GetImagePixelSize(FPDF_PAGEOBJECT image_object,
unsigned int* width,
unsigned int* height);

// Create a new path object at an initial position.
//
// x - initial horizontal position.
Expand Down
18 changes: 9 additions & 9 deletions PdfiumAndroid/src/main/cpp/include/fpdf_formfill.h
Original file line number Diff line number Diff line change
Expand Up @@ -1913,15 +1913,15 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
int flags);

#if defined(_SKIA_SUPPORT_)
FPDF_EXPORT void FPDF_CALLCONV FPDF_FFLRecord(FPDF_FORMHANDLE hHandle,
FPDF_RECORDER recorder,
FPDF_PAGE page,
int start_x,
int start_y,
int size_x,
int size_y,
int rotate,
int flags);
FPDF_EXPORT void FPDF_CALLCONV FPDF_FFLDrawSkia(FPDF_FORMHANDLE hHandle,
FPDF_SKIA_CANVAS canvas,
FPDF_PAGE page,
int start_x,
int start_y,
int size_x,
int size_y,
int rotate,
int flags);
#endif

/*
Expand Down
17 changes: 17 additions & 0 deletions PdfiumAndroid/src/main/cpp/include/fpdf_structtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,23 @@ FPDF_EXPORT FPDF_STRUCTELEMENT FPDF_CALLCONV
FPDF_StructElement_GetChildAtIndex(FPDF_STRUCTELEMENT struct_element,
int index);

// Experimental API.
// Function: FPDF_StructElement_GetChildMarkedContentID
// Get the child's content id
// Parameters:
// struct_element - Handle to the struct element.
// index - The index for the child, 0-based.
// Return value:
// The marked content ID of the child. If no ID exists, returns -1.
// Comments:
// If the child exists but is not a stream or object, then this
// function will return -1. This will also return -1 for out of bounds
// indices. Compared to FPDF_StructElement_GetMarkedContentIdAtIndex,
// it is scoped to the current page.
FPDF_EXPORT int FPDF_CALLCONV
FPDF_StructElement_GetChildMarkedContentID(FPDF_STRUCTELEMENT struct_element,
int index);

// Experimental API.
// Function: FPDF_StructElement_GetParent
// Get the parent of the structure element.
Expand Down
15 changes: 15 additions & 0 deletions PdfiumAndroid/src/main/cpp/include/fpdf_text.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, int index);
FPDF_EXPORT int FPDF_CALLCONV
FPDFText_IsGenerated(FPDF_TEXTPAGE text_page, int index);

// Experimental API.
// Function: FPDFText_IsHyphen
// Get if a character in a page is a hyphen.
// Parameters:
// text_page - Handle to a text page information structure.
// Returned by FPDFText_LoadPage function.
// index - Zero-based index of the character.
// Return value:
// 1 if the character is a hyphen.
// 0 if the character is not a hyphen.
// -1 if there was an error.
//
FPDF_EXPORT int FPDF_CALLCONV
FPDFText_IsHyphen(FPDF_TEXTPAGE text_page, int index);

// Experimental API.
// Function: FPDFText_HasUnicodeMapError
// Get if a character in a page has an invalid unicode mapping.
Expand Down
16 changes: 14 additions & 2 deletions PdfiumAndroid/src/main/cpp/include/fpdfview.h
Original file line number Diff line number Diff line change
Expand Up @@ -646,17 +646,29 @@ FPDF_GetTrailerEnds(FPDF_DOCUMENT document,
unsigned int* buffer,
unsigned long length);

// Function: FPDF_GetDocPermission
// Function: FPDF_GetDocPermissions
// Get file permission flags of the document.
// Parameters:
// document - Handle to a document. Returned by FPDF_LoadDocument.
// Return value:
// A 32-bit integer indicating permission flags. Please refer to the
// PDF Reference for detailed descriptions. If the document is not
// protected, 0xffffffff will be returned.
// protected or was unlocked by the owner, 0xffffffff will be returned.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDF_GetDocPermissions(FPDF_DOCUMENT document);

// Function: FPDF_GetDocUserPermissions
// Get user file permission flags of the document.
// Parameters:
// document - Handle to a document. Returned by FPDF_LoadDocument.
// Return value:
// A 32-bit integer indicating permission flags. Please refer to the
// PDF Reference for detailed descriptions. If the document is not
// protected, 0xffffffff will be returned. Always returns user
// permissions, even if the document was unlocked by the owner.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDF_GetDocUserPermissions(FPDF_DOCUMENT document);

// Function: FPDF_GetSecurityHandlerRevision
// Get the revision for the security handler.
// Parameters:
Expand Down
6 changes: 3 additions & 3 deletions PdfiumAndroid/src/main/cpp/pdfiumandroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ Java_io_legere_pdfiumandroid_PdfiumCore_nativeOpenMemDocument(JNIEnv *env, jobje
}

int size = (int) env->GetArrayLength(data);
auto *cDataCopy = new jbyte[size];
env->GetByteArrayRegion(data, 0, size, cDataCopy);
auto *cDataCopy = malloc(size);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this being changed to malloc?

env->GetByteArrayRegion(data, 0, size, static_cast<jbyte *>(cDataCopy));
FPDF_DOCUMENT document = FPDF_LoadMemDocument( reinterpret_cast<const void*>(cDataCopy),
size, cpassword);

Expand All @@ -312,7 +312,7 @@ Java_io_legere_pdfiumandroid_PdfiumCore_nativeOpenMemDocument(JNIEnv *env, jobje
}

docFile->pdfDocument = document;
docFile->cDataCopy = cDataCopy;
docFile->cDataCopy = static_cast<jbyte *>(cDataCopy);
return reinterpret_cast<jlong>(docFile);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,7 @@ class PdfiumCore(context: Context? = null, logger: LoggerInterface = DefaultLogg
synchronized(lock) {
Log.d(TAG, "init in lock")
try {
System.loadLibrary("absl.cr")
System.loadLibrary("c++_chrome.cr")
System.loadLibrary("chrome_zlib.cr")
System.loadLibrary("icuuc.cr")
System.loadLibrary("partition_alloc.cr")
System.loadLibrary("pdfium.cr")
System.loadLibrary("pdfium")
System.loadLibrary("pdfiumandroid")
isReader.markReady()
} catch (e: UnsatisfiedLinkError) {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed PdfiumAndroid/src/main/jniLibs/x86/libabsl.cr.so
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed PdfiumAndroid/src/main/jniLibs/x86/libicuuc.cr.so
Binary file not shown.
Binary file not shown.
Binary file removed PdfiumAndroid/src/main/jniLibs/x86/libpdfium.cr.so
Binary file not shown.
Binary file added PdfiumAndroid/src/main/jniLibs/x86/libpdfium.so
Binary file not shown.
Binary file removed PdfiumAndroid/src/main/jniLibs/x86_64/libabsl.cr.so
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed PdfiumAndroid/src/main/jniLibs/x86_64/libicuuc.cr.so
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.