Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
platform: darwin-arm64
arch: arm64
skipTests: false
- os: windows-2022
- os: windows-2025
platform: windows-x64
arch: x64
skipTests: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
- os: macos-15
platform: darwin-arm64
arch: arm64
- os: windows-2022
- os: windows-2025
platform: windows-x64
arch: x64

Expand Down
34 changes: 19 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ plugins {

allprojects {
group = "org.grimmory"
version = "1.1.4"
version = "1.2.0"

repositories {
mavenCentral()
Expand Down Expand Up @@ -114,7 +114,8 @@ if (!enableCorpusTools.get()) {

tasks.withType<JavaCompile> {
options.compilerArgs.addAll(listOf(
"--enable-preview"
"--enable-preview",
"-Xlint:-preview"
))
}

Expand All @@ -137,8 +138,21 @@ val pdfiumPlatforms = mapOf(
)

val platformFilter = findProperty("pdfiumPlatformFilter")?.toString()
val hostOs = System.getProperty("os.name").lowercase()
val hostArch = System.getProperty("os.arch").lowercase()
val hostPlatform = when {
hostOs.contains("mac") && (hostArch == "aarch64" || hostArch == "arm64") -> "darwin-arm64"
hostOs.contains("mac") && (hostArch == "x86_64" || hostArch == "amd64") -> "darwin-x64"
hostOs.contains("linux") && (hostArch == "aarch64" || hostArch == "arm64") -> "linux-arm64"
hostOs.contains("linux") && (hostArch == "x86_64" || hostArch == "amd64") -> "linux-x64"
hostOs.contains("windows") && (hostArch == "x86_64" || hostArch == "amd64") -> "windows-x64"
else -> null
}

val activePlatforms = if (platformFilter != null) {
pdfiumPlatforms.filterKeys { it == platformFilter }
} else if (System.getenv("CI") == null && hostPlatform != null) {
pdfiumPlatforms.filterKeys { it == hostPlatform }
} else {
pdfiumPlatforms
}
Expand All @@ -150,17 +164,6 @@ val prebuiltShimsDir = findProperty("prebuiltShimsDir")?.toString()?.let { proje
val pdfiumArchiveDir = layout.buildDirectory.dir("pdfium-archives")
val pdfiumNativesDir = layout.buildDirectory.dir("generated-natives")

val hostOs = System.getProperty("os.name").lowercase()
val hostArch = System.getProperty("os.arch").lowercase()
val hostPlatform = when {
hostOs.contains("mac") && (hostArch == "aarch64" || hostArch == "arm64") -> "darwin-arm64"
hostOs.contains("mac") && (hostArch == "x86_64" || hostArch == "amd64") -> "darwin-x64"
hostOs.contains("linux") && (hostArch == "aarch64" || hostArch == "arm64") -> "linux-arm64"
hostOs.contains("linux") && (hostArch == "x86_64" || hostArch == "amd64") -> "linux-x64"
hostOs.contains("windows") && (hostArch == "x86_64" || hostArch == "amd64") -> "windows-x64"
else -> null
}

val downloadPdfiumBinaries by tasks.registering {
description = "Downloads prebuilt PDFium binaries for all supported platforms"
outputs.dir(pdfiumArchiveDir)
Expand Down Expand Up @@ -549,6 +552,7 @@ tasks.assemble {

tasks.withType<Test> {
useJUnitPlatform()
maxHeapSize = "2g"
testLogging {
showStandardStreams = true
events("passed", "skipped", "failed")
Expand Down Expand Up @@ -645,7 +649,7 @@ tasks.register<JavaExec>("runCorpusProcessor") {
group = "application"
description = "Runs the CorpusProcessor to write metadata to PDFs"
if (enableCorpusTools.get()) {
dependsOn("buildShim")
dependsOn("generateNativeIndex")
}
mainClass.set("org.grimmory.pdfium4j.CorpusProcessor")
classpath = sourceSets["test"].runtimeClasspath
Expand Down Expand Up @@ -682,7 +686,7 @@ tasks.register<JavaExec>("runCorpusMetadataStress") {
group = "application"
description = "Runs metadata save stress validation against corpus PDFs"
if (enableCorpusTools.get()) {
dependsOn("buildShim")
dependsOn("generateNativeIndex")
}
mainClass.set("org.grimmory.pdfium4j.CorpusMetadataStressRunner")
classpath = sourceSets["test"].runtimeClasspath
Expand Down
73 changes: 0 additions & 73 deletions pdfium4j-natives-linux-x64/build.gradle.kts

This file was deleted.

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.

This file was deleted.

11 changes: 9 additions & 2 deletions shim/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# PDFium4j Native Shim Build
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.20)
project(pdfium4j_shim VERSION 1.0.1 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "" FORCE)
Expand All @@ -14,6 +14,13 @@ endif()
# Suppress QPDF PointerHolder transition warnings (and fix MSVC #warning error)
add_definitions(-DPOINTERHOLDER_TRANSITION=0)

if(WIN32)
# Prevent windows.h from defining min/max macros that collide with C++ stdlib
add_definitions(-DNOMINMAX)
# Reduce the amount of Windows header bloat
add_definitions(-DWIN32_LEAN_AND_MEAN)
endif()

# QPDF dependency hints
if(DEFINED ENV{ZLIB_ROOT})
set(ZLIB_ROOT "$ENV{ZLIB_ROOT}")
Expand Down
34 changes: 34 additions & 0 deletions shim/include/pdfium4j_shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
extern "C" {
#endif

typedef struct {
int charCode;
float left;
float bottom;
float right;
float top;
float fontSize;
} pdfium4j_char_info_t;

SHIM_EXPORT int FPDF_CALLCONV pdfium4j_page_count(FPDF_DOCUMENT doc);

SHIM_EXPORT int FPDF_CALLCONV pdfium4j_get_meta_utf8(FPDF_DOCUMENT doc, const char* key, char* buf, int buf_len);
Expand Down Expand Up @@ -128,6 +137,16 @@ SHIM_EXPORT int FPDF_CALLCONV pdfium4j_save_with_metadata_mem_native(
int metadata_count
);

SHIM_EXPORT int FPDF_CALLCONV pdfium4j_save_with_metadata_mem_to_file_native(
const void* src_buf,
size_t src_len,
const char* dst_path,
const char* xmp_metadata,
int xmp_len,
const char** metadata_pairs,
int metadata_count
);

/**
* QPDF-based metadata enumeration
*/
Expand All @@ -146,6 +165,21 @@ SHIM_EXPORT int FPDF_CALLCONV pdfium4j_read_info_dict_mem(
void* userdata
);

SHIM_EXPORT int FPDF_CALLCONV pdfium4j_get_xmp_qpdf(
const char* src_path,
char* buf,
int buf_len
);

SHIM_EXPORT int FPDF_CALLCONV pdfium4j_get_xmp_qpdf_mem(
const char* data,
size_t len,
char* buf,
int buf_len
);

SHIM_EXPORT void FPDF_CALLCONV pdfium4j_resolve_optional_symbols(void);

#ifdef __cplusplus
}
#endif
Expand Down
Loading
Loading