diff --git a/.gitignore b/.gitignore index 995eb561..808ac9b1 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,10 @@ src/main/obj .idea/ .DS_Store /build -/captures \ No newline at end of file +/captures + + +# build directories +builddir/* +freetype-* +libpng diff --git a/CHANGELOG.md b/CHANGELOG.md index ad91218a..5765ef95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,34 @@ +## 2.0.2 (2025-09-27) +* Android 16 (16KB page size support) + +## 1.9.2 (2025-03-15) +* Upgrade libfreetype to 2.13.3 + * It is a security update, see [here](https://nvd.nist.gov/vuln/detail/CVE-2025-27363) for more details. + +## 1.9.1 (2025-01-06) +* Upgrade to latest [PDFium 133.0.6927.0](https://github.com/bblanchon/pdfium-binaries/releases/tag/chromium%2F6927) + * Upgrade `include` folder + * Upgrade `libmodpdfium.so` for `arm32`, `arm64`, `x86` and `x86_64`(`mips` binary not included) + * Use new Pdfium API in `mainJNILib.cpp` +* Add `CMakeLists.txt` for building the PdfiumAndroid library + * Example cmake command + ```bash + export ABI=arm64-v8a && \ + export NDK_ROOT=PATH/TO/NDK && \ + cmake -B builddir/${ANDROID_ABI}/ \ + -S . \ + -DCMAKE_BUILD_TYPE=Release \ + -DANDROID_NDK=${NDK_ROOT} \ + -DCMAKE_ANDROID_NDK=${NDK_ROOT} \ + -DCMAKE_SYSTEM_NAME=Android \ + -DCMAKE_ANDROID_ARCH_ABI=${ANDROID_ABI} \ + -DANDROID_ABI=${ANDROID_ABI} \ + -DANDROID_PLATFORM=android-26 \ + -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON + ``` +* Add [libpng v1.6.44](https://github.com/pnggroup/libpng/releases/tag/v1.6.44) and [libfreetype2 v2.10.0](https://download.savannah.gnu.org/releases/freetype/) binaries for building PdfiumAndroid library. + * Add `build.sh` script for building `libpng` and `libfreetype2` + ## 1.9.0 (2018-06-29) * Updated Pdfium library to 7.1.2_r36 * Changed `gnustl_static` to `c++_shared` diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..1a969286 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,45 @@ +# Set the minimum required version of CMake +cmake_minimum_required(VERSION 3.22) + +# Set the project name and language +project(jniPdfium LANGUAGES CXX) + +message(STATUS "ANDROID_NDK: ${ANDROID_NDK}") +message(STATUS "CMAKE_ANDROID_NDK: ${CMAKE_ANDROID_NDK}") +message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") +message(STATUS "CMAKE_ANDROID_ARCH_ABI: ${CMAKE_ANDROID_ARCH_ABI}") +message(STATUS "ANDROID_ABI: ${ANDROID_ABI}") +message(STATUS "ANDROID_PLATFORM: ${ANDROID_PLATFORM}") + + +# Add the source files for the library +set(SOURCES + src/main/jni/src/mainJNILib.cpp + src/main/jni/src/util.hpp +) + +# Create the shared library target +add_library(jniPdfium SHARED ${SOURCES}) + +# Specify include directories if necessary +target_include_directories(jniPdfium + PRIVATE ${CMAKE_SOURCE_DIR}/src/main/jni/include +) + +# Specify the dependent dynamic libraries to link against +target_link_libraries(jniPdfium + PRIVATE ${CMAKE_SOURCE_DIR}/src/main/jni/lib/${ANDROID_ABI}/libmodft2.so + PRIVATE ${CMAKE_SOURCE_DIR}/src/main/jni/lib/${ANDROID_ABI}/libmodpdfium.so + PRIVATE ${CMAKE_SOURCE_DIR}/src/main/jni/lib/${ANDROID_ABI}/libmodpng.so + PRIVATE ${CMAKE_SOURCE_DIR}/src/main/jni/lib/${ANDROID_ABI}/libc++_shared.so +) + +# Specify additional compile options if required +target_compile_options(jniPdfium PRIVATE + -Wall -Wextra -DHAVE_PTHREADS +) + +# Specify additional linker flags if necessary +target_link_options(jniPdfium PRIVATE + -Wl,--no-undefined -llog -landroid -ljnigraphics +) diff --git a/README.md b/README.md index 30a71ada..f2f6f98c 100644 --- a/README.md +++ b/README.md @@ -1,125 +1,123 @@ -# Pdfium Android binding with Bitmap rendering -Uses pdfium library [from AOSP](https://android.googlesource.com/platform/external/pdfium/) - -The demo app (for not modified lib) is [here](https://github.com/mshockwave/PdfiumAndroid-Demo-App) - -Forked for use with [AndroidPdfViewer](https://github.com/barteksc/AndroidPdfViewer) project. - -API is highly compatible with original version, only additional methods were created. - -## What's new in 1.9.0? -* Updated Pdfium library to 7.1.2_r36 -* Changed `gnustl_static` to `c++_shared` -* Update Gradle plugins -* Update compile SDK and support library to 26 -* Change minimum SDK to 14 -* Add support for mips64 - -## Installation -Add to _build.gradle_: - -`compile 'com.github.barteksc:pdfium-android:1.9.0'` - -Library is available in jcenter and Maven Central repositories. - -## Methods inconsistency -Version 1.8.0 added method for getting page size - `PdfiumCore#getPageSize(...)`. -It is important to note, that this method does not require page to be opened. However, there are also -old `PdfiumCore#getPageWidth(...)`, `PdfiumCore#getPageWidthPoint(...)`, `PdfiumCore#getPageHeight()` -and `PdfiumCore#getPageHeightPoint()` which require page to be opened. - -This inconsistency will be resolved in next major version, which aims to redesign API. - -## Reading links -Version 1.8.0 introduces `PdfiumCore#getPageLinks(PdfDocument, int)` method, which allows to get list -of links from given page. Links are returned as `List` of type `PdfDocument.Link`. -`PdfDocument.Link` holds destination page (may be null), action URI (may be null or empty) -and link bounds in document page coordinates. To map page coordinates to screen coordinates you may use -`PdfiumCore#mapRectToDevice(...)`. See `PdfiumCore#mapPageCoordsToDevice(...)` for parameters description. - -Sample usage: -``` java -PdfiumCore core = ...; -PdfDocument document = ...; -int pageIndex = 0; -core.openPage(document, pageIndex); -List links = core.getPageLinks(document, pageIndex); -for (PdfDocument.Link link : links) { - RectF mappedRect = core.mapRectToDevice(document, pageIndex, ..., link.getBounds()) - - if (clickedArea(mappedRect)) { - String uri = link.getUri(); - if (link.getDestPageIdx() != null) { - // jump to page - } else if (uri != null && !uri.isEmpty()) { - // open URI using Intent - } - } -} +# PdfiumAndroid - SDK 36 / Android 16 Compatible + +This repository is a fork of [meganz/PdfiumAndroid](https://github.com/meganz/PdfiumAndroid), which itself is based on [barteksc/PdfiumAndroid](https://github.com/barteksc/PdfiumAndroid). + +## What's New in This Fork + +This fork is updated to **SDK 35 / NDK 28** and delivers a working AAR compatible with **Android 15 (16KB page size support)**. + +**Version 2.0.2** - Significant updates to the build layer and compatibility improvements warrant a major version bump from the original 1.9.0. + +### Key Updates: +- **Android SDK 36** and **NDK 28** compatibility +- **Android Gradle Plugin 8.13.0** support +- **Java 17** requirement (configured via `gradle.properties`) +- **BuildConfig generation** fixed for library modules +- **Native library packaging** corrected in AAR +- **16KB page size support** for Android 15 +- **Windows Git Bash** compatible build script + +## Requirements + +- **Java 17+** (required for AGP 8.13.0+) +- **Android NDK 28.2.13676358** +- **Git Bash** (for Windows users) +- **Ninja build tool** - https://github.com/ninja-build/ninja/releases + +## Building the Library + +### 1. Build Native Libraries + +Remark: you might need to update the `NDK_ROOT` environment variable in the `build.sh` script to point to your NDK (preferrably v28+) + +```bash +# Run the build script to compile native libraries +./build.sh + +# Optional: Build specific components +./build.sh --build-png --build-freetype ``` -## Simple example -``` java -void openPdf() { - ImageView iv = (ImageView) findViewById(R.id.imageView); - ParcelFileDescriptor fd = ...; - int pageNum = 0; - PdfiumCore pdfiumCore = new PdfiumCore(context); - try { - PdfDocument pdfDocument = pdfiumCore.newDocument(fd); - - pdfiumCore.openPage(pdfDocument, pageNum); - - int width = pdfiumCore.getPageWidthPoint(pdfDocument, pageNum); - int height = pdfiumCore.getPageHeightPoint(pdfDocument, pageNum); - - // ARGB_8888 - best quality, high memory usage, higher possibility of OutOfMemoryError - // RGB_565 - little worse quality, twice less memory usage - Bitmap bitmap = Bitmap.createBitmap(width, height, - Bitmap.Config.RGB_565); - pdfiumCore.renderPageBitmap(pdfDocument, bitmap, pageNum, 0, 0, - width, height); - //if you need to render annotations and form fields, you can use - //the same method above adding 'true' as last param - - iv.setImageBitmap(bitmap); - - printInfo(pdfiumCore, pdfDocument); - - pdfiumCore.closeDocument(pdfDocument); // important! - } catch(IOException ex) { - ex.printStackTrace(); - } -} +### 2. Build AAR -public void printInfo(PdfiumCore core, PdfDocument doc) { - PdfDocument.Meta meta = core.getDocumentMeta(doc); - Log.e(TAG, "title = " + meta.getTitle()); - Log.e(TAG, "author = " + meta.getAuthor()); - Log.e(TAG, "subject = " + meta.getSubject()); - Log.e(TAG, "keywords = " + meta.getKeywords()); - Log.e(TAG, "creator = " + meta.getCreator()); - Log.e(TAG, "producer = " + meta.getProducer()); - Log.e(TAG, "creationDate = " + meta.getCreationDate()); - Log.e(TAG, "modDate = " + meta.getModDate()); +Remark: you might need to update the 'javaHome' environment variable in the `gradle.properties` file to point to your Java 17 installation - printBookmarksTree(core.getTableOfContents(doc), "-"); +```bash +# Build debug AAR +./gradlew assembleDebug -} +# Build release AAR +./gradlew assembleRelease + +# Output: build/outputs/aar/PdfiumAndroid-2.0.0-release.aar +``` -public void printBookmarksTree(List tree, String sep) { - for (PdfDocument.Bookmark b : tree) { +## Using in Your Project - Log.e(TAG, String.format("%s %s, p %d", sep, b.getTitle(), b.getPageIdx())); +### Method 1: Local AAR +1. Copy `PdfiumAndroid-2.0.2-release.aar` to your app's `libs/` folder +2. Add to your app's `build.gradle`: +```groovy +dependencies { + implementation files('libs/PdfiumAndroid-2.0.2-release.aar') + implementation 'androidx.core:core:1.16.0' +} +``` - if (b.hasChildren()) { - printBookmarksTree(b.getChildren(), sep + "-"); - } - } +### Method 2: JitPack (if published) +```groovy +repositories { + maven { url 'https://jitpack.io' } } +dependencies { + implementation 'com.github.aiuspaktyn:PdfiumAndroid:2.0.2' +} +``` + +## Usage Example + +```java +import com.shockwave.pdfium.PdfiumCore; +import com.shockwave.pdfium.PdfDocument; + +// Initialize +PdfiumCore pdfiumCore = new PdfiumCore(context); + +// Open PDF +PdfDocument pdfDocument = pdfiumCore.newDocument(parcelFileDescriptor); + +// Use the library... ``` -## Build native part -Go to `PROJECT_PATH/src/main/jni` and run command `$ ndk-build`. -This step may be executed only once, every future `.aar` build will use generated libs. + +## Changes Made + +### Build System Updates +- Updated `build.gradle` for AGP 8.13.0 compatibility +- Added `buildFeatures { buildConfig = true }` +- Added `buildConfigField` for `VERSION_NAME` +- Fixed `jniLibs.srcDir` path for native libraries +- Configured Java 17 in `gradle.properties` + +### Native Library Fixes +- Updated `build.sh` to use ninja (for windows) +- Updated `build.sh` to copy `libjniPdfium.so` to correct location +- Fixed AAR packaging to include all required `.so` files +- Ensured compatibility with NDK 28 + +### Android 15 Compatibility +- Added 16KB page size support via `ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON` +- Updated manifest and build configuration + +## Original Credits + +- Original work: [barteksc/PdfiumAndroid](https://github.com/barteksc/PdfiumAndroid) +- 16KB page size foundation: [meganz/PdfiumAndroid](https://github.com/meganz/PdfiumAndroid) +- Upgrade to [PDFium 133.0.6927.0](https://github.com/bblanchon/pdfium-binaries/releases/tag/chromium%2F6927) +- Add a `CMakeLists.txt` for building PdfiumAndroid `.so` file. +- Update [libpng v1.6.44](https://github.com/pnggroup/libpng/releases/tag/v1.6.44) and [libfreetype2 v2.10.0](https://download.savannah.gnu.org/releases/freetype/) binaries for building PdfiumAndroid library. + +## License + +Same as original project - check the LICENSE file. diff --git a/build.gradle b/build.gradle index 49863608..a453a9d7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,50 +1,27 @@ buildscript { repositories { - jcenter() google() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.3' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.1' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' + classpath 'com.android.tools.build:gradle:8.13.0' } } apply plugin: 'com.android.library' - -ext { - bintrayRepo = 'maven' - bintrayName = 'pdfium-android' - - publishedGroupId = 'com.github.barteksc' - libraryName = 'PdfiumAndroid' - artifact = 'pdfium-android' - - libraryDescription = 'Fork of library for rendering PDFs on Android\'s Surface or Bitmap' - - siteUrl = 'https://github.com/barteksc/PdfiumAndroid' - gitUrl = 'https://github.com/barteksc/PdfiumAndroid.git' - - libraryVersion = '1.9.0' - - developerId = 'barteksc' - developerName = 'Bartosz Schiller' - developerEmail = 'barteksch@boo.pl' - - licenseName = 'The Apache Software License, Version 2.0' - licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' - allLicenses = ["Apache-2.0"] -} +apply plugin: 'maven-publish' android { - compileSdkVersion 26 + namespace = 'com.shockwave.pdfium' + compileSdkVersion 36 defaultConfig { - minSdkVersion 14 - targetSdkVersion 26 - versionCode 1 - versionName "1.9.0" + minSdkVersion 23 + targetSdkVersion 36 + versionCode 3 + versionName "2.0.2" + buildConfigField "String", "VERSION_NAME", "\"${versionName}\"" } buildTypes { release { @@ -53,23 +30,52 @@ android { } } - sourceSets{ + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } + + sourceSets { main { jni.srcDirs = [] - jniLibs.srcDir 'src/main/libs' + jniLibs.srcDir 'src/main/jni/lib' + } + } + + buildFeatures { + viewBinding = true + buildConfig = true + } + + ndkVersion = '28.2.13676358' + + packagingOptions { + jniLibs { + useLegacyPackaging = true } } + + // Configure AAR filename to include version + libraryVariants.configureEach { variant -> + variant.outputs.all { + outputFileName = "PdfiumAndroid-${defaultConfig.versionName}-${variant.buildType.name}.aar" + } + } + + publishing { + // Configura la pubblicazione per la variante 'release' + singleVariant('release') {} + } } repositories { google() - jcenter() + mavenCentral() } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:support-v4:26.1.0' + implementation 'androidx.core:core:1.17.0' + androidTestImplementation 'androidx.test.ext:junit:1.3.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0' } - -apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' -apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' diff --git a/build.sh b/build.sh new file mode 100644 index 00000000..39f4354b --- /dev/null +++ b/build.sh @@ -0,0 +1,183 @@ +#!/bin/bash -i + +# This script can be used to build PdfiumAndroid library (libjniPdfium) and its dependent libraries(libpng and libfreetype2). + +export NDK_ROOT=/d/Android/ndk/28.2.13676358 + +export BUILD_ROOT="builddir" +rm -fr ${BUILD_ROOT} + +# LIST OF ARCHS TO BE BUILT. +if [ -z "${BUILD_ARCHS}" ]; then + # If no environment variable is defined, use all archs. + BUILD_ARCHS="x86 armeabi-v7a x86_64 arm64-v8a" +fi + +check_command_result() { + local exit_code=$? + local command=$1 + echo "exit code = ${exit_code}" + if [ ${exit_code} -ne 0 ]; then + echo "${command} failed. Exiting." + exit 1 + fi +} + +build_libpng() { + rm -fr libpng + git clone https://github.com/pnggroup/libpng + cd libpng + git checkout v1.6.44 + cd .. + + for ABI in ${BUILD_ARCHS}; do + export BUILD_DIR=${BUILD_ROOT}/libpng/${ABI} + rm -fr ${BUILD_DIR} && + cmake -G "Ninja" -B ${BUILD_DIR} -S libpng \ + -DCMAKE_ANDROID_NDK=${NDK_ROOT} \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_ANDROID_ARCH_ABI=${ABI} \ + -DBUILD_SHARED_LIBS:BOOL=true \ + -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON \ + -DANDROID_ABI=${ABI} \ + -DCMAKE_SYSTEM_NAME=Android + check_command_result "configuring libpng" + cmake --build ${BUILD_DIR} -j10 + check_command_result "building libpng" + + ls -lh ${BUILD_DIR}/*.so + cp ${BUILD_DIR}/libpng16.so src/main/jni/lib/${ABI}/libmodpng.so + done +} + + +build_libfreetype2() { + FREETYPE_VERSION=2.13.3 + rm -fr freetype-${FREETYPE_VERSION}.tar.gz freetype-${FREETYPE_VERSION} + wget https://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VERSION}.tar.gz + tar -xvzf freetype-${FREETYPE_VERSION}.tar.gz + export SRC_DIR=freetype-${FREETYPE_VERSION} + + for ABI in ${BUILD_ARCHS}; do + export BUILD_DIR=${BUILD_ROOT}/${SRC_DIR}/${ABI} + rm -fr ${BUILD_DIR} && + cmake -G "Ninja" -B ${BUILD_DIR} -S ${SRC_DIR} \ + -DCMAKE_ANDROID_NDK=${NDK_ROOT} \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_ANDROID_ARCH_ABI=${ABI} \ + -DBUILD_SHARED_LIBS:BOOL=true \ + -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON \ + -DANDROID_ABI=${ABI} \ + -DCMAKE_SYSTEM_NAME=Android + check_command_result "configuring freetype" + cmake --build ${BUILD_DIR} -j10 + check_command_result "building freetype" + + ls -lh ${BUILD_DIR}/*.so + cp ${BUILD_DIR}/libfreetype.so src/main/jni/lib/${ABI}/libmodft2.so + done +} + +build_pdfiumAndroid() { + + for ABI in ${BUILD_ARCHS}; do + cmake -G "Ninja" -B ${BUILD_ROOT}/pdfiumAndroid/${ABI}/ \ + -S . \ + -DCMAKE_BUILD_TYPE=Release \ + -DANDROID_NDK=${NDK_ROOT} \ + -DCMAKE_ANDROID_NDK=${NDK_ROOT} \ + -DCMAKE_SYSTEM_NAME=Android \ + -DCMAKE_ANDROID_ARCH_ABI=${ABI} \ + -DANDROID_ABI=${ABI} \ + -DANDROID_PLATFORM=android-26 \ + -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON + check_command_result "configuring pdfiumAndroid" + + cmake --build ${BUILD_ROOT}/pdfiumAndroid/${ABI}/ -j10 + check_command_result "building pdfiumAndroid" + + # Copy the built libjniPdfium.so to the jni/lib directory for packaging + echo "Copying libjniPdfium.so for ${ABI}" + cp -fv ${BUILD_ROOT}/pdfiumAndroid/${ABI}/libjniPdfium.so src/main/jni/lib/${ABI}/libjniPdfium.so + check_command_result "copying libjniPdfium.so for ${ABI}" + done +} + +deploy_to_mega() { + local mega_path=$1 + target_folder=${mega_path}/sdk/src/main/jniLibs + for ABI in ${BUILD_ARCHS}; do + cp -fv src/main/jni/lib/${ABI}/libmodpng.so ${target_folder}/${ABI}/ + cp -fv src/main/jni/lib/${ABI}/libmodft2.so ${target_folder}/${ABI}/ + cp -fv src/main/jni/lib/${ABI}/libmodpdfium.so ${target_folder}/${ABI}/ + cp -fv src/main/jni/lib/${ABI}/libmodpdfium.so ${target_folder}/${ABI}/ + cp -fv builddir/pdfiumAndroid/${ABI}/libjniPdfium.so ${target_folder}/${ABI}/ + done +} + +print_usage() { + echo "Build script for PdfiumAndroid library and its dependent libraries(libpng and libfreetype2)." + echo " And deploy the library to MEGA code directly." + echo "Usage: $0 [options]" + echo "Example 1: build everything and deploy to MEGA code" + echo " bash build.sh --build-png --build-freetype --deploy-to-mega /PATH/TO/MEGA/CODE" + echo "Example 2: build only pdfiumAndroid and deploy to MEGA code" + echo " bash build.sh --deploy-to-mega /PATH/TO/MEGA/CODE" + echo "Options:" + echo " --build-png [Optional] Build libpng" + echo " --build-freetype [Optional] Build libfreetype2" + echo " --deploy-to-mega [Optional] Deploy to the specified MEGA code path" + echo " --help Display this help message" +} + +# Parse optional parameters +BUILD_PNG=false +BUILD_FREETYPE=false +MEGA_CODE_PATH="" + +for arg in "$@"; do + case $arg in + --build-png) + BUILD_PNG=true + shift + ;; + --build-freetype) + BUILD_FREETYPE=true + shift + ;; + --deploy-to-mega) + MEGA_CODE_PATH="$2" + shift 2 + ;; + --help) + print_usage + exit 0 + ;; + esac +done + +# Call the functions based on the parameters +if [ "$BUILD_PNG" = true ]; then + echo "building libpng" + build_libpng +fi + +if [ "$BUILD_FREETYPE" = true ]; then + echo "building freetype" + build_libfreetype2 +fi + +build_pdfiumAndroid + +if [ -n "$MEGA_CODE_PATH" ]; then + if [ -d "$MEGA_CODE_PATH" ]; then + deploy_to_mega "$MEGA_CODE_PATH" + else + echo "Directory $MEGA_CODE_PATH does not exist." + exit 1 + fi +fi + + + +echo "Build finished Ok" diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..7891ec1a --- /dev/null +++ b/gradle.properties @@ -0,0 +1,15 @@ +## For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx1024m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +# +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. For more details, visit +# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects +# org.gradle.parallel=true +#Tue Jul 29 19:49:53 CEST 2025 +android.enableJetifier=true +android.useAndroidX=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7d202716..e320fad6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Jun 06 19:49:00 CEST 2017 +#Tue Jul 29 19:08:35 CEST 2025 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/src/androidTest/java/com/shockwave/pdfium/ApplicationTest.java b/src/androidTest/java/com/shockwave/pdfium/ApplicationTest.java index 1f24f8cc..1ba4cf6d 100644 --- a/src/androidTest/java/com/shockwave/pdfium/ApplicationTest.java +++ b/src/androidTest/java/com/shockwave/pdfium/ApplicationTest.java @@ -1,13 +1,16 @@ package com.shockwave.pdfium; import android.app.Application; -import android.test.ApplicationTestCase; + +import androidx.test.core.app.ApplicationProvider; /** * Testing Fundamentals */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); +public class ApplicationTest { + public void testAppContext() { + Application application = ApplicationProvider.getApplicationContext(); + // Perform assertions on the application context } + } \ No newline at end of file diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 00bf1676..c4e83de3 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -1,3 +1,3 @@ - + diff --git a/src/main/java/com/shockwave/pdfium/PdfDocument.java b/src/main/java/com/shockwave/pdfium/PdfDocument.java index b5306a67..5a6930e5 100644 --- a/src/main/java/com/shockwave/pdfium/PdfDocument.java +++ b/src/main/java/com/shockwave/pdfium/PdfDocument.java @@ -2,7 +2,7 @@ import android.graphics.RectF; import android.os.ParcelFileDescriptor; -import android.support.v4.util.ArrayMap; +import androidx.collection.ArrayMap; import java.util.ArrayList; import java.util.List; diff --git a/src/main/jni/include/cpp/fpdf_deleters.h b/src/main/jni/include/cpp/fpdf_deleters.h new file mode 100644 index 00000000..55b85d9e --- /dev/null +++ b/src/main/jni/include/cpp/fpdf_deleters.h @@ -0,0 +1,86 @@ +// Copyright 2017 The PDFium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PUBLIC_CPP_FPDF_DELETERS_H_ +#define PUBLIC_CPP_FPDF_DELETERS_H_ + +#include "../fpdf_annot.h" +#include "../fpdf_dataavail.h" +#include "../fpdf_edit.h" +#include "../fpdf_formfill.h" +#include "../fpdf_javascript.h" +#include "../fpdf_structtree.h" +#include "../fpdf_text.h" +#include "../fpdf_transformpage.h" +#include "../fpdfview.h" + +// Custom deleters for using FPDF_* types with std::unique_ptr<>. + +struct FPDFAnnotationDeleter { + inline void operator()(FPDF_ANNOTATION annot) { FPDFPage_CloseAnnot(annot); } +}; + +struct FPDFAvailDeleter { + inline void operator()(FPDF_AVAIL avail) { FPDFAvail_Destroy(avail); } +}; + +struct FPDFBitmapDeleter { + inline void operator()(FPDF_BITMAP bitmap) { FPDFBitmap_Destroy(bitmap); } +}; + +struct FPDFClipPathDeleter { + inline void operator()(FPDF_CLIPPATH clip_path) { + FPDF_DestroyClipPath(clip_path); + } +}; + +struct FPDFDocumentDeleter { + inline void operator()(FPDF_DOCUMENT doc) { FPDF_CloseDocument(doc); } +}; + +struct FPDFFontDeleter { + inline void operator()(FPDF_FONT font) { FPDFFont_Close(font); } +}; + +struct FPDFFormHandleDeleter { + inline void operator()(FPDF_FORMHANDLE form) { + FPDFDOC_ExitFormFillEnvironment(form); + } +}; + +struct FPDFJavaScriptActionDeleter { + inline void operator()(FPDF_JAVASCRIPT_ACTION javascript) { + FPDFDoc_CloseJavaScriptAction(javascript); + } +}; + +struct FPDFPageDeleter { + inline void operator()(FPDF_PAGE page) { FPDF_ClosePage(page); } +}; + +struct FPDFPageLinkDeleter { + inline void operator()(FPDF_PAGELINK pagelink) { + FPDFLink_CloseWebLinks(pagelink); + } +}; + +struct FPDFPageObjectDeleter { + inline void operator()(FPDF_PAGEOBJECT object) { + FPDFPageObj_Destroy(object); + } +}; + +struct FPDFStructTreeDeleter { + inline void operator()(FPDF_STRUCTTREE tree) { FPDF_StructTree_Close(tree); } +}; + +struct FPDFTextFindDeleter { + inline void operator()(FPDF_SCHHANDLE handle) { FPDFText_FindClose(handle); } +}; + +struct FPDFTextPageDeleter { + inline void operator()(FPDF_TEXTPAGE text) { FPDFText_ClosePage(text); } +}; + +#endif // PUBLIC_CPP_FPDF_DELETERS_H_ diff --git a/src/main/jni/include/cpp/fpdf_scopers.h b/src/main/jni/include/cpp/fpdf_scopers.h new file mode 100644 index 00000000..34cf9c46 --- /dev/null +++ b/src/main/jni/include/cpp/fpdf_scopers.h @@ -0,0 +1,67 @@ +// Copyright 2018 The PDFium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PUBLIC_CPP_FPDF_SCOPERS_H_ +#define PUBLIC_CPP_FPDF_SCOPERS_H_ + +#include +#include + +#include "fpdf_deleters.h" + +// Versions of FPDF types that clean up the object at scope exit. + +using ScopedFPDFAnnotation = + std::unique_ptr::type, + FPDFAnnotationDeleter>; + +using ScopedFPDFAvail = + std::unique_ptr::type, FPDFAvailDeleter>; + +using ScopedFPDFBitmap = + std::unique_ptr::type, FPDFBitmapDeleter>; + +using ScopedFPDFClipPath = + std::unique_ptr::type, + FPDFClipPathDeleter>; + +using ScopedFPDFDocument = + std::unique_ptr::type, + FPDFDocumentDeleter>; + +using ScopedFPDFFont = + std::unique_ptr::type, FPDFFontDeleter>; + +using ScopedFPDFFormHandle = + std::unique_ptr::type, + FPDFFormHandleDeleter>; + +using ScopedFPDFJavaScriptAction = + std::unique_ptr::type, + FPDFJavaScriptActionDeleter>; + +using ScopedFPDFPage = + std::unique_ptr::type, FPDFPageDeleter>; + +using ScopedFPDFPageLink = + std::unique_ptr::type, + FPDFPageLinkDeleter>; + +using ScopedFPDFPageObject = + std::unique_ptr::type, + FPDFPageObjectDeleter>; + +using ScopedFPDFStructTree = + std::unique_ptr::type, + FPDFStructTreeDeleter>; + +using ScopedFPDFTextFind = + std::unique_ptr::type, + FPDFTextFindDeleter>; + +using ScopedFPDFTextPage = + std::unique_ptr::type, + FPDFTextPageDeleter>; + +#endif // PUBLIC_CPP_FPDF_SCOPERS_H_ diff --git a/src/main/jni/include/fpdf_annot.h b/src/main/jni/include/fpdf_annot.h new file mode 100644 index 00000000..ef30d9a2 --- /dev/null +++ b/src/main/jni/include/fpdf_annot.h @@ -0,0 +1,1012 @@ +// Copyright 2017 The PDFium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PUBLIC_FPDF_ANNOT_H_ +#define PUBLIC_FPDF_ANNOT_H_ + +#include + +// NOLINTNEXTLINE(build/include) +#include "fpdfview.h" + +// NOLINTNEXTLINE(build/include) +#include "fpdf_formfill.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +#define FPDF_ANNOT_UNKNOWN 0 +#define FPDF_ANNOT_TEXT 1 +#define FPDF_ANNOT_LINK 2 +#define FPDF_ANNOT_FREETEXT 3 +#define FPDF_ANNOT_LINE 4 +#define FPDF_ANNOT_SQUARE 5 +#define FPDF_ANNOT_CIRCLE 6 +#define FPDF_ANNOT_POLYGON 7 +#define FPDF_ANNOT_POLYLINE 8 +#define FPDF_ANNOT_HIGHLIGHT 9 +#define FPDF_ANNOT_UNDERLINE 10 +#define FPDF_ANNOT_SQUIGGLY 11 +#define FPDF_ANNOT_STRIKEOUT 12 +#define FPDF_ANNOT_STAMP 13 +#define FPDF_ANNOT_CARET 14 +#define FPDF_ANNOT_INK 15 +#define FPDF_ANNOT_POPUP 16 +#define FPDF_ANNOT_FILEATTACHMENT 17 +#define FPDF_ANNOT_SOUND 18 +#define FPDF_ANNOT_MOVIE 19 +#define FPDF_ANNOT_WIDGET 20 +#define FPDF_ANNOT_SCREEN 21 +#define FPDF_ANNOT_PRINTERMARK 22 +#define FPDF_ANNOT_TRAPNET 23 +#define FPDF_ANNOT_WATERMARK 24 +#define FPDF_ANNOT_THREED 25 +#define FPDF_ANNOT_RICHMEDIA 26 +#define FPDF_ANNOT_XFAWIDGET 27 +#define FPDF_ANNOT_REDACT 28 + +// Refer to PDF Reference (6th edition) table 8.16 for all annotation flags. +#define FPDF_ANNOT_FLAG_NONE 0 +#define FPDF_ANNOT_FLAG_INVISIBLE (1 << 0) +#define FPDF_ANNOT_FLAG_HIDDEN (1 << 1) +#define FPDF_ANNOT_FLAG_PRINT (1 << 2) +#define FPDF_ANNOT_FLAG_NOZOOM (1 << 3) +#define FPDF_ANNOT_FLAG_NOROTATE (1 << 4) +#define FPDF_ANNOT_FLAG_NOVIEW (1 << 5) +#define FPDF_ANNOT_FLAG_READONLY (1 << 6) +#define FPDF_ANNOT_FLAG_LOCKED (1 << 7) +#define FPDF_ANNOT_FLAG_TOGGLENOVIEW (1 << 8) + +#define FPDF_ANNOT_APPEARANCEMODE_NORMAL 0 +#define FPDF_ANNOT_APPEARANCEMODE_ROLLOVER 1 +#define FPDF_ANNOT_APPEARANCEMODE_DOWN 2 +#define FPDF_ANNOT_APPEARANCEMODE_COUNT 3 + +// Refer to PDF Reference version 1.7 table 8.70 for field flags common to all +// interactive form field types. +#define FPDF_FORMFLAG_NONE 0 +#define FPDF_FORMFLAG_READONLY (1 << 0) +#define FPDF_FORMFLAG_REQUIRED (1 << 1) +#define FPDF_FORMFLAG_NOEXPORT (1 << 2) + +// Refer to PDF Reference version 1.7 table 8.77 for field flags specific to +// interactive form text fields. +#define FPDF_FORMFLAG_TEXT_MULTILINE (1 << 12) +#define FPDF_FORMFLAG_TEXT_PASSWORD (1 << 13) + +// Refer to PDF Reference version 1.7 table 8.79 for field flags specific to +// interactive form choice fields. +#define FPDF_FORMFLAG_CHOICE_COMBO (1 << 17) +#define FPDF_FORMFLAG_CHOICE_EDIT (1 << 18) +#define FPDF_FORMFLAG_CHOICE_MULTI_SELECT (1 << 21) + +// Additional actions type of form field: +// K, on key stroke, JavaScript action. +// F, on format, JavaScript action. +// V, on validate, JavaScript action. +// C, on calculate, JavaScript action. +#define FPDF_ANNOT_AACTION_KEY_STROKE 12 +#define FPDF_ANNOT_AACTION_FORMAT 13 +#define FPDF_ANNOT_AACTION_VALIDATE 14 +#define FPDF_ANNOT_AACTION_CALCULATE 15 + +typedef enum FPDFANNOT_COLORTYPE { + FPDFANNOT_COLORTYPE_Color = 0, + FPDFANNOT_COLORTYPE_InteriorColor +} FPDFANNOT_COLORTYPE; + +// Experimental API. +// Check if an annotation subtype is currently supported for creation. +// Currently supported subtypes: +// - circle +// - fileattachment +// - freetext +// - highlight +// - ink +// - link +// - popup +// - square, +// - squiggly +// - stamp +// - strikeout +// - text +// - underline +// +// subtype - the subtype to be checked. +// +// Returns true if this subtype supported. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_IsSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype); + +// Experimental API. +// Create an annotation in |page| of the subtype |subtype|. If the specified +// subtype is illegal or unsupported, then a new annotation will not be created. +// Must call FPDFPage_CloseAnnot() when the annotation returned by this +// function is no longer needed. +// +// page - handle to a page. +// subtype - the subtype of the new annotation. +// +// Returns a handle to the new annotation object, or NULL on failure. +FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV +FPDFPage_CreateAnnot(FPDF_PAGE page, FPDF_ANNOTATION_SUBTYPE subtype); + +// Experimental API. +// Get the number of annotations in |page|. +// +// page - handle to a page. +// +// Returns the number of annotations in |page|. +FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetAnnotCount(FPDF_PAGE page); + +// Experimental API. +// Get annotation in |page| at |index|. Must call FPDFPage_CloseAnnot() when the +// annotation returned by this function is no longer needed. +// +// page - handle to a page. +// index - the index of the annotation. +// +// Returns a handle to the annotation object, or NULL on failure. +FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFPage_GetAnnot(FPDF_PAGE page, + int index); + +// Experimental API. +// Get the index of |annot| in |page|. This is the opposite of +// FPDFPage_GetAnnot(). +// +// page - handle to the page that the annotation is on. +// annot - handle to an annotation. +// +// Returns the index of |annot|, or -1 on failure. +FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetAnnotIndex(FPDF_PAGE page, + FPDF_ANNOTATION annot); + +// Experimental API. +// Close an annotation. Must be called when the annotation returned by +// FPDFPage_CreateAnnot() or FPDFPage_GetAnnot() is no longer needed. This +// function does not remove the annotation from the document. +// +// annot - handle to an annotation. +FPDF_EXPORT void FPDF_CALLCONV FPDFPage_CloseAnnot(FPDF_ANNOTATION annot); + +// Experimental API. +// Remove the annotation in |page| at |index|. +// +// page - handle to a page. +// index - the index of the annotation. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_RemoveAnnot(FPDF_PAGE page, + int index); + +// Experimental API. +// Get the subtype of an annotation. +// +// annot - handle to an annotation. +// +// Returns the annotation subtype. +FPDF_EXPORT FPDF_ANNOTATION_SUBTYPE FPDF_CALLCONV +FPDFAnnot_GetSubtype(FPDF_ANNOTATION annot); + +// Experimental API. +// Check if an annotation subtype is currently supported for object extraction, +// update, and removal. +// Currently supported subtypes: ink and stamp. +// +// subtype - the subtype to be checked. +// +// Returns true if this subtype supported. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_IsObjectSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype); + +// Experimental API. +// Update |obj| in |annot|. |obj| must be in |annot| already and must have +// been retrieved by FPDFAnnot_GetObject(). Currently, only ink and stamp +// annotations are supported by this API. Also note that only path, image, and +// text objects have APIs for modification; see FPDFPath_*(), FPDFText_*(), and +// FPDFImageObj_*(). +// +// annot - handle to an annotation. +// obj - handle to the object that |annot| needs to update. +// +// Return true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_UpdateObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj); + +// Experimental API. +// Add a new InkStroke, represented by an array of points, to the InkList of +// |annot|. The API creates an InkList if one doesn't already exist in |annot|. +// This API works only for ink annotations. Please refer to ISO 32000-1:2008 +// spec, section 12.5.6.13. +// +// annot - handle to an annotation. +// points - pointer to a FS_POINTF array representing input points. +// point_count - number of elements in |points| array. This should not exceed +// the maximum value that can be represented by an int32_t). +// +// Returns the 0-based index at which the new InkStroke is added in the InkList +// of the |annot|. Returns -1 on failure. +FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_AddInkStroke(FPDF_ANNOTATION annot, + const FS_POINTF* points, + size_t point_count); + +// Experimental API. +// Removes an InkList in |annot|. +// This API works only for ink annotations. +// +// annot - handle to an annotation. +// +// Return true on successful removal of /InkList entry from context of the +// non-null ink |annot|. Returns false on failure. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_RemoveInkList(FPDF_ANNOTATION annot); + +// Experimental API. +// Add |obj| to |annot|. |obj| must have been created by +// FPDFPageObj_CreateNew{Path|Rect}() or FPDFPageObj_New{Text|Image}Obj(), and +// will be owned by |annot|. Note that an |obj| cannot belong to more than one +// |annot|. Currently, only ink and stamp annotations are supported by this API. +// Also note that only path, image, and text objects have APIs for creation. +// +// annot - handle to an annotation. +// obj - handle to the object that is to be added to |annot|. +// +// Return true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_AppendObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj); + +// Experimental API. +// Get the total number of objects in |annot|, including path objects, text +// objects, external objects, image objects, and shading objects. +// +// annot - handle to an annotation. +// +// Returns the number of objects in |annot|. +FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetObjectCount(FPDF_ANNOTATION annot); + +// Experimental API. +// Get the object in |annot| at |index|. +// +// annot - handle to an annotation. +// index - the index of the object. +// +// Return a handle to the object, or NULL on failure. +FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV +FPDFAnnot_GetObject(FPDF_ANNOTATION annot, int index); + +// Experimental API. +// Remove the object in |annot| at |index|. +// +// annot - handle to an annotation. +// index - the index of the object to be removed. +// +// Return true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_RemoveObject(FPDF_ANNOTATION annot, int index); + +// Experimental API. +// Set the color of an annotation. Fails when called on annotations with +// appearance streams already defined; instead use +// FPDFPath_Set{Stroke|Fill}Color(). +// +// annot - handle to an annotation. +// type - type of the color to be set. +// R, G, B - buffer to hold the RGB value of the color. Ranges from 0 to 255. +// A - buffer to hold the opacity. Ranges from 0 to 255. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetColor(FPDF_ANNOTATION annot, + FPDFANNOT_COLORTYPE type, + unsigned int R, + unsigned int G, + unsigned int B, + unsigned int A); + +// Experimental API. +// Get the color of an annotation. If no color is specified, default to yellow +// for highlight annotation, black for all else. Fails when called on +// annotations with appearance streams already defined; instead use +// FPDFPath_Get{Stroke|Fill}Color(). +// +// annot - handle to an annotation. +// type - type of the color requested. +// R, G, B - buffer to hold the RGB value of the color. Ranges from 0 to 255. +// A - buffer to hold the opacity. Ranges from 0 to 255. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetColor(FPDF_ANNOTATION annot, + FPDFANNOT_COLORTYPE type, + unsigned int* R, + unsigned int* G, + unsigned int* B, + unsigned int* A); + +// Experimental API. +// Check if the annotation is of a type that has attachment points +// (i.e. quadpoints). Quadpoints are the vertices of the rectangle that +// encompasses the texts affected by the annotation. They provide the +// coordinates in the page where the annotation is attached. Only text markup +// annotations (i.e. highlight, strikeout, squiggly, and underline) and link +// annotations have quadpoints. +// +// annot - handle to an annotation. +// +// Returns true if the annotation is of a type that has quadpoints, false +// otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_HasAttachmentPoints(FPDF_ANNOTATION annot); + +// Experimental API. +// Replace the attachment points (i.e. quadpoints) set of an annotation at +// |quad_index|. This index needs to be within the result of +// FPDFAnnot_CountAttachmentPoints(). +// If the annotation's appearance stream is defined and this annotation is of a +// type with quadpoints, then update the bounding box too if the new quadpoints +// define a bigger one. +// +// annot - handle to an annotation. +// quad_index - index of the set of quadpoints. +// quad_points - the quadpoints to be set. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_SetAttachmentPoints(FPDF_ANNOTATION annot, + size_t quad_index, + const FS_QUADPOINTSF* quad_points); + +// Experimental API. +// Append to the list of attachment points (i.e. quadpoints) of an annotation. +// If the annotation's appearance stream is defined and this annotation is of a +// type with quadpoints, then update the bounding box too if the new quadpoints +// define a bigger one. +// +// annot - handle to an annotation. +// quad_points - the quadpoints to be set. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_AppendAttachmentPoints(FPDF_ANNOTATION annot, + const FS_QUADPOINTSF* quad_points); + +// Experimental API. +// Get the number of sets of quadpoints of an annotation. +// +// annot - handle to an annotation. +// +// Returns the number of sets of quadpoints, or 0 on failure. +FPDF_EXPORT size_t FPDF_CALLCONV +FPDFAnnot_CountAttachmentPoints(FPDF_ANNOTATION annot); + +// Experimental API. +// Get the attachment points (i.e. quadpoints) of an annotation. +// +// annot - handle to an annotation. +// quad_index - index of the set of quadpoints. +// quad_points - receives the quadpoints; must not be NULL. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot, + size_t quad_index, + FS_QUADPOINTSF* quad_points); + +// Experimental API. +// Set the annotation rectangle defining the location of the annotation. If the +// annotation's appearance stream is defined and this annotation is of a type +// without quadpoints, then update the bounding box too if the new rectangle +// defines a bigger one. +// +// annot - handle to an annotation. +// rect - the annotation rectangle to be set. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetRect(FPDF_ANNOTATION annot, + const FS_RECTF* rect); + +// Experimental API. +// Get the annotation rectangle defining the location of the annotation. +// +// annot - handle to an annotation. +// rect - receives the rectangle; must not be NULL. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot, + FS_RECTF* rect); + +// Experimental API. +// Get the vertices of a polygon or polyline annotation. |buffer| is an array of +// points of the annotation. If |length| is less than the returned length, or +// |annot| or |buffer| is NULL, |buffer| will not be modified. +// +// annot - handle to an annotation, as returned by e.g. FPDFPage_GetAnnot() +// buffer - buffer for holding the points. +// length - length of the buffer in points. +// +// Returns the number of points if the annotation is of type polygon or +// polyline, 0 otherwise. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFAnnot_GetVertices(FPDF_ANNOTATION annot, + FS_POINTF* buffer, + unsigned long length); + +// Experimental API. +// Get the number of paths in the ink list of an ink annotation. +// +// annot - handle to an annotation, as returned by e.g. FPDFPage_GetAnnot() +// +// Returns the number of paths in the ink list if the annotation is of type ink, +// 0 otherwise. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFAnnot_GetInkListCount(FPDF_ANNOTATION annot); + +// Experimental API. +// Get a path in the ink list of an ink annotation. |buffer| is an array of +// points of the path. If |length| is less than the returned length, or |annot| +// or |buffer| is NULL, |buffer| will not be modified. +// +// annot - handle to an annotation, as returned by e.g. FPDFPage_GetAnnot() +// path_index - index of the path +// buffer - buffer for holding the points. +// length - length of the buffer in points. +// +// Returns the number of points of the path if the annotation is of type ink, 0 +// otherwise. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFAnnot_GetInkListPath(FPDF_ANNOTATION annot, + unsigned long path_index, + FS_POINTF* buffer, + unsigned long length); + +// Experimental API. +// Get the starting and ending coordinates of a line annotation. +// +// annot - handle to an annotation, as returned by e.g. FPDFPage_GetAnnot() +// start - starting point +// end - ending point +// +// Returns true if the annotation is of type line, |start| and |end| are not +// NULL, false otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetLine(FPDF_ANNOTATION annot, + FS_POINTF* start, + FS_POINTF* end); + +// Experimental API. +// Set the characteristics of the annotation's border (rounded rectangle). +// +// annot - handle to an annotation +// horizontal_radius - horizontal corner radius, in default user space units +// vertical_radius - vertical corner radius, in default user space units +// border_width - border width, in default user space units +// +// Returns true if setting the border for |annot| succeeds, false otherwise. +// +// If |annot| contains an appearance stream that overrides the border values, +// then the appearance stream will be removed on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetBorder(FPDF_ANNOTATION annot, + float horizontal_radius, + float vertical_radius, + float border_width); + +// Experimental API. +// Get the characteristics of the annotation's border (rounded rectangle). +// +// annot - handle to an annotation +// horizontal_radius - horizontal corner radius, in default user space units +// vertical_radius - vertical corner radius, in default user space units +// border_width - border width, in default user space units +// +// Returns true if |horizontal_radius|, |vertical_radius| and |border_width| are +// not NULL, false otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_GetBorder(FPDF_ANNOTATION annot, + float* horizontal_radius, + float* vertical_radius, + float* border_width); + +// Experimental API. +// Get the JavaScript of an event of the annotation's additional actions. +// |buffer| is only modified if |buflen| is large enough to hold the whole +// JavaScript string. If |buflen| is smaller, the total size of the JavaScript +// is still returned, but nothing is copied. If there is no JavaScript for +// |event| in |annot|, an empty string is written to |buf| and 2 is returned, +// denoting the size of the null terminator in the buffer. On other errors, +// nothing is written to |buffer| and 0 is returned. +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment(). +// annot - handle to an interactive form annotation. +// event - event type, one of the FPDF_ANNOT_AACTION_* values. +// buffer - buffer for holding the value string, encoded in UTF-16LE. +// buflen - length of the buffer in bytes. +// +// Returns the length of the string value in bytes, including the 2-byte +// null terminator. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFAnnot_GetFormAdditionalActionJavaScript(FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + int event, + FPDF_WCHAR* buffer, + unsigned long buflen); + +// Experimental API. +// Check if |annot|'s dictionary has |key| as a key. +// +// annot - handle to an annotation. +// key - the key to look for, encoded in UTF-8. +// +// Returns true if |key| exists. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_HasKey(FPDF_ANNOTATION annot, + FPDF_BYTESTRING key); + +// Experimental API. +// Get the type of the value corresponding to |key| in |annot|'s dictionary. +// +// annot - handle to an annotation. +// key - the key to look for, encoded in UTF-8. +// +// Returns the type of the dictionary value. +FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV +FPDFAnnot_GetValueType(FPDF_ANNOTATION annot, FPDF_BYTESTRING key); + +// Experimental API. +// Set the string value corresponding to |key| in |annot|'s dictionary, +// overwriting the existing value if any. The value type would be +// FPDF_OBJECT_STRING after this function call succeeds. +// +// annot - handle to an annotation. +// key - the key to the dictionary entry to be set, encoded in UTF-8. +// value - the string value to be set, encoded in UTF-16LE. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_SetStringValue(FPDF_ANNOTATION annot, + FPDF_BYTESTRING key, + FPDF_WIDESTRING value); + +// Experimental API. +// Get the string value corresponding to |key| in |annot|'s dictionary. |buffer| +// is only modified if |buflen| is longer than the length of contents. Note that +// if |key| does not exist in the dictionary or if |key|'s corresponding value +// in the dictionary is not a string (i.e. the value is not of type +// FPDF_OBJECT_STRING or FPDF_OBJECT_NAME), then an empty string would be copied +// to |buffer| and the return value would be 2. On other errors, nothing would +// be added to |buffer| and the return value would be 0. +// +// annot - handle to an annotation. +// key - the key to the requested dictionary entry, encoded in UTF-8. +// buffer - buffer for holding the value string, encoded in UTF-16LE. +// buflen - length of the buffer in bytes. +// +// Returns the length of the string value in bytes. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFAnnot_GetStringValue(FPDF_ANNOTATION annot, + FPDF_BYTESTRING key, + FPDF_WCHAR* buffer, + unsigned long buflen); + +// Experimental API. +// Get the float value corresponding to |key| in |annot|'s dictionary. Writes +// value to |value| and returns True if |key| exists in the dictionary and +// |key|'s corresponding value is a number (FPDF_OBJECT_NUMBER), False +// otherwise. +// +// annot - handle to an annotation. +// key - the key to the requested dictionary entry, encoded in UTF-8. +// value - receives the value, must not be NULL. +// +// Returns True if value found, False otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_GetNumberValue(FPDF_ANNOTATION annot, + FPDF_BYTESTRING key, + float* value); + +// Experimental API. +// Set the AP (appearance string) in |annot|'s dictionary for a given +// |appearanceMode|. +// +// annot - handle to an annotation. +// appearanceMode - the appearance mode (normal, rollover or down) for which +// to get the AP. +// value - the string value to be set, encoded in UTF-16LE. If +// nullptr is passed, the AP is cleared for that mode. If the +// mode is Normal, APs for all modes are cleared. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_SetAP(FPDF_ANNOTATION annot, + FPDF_ANNOT_APPEARANCEMODE appearanceMode, + FPDF_WIDESTRING value); + +// Experimental API. +// Get the AP (appearance string) from |annot|'s dictionary for a given +// |appearanceMode|. +// |buffer| is only modified if |buflen| is large enough to hold the whole AP +// string. If |buflen| is smaller, the total size of the AP is still returned, +// but nothing is copied. +// If there is no appearance stream for |annot| in |appearanceMode|, an empty +// string is written to |buf| and 2 is returned. +// On other errors, nothing is written to |buffer| and 0 is returned. +// +// annot - handle to an annotation. +// appearanceMode - the appearance mode (normal, rollover or down) for which +// to get the AP. +// buffer - buffer for holding the value string, encoded in UTF-16LE. +// buflen - length of the buffer in bytes. +// +// Returns the length of the string value in bytes. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFAnnot_GetAP(FPDF_ANNOTATION annot, + FPDF_ANNOT_APPEARANCEMODE appearanceMode, + FPDF_WCHAR* buffer, + unsigned long buflen); + +// Experimental API. +// Get the annotation corresponding to |key| in |annot|'s dictionary. Common +// keys for linking annotations include "IRT" and "Popup". Must call +// FPDFPage_CloseAnnot() when the annotation returned by this function is no +// longer needed. +// +// annot - handle to an annotation. +// key - the key to the requested dictionary entry, encoded in UTF-8. +// +// Returns a handle to the linked annotation object, or NULL on failure. +FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV +FPDFAnnot_GetLinkedAnnot(FPDF_ANNOTATION annot, FPDF_BYTESTRING key); + +// Experimental API. +// Get the annotation flags of |annot|. +// +// annot - handle to an annotation. +// +// Returns the annotation flags. +FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetFlags(FPDF_ANNOTATION annot); + +// Experimental API. +// Set the |annot|'s flags to be of the value |flags|. +// +// annot - handle to an annotation. +// flags - the flag values to be set. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetFlags(FPDF_ANNOTATION annot, + int flags); + +// Experimental API. +// Get the annotation flags of |annot|. +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment(). +// annot - handle to an interactive form annotation. +// +// Returns the annotation flags specific to interactive forms. +FPDF_EXPORT int FPDF_CALLCONV +FPDFAnnot_GetFormFieldFlags(FPDF_FORMHANDLE handle, + FPDF_ANNOTATION annot); + +// Experimental API. +// Retrieves an interactive form annotation whose rectangle contains a given +// point on a page. Must call FPDFPage_CloseAnnot() when the annotation returned +// is no longer needed. +// +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - handle to the page, returned by FPDF_LoadPage function. +// point - position in PDF "user space". +// +// Returns the interactive form annotation whose rectangle contains the given +// coordinates on the page. If there is no such annotation, return NULL. +FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV +FPDFAnnot_GetFormFieldAtPoint(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + const FS_POINTF* point); + +// Experimental API. +// Gets the name of |annot|, which is an interactive form annotation. +// |buffer| is only modified if |buflen| is longer than the length of contents. +// In case of error, nothing will be added to |buffer| and the return value will +// be 0. Note that return value of empty string is 2 for "\0\0". +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment(). +// annot - handle to an interactive form annotation. +// buffer - buffer for holding the name string, encoded in UTF-16LE. +// buflen - length of the buffer in bytes. +// +// Returns the length of the string value in bytes. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFAnnot_GetFormFieldName(FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + FPDF_WCHAR* buffer, + unsigned long buflen); + +// Experimental API. +// Gets the alternate name of |annot|, which is an interactive form annotation. +// |buffer| is only modified if |buflen| is longer than the length of contents. +// In case of error, nothing will be added to |buffer| and the return value will +// be 0. Note that return value of empty string is 2 for "\0\0". +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment(). +// annot - handle to an interactive form annotation. +// buffer - buffer for holding the alternate name string, encoded in +// UTF-16LE. +// buflen - length of the buffer in bytes. +// +// Returns the length of the string value in bytes. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFAnnot_GetFormFieldAlternateName(FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + FPDF_WCHAR* buffer, + unsigned long buflen); + +// Experimental API. +// Gets the form field type of |annot|, which is an interactive form annotation. +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment(). +// annot - handle to an interactive form annotation. +// +// Returns the type of the form field (one of the FPDF_FORMFIELD_* values) on +// success. Returns -1 on error. +// See field types in fpdf_formfill.h. +FPDF_EXPORT int FPDF_CALLCONV +FPDFAnnot_GetFormFieldType(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot); + +// Experimental API. +// Gets the value of |annot|, which is an interactive form annotation. +// |buffer| is only modified if |buflen| is longer than the length of contents. +// In case of error, nothing will be added to |buffer| and the return value will +// be 0. Note that return value of empty string is 2 for "\0\0". +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment(). +// annot - handle to an interactive form annotation. +// buffer - buffer for holding the value string, encoded in UTF-16LE. +// buflen - length of the buffer in bytes. +// +// Returns the length of the string value in bytes. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFAnnot_GetFormFieldValue(FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + FPDF_WCHAR* buffer, + unsigned long buflen); + +// Experimental API. +// Get the number of options in the |annot|'s "Opt" dictionary. Intended for +// use with listbox and combobox widget annotations. +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment. +// annot - handle to an annotation. +// +// Returns the number of options in "Opt" dictionary on success. Return value +// will be -1 if annotation does not have an "Opt" dictionary or other error. +FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetOptionCount(FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot); + +// Experimental API. +// Get the string value for the label of the option at |index| in |annot|'s +// "Opt" dictionary. Intended for use with listbox and combobox widget +// annotations. |buffer| is only modified if |buflen| is longer than the length +// of contents. If index is out of range or in case of other error, nothing +// will be added to |buffer| and the return value will be 0. Note that +// return value of empty string is 2 for "\0\0". +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment. +// annot - handle to an annotation. +// index - numeric index of the option in the "Opt" array +// buffer - buffer for holding the value string, encoded in UTF-16LE. +// buflen - length of the buffer in bytes. +// +// Returns the length of the string value in bytes. +// If |annot| does not have an "Opt" array, |index| is out of range or if any +// other error occurs, returns 0. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFAnnot_GetOptionLabel(FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + int index, + FPDF_WCHAR* buffer, + unsigned long buflen); + +// Experimental API. +// Determine whether or not the option at |index| in |annot|'s "Opt" dictionary +// is selected. Intended for use with listbox and combobox widget annotations. +// +// handle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment. +// annot - handle to an annotation. +// index - numeric index of the option in the "Opt" array. +// +// Returns true if the option at |index| in |annot|'s "Opt" dictionary is +// selected, false otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_IsOptionSelected(FPDF_FORMHANDLE handle, + FPDF_ANNOTATION annot, + int index); + +// Experimental API. +// Get the float value of the font size for an |annot| with variable text. +// If 0, the font is to be auto-sized: its size is computed as a function of +// the height of the annotation rectangle. +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment. +// annot - handle to an annotation. +// value - Required. Float which will be set to font size on success. +// +// Returns true if the font size was set in |value|, false on error or if +// |value| not provided. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_GetFontSize(FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + float* value); + +// Experimental API. +// Get the RGB value of the font color for an |annot| with variable text. +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment. +// annot - handle to an annotation. +// R, G, B - buffer to hold the RGB value of the color. Ranges from 0 to 255. +// +// Returns true if the font color was set, false on error or if the font +// color was not provided. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_GetFontColor(FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + unsigned int* R, + unsigned int* G, + unsigned int* B); + +// Experimental API. +// Determine if |annot| is a form widget that is checked. Intended for use with +// checkbox and radio button widgets. +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment. +// annot - handle to an annotation. +// +// Returns true if |annot| is a form widget and is checked, false otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_IsChecked(FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot); + +// Experimental API. +// Set the list of focusable annotation subtypes. Annotations of subtype +// FPDF_ANNOT_WIDGET are by default focusable. New subtypes set using this API +// will override the existing subtypes. +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment. +// subtypes - list of annotation subtype which can be tabbed over. +// count - total number of annotation subtype in list. +// Returns true if list of annotation subtype is set successfully, false +// otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_SetFocusableSubtypes(FPDF_FORMHANDLE hHandle, + const FPDF_ANNOTATION_SUBTYPE* subtypes, + size_t count); + +// Experimental API. +// Get the count of focusable annotation subtypes as set by host +// for a |hHandle|. +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment. +// Returns the count of focusable annotation subtypes or -1 on error. +// Note : Annotations of type FPDF_ANNOT_WIDGET are by default focusable. +FPDF_EXPORT int FPDF_CALLCONV +FPDFAnnot_GetFocusableSubtypesCount(FPDF_FORMHANDLE hHandle); + +// Experimental API. +// Get the list of focusable annotation subtype as set by host. +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment. +// subtypes - receives the list of annotation subtype which can be tabbed +// over. Caller must have allocated |subtypes| more than or +// equal to the count obtained from +// FPDFAnnot_GetFocusableSubtypesCount() API. +// count - size of |subtypes|. +// Returns true on success and set list of annotation subtype to |subtypes|, +// false otherwise. +// Note : Annotations of type FPDF_ANNOT_WIDGET are by default focusable. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAnnot_GetFocusableSubtypes(FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION_SUBTYPE* subtypes, + size_t count); + +// Experimental API. +// Gets FPDF_LINK object for |annot|. Intended to use for link annotations. +// +// annot - handle to an annotation. +// +// Returns FPDF_LINK from the FPDF_ANNOTATION and NULL on failure, +// if the input annot is NULL or input annot's subtype is not link. +FPDF_EXPORT FPDF_LINK FPDF_CALLCONV FPDFAnnot_GetLink(FPDF_ANNOTATION annot); + +// Experimental API. +// Gets the count of annotations in the |annot|'s control group. +// A group of interactive form annotations is collectively called a form +// control group. Here, |annot|, an interactive form annotation, should be +// either a radio button or a checkbox. +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment. +// annot - handle to an annotation. +// +// Returns number of controls in its control group or -1 on error. +FPDF_EXPORT int FPDF_CALLCONV +FPDFAnnot_GetFormControlCount(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot); + +// Experimental API. +// Gets the index of |annot| in |annot|'s control group. +// A group of interactive form annotations is collectively called a form +// control group. Here, |annot|, an interactive form annotation, should be +// either a radio button or a checkbox. +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment. +// annot - handle to an annotation. +// +// Returns index of a given |annot| in its control group or -1 on error. +FPDF_EXPORT int FPDF_CALLCONV +FPDFAnnot_GetFormControlIndex(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot); + +// Experimental API. +// Gets the export value of |annot| which is an interactive form annotation. +// Intended for use with radio button and checkbox widget annotations. +// |buffer| is only modified if |buflen| is longer than the length of contents. +// In case of error, nothing will be added to |buffer| and the return value +// will be 0. Note that return value of empty string is 2 for "\0\0". +// +// hHandle - handle to the form fill module, returned by +// FPDFDOC_InitFormFillEnvironment(). +// annot - handle to an interactive form annotation. +// buffer - buffer for holding the value string, encoded in UTF-16LE. +// buflen - length of the buffer in bytes. +// +// Returns the length of the string value in bytes. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFAnnot_GetFormFieldExportValue(FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, + FPDF_WCHAR* buffer, + unsigned long buflen); + +// Experimental API. +// Add a URI action to |annot|, overwriting the existing action, if any. +// +// annot - handle to a link annotation. +// uri - the URI to be set, encoded in 7-bit ASCII. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetURI(FPDF_ANNOTATION annot, + const char* uri); + +// Experimental API. +// Get the attachment from |annot|. +// +// annot - handle to a file annotation. +// +// Returns the handle to the attachment object, or NULL on failure. +FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV +FPDFAnnot_GetFileAttachment(FPDF_ANNOTATION annot); + +// Experimental API. +// Add an embedded file with |name| to |annot|. +// +// annot - handle to a file annotation. +// name - name of the new attachment. +// +// Returns a handle to the new attachment object, or NULL on failure. +FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV +FPDFAnnot_AddFileAttachment(FPDF_ANNOTATION annot, FPDF_WIDESTRING name); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // PUBLIC_FPDF_ANNOT_H_ diff --git a/src/main/jni/include/fpdf_attachment.h b/src/main/jni/include/fpdf_attachment.h new file mode 100644 index 00000000..d25bddab --- /dev/null +++ b/src/main/jni/include/fpdf_attachment.h @@ -0,0 +1,179 @@ +// Copyright 2017 The PDFium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PUBLIC_FPDF_ATTACHMENT_H_ +#define PUBLIC_FPDF_ATTACHMENT_H_ + +// NOLINTNEXTLINE(build/include) +#include "fpdfview.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Experimental API. +// Get the number of embedded files in |document|. +// +// document - handle to a document. +// +// Returns the number of embedded files in |document|. +FPDF_EXPORT int FPDF_CALLCONV +FPDFDoc_GetAttachmentCount(FPDF_DOCUMENT document); + +// Experimental API. +// Add an embedded file with |name| in |document|. If |name| is empty, or if +// |name| is the name of a existing embedded file in |document|, or if +// |document|'s embedded file name tree is too deep (i.e. |document| has too +// many embedded files already), then a new attachment will not be added. +// +// document - handle to a document. +// name - name of the new attachment. +// +// Returns a handle to the new attachment object, or NULL on failure. +FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV +FPDFDoc_AddAttachment(FPDF_DOCUMENT document, FPDF_WIDESTRING name); + +// Experimental API. +// Get the embedded attachment at |index| in |document|. Note that the returned +// attachment handle is only valid while |document| is open. +// +// document - handle to a document. +// index - the index of the requested embedded file. +// +// Returns the handle to the attachment object, or NULL on failure. +FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV +FPDFDoc_GetAttachment(FPDF_DOCUMENT document, int index); + +// Experimental API. +// Delete the embedded attachment at |index| in |document|. Note that this does +// not remove the attachment data from the PDF file; it simply removes the +// file's entry in the embedded files name tree so that it does not appear in +// the attachment list. This behavior may change in the future. +// +// document - handle to a document. +// index - the index of the embedded file to be deleted. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFDoc_DeleteAttachment(FPDF_DOCUMENT document, int index); + +// Experimental API. +// Get the name of the |attachment| file. |buffer| is only modified if |buflen| +// is longer than the length of the file name. On errors, |buffer| is unmodified +// and the returned length is 0. +// +// attachment - handle to an attachment. +// buffer - buffer for holding the file name, encoded in UTF-16LE. +// buflen - length of the buffer in bytes. +// +// Returns the length of the file name in bytes. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFAttachment_GetName(FPDF_ATTACHMENT attachment, + FPDF_WCHAR* buffer, + unsigned long buflen); + +// Experimental API. +// Check if the params dictionary of |attachment| has |key| as a key. +// +// attachment - handle to an attachment. +// key - the key to look for, encoded in UTF-8. +// +// Returns true if |key| exists. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAttachment_HasKey(FPDF_ATTACHMENT attachment, FPDF_BYTESTRING key); + +// Experimental API. +// Get the type of the value corresponding to |key| in the params dictionary of +// the embedded |attachment|. +// +// attachment - handle to an attachment. +// key - the key to look for, encoded in UTF-8. +// +// Returns the type of the dictionary value. +FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV +FPDFAttachment_GetValueType(FPDF_ATTACHMENT attachment, FPDF_BYTESTRING key); + +// Experimental API. +// Set the string value corresponding to |key| in the params dictionary of the +// embedded file |attachment|, overwriting the existing value if any. The value +// type should be FPDF_OBJECT_STRING after this function call succeeds. +// +// attachment - handle to an attachment. +// key - the key to the dictionary entry, encoded in UTF-8. +// value - the string value to be set, encoded in UTF-16LE. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAttachment_SetStringValue(FPDF_ATTACHMENT attachment, + FPDF_BYTESTRING key, + FPDF_WIDESTRING value); + +// Experimental API. +// Get the string value corresponding to |key| in the params dictionary of the +// embedded file |attachment|. |buffer| is only modified if |buflen| is longer +// than the length of the string value. Note that if |key| does not exist in the +// dictionary or if |key|'s corresponding value in the dictionary is not a +// string (i.e. the value is not of type FPDF_OBJECT_STRING or +// FPDF_OBJECT_NAME), then an empty string would be copied to |buffer| and the +// return value would be 2. On other errors, nothing would be added to |buffer| +// and the return value would be 0. +// +// attachment - handle to an attachment. +// key - the key to the requested string value, encoded in UTF-8. +// buffer - buffer for holding the string value encoded in UTF-16LE. +// buflen - length of the buffer in bytes. +// +// Returns the length of the dictionary value string in bytes. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFAttachment_GetStringValue(FPDF_ATTACHMENT attachment, + FPDF_BYTESTRING key, + FPDF_WCHAR* buffer, + unsigned long buflen); + +// Experimental API. +// Set the file data of |attachment|, overwriting the existing file data if any. +// The creation date and checksum will be updated, while all other dictionary +// entries will be deleted. Note that only contents with |len| smaller than +// INT_MAX is supported. +// +// attachment - handle to an attachment. +// contents - buffer holding the file data to write to |attachment|. +// len - length of file data in bytes. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAttachment_SetFile(FPDF_ATTACHMENT attachment, + FPDF_DOCUMENT document, + const void* contents, + unsigned long len); + +// Experimental API. +// Get the file data of |attachment|. +// When the attachment file data is readable, true is returned, and |out_buflen| +// is updated to indicate the file data size. |buffer| is only modified if +// |buflen| is non-null and long enough to contain the entire file data. Callers +// must check both the return value and the input |buflen| is no less than the +// returned |out_buflen| before using the data. +// +// Otherwise, when the attachment file data is unreadable or when |out_buflen| +// is null, false is returned and |buffer| and |out_buflen| remain unmodified. +// +// attachment - handle to an attachment. +// buffer - buffer for holding the file data from |attachment|. +// buflen - length of the buffer in bytes. +// out_buflen - pointer to the variable that will receive the minimum buffer +// size to contain the file data of |attachment|. +// +// Returns true on success, false otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFAttachment_GetFile(FPDF_ATTACHMENT attachment, + void* buffer, + unsigned long buflen, + unsigned long* out_buflen); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // PUBLIC_FPDF_ATTACHMENT_H_ diff --git a/src/main/jni/include/fpdf_catalog.h b/src/main/jni/include/fpdf_catalog.h new file mode 100644 index 00000000..033cca5f --- /dev/null +++ b/src/main/jni/include/fpdf_catalog.h @@ -0,0 +1,42 @@ +// Copyright 2017 The PDFium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PUBLIC_FPDF_CATALOG_H_ +#define PUBLIC_FPDF_CATALOG_H_ + +// NOLINTNEXTLINE(build/include) +#include "fpdfview.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Experimental API. +// +// Determine if |document| represents a tagged PDF. +// +// For the definition of tagged PDF, See (see 10.7 "Tagged PDF" in PDF +// Reference 1.7). +// +// document - handle to a document. +// +// Returns |true| iff |document| is a tagged PDF. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFCatalog_IsTagged(FPDF_DOCUMENT document); + +// Experimental API. +// Sets the language of |document| to |language|. +// +// document - handle to a document. +// language - the language to set to. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFCatalog_SetLanguage(FPDF_DOCUMENT document, FPDF_BYTESTRING language); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // PUBLIC_FPDF_CATALOG_H_ diff --git a/src/main/jni/include/fpdf_dataavail.h b/src/main/jni/include/fpdf_dataavail.h index 0f8ff7d6..004d9beb 100644 --- a/src/main/jni/include/fpdf_dataavail.h +++ b/src/main/jni/include/fpdf_dataavail.h @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,8 +7,9 @@ #ifndef PUBLIC_FPDF_DATAAVAIL_H_ #define PUBLIC_FPDF_DATAAVAIL_H_ -#include // For size_t. +#include +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" #define PDF_LINEARIZATION_UNKNOWN -1 @@ -26,248 +27,178 @@ #ifdef __cplusplus extern "C" { -#endif +#endif // __cplusplus -/** - * Interface: FX_FILEAVAIL - * Interface for checking whether the section of the file is available. - */ +// Interface for checking whether sections of the file are available. typedef struct _FX_FILEAVAIL { - /** - * Version number of the interface. Currently must be 1. - */ + // Version number of the interface. Must be 1. int version; - /** - * Method: IsDataAvail - * Report whether the specified data section is available. A section is - * available only if all bytes in the section is available. - * Interface Version: - * 1 - * Implementation Required: - * Yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * offset - The offset of the data section in the file. - * size - The size of the data section - * Return Value: - * true means the specified data section is available. - * Comments: - * Called by Foxit SDK to check whether the data section is ready. - */ - FPDF_BOOL (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, size_t offset, size_t size); + // Reports if the specified data section is currently available. A section is + // available if all bytes in the section are available. + // + // Interface Version: 1 + // Implementation Required: Yes + // + // pThis - pointer to the interface structure. + // offset - the offset of the data section in the file. + // size - the size of the data section. + // + // Returns true if the specified data section at |offset| of |size| + // is available. + FPDF_BOOL (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, + size_t offset, + size_t size); } FX_FILEAVAIL; -typedef void* FPDF_AVAIL; - -/** -* Function: FPDFAvail_Create -* Create a document availability provider. -* -* Parameters: -* file_avail - Pointer to file availability interface to check -* availability of file data. -* file - Pointer to a file access interface for reading data -* from file. -* Return value: -* A handle to the document availability provider. NULL for error. -* Comments: -* Application must call FPDFAvail_Destroy when done with the -* availability provider. -*/ -DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, - FPDF_FILEACCESS* file); - -/** -* Function: FPDFAvail_Destroy -* Destroy a document availibity provider. -* -* Parameters: -* avail - Handle to document availability provider returned by -* FPDFAvail_Create -* Return Value: -* None. -*/ -DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail); - -/** - * Interface: FX_DOWNLOADHINTS - * Download hints interface. Used to receive hints for further - * downloading. - */ +// Create a document availability provider. +// +// file_avail - pointer to file availability interface. +// file - pointer to a file access interface. +// +// Returns a handle to the document availability provider, or NULL on error. +// +// FPDFAvail_Destroy() must be called when done with the availability provider. +FPDF_EXPORT FPDF_AVAIL FPDF_CALLCONV FPDFAvail_Create(FX_FILEAVAIL* file_avail, + FPDF_FILEACCESS* file); + +// Destroy the |avail| document availability provider. +// +// avail - handle to document availability provider to be destroyed. +FPDF_EXPORT void FPDF_CALLCONV FPDFAvail_Destroy(FPDF_AVAIL avail); + +// Download hints interface. Used to receive hints for further downloading. typedef struct _FX_DOWNLOADHINTS { - /** - * Version number of the interface. Currently must be 1. - */ + // Version number of the interface. Must be 1. int version; - /** - * Method: AddSegment - * Add a section to be downloaded. - * Interface Version: - * 1 - * Implementation Required: - * Yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * offset - The offset of the hint reported to be downloaded. - * size - The size of the hint reported to be downloaded. - * Return Value: - * None. - * Comments: - * Called by Foxit SDK to report some downloading hints for download - * manager. - * The position and size of section may be not accurate, part of the - * section might be already available. - * The download manager must deal with that to maximize download - * efficiency. - */ + // Add a section to be downloaded. + // + // Interface Version: 1 + // Implementation Required: Yes + // + // pThis - pointer to the interface structure. + // offset - the offset of the hint reported to be downloaded. + // size - the size of the hint reported to be downloaded. + // + // The |offset| and |size| of the section may not be unique. Part of the + // section might be already available. The download manager must deal with + // overlapping sections. void (*AddSegment)(struct _FX_DOWNLOADHINTS* pThis, size_t offset, size_t size); } FX_DOWNLOADHINTS; -/** -* Function: FPDFAvail_IsDocAvail -* Check whether the document is ready for loading, if not, get -* download hints. -* -* Parameters: -* avail - Handle to document availability provider returned by -* FPDFAvail_Create -* hints - Pointer to a download hints interface, receiving -* generated hints -* Return value: -* PDF_DATA_ERROR: A common error is returned. It can't tell -* whehter data are availabe or not. -* PDF_DATA_NOTAVAIL: Data are not yet available. -* PDF_DATA_AVAIL: Data are available. -* Comments: -* Applications should call this function whenever new data arrived, -* and process all the generated download hints if any, until the -* function returns PDF_DATA_ERROR or PDF_DATA_AVAIL. Then -* applications can call FPDFAvail_GetDocument() to get a document -* handle. -*/ -DLLEXPORT int STDCALL -FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints); - -/** -* Function: FPDFAvail_GetDocument -* Get document from the availability provider. -* -* Parameters: -* avail - Handle to document availability provider returned by -* FPDFAvail_Create -* password - Optional password for decrypting the PDF file. -* Return value: -* Handle to the document. -* Comments: -* After FPDFAvail_IsDocAvail() returns TRUE, the application should -* call this function to -* get the document handle. To close the document, use -* FPDF_CloseDocument function. -*/ -DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail, - FPDF_BYTESTRING password); - -/** -* Function: FPDFAvail_GetFirstPageNum -* Get page number for the first available page in a linearized PDF -* -* Parameters: -* doc - A document handle returned by FPDFAvail_GetDocument -* Return Value: -* Zero-based index for the first available page. -* Comments: -* For most linearized PDFs, the first available page would be just the -* first page, however, -* some PDFs might make other page to be the first available page. -* For non-linearized PDF, this function will always return zero. -*/ -DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc); - -/** -* Function: FPDFAvail_IsPageAvail -* Check whether a page is ready for loading, if not, get download -* hints. -* -* Parameters: -* avail - Handle to document availability provider returned by -* FPDFAvail_Create -* page_index - Index number of the page. 0 for the first page. -* hints - Pointer to a download hints interface, receiving -* generated hints -* Return value: -* PDF_DATA_ERROR: A common error is returned. It can't tell -* whehter data are availabe or not. -* PDF_DATA_NOTAVAIL: Data are not yet available. -* PDF_DATA_AVAIL: Data are available. -* Comments: -* This function can be called only after FPDFAvail_GetDocument is -* called. Applications should call this function whenever new data -* arrived and process all the generated download hints if any, until -* this function returns PDF_DATA_ERROR or PDF_DATA_AVAIL. Then -* applications can perform page loading. -*/ -DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, - int page_index, - FX_DOWNLOADHINTS* hints); - -/** -* Function: FPDFAvail_ISFormAvail -* Check whether Form data is ready for init, if not, get download -* hints. -* -* Parameters: -* avail - Handle to document availability provider returned by -* FPDFAvail_Create -* hints - Pointer to a download hints interface, receiving -* generated hints -* Return value: -* PDF_FORM_ERROR - A common eror, in general incorrect parameters, -* like 'hints' is nullptr. -* PDF_FORM_NOTAVAIL - data not available -* PDF_FORM_AVAIL - data available -* PDF_FORM_NOTEXIST - no form data -* Comments: -* This function can be called only after FPDFAvail_GetDocument is -* called. -* The application should call this function whenever new data arrived, -* and process all the -* generated download hints if any, until the function returns non-zero -* value. Then the -* application can perform page loading. Recommend to call -* FPDFDOC_InitFormFillEnvironment -* after the function returns non-zero value. -*/ -DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail, - FX_DOWNLOADHINTS* hints); - -/** -* Function: FPDFAvail_IsLinearized -* To check whether a document is Linearized PDF file. -* -* Parameters: -* avail - Handle to document availability provider returned by -* FPDFAvail_Create -* Return value: -* PDF_LINEARIZED is a linearize file. -* PDF_NOT_LINEARIZED is not a linearize file. -* PDF_LINEARIZATION_UNKNOWN doesn't know whether the file is a -*linearize file. -* -* Comments: -* It return PDF_LINEARIZED or PDF_NOT_LINEARIZED as soon as -* we have first 1K data. If the file's size less than 1K, it returns -* PDF_LINEARIZATION_UNKNOWN because there is not enough information to -* tell whether a PDF file is a linearized file or not. -* -*/ -DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail); +// Checks if the document is ready for loading, if not, gets download hints. +// +// avail - handle to document availability provider. +// hints - pointer to a download hints interface. +// +// Returns one of: +// PDF_DATA_ERROR: A common error is returned. Data availability unknown. +// PDF_DATA_NOTAVAIL: Data not yet available. +// PDF_DATA_AVAIL: Data available. +// +// Applications should call this function whenever new data arrives, and process +// all the generated download hints, if any, until the function returns +// |PDF_DATA_ERROR| or |PDF_DATA_AVAIL|. +// if hints is nullptr, the function just check current document availability. +// +// Once all data is available, call FPDFAvail_GetDocument() to get a document +// handle. +FPDF_EXPORT int FPDF_CALLCONV FPDFAvail_IsDocAvail(FPDF_AVAIL avail, + FX_DOWNLOADHINTS* hints); + +// Get document from the availability provider. +// +// avail - handle to document availability provider. +// password - password for decrypting the PDF file. Optional. +// +// Returns a handle to the document. +// +// When FPDFAvail_IsDocAvail() returns TRUE, call FPDFAvail_GetDocument() to +// retrieve the document handle. +// See the comments for FPDF_LoadDocument() regarding the encoding for +// |password|. +FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV +FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password); + +// Get the page number for the first available page in a linearized PDF. +// +// doc - document handle. +// +// Returns the zero-based index for the first available page. +// +// For most linearized PDFs, the first available page will be the first page, +// however, some PDFs might make another page the first available page. +// For non-linearized PDFs, this function will always return zero. +FPDF_EXPORT int FPDF_CALLCONV FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc); + +// Check if |page_index| is ready for loading, if not, get the +// |FX_DOWNLOADHINTS|. +// +// avail - handle to document availability provider. +// page_index - index number of the page. Zero for the first page. +// hints - pointer to a download hints interface. Populated if +// |page_index| is not available. +// +// Returns one of: +// PDF_DATA_ERROR: A common error is returned. Data availability unknown. +// PDF_DATA_NOTAVAIL: Data not yet available. +// PDF_DATA_AVAIL: Data available. +// +// This function can be called only after FPDFAvail_GetDocument() is called. +// Applications should call this function whenever new data arrives and process +// all the generated download |hints|, if any, until this function returns +// |PDF_DATA_ERROR| or |PDF_DATA_AVAIL|. Applications can then perform page +// loading. +// if hints is nullptr, the function just check current availability of +// specified page. +FPDF_EXPORT int FPDF_CALLCONV FPDFAvail_IsPageAvail(FPDF_AVAIL avail, + int page_index, + FX_DOWNLOADHINTS* hints); + +// Check if form data is ready for initialization, if not, get the +// |FX_DOWNLOADHINTS|. +// +// avail - handle to document availability provider. +// hints - pointer to a download hints interface. Populated if form is not +// ready for initialization. +// +// Returns one of: +// PDF_FORM_ERROR: A common eror, in general incorrect parameters. +// PDF_FORM_NOTAVAIL: Data not available. +// PDF_FORM_AVAIL: Data available. +// PDF_FORM_NOTEXIST: No form data. +// +// This function can be called only after FPDFAvail_GetDocument() is called. +// The application should call this function whenever new data arrives and +// process all the generated download |hints|, if any, until the function +// |PDF_FORM_ERROR|, |PDF_FORM_AVAIL| or |PDF_FORM_NOTEXIST|. +// if hints is nullptr, the function just check current form availability. +// +// Applications can then perform page loading. It is recommend to call +// FPDFDOC_InitFormFillEnvironment() when |PDF_FORM_AVAIL| is returned. +FPDF_EXPORT int FPDF_CALLCONV FPDFAvail_IsFormAvail(FPDF_AVAIL avail, + FX_DOWNLOADHINTS* hints); + +// Check whether a document is a linearized PDF. +// +// avail - handle to document availability provider. +// +// Returns one of: +// PDF_LINEARIZED +// PDF_NOT_LINEARIZED +// PDF_LINEARIZATION_UNKNOWN +// +// FPDFAvail_IsLinearized() will return |PDF_LINEARIZED| or |PDF_NOT_LINEARIZED| +// when we have 1k of data. If the files size less than 1k, it returns +// |PDF_LINEARIZATION_UNKNOWN| as there is insufficient information to determine +// if the PDF is linearlized. +FPDF_EXPORT int FPDF_CALLCONV FPDFAvail_IsLinearized(FPDF_AVAIL avail); #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_DATAAVAIL_H_ diff --git a/src/main/jni/include/fpdf_doc.h b/src/main/jni/include/fpdf_doc.h index de05eb3a..2dc22d9c 100644 --- a/src/main/jni/include/fpdf_doc.h +++ b/src/main/jni/include/fpdf_doc.h @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,359 +7,432 @@ #ifndef PUBLIC_FPDF_DOC_H_ #define PUBLIC_FPDF_DOC_H_ +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" -// Exported Functions #ifdef __cplusplus extern "C" { -#endif - -// Function: FPDFBookmark_GetFirstChild -// Get the first child of a bookmark item, or the first top level -// bookmark item. -// Parameters: -// document - Handle to the document. Returned by -// FPDF_LoadDocument or FPDF_LoadMemDocument. -// bookmark - Handle to the current bookmark. Can be NULL if you -// want to get the first top level item. -// Return value: -// Handle to the first child or top level bookmark item. NULL if no -// child or top level bookmark found. -// -DLLEXPORT FPDF_BOOKMARK STDCALL +#endif // __cplusplus + +// Unsupported action type. +#define PDFACTION_UNSUPPORTED 0 +// Go to a destination within current document. +#define PDFACTION_GOTO 1 +// Go to a destination within another document. +#define PDFACTION_REMOTEGOTO 2 +// URI, including web pages and other Internet resources. +#define PDFACTION_URI 3 +// Launch an application or open a file. +#define PDFACTION_LAUNCH 4 +// Go to a destination in an embedded file. +#define PDFACTION_EMBEDDEDGOTO 5 + +// View destination fit types. See pdfmark reference v9, page 48. +#define PDFDEST_VIEW_UNKNOWN_MODE 0 +#define PDFDEST_VIEW_XYZ 1 +#define PDFDEST_VIEW_FIT 2 +#define PDFDEST_VIEW_FITH 3 +#define PDFDEST_VIEW_FITV 4 +#define PDFDEST_VIEW_FITR 5 +#define PDFDEST_VIEW_FITB 6 +#define PDFDEST_VIEW_FITBH 7 +#define PDFDEST_VIEW_FITBV 8 + +// The file identifier entry type. See section 14.4 "File Identifiers" of the +// ISO 32000-1:2008 spec. +typedef enum { + FILEIDTYPE_PERMANENT = 0, + FILEIDTYPE_CHANGING = 1 +} FPDF_FILEIDTYPE; + +// Get the first child of |bookmark|, or the first top-level bookmark item. +// +// document - handle to the document. +// bookmark - handle to the current bookmark. Pass NULL for the first top +// level item. +// +// 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); -// Function: FPDFBookmark_GetNextSibling -// Get next bookmark item at the same level. -// Parameters: -// document - Handle to the document. Returned by -// FPDF_LoadDocument or FPDF_LoadMemDocument. -// bookmark - Handle to the current bookmark. Cannot be NULL. -// Return value: -// Handle to the next bookmark item at the same level. NULL if this is -// the last bookmark at this level. -// -DLLEXPORT FPDF_BOOKMARK STDCALL +// Get the next sibling of |bookmark|. +// +// document - handle to the document. +// bookmark - handle to the current bookmark. +// +// Returns a handle to the next sibling of |bookmark|, or NULL if this is the +// last bookmark at this level. +// +// Note that the caller is responsible for handling circular bookmark +// references, as may arise from malformed documents. +FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV FPDFBookmark_GetNextSibling(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark); -// Function: FPDFBookmark_GetTitle -// Get title of a bookmark. -// Parameters: -// bookmark - Handle to the bookmark. -// buffer - Buffer for the title. Can be NULL. -// buflen - The length of the buffer in bytes. Can be 0. -// Return value: -// Number of bytes the title consumes, including trailing zeros. -// Comments: -// Regardless of the platform, the title is always in UTF-16LE -// encoding. That means the buffer -// can be treated as an array of WORD (on Intel and compatible CPUs), -// each WORD representing the Unicode of -// a character(some special Unicode may take 2 WORDs).The string is -// followed by two bytes of zero -// indicating the end of the string. -// -// The return value always indicates the number of bytes required for -// the buffer, even if no buffer is specified -// or the buffer size is less then required. In these cases, the buffer -// will not be modified. -// -DLLEXPORT unsigned long STDCALL FPDFBookmark_GetTitle(FPDF_BOOKMARK bookmark, - void* buffer, - unsigned long buflen); - -// Function: FPDFBookmark_Find -// Find a bookmark in the document, using the bookmark title. -// Parameters: -// document - Handle to the document. Returned by -// FPDF_LoadDocument or FPDF_LoadMemDocument. -// title - The UTF-16LE encoded Unicode string for the bookmark -// title to be searched. Can't be NULL. -// Return value: -// Handle to the found bookmark item. NULL if the title can't be found. -// Comments: -// It always returns the first found bookmark if more than one -// bookmarks have the same title. -// -DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document, - FPDF_WIDESTRING title); - -// Function: FPDFBookmark_GetDest -// Get the destination associated with a bookmark item. -// Parameters: -// document - Handle to the document. -// bookmark - Handle to the bookmark. -// Return value: -// Handle to the destination data. NULL if no destination is associated -// with this bookmark. -// -DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document, - FPDF_BOOKMARK bookmark); - -// Function: FPDFBookmark_GetAction -// Get the action associated with a bookmark item. -// Parameters: -// bookmark - Handle to the bookmark. -// Return value: -// Handle to the action data. NULL if no action is associated with this -// bookmark. In this case, the -// application should try FPDFBookmark_GetDest. -// -DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK bookmark); - -#define PDFACTION_UNSUPPORTED 0 // Unsupported action type. -#define PDFACTION_GOTO 1 // Go to a destination within current document. -#define PDFACTION_REMOTEGOTO 2 // Go to a destination within another document. -#define PDFACTION_URI 3 // Universal Resource Identifier, including web - // pages and other Internet based resources. -#define PDFACTION_LAUNCH 4 // Launch an application or open a file. - -// Function: FPDFAction_GetType -// Get type of an action. -// Parameters: -// action - Handle to the action. -// Return value: -// A type number as defined above. -// -DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION action); - -// Function: FPDFAction_GetDest -// Get destination of an action. -// Parameters: -// document - Handle to the document. -// action - Handle to the action. It must be a GOTO or -// REMOTEGOTO action. -// Return value: -// Handle to the destination data. -// Comments: -// In case of remote goto action, the application should first use -// FPDFAction_GetFilePath to -// get file path, then load that particular document, and use its -// document handle to call this -// function. -// -DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, - FPDF_ACTION action); - -// Function: FPDFAction_GetFilePath -// Get file path of a remote goto action. -// Parameters: -// action - Handle to the action. Must be a REMOTEGOTO or -// LAUNCH action. -// buffer - A buffer for output the path string. Can be NULL. -// buflen - The length of the buffer, number of bytes. Can be 0. -// Return value: -// Number of bytes the file path consumes, including trailing zero. -// -// Comments: -// The file path is UTF-8 encoded. The return value is the number of -// bytes required for the buffer, even when there is no buffer -// specified, or the buffer size is less then required. In this case, -// the buffer will not be modified. -// -DLLEXPORT unsigned long STDCALL +// Get the title of |bookmark|. +// +// bookmark - handle to the bookmark. +// buffer - buffer for the title. May be NULL. +// buflen - the length of the buffer in bytes. May be 0. +// +// Returns the number of bytes in the title, including the terminating NUL +// character. The number of bytes is returned regardless of the |buffer| and +// |buflen| parameters. +// +// Regardless of the platform, the |buffer| is always in UTF-16LE encoding. The +// string is terminated by a UTF16 NUL character. If |buflen| is less than the +// required length, or |buffer| is NULL, |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFBookmark_GetTitle(FPDF_BOOKMARK bookmark, + void* buffer, + unsigned long buflen); + +// Experimental API. +// Get the number of chlidren of |bookmark|. +// +// bookmark - handle to the bookmark. +// +// Returns a signed integer that represents the number of sub-items the given +// bookmark has. If the value is positive, child items shall be shown by default +// (open state). If the value is negative, child items shall be hidden by +// default (closed state). Please refer to PDF 32000-1:2008, Table 153. +// Returns 0 if the bookmark has no children or is invalid. +FPDF_EXPORT int FPDF_CALLCONV FPDFBookmark_GetCount(FPDF_BOOKMARK bookmark); + +// Find the bookmark with |title| in |document|. +// +// document - handle to the document. +// title - the UTF-16LE encoded Unicode title for which to search. +// +// Returns the handle to the bookmark, or NULL if |title| can't be found. +// +// FPDFBookmark_Find() will always return the first bookmark found even if +// multiple bookmarks have the same |title|. +FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV +FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title); + +// Get the destination associated with |bookmark|. +// +// document - handle to the document. +// bookmark - handle to the bookmark. +// +// Returns the handle to the destination data, or NULL if no destination is +// associated with |bookmark|. +FPDF_EXPORT FPDF_DEST FPDF_CALLCONV +FPDFBookmark_GetDest(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark); + +// Get the action associated with |bookmark|. +// +// bookmark - handle to the bookmark. +// +// Returns the handle to the action data, or NULL if no action is associated +// with |bookmark|. +// If this function returns a valid handle, it is valid as long as |bookmark| is +// valid. +// If this function returns NULL, FPDFBookmark_GetDest() should be called to get +// the |bookmark| destination data. +FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV +FPDFBookmark_GetAction(FPDF_BOOKMARK bookmark); + +// Get the type of |action|. +// +// action - handle to the action. +// +// Returns one of: +// PDFACTION_UNSUPPORTED +// PDFACTION_GOTO +// PDFACTION_REMOTEGOTO +// PDFACTION_URI +// PDFACTION_LAUNCH +FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAction_GetType(FPDF_ACTION action); + +// Get the destination of |action|. +// +// document - handle to the document. +// action - handle to the action. |action| must be a |PDFACTION_GOTO| or +// |PDFACTION_REMOTEGOTO|. +// +// Returns a handle to the destination data, or NULL on error, typically +// because the arguments were bad or the action was of the wrong type. +// +// In the case of |PDFACTION_REMOTEGOTO|, you must first call +// FPDFAction_GetFilePath(), then load the document at that path, then pass +// the document handle from that document as |document| to FPDFAction_GetDest(). +FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDFAction_GetDest(FPDF_DOCUMENT document, + FPDF_ACTION action); + +// Get the file path of |action|. +// +// action - handle to the action. |action| must be a |PDFACTION_LAUNCH| or +// |PDFACTION_REMOTEGOTO|. +// buffer - a buffer for output the path string. May be NULL. +// buflen - the length of the buffer, in bytes. May be 0. +// +// Returns the number of bytes in the file path, including the trailing NUL +// character, or 0 on error, typically because the arguments were bad or the +// action was of the wrong type. +// +// Regardless of the platform, the |buffer| is always in UTF-8 encoding. +// If |buflen| is less than the returned length, or |buffer| is NULL, |buffer| +// will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAction_GetFilePath(FPDF_ACTION action, void* buffer, unsigned long buflen); -// Function: FPDFAction_GetURIPath -// Get URI path of a URI action. -// Parameters: -// document - Handle to the document. -// action - Handle to the action. Must be a URI action. -// buffer - A buffer for output the path string. Can be NULL. -// buflen - The length of the buffer, number of bytes. Can be 0. -// Return value: -// Number of bytes the URI path consumes, including trailing zeros. -// Comments: -// The URI path is always encoded in 7-bit ASCII. -// -// The return value is the number of bytes required for the buffer, -// even when there is no buffer specified, or the buffer size is less -// then required. In this case, the buffer will not be modified. -// -DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, - FPDF_ACTION action, - void* buffer, - unsigned long buflen); - -// Function: FPDFDest_GetPageIndex -// Get page index of a destination. -// Parameters: -// document - Handle to the document. -// dest - Handle to the destination. -// Return value: -// The page index. Starting from 0 for the first page. -// -DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, - FPDF_DEST dest); - -// Function: FPDFLink_GetLinkAtPoint -// Find a link at specified point on a document page. -// Parameters: -// page - Handle to the document page. -// x - The x coordinate of the point, specified in page -// coordinate system. -// y - The y coordinate of the point, specified in page -// coordinate system. -// Return value: -// Handle to the link. NULL if no link found at that point. -// Comments: -// The point coordinates are specified in page coordinate system. You can -// convert coordinates from screen system to page system using -// FPDF_DeviceToPage(). -// -DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, - double x, - double y); - -// Function: FPDFLink_GetLinkZOrderAtPoint -// Find the z-order of a link at specified point on a document page. -// Parameters: -// page - Handle to the document page. -// x - The x coordinate of the point, specified in page -// coordinate system. -// y - The y coordinate of the point, specified in page -// coordinate system. -// Return value: -// Z-order of the link, or -1 if no link found at that point. -// Higher numbers are closer to the front. -// Comments: -// The point coordinates are specified in page coordinate system. You can -// convert coordinates from screen system to page system using -// FPDF_DeviceToPage(). -// -DLLEXPORT int STDCALL -FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y); - -// Function: FPDFLink_GetDest -// Get destination info of a link. -// Parameters: -// document - Handle to the document. -// link - Handle to the link. Returned by -// FPDFLink_GetLinkAtPoint. -// Return value: -// Handle to the destination. NULL if there is no destination -// associated with the link, in this case -// the application should try FPDFLink_GetAction. -// -DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document, - FPDF_LINK link); - -// Function: FPDFLink_GetAction -// Get action info of a link. -// Parameters: -// link - Handle to the link. -// Return value: -// Handle to the action. NULL if there is no action associated with the -// link. -// -DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK link); - -// Function: FPDFLink_Enumerate -// This function would enumerate all the link annotations in a single -// PDF page. -// Parameters: -// page[in] - Handle to the page. -// startPos[in,out] - The start position to enumerate the link -// annotations, which should be specified to start from -// - 0 for the first call, and would receive the -// next position for enumerating to start from. -// linkAnnot[out] - Receive the link handle. -// Return value: -// TRUE if succceed, else False; -// -DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, - int* startPos, - FPDF_LINK* linkAnnot); - -// Function: FPDFLink_GetAnnotRect -// Get the annotation rectangle. (Specified by the ¡°Rect¡± entry of -// annotation dictionary). -// Parameters: -// linkAnnot[in] - Handle to the link annotation. -// rect[out] - The annotation rect. -// Return value: -// TRUE if succceed, else False; -// -DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot, - FS_RECTF* rect); - -// Function: FPDFLink_CountQuadPoints -// Get the count of quadrilateral points to the link annotation. -// Parameters: -// linkAnnot[in] - Handle to the link annotation. -// Return value: -// The count of quadrilateral points. -// -DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot); - -/* _FS_DEF_STRUCTURE_QUADPOINTSF_ */ -#ifndef _FS_DEF_STRUCTURE_QUADPOINTSF_ -#define _FS_DEF_STRUCTURE_QUADPOINTSF_ -typedef struct _FS_QUADPOINTSF { - FS_FLOAT x1; - FS_FLOAT y1; - FS_FLOAT x2; - FS_FLOAT y2; - FS_FLOAT x3; - FS_FLOAT y3; - FS_FLOAT x4; - FS_FLOAT y4; -} FS_QUADPOINTSF; -#endif /* _FS_DEF_STRUCTURE_QUADPOINTSF_ */ - -// Function: FPDFLink_GetQuadPoints -// Get the quadrilateral points for the specified index in the link -// annotation. -// Parameters: -// linkAnnot[in] - Handle to the link annotation. -// quadIndex[in] - The specified quad points index. -// quadPoints[out] - Receive the quadrilateral points. -// Return value: -// True if succeed, else False. -// -DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, - int quadIndex, - FS_QUADPOINTSF* quadPoints); - -// Function: FPDF_GetMetaText -// Get a text from meta data of the document. Result is encoded in -// UTF-16LE. -// Parameters: -// doc - Handle to a document -// tag - The tag for the meta data. Currently, It can be -// "Title", "Author", -// "Subject", "Keywords", "Creator", "Producer", -// "CreationDate", or "ModDate". -// For detailed explanation of these tags and their -// respective values, -// please refer to PDF Reference 1.6, section 10.2.1, -// "Document Information Dictionary". -// buffer - A buffer for output the title. Can be NULL. -// buflen - The length of the buffer, number of bytes. Can be 0. -// Return value: -// Number of bytes the title consumes, including trailing zeros. -// Comments: -// No matter on what platform, the title is always output in UTF-16LE -// encoding, which means the buffer -// can be regarded as an array of WORD (on Intel and compatible CPUs), -// each WORD represent the Unicode of -// a character (some special Unicode may take 2 WORDs). The string is -// followed by two bytes of zero -// indicating end of the string. -// -// The return value always indicated number of bytes required for the -// buffer, even when there is -// no buffer specified, or the buffer size is less then required. In -// this case, the buffer will not -// be modified. -// -DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, - FPDF_BYTESTRING tag, - void* buffer, - unsigned long buflen); +// Get the URI path of |action|. +// +// document - handle to the document. +// action - handle to the action. Must be a |PDFACTION_URI|. +// buffer - a buffer for the path string. May be NULL. +// buflen - the length of the buffer, in bytes. May be 0. +// +// Returns the number of bytes in the URI path, including the trailing NUL +// character, or 0 on error, typically because the arguments were bad or the +// action was of the wrong type. +// +// The |buffer| may contain badly encoded data. The caller should validate the +// output. e.g. Check to see if it is UTF-8. +// +// If |buflen| is less than the returned length, or |buffer| is NULL, |buffer| +// will not be modified. +// +// Historically, the documentation for this API claimed |buffer| is always +// encoded in 7-bit ASCII, but did not actually enforce it. +// https://pdfium.googlesource.com/pdfium.git/+/d609e84cee2e14a18333247485af91df48a40592 +// added that enforcement, but that did not work well for real world PDFs that +// used UTF-8. As of this writing, this API reverted back to its original +// behavior prior to commit d609e84cee. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFAction_GetURIPath(FPDF_DOCUMENT document, + FPDF_ACTION action, + void* buffer, + unsigned long buflen); + +// Get the page index of |dest|. +// +// document - handle to the document. +// dest - handle to the destination. +// +// Returns the 0-based page index containing |dest|. Returns -1 on error. +FPDF_EXPORT int FPDF_CALLCONV FPDFDest_GetDestPageIndex(FPDF_DOCUMENT document, + FPDF_DEST dest); + +// Experimental API. +// Get the view (fit type) specified by |dest|. +// +// dest - handle to the destination. +// pNumParams - receives the number of view parameters, which is at most 4. +// pParams - buffer to write the view parameters. Must be at least 4 +// FS_FLOATs long. +// Returns one of the PDFDEST_VIEW_* constants, PDFDEST_VIEW_UNKNOWN_MODE if +// |dest| does not specify a view. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFDest_GetView(FPDF_DEST dest, unsigned long* pNumParams, FS_FLOAT* pParams); + +// Get the (x, y, zoom) location of |dest| in the destination page, if the +// destination is in [page /XYZ x y zoom] syntax. +// +// dest - handle to the destination. +// hasXVal - out parameter; true if the x value is not null +// hasYVal - out parameter; true if the y value is not null +// hasZoomVal - out parameter; true if the zoom value is not null +// x - out parameter; the x coordinate, in page coordinates. +// y - out parameter; the y coordinate, in page coordinates. +// zoom - out parameter; the zoom value. +// Returns TRUE on successfully reading the /XYZ value. +// +// Note the [x, y, zoom] values are only set if the corresponding hasXVal, +// hasYVal or hasZoomVal flags are true. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFDest_GetLocationInPage(FPDF_DEST dest, + FPDF_BOOL* hasXVal, + FPDF_BOOL* hasYVal, + FPDF_BOOL* hasZoomVal, + FS_FLOAT* x, + FS_FLOAT* y, + FS_FLOAT* zoom); + +// Find a link at point (|x|,|y|) on |page|. +// +// page - handle to the document page. +// x - the x coordinate, in the page coordinate system. +// y - the y coordinate, in the page coordinate system. +// +// Returns a handle to the link, or NULL if no link found at the given point. +// +// You can convert coordinates from screen coordinates to page coordinates using +// FPDF_DeviceToPage(). +FPDF_EXPORT FPDF_LINK FPDF_CALLCONV FPDFLink_GetLinkAtPoint(FPDF_PAGE page, + double x, + double y); + +// Find the Z-order of link at point (|x|,|y|) on |page|. +// +// page - handle to the document page. +// x - the x coordinate, in the page coordinate system. +// y - the y coordinate, in the page coordinate system. +// +// Returns the Z-order of the link, or -1 if no link found at the given point. +// Larger Z-order numbers are closer to the front. +// +// You can convert coordinates from screen coordinates to page coordinates using +// FPDF_DeviceToPage(). +FPDF_EXPORT int FPDF_CALLCONV FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, + double x, + double y); + +// Get destination info for |link|. +// +// document - handle to the document. +// link - handle to the link. +// +// Returns a handle to the destination, or NULL if there is no destination +// associated with the link. In this case, you should call FPDFLink_GetAction() +// to retrieve the action associated with |link|. +FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDFLink_GetDest(FPDF_DOCUMENT document, + FPDF_LINK link); + +// Get action info for |link|. +// +// link - handle to the link. +// +// Returns a handle to the action associated to |link|, or NULL if no action. +// If this function returns a valid handle, it is valid as long as |link| is +// valid. +FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV FPDFLink_GetAction(FPDF_LINK link); + +// Enumerates all the link annotations in |page|. +// +// page - handle to the page. +// start_pos - the start position, should initially be 0 and is updated with +// the next start position on return. +// link_annot - the link handle for |startPos|. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFLink_Enumerate(FPDF_PAGE page, + int* start_pos, + FPDF_LINK* link_annot); + +// Experimental API. +// Gets FPDF_ANNOTATION object for |link_annot|. +// +// page - handle to the page in which FPDF_LINK object is present. +// link_annot - handle to link annotation. +// +// Returns FPDF_ANNOTATION from the FPDF_LINK and NULL on failure, +// if the input link annot or page is NULL. +FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV +FPDFLink_GetAnnot(FPDF_PAGE page, FPDF_LINK link_annot); + +// Get the rectangle for |link_annot|. +// +// link_annot - handle to the link annotation. +// rect - the annotation rectangle. +// +// Returns true on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFLink_GetAnnotRect(FPDF_LINK link_annot, + FS_RECTF* rect); + +// Get the count of quadrilateral points to the |link_annot|. +// +// link_annot - handle to the link annotation. +// +// Returns the count of quadrilateral points. +FPDF_EXPORT int FPDF_CALLCONV FPDFLink_CountQuadPoints(FPDF_LINK link_annot); + +// Get the quadrilateral points for the specified |quad_index| in |link_annot|. +// +// link_annot - handle to the link annotation. +// quad_index - the specified quad point index. +// quad_points - receives the quadrilateral points. +// +// Returns true on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFLink_GetQuadPoints(FPDF_LINK link_annot, + int quad_index, + FS_QUADPOINTSF* quad_points); + +// Experimental API +// Gets an additional-action from |page|. +// +// page - handle to the page, as returned by FPDF_LoadPage(). +// aa_type - the type of the page object's addtional-action, defined +// in public/fpdf_formfill.h +// +// Returns the handle to the action data, or NULL if there is no +// additional-action of type |aa_type|. +// If this function returns a valid handle, it is valid as long as |page| is +// valid. +FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV FPDF_GetPageAAction(FPDF_PAGE page, + int aa_type); + +// Experimental API. +// Get the file identifer defined in the trailer of |document|. +// +// document - handle to the document. +// id_type - the file identifier type to retrieve. +// buffer - a buffer for the file identifier. May be NULL. +// buflen - the length of the buffer, in bytes. May be 0. +// +// Returns the number of bytes in the file identifier, including the NUL +// terminator. +// +// The |buffer| is always a byte string. The |buffer| is followed by a NUL +// terminator. If |buflen| is less than the returned length, or |buffer| is +// NULL, |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDF_GetFileIdentifier(FPDF_DOCUMENT document, + FPDF_FILEIDTYPE id_type, + void* buffer, + unsigned long buflen); + +// Get meta-data |tag| content from |document|. +// +// document - handle to the document. +// tag - the tag to retrieve. The tag can be one of: +// Title, Author, Subject, Keywords, Creator, Producer, +// CreationDate, or ModDate. +// For detailed explanations of these tags and their respective +// values, please refer to PDF Reference 1.6, section 10.2.1, +// 'Document Information Dictionary'. +// buffer - a buffer for the tag. May be NULL. +// buflen - the length of the buffer, in bytes. May be 0. +// +// Returns the number of bytes in the tag, including trailing zeros. +// +// The |buffer| is always encoded in UTF-16LE. The |buffer| is followed by two +// bytes of zeros indicating the end of the string. If |buflen| is less than +// the returned length, or |buffer| is NULL, |buffer| will not be modified. +// +// For linearized files, FPDFAvail_IsFormAvail must be called before this, and +// it must have returned PDF_FORM_AVAIL or PDF_FORM_NOTEXIST. Before that, there +// is no guarantee the metadata has been loaded. +FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetMetaText(FPDF_DOCUMENT document, + FPDF_BYTESTRING tag, + void* buffer, + unsigned long buflen); + +// Get the page label for |page_index| from |document|. +// +// document - handle to the document. +// page_index - the 0-based index of the page. +// buffer - a buffer for the page label. May be NULL. +// buflen - the length of the buffer, in bytes. May be 0. +// +// Returns the number of bytes in the page label, including trailing zeros. +// +// The |buffer| is always encoded in UTF-16LE. The |buffer| is followed by two +// bytes of zeros indicating the end of the string. If |buflen| is less than +// the returned length, or |buffer| is NULL, |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDF_GetPageLabel(FPDF_DOCUMENT document, + int page_index, + void* buffer, + unsigned long buflen); #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_DOC_H_ diff --git a/src/main/jni/include/fpdf_edit.h b/src/main/jni/include/fpdf_edit.h index 64eef263..5dc11c48 100644 --- a/src/main/jni/include/fpdf_edit.h +++ b/src/main/jni/include/fpdf_edit.h @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,299 +9,1616 @@ #include +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" -// Define all types used in the SDK. Note they can be simply regarded as opaque -// pointers -// or long integer numbers. - -#define FPDF_ARGB(a, r, g, b) \ - ((((uint32_t)(((uint8_t)(b) | ((FX_WORD)((uint8_t)(g)) << 8)) | \ - (((FX_DWORD)(uint8_t)(r)) << 16)))) | \ - (((FX_DWORD)(uint8_t)(a)) << 24)) +#define FPDF_ARGB(a, r, g, b) \ + ((uint32_t)(((uint32_t)(b)&0xff) | (((uint32_t)(g)&0xff) << 8) | \ + (((uint32_t)(r)&0xff) << 16) | (((uint32_t)(a)&0xff) << 24))) #define FPDF_GetBValue(argb) ((uint8_t)(argb)) #define FPDF_GetGValue(argb) ((uint8_t)(((uint16_t)(argb)) >> 8)) #define FPDF_GetRValue(argb) ((uint8_t)((argb) >> 16)) #define FPDF_GetAValue(argb) ((uint8_t)((argb) >> 24)) -#ifdef __cplusplus -extern "C" { -#endif - -////////////////////////////////////////////////////////////////////// -// -// Document functions -// -////////////////////////////////////////////////////////////////////// - -// Function: FPDF_CreateNewDocument -// Create a new PDF document. -// Parameters: -// None. -// Return value: -// A handle to a document. If failed, NULL is returned. -DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument(); - -////////////////////////////////////////////////////////////////////// -// -// Page functions -// -////////////////////////////////////////////////////////////////////// - -// Function: FPDFPage_New -// Construct an empty page. -// Parameters: -// document - Handle to document. Returned by FPDF_LoadDocument -// and FPDF_CreateNewDocument. -// page_index - The index of a page. -// width - The page width. -// height - The page height. -// Return value: -// The handle to the page. -// Comments: -// Loaded page can be deleted by FPDFPage_Delete. -DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, - int page_index, - double width, - double height); - -// Function: FPDFPage_Delete -// Delete a PDF page. -// Parameters: -// document - Handle to document. Returned by FPDF_LoadDocument -// and FPDF_CreateNewDocument. -// page_index - The index of a page. -// Return value: -// None. -DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index); - -// Function: FPDFPage_GetRotation -// Get the page rotation. One of following values will be returned: -// 0(0), 1(90), 2(180), 3(270). -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New or -// FPDF_LoadPage. -// Return value: -// The PDF page rotation. -// Comment: -// The PDF page rotation is rotated clockwise. -DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page); - -// Function: FPDFPage_SetRotation -// Set page rotation. One of following values will be set: 0(0), 1(90), -// 2(180), 3(270). -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New or -// FPDF_LoadPage. -// rotate - The value of the PDF page rotation. -// Return value: -// None. -// Comment: -// The PDF page rotation is rotated clockwise. -// -DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate); - -// Function: FPDFPage_InsertObject -// Insert an object to the page. The page object is automatically -// freed. -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New or -// FPDF_LoadPage. -// page_obj - Handle to a page object. Returned by -// FPDFPageObj_NewTextObj,FPDFPageObj_NewTextObjEx and -// FPDFPageObj_NewPathObj. -// Return value: -// None. -DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, - FPDF_PAGEOBJECT page_obj); - -// Function: FPDFPage_CountObject -// Get number of page objects inside the page. -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New or -// FPDF_LoadPage. -// Return value: -// The number of the page object. -DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page); - -// Function: FPDFPage_GetObject -// Get page object by index. -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New or -// FPDF_LoadPage. -// index - The index of a page object. -// Return value: -// The handle of the page object. Null for failed. -DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index); - -// Function: FPDFPage_HasTransparency -// Check that whether the content of specified PDF page contains -// transparency. -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New or -// FPDF_LoadPage. -// Return value: -// TRUE means that the PDF page does contains transparency. -// Otherwise, returns FALSE. -DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page); - -// Function: FPDFPage_GenerateContent -// Generate PDF Page content. -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New or -// FPDF_LoadPage. -// Return value: -// True if successful, false otherwise. -// Comment: -// Before you save the page to a file, or reload the page, you must -// call the FPDFPage_GenerateContent function. -// Or the changed information will be lost. -DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page); - -////////////////////////////////////////////////////////////////////// -// -// Page Object functions -// -////////////////////////////////////////////////////////////////////// - -// Function: FPDFPageObj_HasTransparency -// Check that whether the specified PDF page object contains -// transparency. -// Parameters: -// pageObject - Handle to a page object. -// Return value: -// TRUE means that the PDF page object does contains transparency. -// Otherwise, returns FALSE. -DLLEXPORT FPDF_BOOL STDCALL -FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject); - -// Function: FPDFPageObj_Transform -// Transform (scale, rotate, shear, move) page object. -// Parameters: -// page_object - Handle to a page object. Returned by -// FPDFPageObj_NewImageObj. -// a - The coefficient "a" of the matrix. -// b - The coefficient "b" of the matrix. -// c - The coefficient "c" of the matrix. -// d - The coefficient "d" of the matrix. -// e - The coefficient "e" of the matrix. -// f - The coefficient "f" of the matrix. -// Return value: -// None. -DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, - double a, - double b, - double c, - double d, - double e, - double f); - -// Function: FPDFPage_TransformAnnots -// Transform (scale, rotate, shear, move) all annots in a page. -// Parameters: -// page - Handle to a page. -// a - The coefficient "a" of the matrix. -// b - The coefficient "b" of the matrix. -// c - The coefficient "c" of the matrix. -// d - The coefficient "d" of the matrix. -// e - The coefficient "e" of the matrix. -// f - The coefficient "f" of the matrix. -// Return value: -// None. -DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, - double a, - double b, - double c, - double d, - double e, - double f); +// Refer to PDF Reference version 1.7 table 4.12 for all color space families. +#define FPDF_COLORSPACE_UNKNOWN 0 +#define FPDF_COLORSPACE_DEVICEGRAY 1 +#define FPDF_COLORSPACE_DEVICERGB 2 +#define FPDF_COLORSPACE_DEVICECMYK 3 +#define FPDF_COLORSPACE_CALGRAY 4 +#define FPDF_COLORSPACE_CALRGB 5 +#define FPDF_COLORSPACE_LAB 6 +#define FPDF_COLORSPACE_ICCBASED 7 +#define FPDF_COLORSPACE_SEPARATION 8 +#define FPDF_COLORSPACE_DEVICEN 9 +#define FPDF_COLORSPACE_INDEXED 10 +#define FPDF_COLORSPACE_PATTERN 11 // The page object constants. +#define FPDF_PAGEOBJ_UNKNOWN 0 #define FPDF_PAGEOBJ_TEXT 1 #define FPDF_PAGEOBJ_PATH 2 #define FPDF_PAGEOBJ_IMAGE 3 #define FPDF_PAGEOBJ_SHADING 4 #define FPDF_PAGEOBJ_FORM 5 -////////////////////////////////////////////////////////////////////// -// -// Image functions -// -////////////////////////////////////////////////////////////////////// - -// Function: FPDFPageObj_NewImgeObj -// Create a new Image Object. -// Parameters: -// document - Handle to document. Returned by -// FPDF_LoadDocument or FPDF_CreateNewDocument function. -// Return Value: -// Handle of image object. -DLLEXPORT FPDF_PAGEOBJECT STDCALL -FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document); - -// Function: FPDFImageObj_LoadJpegFile -// Load Image from a JPEG image file and then set it to an image -// object. -// Parameters: -// pages - Pointers to the start of all loaded pages, could -// be NULL. -// nCount - Number of pages, could be 0. -// image_object - Handle of image object returned by -// FPDFPageObj_NewImgeObj. -// fileAccess - The custom file access handler, which specifies -// the JPEG image file. -// Return Value: -// TRUE if successful, FALSE otherwise. -// Note: -// The image object might already has an associated image, which is -// shared and cached by the loaded pages, In this case, we need to -// clear the cache of image for all the loaded pages. -// Pass pages and count to this API to clear the image cache. -DLLEXPORT FPDF_BOOL STDCALL +// The path segment constants. +#define FPDF_SEGMENT_UNKNOWN -1 +#define FPDF_SEGMENT_LINETO 0 +#define FPDF_SEGMENT_BEZIERTO 1 +#define FPDF_SEGMENT_MOVETO 2 + +#define FPDF_FILLMODE_NONE 0 +#define FPDF_FILLMODE_ALTERNATE 1 +#define FPDF_FILLMODE_WINDING 2 + +#define FPDF_FONT_TYPE1 1 +#define FPDF_FONT_TRUETYPE 2 + +#define FPDF_LINECAP_BUTT 0 +#define FPDF_LINECAP_ROUND 1 +#define FPDF_LINECAP_PROJECTING_SQUARE 2 + +#define FPDF_LINEJOIN_MITER 0 +#define FPDF_LINEJOIN_ROUND 1 +#define FPDF_LINEJOIN_BEVEL 2 + +// See FPDF_SetPrintMode() for descriptions. +#define FPDF_PRINTMODE_EMF 0 +#define FPDF_PRINTMODE_TEXTONLY 1 +#define FPDF_PRINTMODE_POSTSCRIPT2 2 +#define FPDF_PRINTMODE_POSTSCRIPT3 3 +#define FPDF_PRINTMODE_POSTSCRIPT2_PASSTHROUGH 4 +#define FPDF_PRINTMODE_POSTSCRIPT3_PASSTHROUGH 5 +#define FPDF_PRINTMODE_EMF_IMAGE_MASKS 6 +#define FPDF_PRINTMODE_POSTSCRIPT3_TYPE42 7 +#define FPDF_PRINTMODE_POSTSCRIPT3_TYPE42_PASSTHROUGH 8 + +typedef struct FPDF_IMAGEOBJ_METADATA { + // The image width in pixels. + unsigned int width; + // The image height in pixels. + unsigned int height; + // The image's horizontal pixel-per-inch. + float horizontal_dpi; + // The image's vertical pixel-per-inch. + float vertical_dpi; + // The number of bits used to represent each pixel. + unsigned int bits_per_pixel; + // The image's colorspace. See above for the list of FPDF_COLORSPACE_*. + int colorspace; + // The image's marked content ID. Useful for pairing with associated alt-text. + // A value of -1 indicates no ID. + int marked_content_id; +} FPDF_IMAGEOBJ_METADATA; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Create a new PDF document. +// +// Returns a handle to a new document, or NULL on failure. +FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_CreateNewDocument(); + +// Create a new PDF page. +// +// document - handle to document. +// page_index - suggested 0-based index of the page to create. If it is larger +// than document's current last index(L), the created page index +// is the next available index -- L+1. +// width - the page width in points. +// height - the page height in points. +// +// Returns the handle to the new page or NULL on failure. +// +// The page should be closed with FPDF_ClosePage() when finished as +// with any other page in the document. +FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDFPage_New(FPDF_DOCUMENT document, + int page_index, + double width, + double height); + +// Delete the page at |page_index|. +// +// document - handle to document. +// page_index - the index of the page to delete. +FPDF_EXPORT void FPDF_CALLCONV FPDFPage_Delete(FPDF_DOCUMENT document, + int page_index); + +// Experimental API. +// 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 +// +// Returns one of the following indicating the page rotation: +// 0 - No rotation. +// 1 - Rotated 90 degrees clockwise. +// 2 - Rotated 180 degrees clockwise. +// 3 - Rotated 270 degrees clockwise. +FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetRotation(FPDF_PAGE page); + +// Set rotation for |page|. +// +// page - handle to a page. +// rotate - the rotation value, one of: +// 0 - No rotation. +// 1 - Rotated 90 degrees clockwise. +// 2 - Rotated 180 degrees clockwise. +// 3 - Rotated 270 degrees clockwise. +FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetRotation(FPDF_PAGE page, int rotate); + +// Insert |page_object| into |page|. +// +// page - handle to a page +// page_object - handle to a page object. The |page_object| will be +// automatically freed. +FPDF_EXPORT void FPDF_CALLCONV +FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_object); + +// Experimental API. +// Remove |page_object| from |page|. +// +// page - handle to a page +// page_object - handle to a page object to be removed. +// +// Returns TRUE on success. +// +// Ownership is transferred to the caller. Call FPDFPageObj_Destroy() to free +// it. +// Note that when removing a |page_object| of type FPDF_PAGEOBJ_TEXT, all +// FPDF_TEXTPAGE handles for |page| are no longer valid. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPage_RemoveObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_object); + +// Get number of page objects inside |page|. +// +// page - handle to a page. +// +// Returns the number of objects in |page|. +FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObjects(FPDF_PAGE page); + +// Get object in |page| at |index|. +// +// page - handle to a page. +// index - the index of a page object. +// +// Returns the handle to the page object, or NULL on failed. +FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPage_GetObject(FPDF_PAGE page, + int index); + +// Checks if |page| contains transparency. +// +// page - handle to a page. +// +// Returns TRUE if |page| contains transparency. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_HasTransparency(FPDF_PAGE page); + +// Generate the content of |page|. +// +// page - handle to a page. +// +// Returns TRUE on success. +// +// Before you save the page to a file, or reload the page, you must call +// |FPDFPage_GenerateContent| or any changes to |page| will be lost. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GenerateContent(FPDF_PAGE page); + +// Destroy |page_object| by releasing its resources. |page_object| must have +// been created by FPDFPageObj_CreateNew{Path|Rect}() or +// FPDFPageObj_New{Text|Image}Obj(). This function must be called on +// newly-created objects if they are not added to a page through +// FPDFPage_InsertObject() or to an annotation through FPDFAnnot_AppendObject(). +// +// page_object - handle to a page object. +FPDF_EXPORT void FPDF_CALLCONV FPDFPageObj_Destroy(FPDF_PAGEOBJECT page_object); + +// Checks if |page_object| contains transparency. +// +// page_object - handle to a page object. +// +// Returns TRUE if |page_object| contains transparency. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT page_object); + +// Get type of |page_object|. +// +// page_object - handle to a page object. +// +// Returns one of the FPDF_PAGEOBJ_* values on success, FPDF_PAGEOBJ_UNKNOWN on +// error. +FPDF_EXPORT int FPDF_CALLCONV FPDFPageObj_GetType(FPDF_PAGEOBJECT page_object); + +// Experimental API. +// Gets active state for |page_object| within page. +// +// page_object - handle to a page object. +// active - pointer to variable that will receive if the page object is +// active. This is a required parameter. Not filled if FALSE +// is returned. +// +// For page objects where |active| is filled with FALSE, the |page_object| is +// treated as if it wasn't in the document even though it is still held +// internally. +// +// Returns TRUE if the operation succeeded, FALSE if it failed. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_GetIsActive(FPDF_PAGEOBJECT page_object, FPDF_BOOL* active); + +// Experimental API. +// Sets if |page_object| is active within page. +// +// page_object - handle to a page object. +// active - a boolean specifying if the object is active. +// +// Returns TRUE on success. +// +// Page objects all start in the active state by default, and remain in that +// state unless this function is called. +// +// When |active| is false, this makes the |page_object| be treated as if it +// wasn't in the document even though it is still held internally. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_SetIsActive(FPDF_PAGEOBJECT page_object, FPDF_BOOL active); + +// Transform |page_object| by the given matrix. +// +// page_object - handle to a page object. +// a - matrix value. +// b - matrix value. +// c - matrix value. +// d - matrix value. +// e - matrix value. +// f - matrix value. +// +// The matrix is composed as: +// |a c e| +// |b d f| +// and can be used to scale, rotate, shear and translate the |page_object|. +FPDF_EXPORT void FPDF_CALLCONV +FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, + double a, + double b, + double c, + double d, + double e, + double f); + +// Experimental API. +// Transform |page_object| by the given matrix. +// +// page_object - handle to a page object. +// matrix - the transform matrix. +// +// Returns TRUE on success. +// +// This can be used to scale, rotate, shear and translate the |page_object|. +// It is an improved version of FPDFPageObj_Transform() that does not do +// unnecessary double to float conversions, and only uses 1 parameter for the +// matrix. It also returns whether the operation succeeded or not. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_TransformF(FPDF_PAGEOBJECT page_object, const FS_MATRIX* matrix); + +// Experimental API. +// Get the transform matrix of a page object. +// +// page_object - handle to a page object. +// matrix - pointer to struct to receive the matrix value. +// +// The matrix is composed as: +// |a c e| +// |b d f| +// and used to scale, rotate, shear and translate the page object. +// +// For page objects outside form objects, the matrix values are relative to the +// page that contains it. +// For page objects inside form objects, the matrix values are relative to the +// form that contains it. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_GetMatrix(FPDF_PAGEOBJECT page_object, FS_MATRIX* matrix); + +// Experimental API. +// Set the transform matrix of a page object. +// +// page_object - handle to a page object. +// matrix - pointer to struct with the matrix value. +// +// The matrix is composed as: +// |a c e| +// |b d f| +// and can be used to scale, rotate, shear and translate the page object. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_SetMatrix(FPDF_PAGEOBJECT page_object, const FS_MATRIX* matrix); + +// Transform all annotations in |page|. +// +// page - handle to a page. +// a - matrix value. +// b - matrix value. +// c - matrix value. +// d - matrix value. +// e - matrix value. +// f - matrix value. +// +// The matrix is composed as: +// |a c e| +// |b d f| +// and can be used to scale, rotate, shear and translate the |page| annotations. +FPDF_EXPORT void FPDF_CALLCONV FPDFPage_TransformAnnots(FPDF_PAGE page, + double a, + double b, + double c, + double d, + double e, + double f); + +// Create a new image object. +// +// document - handle to a document. +// +// Returns a handle to a new image object. +FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV +FPDFPageObj_NewImageObj(FPDF_DOCUMENT document); + +// Experimental API. +// Get the marked content ID for the object. +// +// page_object - handle to a page object. +// +// Returns the page object's marked content ID, or -1 on error. +FPDF_EXPORT int FPDF_CALLCONV +FPDFPageObj_GetMarkedContentID(FPDF_PAGEOBJECT page_object); + +// Experimental API. +// Get number of content marks in |page_object|. +// +// page_object - handle to a page object. +// +// Returns the number of content marks in |page_object|, or -1 in case of +// failure. +FPDF_EXPORT int FPDF_CALLCONV +FPDFPageObj_CountMarks(FPDF_PAGEOBJECT page_object); + +// Experimental API. +// Get content mark in |page_object| at |index|. +// +// page_object - handle to a page object. +// index - the index of a page object. +// +// Returns the handle to the content mark, or NULL on failure. The handle is +// still owned by the library, and it should not be freed directly. It becomes +// invalid if the page object is destroyed, either directly or indirectly by +// unloading the page. +FPDF_EXPORT FPDF_PAGEOBJECTMARK FPDF_CALLCONV +FPDFPageObj_GetMark(FPDF_PAGEOBJECT page_object, unsigned long index); + +// Experimental API. +// Add a new content mark to a |page_object|. +// +// page_object - handle to a page object. +// name - the name (tag) of the mark. +// +// Returns the handle to the content mark, or NULL on failure. The handle is +// still owned by the library, and it should not be freed directly. It becomes +// invalid if the page object is destroyed, either directly or indirectly by +// unloading the page. +FPDF_EXPORT FPDF_PAGEOBJECTMARK FPDF_CALLCONV +FPDFPageObj_AddMark(FPDF_PAGEOBJECT page_object, FPDF_BYTESTRING name); + +// Experimental API. +// Removes a content |mark| from a |page_object|. +// The mark handle will be invalid after the removal. +// +// page_object - handle to a page object. +// mark - handle to a content mark in that object to remove. +// +// Returns TRUE if the operation succeeded, FALSE if it failed. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_RemoveMark(FPDF_PAGEOBJECT page_object, FPDF_PAGEOBJECTMARK mark); + +// Experimental API. +// Get the name of a content mark. +// +// mark - handle to a content mark. +// buffer - buffer for holding the returned name in UTF-16LE. This is only +// modified if |buflen| is large enough to store the name. +// Optional, pass null to just retrieve the size of the buffer +// needed. +// buflen - length of the buffer in bytes. +// out_buflen - pointer to variable that will receive the minimum buffer size +// in bytes to contain the name. This is a required parameter. +// Not filled if FALSE is returned. +// +// Returns TRUE if the operation succeeded, FALSE if it failed. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObjMark_GetName(FPDF_PAGEOBJECTMARK mark, + FPDF_WCHAR* buffer, + unsigned long buflen, + unsigned long* out_buflen); + +// Experimental API. +// Get the number of key/value pair parameters in |mark|. +// +// mark - handle to a content mark. +// +// Returns the number of key/value pair parameters |mark|, or -1 in case of +// failure. +FPDF_EXPORT int FPDF_CALLCONV +FPDFPageObjMark_CountParams(FPDF_PAGEOBJECTMARK mark); + +// Experimental API. +// Get the key of a property in a content mark. +// +// mark - handle to a content mark. +// index - index of the property. +// buffer - buffer for holding the returned key in UTF-16LE. This is only +// modified if |buflen| is large enough to store the key. +// Optional, pass null to just retrieve the size of the buffer +// needed. +// buflen - length of the buffer in bytes. +// out_buflen - pointer to variable that will receive the minimum buffer size +// in bytes to contain the name. This is a required parameter. +// Not filled if FALSE is returned. +// +// Returns TRUE if the operation was successful, FALSE otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObjMark_GetParamKey(FPDF_PAGEOBJECTMARK mark, + unsigned long index, + FPDF_WCHAR* buffer, + unsigned long buflen, + unsigned long* out_buflen); + +// Experimental API. +// Get the type of the value of a property in a content mark by key. +// +// mark - handle to a content mark. +// key - string key of the property. +// +// Returns the type of the value, or FPDF_OBJECT_UNKNOWN in case of failure. +FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV +FPDFPageObjMark_GetParamValueType(FPDF_PAGEOBJECTMARK mark, + FPDF_BYTESTRING key); + +// Experimental API. +// Get the value of a number property in a content mark by key as int. +// FPDFPageObjMark_GetParamValueType() should have returned FPDF_OBJECT_NUMBER +// for this property. +// +// mark - handle to a content mark. +// key - string key of the property. +// out_value - pointer to variable that will receive the value. Not filled if +// false is returned. +// +// Returns TRUE if the key maps to a number value, FALSE otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObjMark_GetParamIntValue(FPDF_PAGEOBJECTMARK mark, + FPDF_BYTESTRING key, + int* out_value); + +// Experimental API. +// Get the value of a string property in a content mark by key. +// +// mark - handle to a content mark. +// key - string key of the property. +// buffer - buffer for holding the returned value in UTF-16LE. This is +// only modified if |buflen| is large enough to store the value. +// Optional, pass null to just retrieve the size of the buffer +// needed. +// buflen - length of the buffer in bytes. +// out_buflen - pointer to variable that will receive the minimum buffer size +// in bytes to contain the name. This is a required parameter. +// Not filled if FALSE is returned. +// +// Returns TRUE if the key maps to a string/blob value, FALSE otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObjMark_GetParamStringValue(FPDF_PAGEOBJECTMARK mark, + FPDF_BYTESTRING key, + FPDF_WCHAR* buffer, + unsigned long buflen, + unsigned long* out_buflen); + +// Experimental API. +// Get the value of a blob property in a content mark by key. +// +// mark - handle to a content mark. +// key - string key of the property. +// buffer - buffer for holding the returned value. This is only modified +// if |buflen| is large enough to store the value. +// Optional, pass null to just retrieve the size of the buffer +// needed. +// buflen - length of the buffer in bytes. +// out_buflen - pointer to variable that will receive the minimum buffer size +// in bytes to contain the name. This is a required parameter. +// Not filled if FALSE is returned. +// +// Returns TRUE if the key maps to a string/blob value, FALSE otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObjMark_GetParamBlobValue(FPDF_PAGEOBJECTMARK mark, + FPDF_BYTESTRING key, + unsigned char* buffer, + unsigned long buflen, + unsigned long* out_buflen); + +// Experimental API. +// Set the value of an int property in a content mark by key. If a parameter +// with key |key| exists, its value is set to |value|. Otherwise, it is added as +// a new parameter. +// +// document - handle to the document. +// page_object - handle to the page object with the mark. +// mark - handle to a content mark. +// key - string key of the property. +// value - int value to set. +// +// Returns TRUE if the operation succeeded, FALSE otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObjMark_SetIntParam(FPDF_DOCUMENT document, + FPDF_PAGEOBJECT page_object, + FPDF_PAGEOBJECTMARK mark, + FPDF_BYTESTRING key, + int value); + +// Experimental API. +// Set the value of a string property in a content mark by key. If a parameter +// with key |key| exists, its value is set to |value|. Otherwise, it is added as +// a new parameter. +// +// document - handle to the document. +// page_object - handle to the page object with the mark. +// mark - handle to a content mark. +// key - string key of the property. +// value - string value to set. +// +// Returns TRUE if the operation succeeded, FALSE otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObjMark_SetStringParam(FPDF_DOCUMENT document, + FPDF_PAGEOBJECT page_object, + FPDF_PAGEOBJECTMARK mark, + FPDF_BYTESTRING key, + FPDF_BYTESTRING value); + +// Experimental API. +// Set the value of a blob property in a content mark by key. If a parameter +// with key |key| exists, its value is set to |value|. Otherwise, it is added as +// a new parameter. +// +// document - handle to the document. +// page_object - handle to the page object with the mark. +// mark - handle to a content mark. +// key - string key of the property. +// value - pointer to blob value to set. +// value_len - size in bytes of |value|. +// +// Returns TRUE if the operation succeeded, FALSE otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObjMark_SetBlobParam(FPDF_DOCUMENT document, + FPDF_PAGEOBJECT page_object, + FPDF_PAGEOBJECTMARK mark, + FPDF_BYTESTRING key, + const unsigned char* value, + unsigned long value_len); + +// Experimental API. +// Removes a property from a content mark by key. +// +// page_object - handle to the page object with the mark. +// mark - handle to a content mark. +// key - string key of the property. +// +// Returns TRUE if the operation succeeded, FALSE otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObjMark_RemoveParam(FPDF_PAGEOBJECT page_object, + FPDF_PAGEOBJECTMARK mark, + FPDF_BYTESTRING key); + +// Load an image from a JPEG image file and then set it into |image_object|. +// +// pages - pointer to the start of all loaded pages, may be NULL. +// count - number of |pages|, may be 0. +// image_object - handle to an image object. +// file_access - file access handler which specifies the JPEG image file. +// +// Returns TRUE on success. +// +// The image object might already have an associated image, which is shared and +// cached by the loaded pages. In that case, we need to clear the cached image +// for all the loaded pages. Pass |pages| and page count (|count|) to this API +// to clear the image cache. If the image is not previously shared, or NULL is a +// valid |pages| value. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, - int nCount, + int count, FPDF_PAGEOBJECT image_object, - FPDF_FILEACCESS* fileAccess); - -// Function: FPDFImageObj_SetMatrix -// Set the matrix of an image object. -// Parameters: -// image_object - Handle of image object returned by -// FPDFPageObj_NewImgeObj. -// a - The coefficient "a" of the matrix. -// b - The coefficient "b" of the matrix. -// c - The coefficient "c" of the matrix. -// d - The coefficient "d" of the matrix. -// e - The coefficient "e" of the matrix. -// f - The coefficient "f" of the matrix. -// Return value: -// TRUE if successful, FALSE otherwise. -DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object, - double a, - double b, - double c, - double d, - double e, - double f); - -// Function: FPDFImageObj_SetBitmap -// Set the bitmap to an image object. -// Parameters: -// pages - Pointer's to the start of all loaded pages. -// nCount - Number of pages. -// image_object - Handle of image object returned by -// FPDFPageObj_NewImgeObj. -// bitmap - The handle of the bitmap which you want to set -// it to the image object. -// Return value: -// TRUE if successful, FALSE otherwise. -DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages, - int nCount, - FPDF_PAGEOBJECT image_object, - FPDF_BITMAP bitmap); + FPDF_FILEACCESS* file_access); + +// Load an image from a JPEG image file and then set it into |image_object|. +// +// pages - pointer to the start of all loaded pages, may be NULL. +// count - number of |pages|, may be 0. +// image_object - handle to an image object. +// file_access - file access handler which specifies the JPEG image file. +// +// Returns TRUE on success. +// +// The image object might already have an associated image, which is shared and +// cached by the loaded pages. In that case, we need to clear the cached image +// for all the loaded pages. Pass |pages| and page count (|count|) to this API +// to clear the image cache. If the image is not previously shared, or NULL is a +// valid |pages| value. This function loads the JPEG image inline, so the image +// content is copied to the file. This allows |file_access| and its associated +// data to be deleted after this function returns. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFImageObj_LoadJpegFileInline(FPDF_PAGE* pages, + int count, + FPDF_PAGEOBJECT image_object, + FPDF_FILEACCESS* file_access); + +// TODO(thestig): Start deprecating this once FPDFPageObj_SetMatrix() is stable. +// +// Set the transform matrix of |image_object|. +// +// image_object - handle to an image object. +// a - matrix value. +// b - matrix value. +// c - matrix value. +// d - matrix value. +// e - matrix value. +// f - matrix value. +// +// The matrix is composed as: +// |a c e| +// |b d f| +// and can be used to scale, rotate, shear and translate the |image_object|. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object, + double a, + double b, + double c, + double d, + double e, + double f); + +// Set |bitmap| to |image_object|. +// +// pages - pointer to the start of all loaded pages, may be NULL. +// count - number of |pages|, may be 0. +// image_object - handle to an image object. +// bitmap - handle of the bitmap. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFImageObj_SetBitmap(FPDF_PAGE* pages, + int count, + FPDF_PAGEOBJECT image_object, + FPDF_BITMAP bitmap); + +// Get a bitmap rasterization of |image_object|. FPDFImageObj_GetBitmap() only +// operates on |image_object| and does not take the associated image mask into +// account. It also ignores the matrix for |image_object|. +// The returned bitmap will be owned by the caller, and FPDFBitmap_Destroy() +// must be called on the returned bitmap when it is no longer needed. +// +// image_object - handle to an image object. +// +// Returns the bitmap. +FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV +FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object); + +// Experimental API. +// Get a bitmap rasterization of |image_object| that takes the image mask and +// image matrix into account. To render correctly, the caller must provide the +// |document| associated with |image_object|. If there is a |page| associated +// with |image_object|, the caller should provide that as well. +// The returned bitmap will be owned by the caller, and FPDFBitmap_Destroy() +// must be called on the returned bitmap when it is no longer needed. +// +// document - handle to a document associated with |image_object|. +// page - handle to an optional page associated with |image_object|. +// image_object - handle to an image object. +// +// Returns the bitmap or NULL on failure. +FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV +FPDFImageObj_GetRenderedBitmap(FPDF_DOCUMENT document, + FPDF_PAGE page, + FPDF_PAGEOBJECT image_object); + +// Get the decoded image data of |image_object|. The decoded data is the +// uncompressed image data, i.e. the raw image data after having all filters +// applied. |buffer| is only modified if |buflen| is longer than the length of +// the decoded image data. +// +// image_object - handle to an image object. +// buffer - buffer for holding the decoded image data. +// buflen - length of the buffer in bytes. +// +// Returns the length of the decoded image data. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object, + void* buffer, + unsigned long buflen); + +// Get the raw image data of |image_object|. The raw data is the image data as +// stored in the PDF without applying any filters. |buffer| is only modified if +// |buflen| is longer than the length of the raw image data. +// +// image_object - handle to an image object. +// buffer - buffer for holding the raw image data. +// buflen - length of the buffer in bytes. +// +// Returns the length of the raw image data. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFImageObj_GetImageDataRaw(FPDF_PAGEOBJECT image_object, + void* buffer, + unsigned long buflen); + +// Get the number of filters (i.e. decoders) of the image in |image_object|. +// +// image_object - handle to an image object. +// +// Returns the number of |image_object|'s filters. +FPDF_EXPORT int FPDF_CALLCONV +FPDFImageObj_GetImageFilterCount(FPDF_PAGEOBJECT image_object); + +// Get the filter at |index| of |image_object|'s list of filters. Note that the +// filters need to be applied in order, i.e. the first filter should be applied +// first, then the second, etc. |buffer| is only modified if |buflen| is longer +// than the length of the filter string. +// +// image_object - handle to an image object. +// index - the index of the filter requested. +// buffer - buffer for holding filter string, encoded in UTF-8. +// buflen - length of the buffer. +// +// Returns the length of the filter string. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFImageObj_GetImageFilter(FPDF_PAGEOBJECT image_object, + int index, + void* buffer, + unsigned long buflen); + +// Get the image metadata of |image_object|, including dimension, DPI, bits per +// pixel, and colorspace. If the |image_object| is not an image object or if it +// does not have an image, then the return value will be false. Otherwise, +// failure to retrieve any specific parameter would result in its value being 0. +// +// image_object - handle to an image object. +// page - handle to the page that |image_object| is on. Required for +// retrieving the image's bits per pixel and colorspace. +// metadata - receives the image metadata; must not be NULL. +// +// Returns true if successful. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +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); + +// Experimental API. +// Get ICC profile decoded data of |image_object|. If the |image_object| is not +// an image object or if it does not have an image, then the return value will +// be false. It also returns false if the |image_object| has no ICC profile. +// |buffer| is only modified if ICC profile exists and |buflen| is longer than +// the length of the ICC profile decoded data. +// +// image_object - handle to an image object; must not be NULL. +// page - handle to the page containing |image_object|; must not be +// NULL. Required for retrieving the image's colorspace. +// buffer - Buffer to receive ICC profile data; may be NULL if querying +// required size via |out_buflen|. +// buflen - Length of the buffer in bytes. Ignored if |buffer| is NULL. +// out_buflen - Pointer to receive the ICC profile data size in bytes; must +// not be NULL. Will be set if this API returns true. +// +// Returns true if |out_buflen| is not null and an ICC profile exists for the +// given |image_object|. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFImageObj_GetIccProfileDataDecoded(FPDF_PAGEOBJECT image_object, + FPDF_PAGE page, + uint8_t* buffer, + size_t buflen, + size_t* out_buflen); + +// Create a new path object at an initial position. +// +// x - initial horizontal position. +// y - initial vertical position. +// +// Returns a handle to a new path object. +FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewPath(float x, + float y); + +// Create a closed path consisting of a rectangle. +// +// x - horizontal position for the left boundary of the rectangle. +// y - vertical position for the bottom boundary of the rectangle. +// w - width of the rectangle. +// h - height of the rectangle. +// +// Returns a handle to the new path object. +FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewRect(float x, + float y, + float w, + float h); + +// Get the bounding box of |page_object|. +// +// page_object - handle to a page object. +// left - pointer where the left coordinate will be stored +// bottom - pointer where the bottom coordinate will be stored +// right - pointer where the right coordinate will be stored +// top - pointer where the top coordinate will be stored +// +// On success, returns TRUE and fills in the 4 coordinates. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_GetBounds(FPDF_PAGEOBJECT page_object, + float* left, + float* bottom, + float* right, + float* top); + +// Experimental API. +// Get the quad points that bounds |page_object|. +// +// page_object - handle to a page object. +// quad_points - pointer where the quadrilateral points will be stored. +// +// On success, returns TRUE and fills in |quad_points|. +// +// Similar to FPDFPageObj_GetBounds(), this returns the bounds of a page +// object. When the object is rotated by a non-multiple of 90 degrees, this API +// returns a tighter bound that cannot be represented with just the 4 sides of +// a rectangle. +// +// Currently only works the following |page_object| types: FPDF_PAGEOBJ_TEXT and +// FPDF_PAGEOBJ_IMAGE. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_GetRotatedBounds(FPDF_PAGEOBJECT page_object, + FS_QUADPOINTSF* quad_points); + +// Set the blend mode of |page_object|. +// +// page_object - handle to a page object. +// blend_mode - string containing the blend mode. +// +// Blend mode can be one of following: Color, ColorBurn, ColorDodge, Darken, +// Difference, Exclusion, HardLight, Hue, Lighten, Luminosity, Multiply, Normal, +// Overlay, Saturation, Screen, SoftLight +FPDF_EXPORT void FPDF_CALLCONV +FPDFPageObj_SetBlendMode(FPDF_PAGEOBJECT page_object, + FPDF_BYTESTRING blend_mode); + +// Set the stroke RGBA of a page object. Range of values: 0 - 255. +// +// page_object - the handle to the page object. +// R - the red component for the object's stroke color. +// G - the green component for the object's stroke color. +// B - the blue component for the object's stroke color. +// A - the stroke alpha for the object. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_SetStrokeColor(FPDF_PAGEOBJECT page_object, + unsigned int R, + unsigned int G, + unsigned int B, + unsigned int A); + +// Get the stroke RGBA of a page object. Range of values: 0 - 255. +// +// page_object - the handle to the page object. +// R - the red component of the path stroke color. +// G - the green component of the object's stroke color. +// B - the blue component of the object's stroke color. +// A - the stroke alpha of the object. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_GetStrokeColor(FPDF_PAGEOBJECT page_object, + unsigned int* R, + unsigned int* G, + unsigned int* B, + unsigned int* A); + +// Set the stroke width of a page object. +// +// path - the handle to the page object. +// width - the width of the stroke. +// +// Returns TRUE on success +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_SetStrokeWidth(FPDF_PAGEOBJECT page_object, float width); + +// Get the stroke width of a page object. +// +// path - the handle to the page object. +// width - the width of the stroke. +// +// Returns TRUE on success +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_GetStrokeWidth(FPDF_PAGEOBJECT page_object, float* width); + +// Get the line join of |page_object|. +// +// page_object - handle to a page object. +// +// Returns the line join, or -1 on failure. +// Line join can be one of following: FPDF_LINEJOIN_MITER, FPDF_LINEJOIN_ROUND, +// FPDF_LINEJOIN_BEVEL +FPDF_EXPORT int FPDF_CALLCONV +FPDFPageObj_GetLineJoin(FPDF_PAGEOBJECT page_object); + +// Set the line join of |page_object|. +// +// page_object - handle to a page object. +// line_join - line join +// +// Line join can be one of following: FPDF_LINEJOIN_MITER, FPDF_LINEJOIN_ROUND, +// FPDF_LINEJOIN_BEVEL +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_SetLineJoin(FPDF_PAGEOBJECT page_object, int line_join); + +// Get the line cap of |page_object|. +// +// page_object - handle to a page object. +// +// Returns the line cap, or -1 on failure. +// Line cap can be one of following: FPDF_LINECAP_BUTT, FPDF_LINECAP_ROUND, +// FPDF_LINECAP_PROJECTING_SQUARE +FPDF_EXPORT int FPDF_CALLCONV +FPDFPageObj_GetLineCap(FPDF_PAGEOBJECT page_object); + +// Set the line cap of |page_object|. +// +// page_object - handle to a page object. +// line_cap - line cap +// +// Line cap can be one of following: FPDF_LINECAP_BUTT, FPDF_LINECAP_ROUND, +// FPDF_LINECAP_PROJECTING_SQUARE +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap); + +// Set the fill RGBA of a page object. Range of values: 0 - 255. +// +// page_object - the handle to the page object. +// R - the red component for the object's fill color. +// G - the green component for the object's fill color. +// B - the blue component for the object's fill color. +// A - the fill alpha for the object. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_SetFillColor(FPDF_PAGEOBJECT page_object, + unsigned int R, + unsigned int G, + unsigned int B, + unsigned int A); + +// Get the fill RGBA of a page object. Range of values: 0 - 255. +// +// page_object - the handle to the page object. +// R - the red component of the object's fill color. +// G - the green component of the object's fill color. +// B - the blue component of the object's fill color. +// A - the fill alpha of the object. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_GetFillColor(FPDF_PAGEOBJECT page_object, + unsigned int* R, + unsigned int* G, + unsigned int* B, + unsigned int* A); + +// Experimental API. +// Get the line dash |phase| of |page_object|. +// +// page_object - handle to a page object. +// phase - pointer where the dashing phase will be stored. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_GetDashPhase(FPDF_PAGEOBJECT page_object, float* phase); + +// Experimental API. +// Set the line dash phase of |page_object|. +// +// page_object - handle to a page object. +// phase - line dash phase. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_SetDashPhase(FPDF_PAGEOBJECT page_object, float phase); + +// Experimental API. +// Get the line dash array of |page_object|. +// +// page_object - handle to a page object. +// +// Returns the line dash array size or -1 on failure. +FPDF_EXPORT int FPDF_CALLCONV +FPDFPageObj_GetDashCount(FPDF_PAGEOBJECT page_object); + +// Experimental API. +// Get the line dash array of |page_object|. +// +// page_object - handle to a page object. +// dash_array - pointer where the dashing array will be stored. +// dash_count - number of elements in |dash_array|. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_GetDashArray(FPDF_PAGEOBJECT page_object, + float* dash_array, + size_t dash_count); + +// Experimental API. +// Set the line dash array of |page_object|. +// +// page_object - handle to a page object. +// dash_array - the dash array. +// dash_count - number of elements in |dash_array|. +// phase - the line dash phase. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_SetDashArray(FPDF_PAGEOBJECT page_object, + const float* dash_array, + size_t dash_count, + float phase); + +// Get number of segments inside |path|. +// +// path - handle to a path. +// +// A segment is a command, created by e.g. FPDFPath_MoveTo(), +// FPDFPath_LineTo() or FPDFPath_BezierTo(). +// +// Returns the number of objects in |path| or -1 on failure. +FPDF_EXPORT int FPDF_CALLCONV FPDFPath_CountSegments(FPDF_PAGEOBJECT path); + +// Get segment in |path| at |index|. +// +// path - handle to a path. +// index - the index of a segment. +// +// Returns the handle to the segment, or NULL on faiure. +FPDF_EXPORT FPDF_PATHSEGMENT FPDF_CALLCONV +FPDFPath_GetPathSegment(FPDF_PAGEOBJECT path, int index); + +// Get coordinates of |segment|. +// +// segment - handle to a segment. +// x - the horizontal position of the segment. +// y - the vertical position of the segment. +// +// Returns TRUE on success, otherwise |x| and |y| is not set. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPathSegment_GetPoint(FPDF_PATHSEGMENT segment, float* x, float* y); + +// Get type of |segment|. +// +// segment - handle to a segment. +// +// Returns one of the FPDF_SEGMENT_* values on success, +// FPDF_SEGMENT_UNKNOWN on error. +FPDF_EXPORT int FPDF_CALLCONV FPDFPathSegment_GetType(FPDF_PATHSEGMENT segment); + +// Gets if the |segment| closes the current subpath of a given path. +// +// segment - handle to a segment. +// +// Returns close flag for non-NULL segment, FALSE otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPathSegment_GetClose(FPDF_PATHSEGMENT segment); + +// Move a path's current point. +// +// path - the handle to the path object. +// x - the horizontal position of the new current point. +// y - the vertical position of the new current point. +// +// Note that no line will be created between the previous current point and the +// new one. +// +// Returns TRUE on success +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_MoveTo(FPDF_PAGEOBJECT path, + float x, + float y); + +// Add a line between the current point and a new point in the path. +// +// path - the handle to the path object. +// x - the horizontal position of the new point. +// y - the vertical position of the new point. +// +// The path's current point is changed to (x, y). +// +// Returns TRUE on success +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_LineTo(FPDF_PAGEOBJECT path, + float x, + float y); + +// Add a cubic Bezier curve to the given path, starting at the current point. +// +// path - the handle to the path object. +// x1 - the horizontal position of the first Bezier control point. +// y1 - the vertical position of the first Bezier control point. +// x2 - the horizontal position of the second Bezier control point. +// y2 - the vertical position of the second Bezier control point. +// x3 - the horizontal position of the ending point of the Bezier curve. +// y3 - the vertical position of the ending point of the Bezier curve. +// +// Returns TRUE on success +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_BezierTo(FPDF_PAGEOBJECT path, + float x1, + float y1, + float x2, + float y2, + float x3, + float y3); + +// Close the current subpath of a given path. +// +// path - the handle to the path object. +// +// This will add a line between the current point and the initial point of the +// subpath, thus terminating the current subpath. +// +// Returns TRUE on success +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_Close(FPDF_PAGEOBJECT path); + +// Set the drawing mode of a path. +// +// path - the handle to the path object. +// fillmode - the filling mode to be set: one of the FPDF_FILLMODE_* flags. +// stroke - a boolean specifying if the path should be stroked or not. +// +// Returns TRUE on success +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path, + int fillmode, + FPDF_BOOL stroke); + +// Get the drawing mode of a path. +// +// path - the handle to the path object. +// fillmode - the filling mode of the path: one of the FPDF_FILLMODE_* flags. +// stroke - a boolean specifying if the path is stroked or not. +// +// Returns TRUE on success +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetDrawMode(FPDF_PAGEOBJECT path, + int* fillmode, + FPDF_BOOL* stroke); + +// Create a new text object using one of the standard PDF fonts. +// +// document - handle to the document. +// font - string containing the font name, without spaces. +// font_size - the font size for the new text object. +// +// Returns a handle to a new text object, or NULL on failure +FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV +FPDFPageObj_NewTextObj(FPDF_DOCUMENT document, + FPDF_BYTESTRING font, + float font_size); + +// Set the text for a text object. If it had text, it will be replaced. +// +// text_object - handle to the text object. +// text - the UTF-16LE encoded string containing the text to be added. +// +// Returns TRUE on success +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFText_SetText(FPDF_PAGEOBJECT text_object, FPDF_WIDESTRING text); + +// Experimental API. +// Set the text using charcodes for a text object. If it had text, it will be +// replaced. +// +// text_object - handle to the text object. +// charcodes - pointer to an array of charcodes to be added. +// count - number of elements in |charcodes|. +// +// Returns TRUE on success +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFText_SetCharcodes(FPDF_PAGEOBJECT text_object, + const uint32_t* charcodes, + size_t count); + +// Returns a font object loaded from a stream of data. The font is loaded +// into the document. Various font data structures, such as the ToUnicode data, +// are auto-generated based on the inputs. +// +// document - handle to the document. +// data - the stream of font data, which will be copied by the font object. +// size - the size of the font data, in bytes. +// font_type - FPDF_FONT_TYPE1 or FPDF_FONT_TRUETYPE depending on the font type. +// cid - a boolean specifying if the font is a CID font or not. +// +// The loaded font can be closed using FPDFFont_Close(). +// +// Returns NULL on failure +FPDF_EXPORT FPDF_FONT FPDF_CALLCONV FPDFText_LoadFont(FPDF_DOCUMENT document, + const uint8_t* data, + uint32_t size, + int font_type, + FPDF_BOOL cid); + +// Experimental API. +// Loads one of the standard 14 fonts per PDF spec 1.7 page 416. The preferred +// way of using font style is using a dash to separate the name from the style, +// for example 'Helvetica-BoldItalic'. +// +// document - handle to the document. +// font - string containing the font name, without spaces. +// +// The loaded font can be closed using FPDFFont_Close(). +// +// Returns NULL on failure. +FPDF_EXPORT FPDF_FONT FPDF_CALLCONV +FPDFText_LoadStandardFont(FPDF_DOCUMENT document, FPDF_BYTESTRING font); + +// Experimental API. +// Returns a font object loaded from a stream of data for a type 2 CID font. The +// font is loaded into the document. Unlike FPDFText_LoadFont(), the ToUnicode +// data and the CIDToGIDMap data are caller provided, instead of auto-generated. +// +// document - handle to the document. +// font_data - the stream of font data, which will be copied by +// the font object. +// font_data_size - the size of the font data, in bytes. +// to_unicode_cmap - the ToUnicode data. +// cid_to_gid_map_data - the stream of CIDToGIDMap data. +// cid_to_gid_map_data_size - the size of the CIDToGIDMap data, in bytes. +// +// The loaded font can be closed using FPDFFont_Close(). +// +// Returns NULL on failure. +FPDF_EXPORT FPDF_FONT FPDF_CALLCONV +FPDFText_LoadCidType2Font(FPDF_DOCUMENT document, + const uint8_t* font_data, + uint32_t font_data_size, + FPDF_BYTESTRING to_unicode_cmap, + const uint8_t* cid_to_gid_map_data, + uint32_t cid_to_gid_map_data_size); + +// Get the font size of a text object. +// +// text - handle to a text. +// size - pointer to the font size of the text object, measured in points +// (about 1/72 inch) +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text, float* size); + +// Close a loaded PDF font. +// +// font - Handle to the loaded font. +FPDF_EXPORT void FPDF_CALLCONV FPDFFont_Close(FPDF_FONT font); + +// Create a new text object using a loaded font. +// +// document - handle to the document. +// font - handle to the font object. +// font_size - the font size for the new text object. +// +// Returns a handle to a new text object, or NULL on failure +FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV +FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document, + FPDF_FONT font, + float font_size); + +// Get the text rendering mode of a text object. +// +// text - the handle to the text object. +// +// Returns one of the known FPDF_TEXT_RENDERMODE enum values on success, +// FPDF_TEXTRENDERMODE_UNKNOWN on error. +FPDF_EXPORT FPDF_TEXT_RENDERMODE FPDF_CALLCONV +FPDFTextObj_GetTextRenderMode(FPDF_PAGEOBJECT text); + +// Experimental API. +// Set the text rendering mode of a text object. +// +// text - the handle to the text object. +// render_mode - the FPDF_TEXT_RENDERMODE enum value to be set (cannot set to +// FPDF_TEXTRENDERMODE_UNKNOWN). +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFTextObj_SetTextRenderMode(FPDF_PAGEOBJECT text, + FPDF_TEXT_RENDERMODE render_mode); + +// Get the text of a text object. +// +// text_object - the handle to the text object. +// text_page - the handle to the text page. +// buffer - the address of a buffer that receives the text. +// length - the size, in bytes, of |buffer|. +// +// Returns the number of bytes in the text (including the trailing NUL +// character) on success, 0 on error. +// +// Regardless of the platform, the |buffer| is always in UTF-16LE encoding. +// If |length| is less than the returned length, or |buffer| is NULL, |buffer| +// will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFTextObj_GetText(FPDF_PAGEOBJECT text_object, + FPDF_TEXTPAGE text_page, + FPDF_WCHAR* buffer, + unsigned long length); + +// Experimental API. +// Get a bitmap rasterization of |text_object|. To render correctly, the caller +// must provide the |document| associated with |text_object|. If there is a +// |page| associated with |text_object|, the caller should provide that as well. +// The returned bitmap will be owned by the caller, and FPDFBitmap_Destroy() +// must be called on the returned bitmap when it is no longer needed. +// +// document - handle to a document associated with |text_object|. +// page - handle to an optional page associated with |text_object|. +// text_object - handle to a text object. +// scale - the scaling factor, which must be greater than 0. +// +// Returns the bitmap or NULL on failure. +FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV +FPDFTextObj_GetRenderedBitmap(FPDF_DOCUMENT document, + FPDF_PAGE page, + FPDF_PAGEOBJECT text_object, + float scale); + +// Experimental API. +// Get the font of a text object. +// +// text - the handle to the text object. +// +// Returns a handle to the font object held by |text| which retains ownership. +FPDF_EXPORT FPDF_FONT FPDF_CALLCONV FPDFTextObj_GetFont(FPDF_PAGEOBJECT text); + +// Experimental API. +// Get the base name of a font. +// +// font - the handle to the font object. +// buffer - the address of a buffer that receives the base font name. +// length - the size, in bytes, of |buffer|. +// +// Returns the number of bytes in the base name (including the trailing NUL +// character) on success, 0 on error. The base name is typically the font's +// PostScript name. See descriptions of "BaseFont" in ISO 32000-1:2008 spec. +// +// Regardless of the platform, the |buffer| is always in UTF-8 encoding. +// If |length| is less than the returned length, or |buffer| is NULL, |buffer| +// will not be modified. +FPDF_EXPORT size_t FPDF_CALLCONV FPDFFont_GetBaseFontName(FPDF_FONT font, + char* buffer, + size_t length); + +// Experimental API. +// Get the family name of a font. +// +// font - the handle to the font object. +// buffer - the address of a buffer that receives the font name. +// length - the size, in bytes, of |buffer|. +// +// Returns the number of bytes in the family name (including the trailing NUL +// character) on success, 0 on error. +// +// Regardless of the platform, the |buffer| is always in UTF-8 encoding. +// If |length| is less than the returned length, or |buffer| is NULL, |buffer| +// will not be modified. +FPDF_EXPORT size_t FPDF_CALLCONV FPDFFont_GetFamilyName(FPDF_FONT font, + char* buffer, + size_t length); + +// Experimental API. +// Get the decoded data from the |font| object. +// +// font - The handle to the font object. (Required) +// buffer - The address of a buffer that receives the font data. +// buflen - Length of the buffer. +// out_buflen - Pointer to variable that will receive the minimum buffer size +// to contain the font data. Not filled if the return value is +// FALSE. (Required) +// +// Returns TRUE on success. In which case, |out_buflen| will be filled, and +// |buffer| will be filled if it is large enough. Returns FALSE if any of the +// required parameters are null. +// +// The decoded data is the uncompressed font data. i.e. the raw font data after +// having all stream filters applied, when the data is embedded. +// +// If the font is not embedded, then this API will instead return the data for +// the substitution font it is using. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFFont_GetFontData(FPDF_FONT font, + uint8_t* buffer, + size_t buflen, + size_t* out_buflen); + +// Experimental API. +// Get whether |font| is embedded or not. +// +// font - the handle to the font object. +// +// Returns 1 if the font is embedded, 0 if it not, and -1 on failure. +FPDF_EXPORT int FPDF_CALLCONV FPDFFont_GetIsEmbedded(FPDF_FONT font); + +// Experimental API. +// Get the descriptor flags of a font. +// +// font - the handle to the font object. +// +// Returns the bit flags specifying various characteristics of the font as +// defined in ISO 32000-1:2008, table 123, -1 on failure. +FPDF_EXPORT int FPDF_CALLCONV FPDFFont_GetFlags(FPDF_FONT font); + +// Experimental API. +// Get the font weight of a font. +// +// font - the handle to the font object. +// +// Returns the font weight, -1 on failure. +// Typical values are 400 (normal) and 700 (bold). +FPDF_EXPORT int FPDF_CALLCONV FPDFFont_GetWeight(FPDF_FONT font); + +// Experimental API. +// Get the italic angle of a font. +// +// font - the handle to the font object. +// angle - pointer where the italic angle will be stored +// +// The italic angle of a |font| is defined as degrees counterclockwise +// from vertical. For a font that slopes to the right, this will be negative. +// +// Returns TRUE on success; |angle| unmodified on failure. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFFont_GetItalicAngle(FPDF_FONT font, + int* angle); + +// Experimental API. +// Get ascent distance of a font. +// +// font - the handle to the font object. +// font_size - the size of the |font|. +// ascent - pointer where the font ascent will be stored +// +// Ascent is the maximum distance in points above the baseline reached by the +// glyphs of the |font|. One point is 1/72 inch (around 0.3528 mm). +// +// Returns TRUE on success; |ascent| unmodified on failure. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFFont_GetAscent(FPDF_FONT font, + float font_size, + float* ascent); + +// Experimental API. +// Get descent distance of a font. +// +// font - the handle to the font object. +// font_size - the size of the |font|. +// descent - pointer where the font descent will be stored +// +// Descent is the maximum distance in points below the baseline reached by the +// glyphs of the |font|. One point is 1/72 inch (around 0.3528 mm). +// +// Returns TRUE on success; |descent| unmodified on failure. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFFont_GetDescent(FPDF_FONT font, + float font_size, + float* descent); + +// Experimental API. +// Get the width of a glyph in a font. +// +// font - the handle to the font object. +// glyph - the glyph. +// font_size - the size of the font. +// width - pointer where the glyph width will be stored +// +// Glyph width is the distance from the end of the prior glyph to the next +// glyph. This will be the vertical distance for vertical writing. +// +// Returns TRUE on success; |width| unmodified on failure. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFFont_GetGlyphWidth(FPDF_FONT font, + uint32_t glyph, + float font_size, + float* width); + +// Experimental API. +// Get the glyphpath describing how to draw a font glyph. +// +// font - the handle to the font object. +// glyph - the glyph being drawn. +// font_size - the size of the font. +// +// Returns the handle to the segment, or NULL on faiure. +FPDF_EXPORT FPDF_GLYPHPATH FPDF_CALLCONV FPDFFont_GetGlyphPath(FPDF_FONT font, + uint32_t glyph, + float font_size); + +// Experimental API. +// Get number of segments inside glyphpath. +// +// glyphpath - handle to a glyph path. +// +// Returns the number of objects in |glyphpath| or -1 on failure. +FPDF_EXPORT int FPDF_CALLCONV +FPDFGlyphPath_CountGlyphSegments(FPDF_GLYPHPATH glyphpath); + +// Experimental API. +// Get segment in glyphpath at index. +// +// glyphpath - handle to a glyph path. +// index - the index of a segment. +// +// Returns the handle to the segment, or NULL on faiure. +FPDF_EXPORT FPDF_PATHSEGMENT FPDF_CALLCONV +FPDFGlyphPath_GetGlyphPathSegment(FPDF_GLYPHPATH glyphpath, int index); + +// Get number of page objects inside |form_object|. +// +// form_object - handle to a form object. +// +// Returns the number of objects in |form_object| on success, -1 on error. +FPDF_EXPORT int FPDF_CALLCONV +FPDFFormObj_CountObjects(FPDF_PAGEOBJECT form_object); + +// Get page object in |form_object| at |index|. +// +// form_object - handle to a form object. +// index - the 0-based index of a page object. +// +// Returns the handle to the page object, or NULL on error. +FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV +FPDFFormObj_GetObject(FPDF_PAGEOBJECT form_object, unsigned long index); #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_EDIT_H_ diff --git a/src/main/jni/include/fpdf_ext.h b/src/main/jni/include/fpdf_ext.h index c80dcbbf..068a977c 100644 --- a/src/main/jni/include/fpdf_ext.h +++ b/src/main/jni/include/fpdf_ext.h @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,102 +7,113 @@ #ifndef PUBLIC_FPDF_EXT_H_ #define PUBLIC_FPDF_EXT_H_ +#include + +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" #ifdef __cplusplus extern "C" { -#endif +#endif // __cplusplus -// flags for type of unsupport object. +// Unsupported XFA form. #define FPDF_UNSP_DOC_XFAFORM 1 +// Unsupported portable collection. #define FPDF_UNSP_DOC_PORTABLECOLLECTION 2 +// Unsupported attachment. #define FPDF_UNSP_DOC_ATTACHMENT 3 +// Unsupported security. #define FPDF_UNSP_DOC_SECURITY 4 +// Unsupported shared review. #define FPDF_UNSP_DOC_SHAREDREVIEW 5 +// Unsupported shared form, acrobat. #define FPDF_UNSP_DOC_SHAREDFORM_ACROBAT 6 +// Unsupported shared form, filesystem. #define FPDF_UNSP_DOC_SHAREDFORM_FILESYSTEM 7 +// Unsupported shared form, email. #define FPDF_UNSP_DOC_SHAREDFORM_EMAIL 8 +// Unsupported 3D annotation. #define FPDF_UNSP_ANNOT_3DANNOT 11 +// Unsupported movie annotation. #define FPDF_UNSP_ANNOT_MOVIE 12 +// Unsupported sound annotation. #define FPDF_UNSP_ANNOT_SOUND 13 +// Unsupported screen media annotation. #define FPDF_UNSP_ANNOT_SCREEN_MEDIA 14 +// Unsupported screen rich media annotation. #define FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA 15 +// Unsupported attachment annotation. #define FPDF_UNSP_ANNOT_ATTACHMENT 16 +// Unsupported signature annotation. #define FPDF_UNSP_ANNOT_SIG 17 +// Interface for unsupported feature notifications. typedef struct _UNSUPPORT_INFO { - /** - * Version number of the interface. Currently must be 1. - **/ + // Version number of the interface. Must be 1. int version; - /** - * Method: FSDK_UnSupport_Handler - * UnSupport Object process handling function. - * Interface Version: - * 1 - * Implementation Required: - * Yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * nType - The type of unsupportObject - * Return value: - * None. - * */ - + // Unsupported object notification function. + // Interface Version: 1 + // Implementation Required: Yes + // + // pThis - pointer to the interface structure. + // nType - the type of unsupported object. One of the |FPDF_UNSP_*| entries. void (*FSDK_UnSupport_Handler)(struct _UNSUPPORT_INFO* pThis, int nType); } UNSUPPORT_INFO; -/** - * Function: FSDK_SetUnSpObjProcessHandler - * Setup A UnSupport Object process handler for foxit sdk. - * Parameters: - * unsp_info - Pointer to a UNSUPPORT_INFO structure. - * Return Value: - * TRUE means successful. FALSE means fails. - **/ - -DLLEXPORT FPDF_BOOL STDCALL +// Setup an unsupported object handler. +// +// unsp_info - Pointer to an UNSUPPORT_INFO structure. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_info); -// flags for page mode. - -// Unknown value +// Set replacement function for calls to time(). +// +// This API is intended to be used only for testing, thus may cause PDFium to +// behave poorly in production environments. +// +// func - Function pointer to alternate implementation of time(), or +// NULL to restore to actual time() call itself. +FPDF_EXPORT void FPDF_CALLCONV FSDK_SetTimeFunction(time_t (*func)()); + +// Set replacement function for calls to localtime(). +// +// This API is intended to be used only for testing, thus may cause PDFium to +// behave poorly in production environments. +// +// func - Function pointer to alternate implementation of localtime(), or +// NULL to restore to actual localtime() call itself. +FPDF_EXPORT void FPDF_CALLCONV +FSDK_SetLocaltimeFunction(struct tm* (*func)(const time_t*)); + +// Unknown page mode. #define PAGEMODE_UNKNOWN -1 - -// Neither document outline nor thumbnail images visible +// Document outline, and thumbnails hidden. #define PAGEMODE_USENONE 0 - -// Document outline visible +// Document outline visible. #define PAGEMODE_USEOUTLINES 1 - -// Thumbnial images visible +// Thumbnail images visible. #define PAGEMODE_USETHUMBS 2 - -// Full-screen mode, with no menu bar, window controls, or any other window -// visible +// Full-screen mode, no menu bar, window controls, or other decorations visible. #define PAGEMODE_FULLSCREEN 3 - -// Optional content group panel visible +// Optional content group panel visible. #define PAGEMODE_USEOC 4 - -// Attachments panel visible +// Attachments panel visible. #define PAGEMODE_USEATTACHMENTS 5 -/** - * Function: FPDFDoc_GetPageMode - * Get the document's PageMode(How the document should be displayed - *when opened) - * Parameters: - * doc - Handle to document. Returned by FPDF_LoadDocument - *function. - * Return Value: - * The flags for page mode. - **/ -DLLEXPORT int FPDFDoc_GetPageMode(FPDF_DOCUMENT document); +// Get the document's PageMode. +// +// doc - Handle to document. +// +// Returns one of the |PAGEMODE_*| flags defined above. +// +// The page mode defines how the document should be initially displayed. +FPDF_EXPORT int FPDF_CALLCONV FPDFDoc_GetPageMode(FPDF_DOCUMENT document); #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_EXT_H_ diff --git a/src/main/jni/include/fpdf_flatten.h b/src/main/jni/include/fpdf_flatten.h index af77c293..aba5186b 100644 --- a/src/main/jni/include/fpdf_flatten.h +++ b/src/main/jni/include/fpdf_flatten.h @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,39 +7,38 @@ #ifndef PUBLIC_FPDF_FLATTEN_H_ #define PUBLIC_FPDF_FLATTEN_H_ +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" -// Result codes. -#define FLATTEN_FAIL 0 // Flatten operation failed. -#define FLATTEN_SUCCESS 1 // Flatten operation succeed. -#define FLATTEN_NOTHINGTODO 2 // There is nothing to be flattened. +// Flatten operation failed. +#define FLATTEN_FAIL 0 +// Flatten operation succeed. +#define FLATTEN_SUCCESS 1 +// Nothing to be flattened. +#define FLATTEN_NOTHINGTODO 2 -// Flags. +// Flatten for normal display. #define FLAT_NORMALDISPLAY 0 +// Flatten for print. #define FLAT_PRINT 1 #ifdef __cplusplus extern "C" { -#endif - -// Function: FPDFPage_Flatten -// Make annotations and form fields become part of the page contents -// itself. -// Parameters: -// page - Handle to the page, as returned by FPDF_LoadPage(). -// nFlag - Intended use of the flattened result: 0 for normal display, -// 1 for printing. -// Return value: -// Either FLATTEN_FAIL, FLATTEN_SUCCESS, or FLATTEN_NOTHINGTODO (see -// above). -// Comments: -// Currently, all failures return FLATTEN_FAIL, with no indication for -// the reason -// for the failure. -DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag); +#endif // __cplusplus + +// Flatten annotations and form fields into the page contents. +// +// page - handle to the page. +// nFlag - One of the |FLAT_*| values denoting the page usage. +// +// Returns one of the |FLATTEN_*| values. +// +// Currently, all failures return |FLATTEN_FAIL| with no indication of the +// cause. +FPDF_EXPORT int FPDF_CALLCONV FPDFPage_Flatten(FPDF_PAGE page, int nFlag); #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_FLATTEN_H_ diff --git a/src/main/jni/include/fpdf_formfill.h b/src/main/jni/include/fpdf_formfill.h index b3bbb928..1f0b1298 100644 --- a/src/main/jni/include/fpdf_formfill.h +++ b/src/main/jni/include/fpdf_formfill.h @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,15 +7,42 @@ #ifndef PUBLIC_FPDF_FORMFILL_H_ #define PUBLIC_FPDF_FORMFILL_H_ +// clang-format off +// NOLINTNEXTLINE(build/include_directory) #include "fpdfview.h" -typedef void* FPDF_FORMHANDLE; - -#ifdef PDF_ENABLE_XFA -#define DOCTYPE_PDF 0 // Normal pdf Document -#define DOCTYPE_DYNAMIC_XFA 1 // Dynamic xfa Document Type -#define DOCTYPE_STATIC_XFA 2 // Static xfa Document Type -#endif // PDF_ENABLE_XFA +// These values are return values for a public API, so should not be changed +// other than the count when adding new values. +#define FORMTYPE_NONE 0 // Document contains no forms +#define FORMTYPE_ACRO_FORM 1 // Forms are specified using AcroForm spec +#define FORMTYPE_XFA_FULL 2 // Forms are specified using entire XFA spec +#define FORMTYPE_XFA_FOREGROUND 3 // Forms are specified using the XFAF subset + // of XFA spec +#define FORMTYPE_COUNT 4 // The number of form types + +#define JSPLATFORM_ALERT_BUTTON_OK 0 // OK button +#define JSPLATFORM_ALERT_BUTTON_OKCANCEL 1 // OK & Cancel buttons +#define JSPLATFORM_ALERT_BUTTON_YESNO 2 // Yes & No buttons +#define JSPLATFORM_ALERT_BUTTON_YESNOCANCEL 3 // Yes, No & Cancel buttons +#define JSPLATFORM_ALERT_BUTTON_DEFAULT JSPLATFORM_ALERT_BUTTON_OK + +#define JSPLATFORM_ALERT_ICON_ERROR 0 // Error +#define JSPLATFORM_ALERT_ICON_WARNING 1 // Warning +#define JSPLATFORM_ALERT_ICON_QUESTION 2 // Question +#define JSPLATFORM_ALERT_ICON_STATUS 3 // Status +#define JSPLATFORM_ALERT_ICON_ASTERISK 4 // Asterisk +#define JSPLATFORM_ALERT_ICON_DEFAULT JSPLATFORM_ALERT_ICON_ERROR + +#define JSPLATFORM_ALERT_RETURN_OK 1 // OK +#define JSPLATFORM_ALERT_RETURN_CANCEL 2 // Cancel +#define JSPLATFORM_ALERT_RETURN_NO 3 // No +#define JSPLATFORM_ALERT_RETURN_YES 4 // Yes + +#define JSPLATFORM_BEEP_ERROR 0 // Error +#define JSPLATFORM_BEEP_WARNING 1 // Warning +#define JSPLATFORM_BEEP_QUESTION 2 // Question +#define JSPLATFORM_BEEP_STATUS 3 // Status +#define JSPLATFORM_BEEP_DEFAULT 4 // Default // Exported Functions #ifdef __cplusplus @@ -23,103 +50,81 @@ extern "C" { #endif typedef struct _IPDF_JsPlatform { - /** - * Version number of the interface. Currently must be 2. - **/ + // Version number of the interface. Currently must be 2. int version; - /* Version 1. */ - - /** - * Method: app_alert - * pop up a dialog to show warning or hint. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * Msg - A string containing the message to be displayed. - * Title - The title of the dialog. - * Type - The stype of button group. - * 0-OK(default); - * 1-OK,Cancel; - * 2-Yes,NO; - * 3-Yes, NO, Cancel. - * nIcon - The Icon type. - * 0-Error(default); - * 1-Warning; - * 2-Question; - * 3-Status. - * 4-Asterisk - * Return Value: - * The return value could be the folowing type: - * 1-OK; - * 2-Cancel; - * 3-NO; - * 4-Yes; - */ + // Version 1. + + // Method: app_alert + // Pop up a dialog to show warning or hint. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself. + // Msg - A string containing the message to be displayed. + // Title - The title of the dialog. + // Type - The type of button group, one of the + // JSPLATFORM_ALERT_BUTTON_* values above. + // nIcon - The type of the icon, one of the + // JSPLATFORM_ALERT_ICON_* above. + // Return Value: + // Option selected by user in dialogue, one of the + // JSPLATFORM_ALERT_RETURN_* values above. int (*app_alert)(struct _IPDF_JsPlatform* pThis, FPDF_WIDESTRING Msg, FPDF_WIDESTRING Title, int Type, int Icon); - /** - * Method: app_beep - * Causes the system to play a sound. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * nType - The sound type. - * 0 - Error - * 1 - Warning - * 2 - Question - * 3 - Status - * 4 - Default (default value) - * Return Value: - * None - */ + // Method: app_beep + // Causes the system to play a sound. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself + // nType - The sound type, see JSPLATFORM_BEEP_TYPE_* + // above. + // Return Value: + // None void (*app_beep)(struct _IPDF_JsPlatform* pThis, int nType); - /** - * Method: app_response - * Displays a dialog box containing a question and an entry field for - * the user to reply to the question. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * Question - The question to be posed to the user. - * Title - The title of the dialog box. - * Default - A default value for the answer to the question. If - * not specified, no default value is presented. - * cLabel - A short string to appear in front of and on the - * same line as the edit text field. - * bPassword - If true, indicates that the user's response should - * show as asterisks (*) or bullets (?) to mask the response, which might be - * sensitive information. The default is false. - * response - A string buffer allocated by SDK, to receive the - * user's response. - * length - The length of the buffer, number of bytes. - * Currently, It's always be 2048. - * Return Value: - * Number of bytes the complete user input would actually require, not - * including trailing zeros, regardless of the value of the length - * parameter or the presence of the response buffer. - * Comments: - * No matter on what platform, the response buffer should be always - * written using UTF-16LE encoding. If a response buffer is - * present and the size of the user input exceeds the capacity of the - * buffer as specified by the length parameter, only the - * first "length" bytes of the user input are to be written to the - * buffer. - */ + // Method: app_response + // Displays a dialog box containing a question and an entry field for + // the user to reply to the question. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself + // Question - The question to be posed to the user. + // Title - The title of the dialog box. + // Default - A default value for the answer to the question. If + // not specified, no default value is presented. + // cLabel - A short string to appear in front of and on the + // same line as the edit text field. + // bPassword - If true, indicates that the user's response should + // be shown as asterisks (*) or bullets (?) to mask + // the response, which might be sensitive information. + // response - A string buffer allocated by PDFium, to receive the + // user's response. + // length - The length of the buffer in bytes. Currently, it is + // always 2048. + // Return Value: + // Number of bytes the complete user input would actually require, not + // including trailing zeros, regardless of the value of the length + // parameter or the presence of the response buffer. + // Comments: + // No matter on what platform, the response buffer should be always + // written using UTF-16LE encoding. If a response buffer is + // present and the size of the user input exceeds the capacity of the + // buffer as specified by the length parameter, only the + // first "length" bytes of the user input are to be written to the + // buffer. int (*app_response)(struct _IPDF_JsPlatform* pThis, FPDF_WIDESTRING Question, FPDF_WIDESTRING Title, @@ -129,66 +134,61 @@ typedef struct _IPDF_JsPlatform { void* response, int length); - /* - * Method: Doc_getFilePath - * Get the file path of the current document. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * filePath - The string buffer to receive the file path. Can be - * NULL. - * length - The length of the buffer, number of bytes. Can be - * 0. - * Return Value: - * Number of bytes the filePath consumes, including trailing zeros. - * Comments: - * The filePath should be always input in local encoding. - * - * The return value always indicated number of bytes required for the - * buffer, even when there is - * no buffer specified, or the buffer size is less then required. In this - * case, the buffer will not - * be modified. - */ + // Method: Doc_getFilePath + // Get the file path of the current document. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself + // filePath - The string buffer to receive the file path. Can + // be NULL. + // length - The length of the buffer, number of bytes. Can + // be 0. + // Return Value: + // Number of bytes the filePath consumes, including trailing zeros. + // Comments: + // The filePath should always be provided in the local encoding. + // The return value always indicated number of bytes required for + // the buffer, even when there is no buffer specified, or the buffer + // size is less than required. In this case, the buffer will not + // be modified. int (*Doc_getFilePath)(struct _IPDF_JsPlatform* pThis, void* filePath, int length); - /* - * Method: Doc_mail - * Mails the data buffer as an attachment to all recipients, with or - * without user interaction. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * mailData - Pointer to the data buffer to be sent.Can be NULL. - * length - The size,in bytes, of the buffer pointed by - * mailData parameter.Can be 0. - * bUI - If true, the rest of the parameters are used in a - * compose-new-message window that is displayed to the user. If false, the cTo - * parameter is required and all others are optional. - * To - A semicolon-delimited list of recipients for the - * message. - * Subject - The subject of the message. The length limit is 64 - * KB. - * CC - A semicolon-delimited list of CC recipients for - * the message. - * BCC - A semicolon-delimited list of BCC recipients for - * the message. - * Msg - The content of the message. The length limit is 64 - * KB. - * Return Value: - * None. - * Comments: - * If the parameter mailData is NULL or length is 0, the current - * document will be mailed as an attachment to all recipients. - */ + // Method: Doc_mail + // Mails the data buffer as an attachment to all recipients, with or + // without user interaction. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself + // mailData - Pointer to the data buffer to be sent. Can be NULL. + // length - The size,in bytes, of the buffer pointed by + // mailData parameter. Can be 0. + // bUI - If true, the rest of the parameters are used in a + // compose-new-message window that is displayed to the + // user. If false, the cTo parameter is required and + // all others are optional. + // To - A semicolon-delimited list of recipients for the + // message. + // Subject - The subject of the message. The length limit is + // 64 KB. + // CC - A semicolon-delimited list of CC recipients for + // the message. + // BCC - A semicolon-delimited list of BCC recipients for + // the message. + // Msg - The content of the message. The length limit is + // 64 KB. + // Return Value: + // None. + // Comments: + // If the parameter mailData is NULL or length is 0, the current + // document will be mailed as an attachment to all recipients. void (*Doc_mail)(struct _IPDF_JsPlatform* pThis, void* mailData, int length, @@ -199,30 +199,31 @@ typedef struct _IPDF_JsPlatform { FPDF_WIDESTRING BCC, FPDF_WIDESTRING Msg); - /* - * Method: Doc_print - * Prints all or a specific number of pages of the document. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * bUI - If true, will cause a UI to be presented to the - * user to obtain printing information and confirm the action. - * nStart - A 0-based index that defines the start of an - * inclusive range of pages. - * nEnd - A 0-based index that defines the end of an - * inclusive page range. - * bSilent - If true, suppresses the cancel dialog box while - * the document is printing. The default is false. - * bShrinkToFit - If true, the page is shrunk (if necessary) to - * fit within the imageable area of the printed page. - * bPrintAsImage - If true, print pages as an image. - * bReverse - If true, print from nEnd to nStart. - * bAnnotations - If true (the default), annotations are - * printed. - */ + // Method: Doc_print + // Prints all or a specific number of pages of the document. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself. + // bUI - If true, will cause a UI to be presented to the + // user to obtain printing information and confirm + // the action. + // nStart - A 0-based index that defines the start of an + // inclusive range of pages. + // nEnd - A 0-based index that defines the end of an + // inclusive page range. + // bSilent - If true, suppresses the cancel dialog box while + // the document is printing. The default is false. + // bShrinkToFit - If true, the page is shrunk (if necessary) to + // fit within the imageable area of the printed page. + // bPrintAsImage - If true, print pages as an image. + // bReverse - If true, print from nEnd to nStart. + // bAnnotations - If true (the default), annotations are + // printed. + // Return Value: + // None. void (*Doc_print)(struct _IPDF_JsPlatform* pThis, FPDF_BOOL bUI, int nStart, @@ -233,79 +234,69 @@ typedef struct _IPDF_JsPlatform { FPDF_BOOL bReverse, FPDF_BOOL bAnnotations); - /* - * Method: Doc_submitForm - * Send the form data to a specified URL. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * formData - Pointer to the data buffer to be sent. - * length - The size,in bytes, of the buffer pointed by - * formData parameter. - * URL - The URL to send to. - * Return Value: - * None. - * - */ + // Method: Doc_submitForm + // Send the form data to a specified URL. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself + // formData - Pointer to the data buffer to be sent. + // length - The size,in bytes, of the buffer pointed by + // formData parameter. + // URL - The URL to send to. + // Return Value: + // None. void (*Doc_submitForm)(struct _IPDF_JsPlatform* pThis, void* formData, int length, FPDF_WIDESTRING URL); - /* - * Method: Doc_gotoPage - * Jump to a specified page. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * nPageNum - The specified page number, zero for the first - * page. - * Return Value: - * None. - * - */ + // Method: Doc_gotoPage + // Jump to a specified page. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself + // nPageNum - The specified page number, zero for the first page. + // Return Value: + // None. void (*Doc_gotoPage)(struct _IPDF_JsPlatform* pThis, int nPageNum); - /* - * Method: Field_browse - * Show a file selection dialog, and return the selected file path. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * filePath - Pointer to the data buffer to receive the file - * path.Can be NULL. - * length - The length of the buffer, number of bytes. Can be - * 0. - * Return Value: - * Number of bytes the filePath consumes, including trailing zeros. - * Comments: - * The filePath shoule be always input in local encoding. - */ + + // Method: Field_browse + // Show a file selection dialog, and return the selected file path. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself. + // filePath - Pointer to the data buffer to receive the file + // path. Can be NULL. + // length - The length of the buffer, in bytes. Can be 0. + // Return Value: + // Number of bytes the filePath consumes, including trailing zeros. + // Comments: + // The filePath should always be provided in local encoding. int (*Field_browse)(struct _IPDF_JsPlatform* pThis, void* filePath, int length); - /** - * pointer to FPDF_FORMFILLINFO interface. - **/ + // Pointer for embedder-specific data. Unused by PDFium, and despite + // its name, can be any data the embedder desires, though traditionally + // a FPDF_FORMFILLINFO interface. void* m_pFormfillinfo; - /* Version 2. */ + // Version 2. - void* m_isolate; /* Unused in v3, retain for compatibility. */ - unsigned int m_v8EmbedderSlot; /* Unused in v3, retain for compatibility. */ - - /* Version 3. */ - /* Version 3 moves m_Isolate and m_v8EmbedderSlot to FPDF_LIBRARY_CONFIG. */ + void* m_isolate; // Unused in v3, retain for compatibility. + unsigned int m_v8EmbedderSlot; // Unused in v3, retain for compatibility. + // Version 3. + // Version 3 moves m_Isolate and m_v8EmbedderSlot to FPDF_LIBRARY_CONFIG. } IPDF_JSPLATFORM; // Flags for Cursor type @@ -316,117 +307,100 @@ typedef struct _IPDF_JsPlatform { #define FXCT_HBEAM 4 #define FXCT_HAND 5 -/** - * Declares of a pointer type to the callback function for the FFI_SetTimer - *method. - * Parameters: - * idEvent - Identifier of the timer. - * Return value: - * None. - **/ +// Function signature for the callback function passed to the FFI_SetTimer +// method. +// Parameters: +// idEvent - Identifier of the timer. +// Return value: +// None. typedef void (*TimerCallback)(int idEvent); -/** - * Declares of a struct type to the local system time. -**/ +// Declares of a struct type to the local system time. typedef struct _FPDF_SYSTEMTIME { - unsigned short wYear; /* years since 1900 */ - unsigned short wMonth; /* months since January - [0,11] */ - unsigned short wDayOfWeek; /* days since Sunday - [0,6] */ - unsigned short wDay; /* day of the month - [1,31] */ - unsigned short wHour; /* hours since midnight - [0,23] */ - unsigned short wMinute; /* minutes after the hour - [0,59] */ - unsigned short wSecond; /* seconds after the minute - [0,59] */ - unsigned short wMilliseconds; /* milliseconds after the second - [0,999] */ + unsigned short wYear; // years since 1900 + unsigned short wMonth; // months since January - [0,11] + unsigned short wDayOfWeek; // days since Sunday - [0,6] + unsigned short wDay; // day of the month - [1,31] + unsigned short wHour; // hours since midnight - [0,23] + unsigned short wMinute; // minutes after the hour - [0,59] + unsigned short wSecond; // seconds after the minute - [0,59] + unsigned short wMilliseconds; // milliseconds after the second - [0,999] } FPDF_SYSTEMTIME; #ifdef PDF_ENABLE_XFA -// XFA -/** - * @name Pageview event flags - */ -/*@{*/ -/** @brief After a new pageview is added. */ -#define FXFA_PAGEVIEWEVENT_POSTADDED 1 -/** @brief After a pageview is removed. */ -#define FXFA_PAGEVIEWEVENT_POSTREMOVED 3 -/*@}*/ - -// menu -/** - * @name Macro Definitions for Right Context Menu Features Of XFA Fields - */ -/*@{*/ -#define FXFA_MEMU_COPY 1 -#define FXFA_MEMU_CUT 2 -#define FXFA_MEMU_SELECTALL 4 -#define FXFA_MEMU_UNDO 8 -#define FXFA_MEMU_REDO 16 -#define FXFA_MEMU_PASTE 32 -/*@}*/ - -// file type -/** - * @name Macro Definitions for File Type. - */ -/*@{*/ + +// Pageview event flags +#define FXFA_PAGEVIEWEVENT_POSTADDED 1 // After a new pageview is added. +#define FXFA_PAGEVIEWEVENT_POSTREMOVED 3 // After a pageview is removed. + +// Definitions for Right Context Menu Features Of XFA Fields +#define FXFA_MENU_COPY 1 +#define FXFA_MENU_CUT 2 +#define FXFA_MENU_SELECTALL 4 +#define FXFA_MENU_UNDO 8 +#define FXFA_MENU_REDO 16 +#define FXFA_MENU_PASTE 32 + +// Definitions for File Type. #define FXFA_SAVEAS_XML 1 #define FXFA_SAVEAS_XDP 2 -/*@}*/ + #endif // PDF_ENABLE_XFA typedef struct _FPDF_FORMFILLINFO { - /** - * Version number of the interface. Currently must be 1 (when PDFium is built - * without the XFA module) or must be 2 (when built with the XFA module). - **/ + // Version number of the interface. + // Version 1 contains stable interfaces. Version 2 has additional + // experimental interfaces. + // When PDFium is built without the XFA module, version can be 1 or 2. + // With version 1, only stable interfaces are called. With version 2, + // additional experimental interfaces are also called. + // When PDFium is built with the XFA module, version must be 2. + // All the XFA related interfaces are experimental. If PDFium is built with + // the XFA module and version 1 then none of the XFA related interfaces + // would be called. When PDFium is built with XFA module then the version + // must be 2. int version; - /* Version 1. */ - /** - *Method: Release - * Give implementation a chance to release any data after the - * interface is no longer used - *Interface Version: - * 1 - *Implementation Required: - * No - *Comments: - * Called by Foxit SDK during the final cleanup process. - *Parameters: - * pThis - Pointer to the interface structure itself - *Return Value: - * None - */ + // Version 1. + + // Method: Release + // Give the implementation a chance to release any resources after the + // interface is no longer used. + // Interface Version: + // 1 + // Implementation Required: + // No + // Comments: + // Called by PDFium during the final cleanup process. + // Parameters: + // pThis - Pointer to the interface structure itself + // Return Value: + // None void (*Release)(struct _FPDF_FORMFILLINFO* pThis); - /** - * Method: FFI_Invalidate - * Invalidate the client area within the specified rectangle. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * page - Handle to the page. Returned by FPDF_LoadPage - *function. - * left - Left position of the client area in PDF page - *coordinate. - * top - Top position of the client area in PDF page - *coordinate. - * right - Right position of the client area in PDF page - *coordinate. - * bottom - Bottom position of the client area in PDF page - *coordinate. - * Return Value: - * None. - * - *comments: - * All positions are measured in PDF "user space". - * Implementation should call FPDF_RenderPageBitmap() function for - *repainting a specified page area. - */ + // Method: FFI_Invalidate + // Invalidate the client area within the specified rectangle. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself. + // page - Handle to the page. Returned by FPDF_LoadPage(). + // left - Left position of the client area in PDF page + // coordinates. + // top - Top position of the client area in PDF page + // coordinates. + // right - Right position of the client area in PDF page + // coordinates. + // bottom - Bottom position of the client area in PDF page + // coordinates. + // Return Value: + // None. + // Comments: + // All positions are measured in PDF "user space". + // Implementation should call FPDF_RenderPageBitmap() for repainting + // the specified page area. void (*FFI_Invalidate)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, double left, @@ -434,38 +408,32 @@ typedef struct _FPDF_FORMFILLINFO { double right, double bottom); - /** - * Method: FFI_OutputSelectedRect - * When user is taking the mouse to select texts on a form field, - * this callback function will keep - * returning the selected areas to the implementation. - * - * Interface Version: - * 1 - * Implementation Required: - * No - * Parameters: - * pThis - Pointer to the interface structure itself. - * page - Handle to the page. Returned by FPDF_LoadPage - * function. - * left - Left position of the client area in PDF page - * coordinate. - * top - Top position of the client area in PDF page - * coordinate. - * right - Right position of the client area in PDF page - * coordinate. - * bottom - Bottom position of the client area in PDF page - * coordinate. - * Return Value: - * None. - * - * comments: - * This CALLBACK function is useful for implementing special text - * selection effect. Implementation should - * first records the returned rectangles, then draw them one by one - * at the painting period, last,remove all - * the recorded rectangles when finish painting. - */ + // Method: FFI_OutputSelectedRect + // When the user selects text in form fields with the mouse, this + // callback function will be invoked with the selected areas. + // Interface Version: + // 1 + // Implementation Required: + // No + // Parameters: + // pThis - Pointer to the interface structure itself. + // page - Handle to the page. Returned by FPDF_LoadPage()/ + // left - Left position of the client area in PDF page + // coordinates. + // top - Top position of the client area in PDF page + // coordinates. + // right - Right position of the client area in PDF page + // coordinates. + // bottom - Bottom position of the client area in PDF page + // coordinates. + // Return Value: + // None. + // Comments: + // This callback function is useful for implementing special text + // selection effects. An implementation should first record the + // returned rectangles, then draw them one by one during the next + // painting period. Lastly, it should remove all the recorded + // rectangles when finished painting. void (*FFI_OutputSelectedRect)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, double left, @@ -473,260 +441,266 @@ typedef struct _FPDF_FORMFILLINFO { double right, double bottom); - /** - * Method: FFI_SetCursor - * Set the Cursor shape. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * nCursorType - Cursor type. see Flags for Cursor type for the - * details. - * Return value: - * None. - * */ + // Method: FFI_SetCursor + // Set the Cursor shape. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself. + // nCursorType - Cursor type, see Flags for Cursor type for details. + // Return value: + // None. void (*FFI_SetCursor)(struct _FPDF_FORMFILLINFO* pThis, int nCursorType); - /** - * Method: FFI_SetTimer - * This method installs a system timer. A time-out value is - * specified, - * and every time a time-out occurs, the system passes a message to - * the TimerProc callback function. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * uElapse - Specifies the time-out value, in milliseconds. - * lpTimerFunc - A pointer to the callback function-TimerCallback. - * Return value: - * The timer identifier of the new timer if the function is successful. - * An application passes this value to the FFI_KillTimer method to kill - * the timer. Nonzero if it is successful; otherwise, it is zero. - * */ + // Method: FFI_SetTimer + // This method installs a system timer. An interval value is specified, + // and every time that interval elapses, the system must call into the + // callback function with the timer ID as returned by this function. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself. + // uElapse - Specifies the time-out value, in milliseconds. + // lpTimerFunc - A pointer to the callback function-TimerCallback. + // Return value: + // The timer identifier of the new timer if the function is successful. + // An application passes this value to the FFI_KillTimer method to kill + // the timer. Nonzero if it is successful; otherwise, it is zero. int (*FFI_SetTimer)(struct _FPDF_FORMFILLINFO* pThis, int uElapse, TimerCallback lpTimerFunc); - /** - * Method: FFI_KillTimer - * This method kills the timer event identified by nIDEvent, set by - * an earlier call to FFI_SetTimer. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * nTimerID - The timer ID return by FFI_SetTimer function. - * Return value: - * None. - * */ + // Method: FFI_KillTimer + // This method uninstalls a system timer, as set by an earlier call to + // FFI_SetTimer. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself. + // nTimerID - The timer ID returned by FFI_SetTimer function. + // Return value: + // None. void (*FFI_KillTimer)(struct _FPDF_FORMFILLINFO* pThis, int nTimerID); - /** - * Method: FFI_GetLocalTime - * This method receives the current local time on the system. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * Return value: - * None. - * */ + // Method: FFI_GetLocalTime + // This method receives the current local time on the system. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself. + // Return value: + // The local time. See FPDF_SYSTEMTIME above for details. + // Note: Unused. FPDF_SYSTEMTIME (*FFI_GetLocalTime)(struct _FPDF_FORMFILLINFO* pThis); - /** - * Method: FFI_OnChange - * This method will be invoked to notify implementation when the - * value of any FormField on the document had been changed. - * Interface Version: - * 1 - * Implementation Required: - * no - * Parameters: - * pThis - Pointer to the interface structure itself. - * Return value: - * None. - * */ + // Method: FFI_OnChange + // This method will be invoked to notify the implementation when the + // value of any FormField on the document had been changed. + // Interface Version: + // 1 + // Implementation Required: + // no + // Parameters: + // pThis - Pointer to the interface structure itself. + // Return value: + // None. void (*FFI_OnChange)(struct _FPDF_FORMFILLINFO* pThis); - /** - * Method: FFI_GetPage - * This method receives the page pointer associated with a specified - * page index. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * document - Handle to document. Returned by FPDF_LoadDocument - * function. - * nPageIndex - Index number of the page. 0 for the first page. - * Return value: - * Handle to the page. Returned by FPDF_LoadPage function. - * Comments: - * In some cases, the document-level JavaScript action may refer to a - * page which hadn't been loaded yet. - * To successfully run the javascript action, implementation need to load - * the page for SDK. - * */ - FPDF_PAGE (*FFI_GetPage)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document, int nPageIndex); - - /** - * Method: FFI_GetCurrentPage - * This method receives the current page pointer. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * document - Handle to document. Returned by FPDF_LoadDocument - * function. - * Return value: - * Handle to the page. Returned by FPDF_LoadPage function. - * */ - FPDF_PAGE (*FFI_GetCurrentPage)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document); - - /** - * Method: FFI_GetRotation - * This method receives currently rotation of the page view. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * page - Handle to page. Returned by FPDF_LoadPage function. - * Return value: - * The page rotation. Should be 0(0 degree),1(90 degree),2(180 - * degree),3(270 degree), in a clockwise direction. - * */ + // Method: FFI_GetPage + // This method receives the page handle associated with a specified + // page index. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself. + // document - Handle to document. Returned by FPDF_LoadDocument(). + // nPageIndex - Index number of the page. 0 for the first page. + // Return value: + // Handle to the page, as previously returned to the implementation by + // FPDF_LoadPage(). + // Comments: + // The implementation is expected to keep track of the page handles it + // receives from PDFium, and their mappings to page numbers. In some + // cases, the document-level JavaScript action may refer to a page + // which hadn't been loaded yet. To successfully run the Javascript + // action, the implementation needs to load the page. + FPDF_PAGE (*FFI_GetPage)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_DOCUMENT document, + int nPageIndex); + + // Method: FFI_GetCurrentPage + // This method receives the handle to the current page. + // Interface Version: + // 1 + // Implementation Required: + // Yes when V8 support is present, otherwise unused. + // Parameters: + // pThis - Pointer to the interface structure itself. + // document - Handle to document. Returned by FPDF_LoadDocument(). + // Return value: + // Handle to the page. Returned by FPDF_LoadPage(). + // Comments: + // PDFium doesn't keep keep track of the "current page" (e.g. the one + // that is most visible on screen), so it must ask the embedder for + // this information. + FPDF_PAGE (*FFI_GetCurrentPage)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_DOCUMENT document); + + // Method: FFI_GetRotation + // This method receives currently rotation of the page view. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself. + // page - Handle to page, as returned by FPDF_LoadPage(). + // Return value: + // A number to indicate the page rotation in 90 degree increments + // in a clockwise direction: + // 0 - 0 degrees + // 1 - 90 degrees + // 2 - 180 degrees + // 3 - 270 degrees + // Note: Unused. int (*FFI_GetRotation)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page); - /** - * Method: FFI_ExecuteNamedAction - * This method will execute an named action. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * namedAction - A byte string which indicates the named action, - * terminated by 0. - * Return value: - * None. - * Comments: - * See the named actions description of <> - * for more details. - * */ + // Method: FFI_ExecuteNamedAction + // This method will execute a named action. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself. + // namedAction - A byte string which indicates the named action, + // terminated by 0. + // Return value: + // None. + // Comments: + // See ISO 32000-1:2008, section 12.6.4.11 for descriptions of the + // standard named actions, but note that a document may supply any + // name of its choosing. void (*FFI_ExecuteNamedAction)(struct _FPDF_FORMFILLINFO* pThis, FPDF_BYTESTRING namedAction); - /** - * @brief This method will be called when a text field is getting or losing a - * focus. - * - * @param[in] pThis Pointer to the interface structure itself. - * @param[in] value The string value of the form field, in UTF-16LE - * format. - * @param[in] valueLen The length of the string value, number of characters - * (not bytes). - * @param[in] is_focus True if the form field is getting a focus, False for - * losing a focus. - * - * @return None. - * - * @note Currently,only support text field and combobox field. - * */ + // Method: FFI_SetTextFieldFocus + // Called when a text field is getting or losing focus. + // Interface Version: + // 1 + // Implementation Required: + // no + // Parameters: + // pThis - Pointer to the interface structure itself. + // value - The string value of the form field, in UTF-16LE + // format. + // valueLen - The length of the string value. This is the + // number of characters, not bytes. + // is_focus - True if the form field is getting focus, false + // if the form field is losing focus. + // Return value: + // None. + // Comments: + // Only supports text fields and combobox fields. void (*FFI_SetTextFieldFocus)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING value, FPDF_DWORD valueLen, FPDF_BOOL is_focus); - /** - * Method: FFI_DoURIAction - * This action resolves to a uniform resource identifier. - * Interface Version: - * 1 - * Implementation Required: - * No - * Parameters: - * pThis - Pointer to the interface structure itself. - * bsURI - A byte string which indicates the uniform resource - * identifier, terminated by 0. - * Return value: - * None. - * Comments: - * See the URI actions description of <> for - * more details. - * */ + // Method: FFI_DoURIAction + // Ask the implementation to navigate to a uniform resource identifier. + // Interface Version: + // 1 + // Implementation Required: + // No + // Parameters: + // pThis - Pointer to the interface structure itself. + // bsURI - A byte string which indicates the uniform + // resource identifier, terminated by 0. + // Return value: + // None. + // Comments: + // If the embedder is version 2 or higher and have implementation for + // FFI_DoURIActionWithKeyboardModifier, then + // FFI_DoURIActionWithKeyboardModifier takes precedence over + // FFI_DoURIAction. + // See the URI actions description of <> + // for more details. void (*FFI_DoURIAction)(struct _FPDF_FORMFILLINFO* pThis, FPDF_BYTESTRING bsURI); - /** - * Method: FFI_DoGoToAction - * This action changes the view to a specified destination. - * Interface Version: - * 1 - * Implementation Required: - * No - * Parameters: - * pThis - Pointer to the interface structure itself. - * nPageIndex - The index of the PDF page. - * zoomMode - The zoom mode for viewing page.See Macros - *"PDFZOOM_XXX" defined in "fpdfdoc.h". - * fPosArray - The float array which carries the position info. - * sizeofArray - The size of float array. - * Return value: - * None. - * Comments: - * See the Destinations description of <> in - *8.2.1 for more details. - **/ + // Method: FFI_DoGoToAction + // This action changes the view to a specified destination. + // Interface Version: + // 1 + // Implementation Required: + // No + // Parameters: + // pThis - Pointer to the interface structure itself. + // nPageIndex - The index of the PDF page. + // zoomMode - The zoom mode for viewing page. See below. + // fPosArray - The float array which carries the position info. + // sizeofArray - The size of float array. + // PDFZoom values: + // - XYZ = 1 + // - FITPAGE = 2 + // - FITHORZ = 3 + // - FITVERT = 4 + // - FITRECT = 5 + // - FITBBOX = 6 + // - FITBHORZ = 7 + // - FITBVERT = 8 + // Return value: + // None. + // Comments: + // See the Destinations description of <> + // in 8.2.1 for more details. void (*FFI_DoGoToAction)(struct _FPDF_FORMFILLINFO* pThis, int nPageIndex, int zoomMode, float* fPosArray, int sizeofArray); - /** - * pointer to IPDF_JSPLATFORM interface - **/ + // Pointer to IPDF_JSPLATFORM interface. + // Unused if PDFium is built without V8 support. Otherwise, if NULL, then + // JavaScript will be prevented from executing while rendering the document. IPDF_JSPLATFORM* m_pJsPlatform; -#ifdef PDF_ENABLE_XFA - /* Version 2. */ - /** - * Method: FFI_DisplayCaret - * This method will show the caret at specified position. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * page - Handle to page. Returned by FPDF_LoadPage - *function. - * left - Left position of the client area in PDF page - *coordinate. - * top - Top position of the client area in PDF page - *coordinate. - * right - Right position of the client area in PDF page - *coordinate. - * bottom - Bottom position of the client area in PDF page - *coordinate. - * Return value: - * None. - **/ + // Version 2 - Experimental. + + // Whether the XFA module is disabled when built with the XFA module. + // Interface Version: + // Ignored if |version| < 2. + FPDF_BOOL xfa_disabled; + + // Method: FFI_DisplayCaret + // This method will show the caret at specified position. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // Required for XFA, otherwise set to NULL. + // Parameters: + // pThis - Pointer to the interface structure itself. + // page - Handle to page. Returned by FPDF_LoadPage(). + // left - Left position of the client area in PDF page + // coordinates. + // top - Top position of the client area in PDF page + // coordinates. + // right - Right position of the client area in PDF page + // coordinates. + // bottom - Bottom position of the client area in PDF page + // coordinates. + // Return value: + // None. void (*FFI_DisplayCaret)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, FPDF_BOOL bVisible, @@ -735,157 +709,169 @@ typedef struct _FPDF_FORMFILLINFO { double right, double bottom); - /** - * Method: FFI_GetCurrentPageIndex - * This method will get the current page index. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * document - Handle to document. Returned by FPDF_LoadDocument - *function. - * Return value: - * The index of current page. - **/ + // Method: FFI_GetCurrentPageIndex + // This method will get the current page index. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // Required for XFA, otherwise set to NULL. + // Parameters: + // pThis - Pointer to the interface structure itself. + // document - Handle to document from FPDF_LoadDocument(). + // Return value: + // The index of current page. int (*FFI_GetCurrentPageIndex)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document); - /** - * Method: FFI_SetCurrentPage - * This method will set the current page. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * document - Handle to document. Returned by FPDF_LoadDocument - *function. - * iCurPage - The index of the PDF page. - * Return value: - * None. - **/ + // Method: FFI_SetCurrentPage + // This method will set the current page. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // Required for XFA, otherwise set to NULL. + // Parameters: + // pThis - Pointer to the interface structure itself. + // document - Handle to document from FPDF_LoadDocument(). + // iCurPage - The index of the PDF page. + // Return value: + // None. void (*FFI_SetCurrentPage)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document, int iCurPage); - /** - * Method: FFI_GotoURL - * This method will link to the specified URL. - * Interface Version: - * 1 - * Implementation Required: - * no - * Parameters: - * pThis - Pointer to the interface structure itself. - * document - Handle to document. Returned by FPDF_LoadDocument - *function. - * wsURL - The string value of the URL, in UTF-16LE format. - * Return value: - * None. - **/ + // Method: FFI_GotoURL + // This method will navigate to the specified URL. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // Required for XFA, otherwise set to NULL. + // Parameters: + // pThis - Pointer to the interface structure itself. + // document - Handle to document from FPDF_LoadDocument(). + // wsURL - The string value of the URL, in UTF-16LE format. + // Return value: + // None. void (*FFI_GotoURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document, FPDF_WIDESTRING wsURL); - /** - * Method: FFI_GetPageViewRect - * This method will get the current page view rectangle. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * page - Handle to page. Returned by FPDF_LoadPage - *function. - * left - The pointer to receive left position of the page - *view area in PDF page coordinate. - * top - The pointer to receive top position of the page - *view area in PDF page coordinate. - * right - The pointer to receive right position of the - *client area in PDF page coordinate. - * bottom - The pointer to receive bottom position of the - *client area in PDF page coordinate. - * Return value: - * None. - **/ + // Method: FFI_GetPageViewRect + // This method will get the current page view rectangle. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // Required for XFA, otherwise set to NULL. + // Parameters: + // pThis - Pointer to the interface structure itself. + // page - Handle to page. Returned by FPDF_LoadPage(). + // left - The pointer to receive left position of the page + // view area in PDF page coordinates. + // top - The pointer to receive top position of the page + // view area in PDF page coordinates. + // right - The pointer to receive right position of the + // page view area in PDF page coordinates. + // bottom - The pointer to receive bottom position of the + // page view area in PDF page coordinates. + // Return value: + // None. void (*FFI_GetPageViewRect)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, double* left, double* top, double* right, double* bottom); - /** - * Method: FFI_PopupMenu - * This method will track the right context menu for XFA fields. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * page - Handle to page. Returned by FPDF_LoadPage - *function. - * hWidget - Handle to XFA fields. - * menuFlag - The menu flags. Please refer to macro definition - *of FXFA_MEMU_XXX and this can be one or a combination of these macros. - * x - X position of the client area in PDF page - *coordinate. - * y - Y position of the client area in PDF page - *coordinate. - * Return value: - * TRUE indicates success; otherwise false. - **/ - FPDF_BOOL (*FFI_PopupMenu)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, FPDF_WIDGET hWidget, int menuFlag, float x, float y); - - /** - * Method: FFI_OpenFile - * This method will open the specified file with the specified mode. - * Interface Version - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * fileFlag - The file flag.Please refer to macro definition of - *FXFA_SAVEAS_XXX and this can be one of these macros. - * wsURL - The string value of the file URL, in UTF-16LE - *format. - * mode - The mode for open file. - * Return value: - * The handle to FPDF_FILEHANDLER. - **/ + + // Method: FFI_PageEvent + // This method fires when pages have been added to or deleted from + // the XFA document. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // Required for XFA, otherwise set to NULL. + // Parameters: + // pThis - Pointer to the interface structure itself. + // page_count - The number of pages to be added or deleted. + // event_type - See FXFA_PAGEVIEWEVENT_* above. + // Return value: + // None. + // Comments: + // The pages to be added or deleted always start from the last page + // of document. This means that if parameter page_count is 2 and + // event type is FXFA_PAGEVIEWEVENT_POSTADDED, 2 new pages have been + // appended to the tail of document; If page_count is 2 and + // event type is FXFA_PAGEVIEWEVENT_POSTREMOVED, the last 2 pages + // have been deleted. + void (*FFI_PageEvent)(struct _FPDF_FORMFILLINFO* pThis, + int page_count, + FPDF_DWORD event_type); + + // Method: FFI_PopupMenu + // This method will track the right context menu for XFA fields. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // Required for XFA, otherwise set to NULL. + // Parameters: + // pThis - Pointer to the interface structure itself. + // page - Handle to page. Returned by FPDF_LoadPage(). + // hWidget - Always null, exists for compatibility. + // menuFlag - The menu flags. Please refer to macro definition + // of FXFA_MENU_XXX and this can be one or a + // combination of these macros. + // x - X position of the client area in PDF page + // coordinates. + // y - Y position of the client area in PDF page + // coordinates. + // Return value: + // TRUE indicates success; otherwise false. + FPDF_BOOL (*FFI_PopupMenu)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_PAGE page, + FPDF_WIDGET hWidget, + int menuFlag, + float x, + float y); + + // Method: FFI_OpenFile + // This method will open the specified file with the specified mode. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // Required for XFA, otherwise set to NULL. + // Parameters: + // pThis - Pointer to the interface structure itself. + // fileFlag - The file flag. Please refer to macro definition + // of FXFA_SAVEAS_XXX and use one of these macros. + // wsURL - The string value of the file URL, in UTF-16LE + // format. + // mode - The mode for open file, e.g. "rb" or "wb". + // Return value: + // The handle to FPDF_FILEHANDLER. FPDF_FILEHANDLER* (*FFI_OpenFile)(struct _FPDF_FORMFILLINFO* pThis, int fileFlag, FPDF_WIDESTRING wsURL, const char* mode); - /** - * Method: FFI_EmailTo - * This method will email the specified file stream to the specified - *contacter. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * pFileHandler - Handle to the FPDF_FILEHANDLER. - * pTo - A semicolon-delimited list of recipients for the - *message,in UTF-16LE format. - * pSubject - The subject of the message,in UTF-16LE format. - * pCC - A semicolon-delimited list of CC recipients for - *the message,in UTF-16LE format. - * pBcc - A semicolon-delimited list of BCC recipients for - *the message,in UTF-16LE format. - * pMsg - Pointer to the data buffer to be sent.Can be - *NULL,in UTF-16LE format. - * Return value: - * None. - **/ + // Method: FFI_EmailTo + // This method will email the specified file stream to the specified + // contact. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // Required for XFA, otherwise set to NULL. + // Parameters: + // pThis - Pointer to the interface structure itself. + // pFileHandler - Handle to the FPDF_FILEHANDLER. + // pTo - A semicolon-delimited list of recipients for the + // message,in UTF-16LE format. + // pSubject - The subject of the message,in UTF-16LE format. + // pCC - A semicolon-delimited list of CC recipients for + // the message,in UTF-16LE format. + // pBcc - A semicolon-delimited list of BCC recipients for + // the message,in UTF-16LE format. + // pMsg - Pointer to the data buffer to be sent.Can be + // NULL,in UTF-16LE format. + // Return value: + // None. void (*FFI_EmailTo)(struct _FPDF_FORMFILLINFO* pThis, FPDF_FILEHANDLER* fileHandler, FPDF_WIDESTRING pTo, @@ -894,427 +880,700 @@ typedef struct _FPDF_FORMFILLINFO { FPDF_WIDESTRING pBcc, FPDF_WIDESTRING pMsg); - /** - * Method: FFI_UploadTo - * This method will get upload the specified file stream to the - *specified URL. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * pFileHandler - Handle to the FPDF_FILEHANDLER. - * fileFlag - The file flag.Please refer to macro definition of - *FXFA_SAVEAS_XXX and this can be one of these macros. - * uploadTo - Pointer to the URL path, in UTF-16LE format. - * Return value: - * None. - **/ + // Method: FFI_UploadTo + // This method will upload the specified file stream to the + // specified URL. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // Required for XFA, otherwise set to NULL. + // Parameters: + // pThis - Pointer to the interface structure itself. + // pFileHandler - Handle to the FPDF_FILEHANDLER. + // fileFlag - The file flag. Please refer to macro definition + // of FXFA_SAVEAS_XXX and use one of these macros. + // uploadTo - Pointer to the URL path, in UTF-16LE format. + // Return value: + // None. void (*FFI_UploadTo)(struct _FPDF_FORMFILLINFO* pThis, FPDF_FILEHANDLER* fileHandler, int fileFlag, FPDF_WIDESTRING uploadTo); - /** - * Method: FFI_GetPlatform - * This method will get the current platform. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * platform - Pointer to the data buffer to receive the - *platform.Can be NULL,in UTF-16LE format. - * length - The length of the buffer, number of bytes. Can be - *0. - * Return value: - * The length of the buffer, number of bytes. - **/ + // Method: FFI_GetPlatform + // This method will get the current platform. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // Required for XFA, otherwise set to NULL. + // Parameters: + // pThis - Pointer to the interface structure itself. + // platform - Pointer to the data buffer to receive the + // platform,in UTF-16LE format. Can be NULL. + // length - The length of the buffer in bytes. Can be + // 0 to query the required size. + // Return value: + // The length of the buffer, number of bytes. int (*FFI_GetPlatform)(struct _FPDF_FORMFILLINFO* pThis, void* platform, int length); - /** - * Method: FFI_GetLanguage - * This method will get the current language. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * language - Pointer to the data buffer to receive the current - *language.Can be NULL. - * length - The length of the buffer, number of bytes. Can be - *0. - * Return value: - * The length of the buffer, number of bytes. - **/ + // Method: FFI_GetLanguage + // This method will get the current language. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // Required for XFA, otherwise set to NULL. + // Parameters: + // pThis - Pointer to the interface structure itself. + // language - Pointer to the data buffer to receive the + // current language. Can be NULL. + // length - The length of the buffer in bytes. Can be + // 0 to query the required size. + // Return value: + // The length of the buffer, number of bytes. int (*FFI_GetLanguage)(struct _FPDF_FORMFILLINFO* pThis, void* language, int length); - /** - * Method: FFI_DownloadFromURL - * This method will download the specified file from the URL. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * URL - The string value of the file URL, in UTF-16LE - *format. - * Return value: - * The handle to FPDF_FILEHANDLER. - **/ - FPDF_LPFILEHANDLER (*FFI_DownloadFromURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING URL); - /** - * Method: FFI_PostRequestURL - * This method will post the request to the server URL. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * wsURL - The string value of the server URL, in UTF-16LE - *format. - * wsData - The post data,in UTF-16LE format. - * wsContentType - The content type of the request data,in UTF-16LE - *format. - * wsEncode - The encode type,in UTF-16LE format. - * wsHeader - The request header,in UTF-16LE format. - * response - Pointer to the FPDF_BSTR to receive the response - *data from server,,in UTF-16LE format. - * Return value: - * TRUE indicates success, otherwise FALSE. - **/ - FPDF_BOOL (*FFI_PostRequestURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING wsURL, FPDF_WIDESTRING wsData, FPDF_WIDESTRING wsContentType, FPDF_WIDESTRING wsEncode, FPDF_WIDESTRING wsHeader, FPDF_BSTR* respone); - - /** - * Method: FFI_PutRequestURL - * This method will put the request to the server URL. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * wsURL - The string value of the server URL, in UTF-16LE - *format. - * wsData - The put data, in UTF-16LE format. - * wsEncode - The encode type, in UTR-16LE format. - * Return value: - * TRUE indicates success, otherwise FALSE. - **/ - FPDF_BOOL (*FFI_PutRequestURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING wsURL, FPDF_WIDESTRING wsData, FPDF_WIDESTRING wsEncode); -#endif // PDF_ENABLE_XFA - + // Method: FFI_DownloadFromURL + // This method will download the specified file from the URL. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // Required for XFA, otherwise set to NULL. + // Parameters: + // pThis - Pointer to the interface structure itself. + // URL - The string value of the file URL, in UTF-16LE + // format. + // Return value: + // The handle to FPDF_FILEHANDLER. + FPDF_FILEHANDLER* (*FFI_DownloadFromURL)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_WIDESTRING URL); + // Method: FFI_PostRequestURL + // This method will post the request to the server URL. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // Required for XFA, otherwise set to NULL. + // Parameters: + // pThis - Pointer to the interface structure itself. + // wsURL - The string value of the server URL, in UTF-16LE + // format. + // wsData - The post data,in UTF-16LE format. + // wsContentType - The content type of the request data, in + // UTF-16LE format. + // wsEncode - The encode type, in UTF-16LE format. + // wsHeader - The request header,in UTF-16LE format. + // response - Pointer to the FPDF_BSTR to receive the response + // data from the server, in UTF-16LE format. + // Return value: + // TRUE indicates success, otherwise FALSE. + FPDF_BOOL (*FFI_PostRequestURL)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_WIDESTRING wsURL, + FPDF_WIDESTRING wsData, + FPDF_WIDESTRING wsContentType, + FPDF_WIDESTRING wsEncode, + FPDF_WIDESTRING wsHeader, + FPDF_BSTR* response); + + // Method: FFI_PutRequestURL + // This method will put the request to the server URL. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // Required for XFA, otherwise set to NULL. + // Parameters: + // pThis - Pointer to the interface structure itself. + // wsURL - The string value of the server URL, in UTF-16LE + // format. + // wsData - The put data, in UTF-16LE format. + // wsEncode - The encode type, in UTR-16LE format. + // Return value: + // TRUE indicates success, otherwise FALSE. + FPDF_BOOL (*FFI_PutRequestURL)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_WIDESTRING wsURL, + FPDF_WIDESTRING wsData, + FPDF_WIDESTRING wsEncode); + + // Method: FFI_OnFocusChange + // Called when the focused annotation is updated. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // No + // Parameters: + // param - Pointer to the interface structure itself. + // annot - The focused annotation. + // page_index - Index number of the page which contains the + // focused annotation. 0 for the first page. + // Return value: + // None. + // Comments: + // This callback function is useful for implementing any view based + // action such as scrolling the annotation rect into view. The + // embedder should not copy and store the annot as its scope is + // limited to this call only. + void (*FFI_OnFocusChange)(struct _FPDF_FORMFILLINFO* param, + FPDF_ANNOTATION annot, + int page_index); + + // Method: FFI_DoURIActionWithKeyboardModifier + // Ask the implementation to navigate to a uniform resource identifier + // with the specified modifiers. + // Interface Version: + // Ignored if |version| < 2. + // Implementation Required: + // No + // Parameters: + // param - Pointer to the interface structure itself. + // uri - A byte string which indicates the uniform + // resource identifier, terminated by 0. + // modifiers - Keyboard modifier that indicates which of + // the virtual keys are down, if any. + // Return value: + // None. + // Comments: + // If the embedder who is version 2 and does not implement this API, + // then a call will be redirected to FFI_DoURIAction. + // See the URI actions description of <> + // for more details. + void(*FFI_DoURIActionWithKeyboardModifier)(struct _FPDF_FORMFILLINFO* param, + FPDF_BYTESTRING uri, + int modifiers); } FPDF_FORMFILLINFO; -/** - * Function: FPDFDOC_InitFormFillEnvironment - * Init form fill environment. - * Comments: - * This function should be called before any form fill operation. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * pFormFillInfo - Pointer to a FPDF_FORMFILLINFO structure. - * Return Value: - * Return handler to the form fill module. NULL means fails. - **/ -DLLEXPORT FPDF_FORMHANDLE STDCALL +// Function: FPDFDOC_InitFormFillEnvironment +// Initialize form fill environment. +// Parameters: +// document - Handle to document from FPDF_LoadDocument(). +// formInfo - Pointer to a FPDF_FORMFILLINFO structure. +// Return Value: +// Handle to the form fill module, or NULL on failure. +// Comments: +// This function should be called before any form fill operation. +// The FPDF_FORMFILLINFO passed in via |formInfo| must remain valid until +// the returned FPDF_FORMHANDLE is closed. +FPDF_EXPORT FPDF_FORMHANDLE FPDF_CALLCONV FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document, FPDF_FORMFILLINFO* formInfo); -/** - * Function: FPDFDOC_ExitFormFillEnvironment - * Exit form fill environment. - * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * Return Value: - * NULL. - **/ -DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle); - -/** - * Function: FORM_OnAfterLoadPage - * This method is required for implementing all the form related - *functions. Should be invoked after user - * successfully loaded a PDF page, and method - *FPDFDOC_InitFormFillEnvironment had been invoked. - * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * Return Value: - * NONE. - **/ -DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, - FPDF_FORMHANDLE hHandle); - -/** - * Function: FORM_OnBeforeClosePage - * This method is required for implementing all the form related - *functions. Should be invoked before user - * close the PDF page. - * Parameters: - * page - Handle to the page. Returned by FPDF_LoadPage - *function. - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * Return Value: - * NONE. - **/ -DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, - FPDF_FORMHANDLE hHandle); - -/** -* Function: FORM_DoDocumentJSAction -* This method is required for performing Document-level JavaScript -*action. It should be invoked after the PDF document -* had been loaded. -* Parameters: -* hHandle - Handle to the form fill module. Returned by -*FPDFDOC_InitFormFillEnvironment. -* Return Value: -* NONE -* Comments: -* If there is Document-level JavaScript action embedded in the -*document, this method will execute the javascript action; -* otherwise, the method will do nothing. -**/ -DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle); - -/** -* Function: FORM_DoDocumentOpenAction -* This method is required for performing open-action when the document -*is opened. -* Parameters: -* hHandle - Handle to the form fill module. Returned by -*FPDFDOC_InitFormFillEnvironment. -* Return Value: -* NONE -* Comments: -* This method will do nothing if there is no open-actions embedded in -*the document. -**/ -DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle); - -// additional actions type of document. -#define FPDFDOC_AACTION_WC \ - 0x10 // WC, before closing document, JavaScript action. -#define FPDFDOC_AACTION_WS \ - 0x11 // WS, before saving document, JavaScript action. -#define FPDFDOC_AACTION_DS 0x12 // DS, after saving document, JavaScript - // action. -#define FPDFDOC_AACTION_WP \ - 0x13 // WP, before printing document, JavaScript action. -#define FPDFDOC_AACTION_DP \ - 0x14 // DP, after printing document, JavaScript action. - -/** -* Function: FORM_DoDocumentAAction -* This method is required for performing the document's -*additional-action. -* Parameters: -* hHandle - Handle to the form fill module. Returned by -*FPDFDOC_InitFormFillEnvironment. -* aaType - The type of the additional-actions which defined -*above. -* Return Value: -* NONE -* Comments: -* This method will do nothing if there is no document -*additional-action corresponding to the specified aaType. -**/ - -DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, - int aaType); - -// Additional-action types of page object -#define FPDFPAGE_AACTION_OPEN \ - 0 // /O -- An action to be performed when the page is opened -#define FPDFPAGE_AACTION_CLOSE \ - 1 // /C -- An action to be performed when the page is closed - -/** -* Function: FORM_DoPageAAction -* This method is required for performing the page object's -*additional-action when opened or closed. -* Parameters: -* page - Handle to the page. Returned by FPDF_LoadPage -*function. -* hHandle - Handle to the form fill module. Returned by -*FPDFDOC_InitFormFillEnvironment. -* aaType - The type of the page object's additional-actions -*which defined above. -* Return Value: -* NONE -* Comments: -* This method will do nothing if no additional-action corresponding to -*the specified aaType exists. -**/ -DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, - FPDF_FORMHANDLE hHandle, - int aaType); - -/** - * Function: FORM_OnMouseMove - * You can call this member function when the mouse cursor moves. - * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * page - Handle to the page. Returned by FPDF_LoadPage - *function. - * modifier - Indicates whether various virtual keys are down. - * page_x - Specifies the x-coordinate of the cursor in PDF user - *space. - * page_y - Specifies the y-coordinate of the cursor in PDF user - *space. - * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int modifier, - double page_x, - double page_y); - -/** - * Function: FORM_OnLButtonDown - * You can call this member function when the user presses the left - *mouse button. - * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * page - Handle to the page. Returned by FPDF_LoadPage - *function. - * modifier - Indicates whether various virtual keys are down. - * page_x - Specifies the x-coordinate of the cursor in PDF user - *space. - * page_y - Specifies the y-coordinate of the cursor in PDF user - *space. - * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int modifier, - double page_x, - double page_y); - -/** - * Function: FORM_OnLButtonUp - * You can call this member function when the user releases the left - *mouse button. - * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * page - Handle to the page. Returned by FPDF_LoadPage - *function. - * modifier - Indicates whether various virtual keys are down. - * page_x - Specifies the x-coordinate of the cursor in device. - * page_y - Specifies the y-coordinate of the cursor in device. - * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int modifier, - double page_x, - double page_y); - -#ifdef PDF_ENABLE_XFA -DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int modifier, - double page_x, - double page_y); -DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int modifier, - double page_x, - double page_y); -#endif // PDF_ENABLE_XFA - -/** - * Function: FORM_OnKeyDown - * You can call this member function when a nonsystem key is pressed. - * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * page - Handle to the page. Returned by FPDF_LoadPage - *function. - * nKeyCode - Indicates whether various virtual keys are down. - * modifier - Contains the scan code, key-transition code, - *previous key state, and context code. - * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int nKeyCode, - int modifier); - -/** - * Function: FORM_OnKeyUp - * You can call this member function when a nonsystem key is released. - * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * page - Handle to the page. Returned by FPDF_LoadPage - *function. - * nKeyCode - The virtual-key code of the given key. - * modifier - Contains the scan code, key-transition code, - *previous key state, and context code. - * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int nKeyCode, - int modifier); - -/** - * Function: FORM_OnChar - * You can call this member function when a keystroke translates to a - *nonsystem character. - * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * page - Handle to the page. Returned by FPDF_LoadPage - *function. - * nChar - The character code value of the key. - * modifier - Contains the scan code, key-transition code, - *previous key state, and context code. - * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int nChar, - int modifier); - -/** - * Function: FORM_ForceToKillFocus. - * You can call this member function to force to kill the focus of the - *form field which got focus. - * It would kill the focus on the form field, save the value of form - *field if it's changed by user. - * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle); - -// Field Types +// Function: FPDFDOC_ExitFormFillEnvironment +// Take ownership of |hHandle| and exit form fill environment. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// Return Value: +// None. +// Comments: +// This function is a no-op when |hHandle| is null. +FPDF_EXPORT void FPDF_CALLCONV +FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle); + +// Function: FORM_OnAfterLoadPage +// This method is required for implementing all the form related +// functions. Should be invoked after user successfully loaded a +// PDF page, and FPDFDOC_InitFormFillEnvironment() has been invoked. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// Return Value: +// None. +FPDF_EXPORT void FPDF_CALLCONV FORM_OnAfterLoadPage(FPDF_PAGE page, + FPDF_FORMHANDLE hHandle); + +// Function: FORM_OnBeforeClosePage +// This method is required for implementing all the form related +// functions. Should be invoked before user closes the PDF page. +// Parameters: +// page - Handle to the page, as returned by FPDF_LoadPage(). +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// Return Value: +// None. +FPDF_EXPORT void FPDF_CALLCONV FORM_OnBeforeClosePage(FPDF_PAGE page, + FPDF_FORMHANDLE hHandle); + +// Function: FORM_DoDocumentJSAction +// This method is required for performing document-level JavaScript +// actions. It should be invoked after the PDF document has been loaded. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// Return Value: +// None. +// Comments: +// If there is document-level JavaScript action embedded in the +// document, this method will execute the JavaScript action. Otherwise, +// the method will do nothing. +FPDF_EXPORT void FPDF_CALLCONV +FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle); + +// Function: FORM_DoDocumentOpenAction +// This method is required for performing open-action when the document +// is opened. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// Return Value: +// None. +// Comments: +// This method will do nothing if there are no open-actions embedded +// in the document. +FPDF_EXPORT void FPDF_CALLCONV +FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle); + +// Additional actions type of document: +// WC, before closing document, JavaScript action. +// WS, before saving document, JavaScript action. +// DS, after saving document, JavaScript action. +// WP, before printing document, JavaScript action. +// DP, after printing document, JavaScript action. +#define FPDFDOC_AACTION_WC 0x10 +#define FPDFDOC_AACTION_WS 0x11 +#define FPDFDOC_AACTION_DS 0x12 +#define FPDFDOC_AACTION_WP 0x13 +#define FPDFDOC_AACTION_DP 0x14 + +// Function: FORM_DoDocumentAAction +// This method is required for performing the document's +// additional-action. +// Parameters: +// hHandle - Handle to the form fill module. Returned by +// FPDFDOC_InitFormFillEnvironment. +// aaType - The type of the additional-actions which defined +// above. +// Return Value: +// None. +// Comments: +// This method will do nothing if there is no document +// additional-action corresponding to the specified |aaType|. +FPDF_EXPORT void FPDF_CALLCONV FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, + int aaType); + +// Additional-action types of page object: +// OPEN (/O) -- An action to be performed when the page is opened +// CLOSE (/C) -- An action to be performed when the page is closed +#define FPDFPAGE_AACTION_OPEN 0 +#define FPDFPAGE_AACTION_CLOSE 1 + +// Function: FORM_DoPageAAction +// This method is required for performing the page object's +// additional-action when opened or closed. +// Parameters: +// page - Handle to the page, as returned by FPDF_LoadPage(). +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// aaType - The type of the page object's additional-actions +// which defined above. +// Return Value: +// None. +// Comments: +// This method will do nothing if no additional-action corresponding +// to the specified |aaType| exists. +FPDF_EXPORT void FPDF_CALLCONV FORM_DoPageAAction(FPDF_PAGE page, + FPDF_FORMHANDLE hHandle, + int aaType); + +// Function: FORM_OnMouseMove +// Call this member function when the mouse cursor moves. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// modifier - Indicates whether various virtual keys are down. +// page_x - Specifies the x-coordinate of the cursor in PDF user +// space. +// page_y - Specifies the y-coordinate of the cursor in PDF user +// space. +// Return Value: +// True indicates success; otherwise false. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int modifier, + double page_x, + double page_y); + +// Experimental API +// Function: FORM_OnMouseWheel +// Call this member function when the user scrolls the mouse wheel. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// modifier - Indicates whether various virtual keys are down. +// page_coord - Specifies the coordinates of the cursor in PDF user +// space. +// delta_x - Specifies the amount of wheel movement on the x-axis, +// in units of platform-agnostic wheel deltas. Negative +// values mean left. +// delta_y - Specifies the amount of wheel movement on the y-axis, +// in units of platform-agnostic wheel deltas. Negative +// values mean down. +// Return Value: +// True indicates success; otherwise false. +// Comments: +// For |delta_x| and |delta_y|, the caller must normalize +// platform-specific wheel deltas. e.g. On Windows, a delta value of 240 +// for a WM_MOUSEWHEEL event normalizes to 2, since Windows defines +// WHEEL_DELTA as 120. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnMouseWheel( + FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int modifier, + const FS_POINTF* page_coord, + int delta_x, + int delta_y); + +// Function: FORM_OnFocus +// This function focuses the form annotation at a given point. If the +// annotation at the point already has focus, nothing happens. If there +// is no annotation at the point, removes form focus. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// modifier - Indicates whether various virtual keys are down. +// page_x - Specifies the x-coordinate of the cursor in PDF user +// space. +// page_y - Specifies the y-coordinate of the cursor in PDF user +// space. +// Return Value: +// True if there is an annotation at the given point and it has focus. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnFocus(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int modifier, + double page_x, + double page_y); + +// Function: FORM_OnLButtonDown +// Call this member function when the user presses the left +// mouse button. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// modifier - Indicates whether various virtual keys are down. +// page_x - Specifies the x-coordinate of the cursor in PDF user +// space. +// page_y - Specifies the y-coordinate of the cursor in PDF user +// space. +// Return Value: +// True indicates success; otherwise false. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int modifier, + double page_x, + double page_y); + +// Function: FORM_OnRButtonDown +// Same as above, execpt for the right mouse button. +// Comments: +// At the present time, has no effect except in XFA builds, but is +// included for the sake of symmetry. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int modifier, + double page_x, + double page_y); +// Function: FORM_OnLButtonUp +// Call this member function when the user releases the left +// mouse button. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// modifier - Indicates whether various virtual keys are down. +// page_x - Specifies the x-coordinate of the cursor in device. +// page_y - Specifies the y-coordinate of the cursor in device. +// Return Value: +// True indicates success; otherwise false. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int modifier, + double page_x, + double page_y); + +// Function: FORM_OnRButtonUp +// Same as above, execpt for the right mouse button. +// Comments: +// At the present time, has no effect except in XFA builds, but is +// included for the sake of symmetry. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int modifier, + double page_x, + double page_y); + +// Function: FORM_OnLButtonDoubleClick +// Call this member function when the user double clicks the +// left mouse button. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// modifier - Indicates whether various virtual keys are down. +// page_x - Specifies the x-coordinate of the cursor in PDF user +// space. +// page_y - Specifies the y-coordinate of the cursor in PDF user +// space. +// Return Value: +// True indicates success; otherwise false. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FORM_OnLButtonDoubleClick(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int modifier, + double page_x, + double page_y); + +// Function: FORM_OnKeyDown +// Call this member function when a nonsystem key is pressed. +// Parameters: +// hHandle - Handle to the form fill module, aseturned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// nKeyCode - The virtual-key code of the given key (see +// fpdf_fwlevent.h for virtual key codes). +// modifier - Mask of key flags (see fpdf_fwlevent.h for key +// flag values). +// Return Value: +// True indicates success; otherwise false. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int nKeyCode, + int modifier); + +// Function: FORM_OnKeyUp +// Call this member function when a nonsystem key is released. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// nKeyCode - The virtual-key code of the given key (see +// fpdf_fwlevent.h for virtual key codes). +// modifier - Mask of key flags (see fpdf_fwlevent.h for key +// flag values). +// Return Value: +// True indicates success; otherwise false. +// Comments: +// Currently unimplemented and always returns false. PDFium reserves this +// API and may implement it in the future on an as-needed basis. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int nKeyCode, + int modifier); + +// Function: FORM_OnChar +// Call this member function when a keystroke translates to a +// nonsystem character. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// nChar - The character code value itself. +// modifier - Mask of key flags (see fpdf_fwlevent.h for key +// flag values). +// Return Value: +// True indicates success; otherwise false. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnChar(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int nChar, + int modifier); + +// Experimental API +// Function: FORM_GetFocusedText +// Call this function to obtain the text within the current focused +// field, if any. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// buffer - Buffer for holding the form text, encoded in +// UTF-16LE. If NULL, |buffer| is not modified. +// buflen - Length of |buffer| in bytes. If |buflen| is less +// than the length of the form text string, |buffer| is +// not modified. +// Return Value: +// Length in bytes for the text in the focused field. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FORM_GetFocusedText(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + void* buffer, + unsigned long buflen); + +// Function: FORM_GetSelectedText +// Call this function to obtain selected text within a form text +// field or form combobox text field. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// buffer - Buffer for holding the selected text, encoded in +// UTF-16LE. If NULL, |buffer| is not modified. +// buflen - Length of |buffer| in bytes. If |buflen| is less +// than the length of the selected text string, +// |buffer| is not modified. +// Return Value: +// Length in bytes of selected text in form text field or form combobox +// text field. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FORM_GetSelectedText(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + void* buffer, + unsigned long buflen); + +// Experimental API +// Function: FORM_ReplaceAndKeepSelection +// Call this function to replace the selected text in a form +// text field or user-editable form combobox text field with another +// text string (which can be empty or non-empty). If there is no +// selected text, this function will append the replacement text after +// the current caret position. After the insertion, the inserted text +// will be selected. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as Returned by FPDF_LoadPage(). +// wsText - The text to be inserted, in UTF-16LE format. +// Return Value: +// None. +FPDF_EXPORT void FPDF_CALLCONV +FORM_ReplaceAndKeepSelection(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + FPDF_WIDESTRING wsText); + +// Function: FORM_ReplaceSelection +// Call this function to replace the selected text in a form +// text field or user-editable form combobox text field with another +// text string (which can be empty or non-empty). If there is no +// selected text, this function will append the replacement text after +// the current caret position. After the insertion, the selection range +// will be set to empty. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as Returned by FPDF_LoadPage(). +// wsText - The text to be inserted, in UTF-16LE format. +// Return Value: +// None. +FPDF_EXPORT void FPDF_CALLCONV FORM_ReplaceSelection(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + FPDF_WIDESTRING wsText); + +// Experimental API +// Function: FORM_SelectAllText +// Call this function to select all the text within the currently focused +// form text field or form combobox text field. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// Return Value: +// Whether the operation succeeded or not. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FORM_SelectAllText(FPDF_FORMHANDLE hHandle, FPDF_PAGE page); + +// Function: FORM_CanUndo +// Find out if it is possible for the current focused widget in a given +// form to perform an undo operation. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// Return Value: +// True if it is possible to undo. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_CanUndo(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page); + +// Function: FORM_CanRedo +// Find out if it is possible for the current focused widget in a given +// form to perform a redo operation. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// Return Value: +// True if it is possible to redo. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_CanRedo(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page); + +// Function: FORM_Undo +// Make the current focused widget perform an undo operation. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// Return Value: +// True if the undo operation succeeded. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_Undo(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page); + +// Function: FORM_Redo +// Make the current focused widget perform a redo operation. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// Return Value: +// True if the redo operation succeeded. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_Redo(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page); + +// Function: FORM_ForceToKillFocus. +// Call this member function to force to kill the focus of the form +// field which has focus. If it would kill the focus of a form field, +// save the value of form field if was changed by theuser. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// Return Value: +// True indicates success; otherwise false. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle); + +// Experimental API. +// Function: FORM_GetFocusedAnnot. +// Call this member function to get the currently focused annotation. +// Parameters: +// handle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// page_index - Buffer to hold the index number of the page which +// contains the focused annotation. 0 for the first page. +// Can't be NULL. +// annot - Buffer to hold the focused annotation. Can't be NULL. +// Return Value: +// On success, return true and write to the out parameters. Otherwise +// return false and leave the out parameters unmodified. +// Comments: +// Not currently supported for XFA forms - will report no focused +// annotation. +// Must call FPDFPage_CloseAnnot() when the annotation returned in |annot| +// by this function is no longer needed. +// This will return true and set |page_index| to -1 and |annot| to NULL, +// if there is no focused annotation. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FORM_GetFocusedAnnot(FPDF_FORMHANDLE handle, + int* page_index, + FPDF_ANNOTATION* annot); + +// Experimental API. +// Function: FORM_SetFocusedAnnot. +// Call this member function to set the currently focused annotation. +// Parameters: +// handle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// annot - Handle to an annotation. +// Return Value: +// True indicates success; otherwise false. +// Comments: +// |annot| can't be NULL. To kill focus, use FORM_ForceToKillFocus() +// instead. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FORM_SetFocusedAnnot(FPDF_FORMHANDLE handle, FPDF_ANNOTATION annot); + +// Form Field Types +// The names of the defines are stable, but the specific values associated with +// them are not, so do not hardcode their values. #define FPDF_FORMFIELD_UNKNOWN 0 // Unknown. #define FPDF_FORMFIELD_PUSHBUTTON 1 // push button type. #define FPDF_FORMFIELD_CHECKBOX 2 // check box type. @@ -1322,372 +1581,248 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle); #define FPDF_FORMFIELD_COMBOBOX 4 // combo box type. #define FPDF_FORMFIELD_LISTBOX 5 // list box type. #define FPDF_FORMFIELD_TEXTFIELD 6 // text field type. +#define FPDF_FORMFIELD_SIGNATURE 7 // text field type. #ifdef PDF_ENABLE_XFA -#define FPDF_FORMFIELD_XFA 7 // text field type. -#endif // PDF_ENABLE_XFA +#define FPDF_FORMFIELD_XFA 8 // Generic XFA type. +#define FPDF_FORMFIELD_XFA_CHECKBOX 9 // XFA check box type. +#define FPDF_FORMFIELD_XFA_COMBOBOX 10 // XFA combo box type. +#define FPDF_FORMFIELD_XFA_IMAGEFIELD 11 // XFA image field type. +#define FPDF_FORMFIELD_XFA_LISTBOX 12 // XFA list box type. +#define FPDF_FORMFIELD_XFA_PUSHBUTTON 13 // XFA push button type. +#define FPDF_FORMFIELD_XFA_SIGNATURE 14 // XFA signture field type. +#define FPDF_FORMFIELD_XFA_TEXTFIELD 15 // XFA text field type. +#endif // PDF_ENABLE_XFA -/** - * Function: FPDFPage_HasFormFieldAtPoint - * Get the form field type by point. - * Parameters: - * hHandle - Handle to the form fill module. Returned by - * FPDFDOC_InitFormFillEnvironment(). - * page - Handle to the page. Returned by FPDF_LoadPage(). - * page_x - X position in PDF "user space". - * page_y - Y position in PDF "user space". - * Return Value: - * Return the type of the form field; -1 indicates no field. - * See field types above. - **/ -DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - double page_x, - double page_y); - -/** - * Function: FPDPage_HasFormFieldAtPoint - * DEPRECATED. Please use FPDFPage_HasFormFieldAtPoint. - **/ -DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - double page_x, - double page_y); - -/** - * Function: FPDFPage_FormFieldZOrderAtPoint - * Get the form field z-order by point. - * Parameters: - * hHandle - Handle to the form fill module. Returned by - * FPDFDOC_InitFormFillEnvironment(). - * page - Handle to the page. Returned by FPDF_LoadPage(). - * page_x - X position in PDF "user space". - * page_y - Y position in PDF "user space". - * Return Value: - * Return the z-order of the form field; -1 indicates no field. - * Higher numbers are closer to the front. - **/ -DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - double page_x, - double page_y); - -/** - * Function: FPDF_SetFormFieldHighlightColor - * Set the highlight color of specified or all the form fields in the - *document. - * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * doc - Handle to the document. Returned by - *FPDF_LoadDocument function. - * fieldType - A 32-bit integer indicating the type of a form - *field(defined above). - * color - The highlight color of the form field.Constructed by - *0xxxrrggbb. - * Return Value: - * NONE. - * Comments: - * When the parameter fieldType is set to zero, the highlight color - *will be applied to all the form fields in the - * document. - * Please refresh the client window to show the highlight immediately - *if necessary. - **/ -DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, - int fieldType, - unsigned long color); - -/** - * Function: FPDF_SetFormFieldHighlightAlpha - * Set the transparency of the form field highlight color in the - *document. - * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * doc - Handle to the document. Returned by - *FPDF_LoadDocument function. - * alpha - The transparency of the form field highlight color. - *between 0-255. - * Return Value: - * NONE. - **/ -DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, - unsigned char alpha); - -/** - * Function: FPDF_RemoveFormFieldHighlight - * Remove the form field highlight color in the document. - * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * Return Value: - * NONE. - * Comments: - * Please refresh the client window to remove the highlight immediately - *if necessary. - **/ -DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle); - -/** -* Function: FPDF_FFLDraw -* Render FormFeilds on a page to a device independent bitmap. -* Parameters: -* hHandle - Handle to the form fill module. Returned by -*FPDFDOC_InitFormFillEnvironment. -* bitmap - Handle to the device independent bitmap (as the -*output buffer). -* Bitmap handle can be created by FPDFBitmap_Create -*function. -* page - Handle to the page. Returned by FPDF_LoadPage -*function. -* start_x - Left pixel position of the display area in the -*device coordinate. -* start_y - Top pixel position of the display area in the device -*coordinate. -* size_x - Horizontal size (in pixels) for displaying the page. -* size_y - Vertical size (in pixels) for displaying the page. -* rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees -*clockwise), -* 2 (rotated 180 degrees), 3 (rotated 90 degrees -*counter-clockwise). -* flags - 0 for normal display, or combination of flags -*defined above. -* Return Value: -* None. -* Comments: -* This method is designed to only render annotations and FormFields on -*the page. -* Without FPDF_ANNOT specified for flags, Rendering functions such as -*FPDF_RenderPageBitmap or FPDF_RenderPageBitmap_Start will only render page -*contents(without annotations) to a bitmap. -* In order to implement the FormFill functions,Implementation should -*call this method after rendering functions finish rendering the page contents. -**/ -DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, - FPDF_BITMAP bitmap, - FPDF_PAGE page, - int start_x, - int start_y, - int size_x, - int size_y, - int rotate, - int flags); +#ifdef PDF_ENABLE_XFA +#define FPDF_FORMFIELD_COUNT 16 +#else // PDF_ENABLE_XFA +#define FPDF_FORMFIELD_COUNT 8 +#endif // PDF_ENABLE_XFA #ifdef PDF_ENABLE_XFA -/** - * Function: FPDF_HasXFAField - * This method is designed to check whether a pdf document - *has XFA fields. - * Parameters: - * document - Handle to document. - *Returned by FPDF_LoadDocument function. - * docType - Document type defined as - *DOCTYPE_xxx. - * Return Value: - * TRUE indicates that the input document has XFA fields, - *otherwise FALSE. - **/ -DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, - int* docType); - -/** - * Function: FPDF_LoadXFA - * If the document consists of XFA fields, there should call this - *method to load XFA fields. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * Return Value: - * TRUE indicates success,otherwise FALSE. - **/ -DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document); - -/** - * Function: FPDF_Widget_Undo - * This method will implement the undo feature for the specified xfa - *field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget); -/** - * Function: FPDF_Widget_Redo - * This method will implement the redo feature for the specified xfa - *field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget); -/** - * Function: FPDF_Widget_SelectAll - * This method will implement the select all feature for the specified - *xfa field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget); -/** - * Function: FPDF_Widget_Copy - * This method will implement the copy feature for the specified xfa - *field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * wsText - Pointer to data buffer to receive the copied - *data, in UTF-16LE format. - * size - The data buffer size. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget, - FPDF_WIDESTRING wsText, - FPDF_DWORD* size); -/** - * Function: FPDF_Widget_Cut - * This method will implement the cut feature for the specified xfa - *field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * wsText - Pointer to data buffer to receive the cut - *data,in UTF-16LE format. - * size - The data buffer size,not the byte number. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget, - FPDF_WIDESTRING wsText, - FPDF_DWORD* size); -/** - * Function: FPDF_Widget_Paste - * This method will implement the paste feature for the specified xfa - *field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * wsText - The paste text buffer, in UTF-16LE format. - * size - The data buffer size,not the byte number. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL FPDF_Widget_Paste(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget, - FPDF_WIDESTRING wsText, - FPDF_DWORD size); -/** - * Function: FPDF_Widget_ReplaceSpellCheckWord - * This method will implement the spell check feature for the specified - *xfa field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * x - The x value of the specified point. - * y - The y value of the specified point. - * bsText - The text buffer needed to be speck check, in - *UTF-16LE format. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL -FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget, - float x, - float y, - FPDF_BYTESTRING bsText); -/** - * Function: FPDF_Widget_GetSpellCheckWords - * This method will implement the spell check feature for the specified - *xfa field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * x - The x value of the specified point. - * y - The y value of the specified point. - * stringHandle - Pointer to FPDF_STRINGHANDLE to receive the - *speck check text buffer, in UTF-16LE format. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL -FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget, - float x, - float y, - FPDF_STRINGHANDLE* stringHandle); -/** - * Function: FPDF_StringHandleCounts - * This method will get the count of the text buffer. - * Parameters: - * stringHandle - Pointer to FPDF_STRINGHANDLE. - * Return Value: - * None. - **/ -DLLEXPORT int STDCALL FPDF_StringHandleCounts(FPDF_STRINGHANDLE stringHandle); -/** - * Function: FPDF_StringHandleGetStringByIndex - * This method will get the specified index of the text buffer. - * Parameters: - * stringHandle - Pointer to FPDF_STRINGHANDLE. - * index - The specified index of text buffer. - * bsText - Pointer to data buffer to receive the text - *buffer, in UTF-16LE format. - * size - The byte size of data buffer. - * Return Value: - * TRUE indicates success, otherwise FALSE. - **/ -DLLEXPORT FPDF_BOOL STDCALL -FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE stringHandle, - int index, - FPDF_BYTESTRING bsText, - FPDF_DWORD* size); -/** - * Function: FPDF_StringHandleRelease - * This method will release the FPDF_STRINGHANDLE. - * Parameters: - * stringHandle - Pointer to FPDF_STRINGHANDLE. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL FPDF_StringHandleRelease(FPDF_STRINGHANDLE stringHandle); -/** - * Function: FPDF_StringHandleAddString - * This method will add the specified text buffer. - * Parameters: - * stringHandle - Pointer to FPDF_STRINGHANDLE. - * bsText - Pointer to data buffer of the text buffer, in - *UTF-16LE format. - * size - The byte size of data buffer. - * Return Value: - * TRUE indicates success, otherwise FALSE. - **/ -DLLEXPORT FPDF_BOOL STDCALL -FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringHandle, - FPDF_BYTESTRING bsText, - FPDF_DWORD size); +#define IS_XFA_FORMFIELD(type) \ + (((type) == FPDF_FORMFIELD_XFA) || \ + ((type) == FPDF_FORMFIELD_XFA_CHECKBOX) || \ + ((type) == FPDF_FORMFIELD_XFA_COMBOBOX) || \ + ((type) == FPDF_FORMFIELD_XFA_IMAGEFIELD) || \ + ((type) == FPDF_FORMFIELD_XFA_LISTBOX) || \ + ((type) == FPDF_FORMFIELD_XFA_PUSHBUTTON) || \ + ((type) == FPDF_FORMFIELD_XFA_SIGNATURE) || \ + ((type) == FPDF_FORMFIELD_XFA_TEXTFIELD)) #endif // PDF_ENABLE_XFA +// Function: FPDFPage_HasFormFieldAtPoint +// Get the form field type by point. +// Parameters: +// hHandle - Handle to the form fill module. Returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page. Returned by FPDF_LoadPage(). +// page_x - X position in PDF "user space". +// page_y - Y position in PDF "user space". +// Return Value: +// Return the type of the form field; -1 indicates no field. +// See field types above. +FPDF_EXPORT int FPDF_CALLCONV +FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + double page_x, + double page_y); + +// Function: FPDFPage_FormFieldZOrderAtPoint +// Get the form field z-order by point. +// Parameters: +// hHandle - Handle to the form fill module. Returned by +// FPDFDOC_InitFormFillEnvironment(). +// page - Handle to the page. Returned by FPDF_LoadPage(). +// page_x - X position in PDF "user space". +// page_y - Y position in PDF "user space". +// Return Value: +// Return the z-order of the form field; -1 indicates no field. +// Higher numbers are closer to the front. +FPDF_EXPORT int FPDF_CALLCONV +FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + double page_x, + double page_y); + +// Function: FPDF_SetFormFieldHighlightColor +// Set the highlight color of the specified (or all) form fields +// in the document. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// doc - Handle to the document, as returned by +// FPDF_LoadDocument(). +// fieldType - A 32-bit integer indicating the type of a form +// field (defined above). +// color - The highlight color of the form field. Constructed by +// 0xxxrrggbb. +// Return Value: +// None. +// Comments: +// When the parameter fieldType is set to FPDF_FORMFIELD_UNKNOWN, the +// highlight color will be applied to all the form fields in the +// document. +// Please refresh the client window to show the highlight immediately +// if necessary. +FPDF_EXPORT void FPDF_CALLCONV +FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, + int fieldType, + unsigned long color); + +// Function: FPDF_SetFormFieldHighlightAlpha +// Set the transparency of the form field highlight color in the +// document. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// doc - Handle to the document, as returaned by +// FPDF_LoadDocument(). +// alpha - The transparency of the form field highlight color, +// between 0-255. +// Return Value: +// None. +FPDF_EXPORT void FPDF_CALLCONV +FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, unsigned char alpha); + +// Function: FPDF_RemoveFormFieldHighlight +// Remove the form field highlight color in the document. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// Return Value: +// None. +// Comments: +// Please refresh the client window to remove the highlight immediately +// if necessary. +FPDF_EXPORT void FPDF_CALLCONV +FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle); + +// Function: FPDF_FFLDraw +// Render FormFields and popup window on a page to a device independent +// bitmap. +// Parameters: +// hHandle - Handle to the form fill module, as returned by +// FPDFDOC_InitFormFillEnvironment(). +// bitmap - Handle to the device independent bitmap (as the +// output buffer). Bitmap handles can be created by +// FPDFBitmap_Create(). +// page - Handle to the page, as returned by FPDF_LoadPage(). +// start_x - Left pixel position of the display area in the +// device coordinates. +// start_y - Top pixel position of the display area in the device +// coordinates. +// size_x - Horizontal size (in pixels) for displaying the page. +// size_y - Vertical size (in pixels) for displaying the page. +// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees +// clockwise), 2 (rotated 180 degrees), 3 (rotated 90 +// degrees counter-clockwise). +// flags - 0 for normal display, or combination of flags +// defined above. +// Return Value: +// None. +// Comments: +// This function is designed to render annotations that are +// user-interactive, which are widget annotations (for FormFields) and +// popup annotations. +// With the FPDF_ANNOT flag, this function will render a popup annotation +// when users mouse-hover on a non-widget annotation. Regardless of +// FPDF_ANNOT flag, this function will always render widget annotations +// for FormFields. +// In order to implement the FormFill functions, implementation should +// call this function after rendering functions, such as +// FPDF_RenderPageBitmap() or FPDF_RenderPageBitmap_Start(), have +// finished rendering the page contents. +FPDF_EXPORT void FPDF_CALLCONV FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, + FPDF_BITMAP bitmap, + FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int flags); + +#if defined(PDF_USE_SKIA) +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 + +// Experimental API +// Function: FPDF_GetFormType +// Returns the type of form contained in the PDF document. +// Parameters: +// document - Handle to document. +// Return Value: +// Integer value representing one of the FORMTYPE_ values. +// Comments: +// If |document| is NULL, then the return value is FORMTYPE_NONE. +FPDF_EXPORT int FPDF_CALLCONV FPDF_GetFormType(FPDF_DOCUMENT document); + +// Experimental API +// Function: FORM_SetIndexSelected +// Selects/deselects the value at the given |index| of the focused +// annotation. +// Parameters: +// hHandle - Handle to the form fill module. Returned by +// FPDFDOC_InitFormFillEnvironment. +// page - Handle to the page. Returned by FPDF_LoadPage +// index - 0-based index of value to be set as +// selected/unselected +// selected - true to select, false to deselect +// Return Value: +// TRUE if the operation succeeded. +// FALSE if the operation failed or widget is not a supported type. +// Comments: +// Intended for use with listbox/combobox widget types. Comboboxes +// have at most a single value selected at a time which cannot be +// deselected. Deselect on a combobox is a no-op that returns false. +// Default implementation is a no-op that will return false for +// other types. +// Not currently supported for XFA forms - will return false. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FORM_SetIndexSelected(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int index, + FPDF_BOOL selected); + +// Experimental API +// Function: FORM_IsIndexSelected +// Returns whether or not the value at |index| of the focused +// annotation is currently selected. +// Parameters: +// hHandle - Handle to the form fill module. Returned by +// FPDFDOC_InitFormFillEnvironment. +// page - Handle to the page. Returned by FPDF_LoadPage +// index - 0-based Index of value to check +// Return Value: +// TRUE if value at |index| is currently selected. +// FALSE if value at |index| is not selected or widget is not a +// supported type. +// Comments: +// Intended for use with listbox/combobox widget types. Default +// implementation is a no-op that will return false for other types. +// Not currently supported for XFA forms - will return false. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FORM_IsIndexSelected(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int index); + +// Function: FPDF_LoadXFA +// If the document consists of XFA fields, call this method to +// attempt to load XFA fields. +// Parameters: +// document - Handle to document from FPDF_LoadDocument(). +// Return Value: +// TRUE upon success, otherwise FALSE. If XFA support is not built +// into PDFium, performs no action and always returns FALSE. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_LoadXFA(FPDF_DOCUMENT document); + #ifdef __cplusplus } #endif diff --git a/src/main/jni/include/fpdf_fwlevent.h b/src/main/jni/include/fpdf_fwlevent.h index 22c01e42..e61606d3 100644 --- a/src/main/jni/include/fpdf_fwlevent.h +++ b/src/main/jni/include/fpdf_fwlevent.h @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,23 +7,14 @@ #ifndef PUBLIC_FPDF_FWLEVENT_H_ #define PUBLIC_FPDF_FWLEVENT_H_ +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" #ifdef __cplusplus extern "C" { -#endif +#endif // __cplusplus -typedef int FPDF_INT32; -typedef unsigned int FPDF_UINT32; -typedef float FPDF_FLOAT; -// event type -typedef enum { - FWL_EVENTTYPE_Mouse = 0, - FWL_EVENTTYPE_MouseWheel, - FWL_EVENTTYPE_Key, -} FWL_EVENTTYPE; - -// key flag +// Key flags. typedef enum { FWL_EVENTFLAG_ShiftKey = 1 << 0, FWL_EVENTFLAG_ControlKey = 1 << 1, @@ -36,44 +27,11 @@ typedef enum { FWL_EVENTFLAG_RightButtonDown = 1 << 8, } FWL_EVENTFLAG; -// Mouse message command -typedef enum { - FWL_EVENTMOUSECMD_LButtonDown = 1, - FWL_EVENTMOUSECMD_LButtonUp, - FWL_EVENTMOUSECMD_LButtonDblClk, - FWL_EVENTMOUSECMD_RButtonDown, - FWL_EVENTMOUSECMD_RButtonUp, - FWL_EVENTMOUSECMD_RButtonDblClk, - FWL_EVENTMOUSECMD_MButtonDown, - FWL_EVENTMOUSECMD_MButtonUp, - FWL_EVENTMOUSECMD_MButtonDblClk, - FWL_EVENTMOUSECMD_MouseMove, - FWL_EVENTMOUSECMD_MouseEnter, - FWL_EVENTMOUSECMD_MouseHover, - FWL_EVENTMOUSECMD_MouseLeave, -} FWL_EVENT_MOUSECMD; - -// mouse event -struct FWL_EVENT_MOUSE { - FPDF_UINT32 command; - FPDF_DWORD flag; - FPDF_FLOAT x; - FPDF_FLOAT y; -}; - -// mouse wheel -struct FWL_EVENT_MOUSEWHEEL { - FPDF_DWORD flag; - FPDF_FLOAT x; - FPDF_FLOAT y; - FPDF_FLOAT deltaX; - FPDF_FLOAT deltaY; -}; - -// virtual keycode +// Virtual keycodes. typedef enum { FWL_VKEY_Back = 0x08, FWL_VKEY_Tab = 0x09, + FWL_VKEY_NewLine = 0x0A, FWL_VKEY_Clear = 0x0C, FWL_VKEY_Return = 0x0D, FWL_VKEY_Shift = 0x10, @@ -242,40 +200,8 @@ typedef enum { FWL_VKEY_Unknown = 0, } FWL_VKEYCODE; -// key event command -typedef enum { - FWL_EVENTKEYCMD_KeyDown = 1, - FWL_EVENTKEYCMD_KeyUp, - FWL_EVENTKEYCMD_Char, -} FWL_EVENTKEYCMD; - -// key event -struct FWL_EVENT_KEY { - FPDF_UINT32 command; - FPDF_DWORD flag; - union { - // Virtual key code. - FPDF_UINT32 vkcode; - // Character code. - FPDF_DWORD charcode; - } code; -}; - -// event type -struct FWL_EVENT { - // structure size. - FPDF_UINT32 size; - // FWL_EVENTTYPE. - FPDF_UINT32 type; - union { - struct FWL_EVENT_MOUSE mouse; - struct FWL_EVENT_MOUSEWHEEL wheel; - struct FWL_EVENT_KEY key; - } s; -}; - #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_FWLEVENT_H_ diff --git a/src/main/jni/include/fpdf_javascript.h b/src/main/jni/include/fpdf_javascript.h new file mode 100644 index 00000000..2b024056 --- /dev/null +++ b/src/main/jni/include/fpdf_javascript.h @@ -0,0 +1,77 @@ +// Copyright 2019 The PDFium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PUBLIC_FPDF_JAVASCRIPT_H_ +#define PUBLIC_FPDF_JAVASCRIPT_H_ + +// NOLINTNEXTLINE(build/include) +#include "fpdfview.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Experimental API. +// Get the number of JavaScript actions in |document|. +// +// document - handle to a document. +// +// Returns the number of JavaScript actions in |document| or -1 on error. +FPDF_EXPORT int FPDF_CALLCONV +FPDFDoc_GetJavaScriptActionCount(FPDF_DOCUMENT document); + +// Experimental API. +// Get the JavaScript action at |index| in |document|. +// +// document - handle to a document. +// index - the index of the requested JavaScript action. +// +// Returns the handle to the JavaScript action, or NULL on failure. +// Caller owns the returned handle and must close it with +// FPDFDoc_CloseJavaScriptAction(). +FPDF_EXPORT FPDF_JAVASCRIPT_ACTION FPDF_CALLCONV +FPDFDoc_GetJavaScriptAction(FPDF_DOCUMENT document, int index); + +// Experimental API. +// Close a loaded FPDF_JAVASCRIPT_ACTION object. + +// javascript - Handle to a JavaScript action. +FPDF_EXPORT void FPDF_CALLCONV +FPDFDoc_CloseJavaScriptAction(FPDF_JAVASCRIPT_ACTION javascript); + +// Experimental API. +// Get the name from the |javascript| handle. |buffer| is only modified if +// |buflen| is longer than the length of the name. On errors, |buffer| is +// unmodified and the returned length is 0. +// +// javascript - handle to an JavaScript action. +// buffer - buffer for holding the name, encoded in UTF-16LE. +// buflen - length of the buffer in bytes. +// +// Returns the length of the JavaScript action name in bytes. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFJavaScriptAction_GetName(FPDF_JAVASCRIPT_ACTION javascript, + FPDF_WCHAR* buffer, + unsigned long buflen); + +// Experimental API. +// Get the script from the |javascript| handle. |buffer| is only modified if +// |buflen| is longer than the length of the script. On errors, |buffer| is +// unmodified and the returned length is 0. +// +// javascript - handle to an JavaScript action. +// buffer - buffer for holding the name, encoded in UTF-16LE. +// buflen - length of the buffer in bytes. +// +// Returns the length of the JavaScript action name in bytes. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFJavaScriptAction_GetScript(FPDF_JAVASCRIPT_ACTION javascript, + FPDF_WCHAR* buffer, + unsigned long buflen); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // PUBLIC_FPDF_JAVASCRIPT_H_ diff --git a/src/main/jni/include/fpdf_ppo.h b/src/main/jni/include/fpdf_ppo.h index e7d77678..1734bc68 100644 --- a/src/main/jni/include/fpdf_ppo.h +++ b/src/main/jni/include/fpdf_ppo.h @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,41 +7,109 @@ #ifndef PUBLIC_FPDF_PPO_H_ #define PUBLIC_FPDF_PPO_H_ +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" #ifdef __cplusplus extern "C" { #endif -// Function: FPDF_ImportPages -// Import some pages to a PDF document. -// Parameters: -// dest_doc - The destination document which add the pages. -// src_doc - A document to be imported. -// pagerange - A page range string, Such as "1,3,5-7". -// If this parameter is NULL, it would import all pages -// in src_doc. -// index - The page index wanted to insert from. -// Return value: -// TRUE for succeed, FALSE for Failed. -DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc, - FPDF_DOCUMENT src_doc, - FPDF_BYTESTRING pagerange, - int index); - -// Function: FPDF_CopyViewerPreferences -// Copy the viewer preferences from one PDF document to another.#endif -// Parameters: -// dest_doc - Handle to document to write the viewer preferences -// to. -// src_doc - Handle to document with the viewer preferences. +// Experimental API. +// Import pages to a FPDF_DOCUMENT. +// +// dest_doc - The destination document for the pages. +// src_doc - The document to be imported. +// page_indices - An array of page indices to be imported. The first page is +// zero. If |page_indices| is NULL, all pages from |src_doc| +// are imported. +// length - The length of the |page_indices| array. +// index - The page index at which to insert the first imported page +// into |dest_doc|. The first page is zero. +// +// Returns TRUE on success. Returns FALSE if any pages in |page_indices| is +// invalid. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDF_ImportPagesByIndex(FPDF_DOCUMENT dest_doc, + FPDF_DOCUMENT src_doc, + const int* page_indices, + unsigned long length, + int index); + +// Import pages to a FPDF_DOCUMENT. +// +// dest_doc - The destination document for the pages. +// src_doc - The document to be imported. +// pagerange - A page range string, Such as "1,3,5-7". The first page is one. +// If |pagerange| is NULL, all pages from |src_doc| are imported. +// index - The page index at which to insert the first imported page into +// |dest_doc|. The first page is zero. +// +// Returns TRUE on success. Returns FALSE if any pages in |pagerange| is +// invalid or if |pagerange| cannot be read. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_ImportPages(FPDF_DOCUMENT dest_doc, + FPDF_DOCUMENT src_doc, + FPDF_BYTESTRING pagerange, + int index); + +// Experimental API. +// Create a new document from |src_doc|. The pages of |src_doc| will be +// combined to provide |num_pages_on_x_axis x num_pages_on_y_axis| pages per +// |output_doc| page. +// +// src_doc - The document to be imported. +// output_width - The output page width in PDF "user space" units. +// output_height - The output page height in PDF "user space" units. +// num_pages_on_x_axis - The number of pages on X Axis. +// num_pages_on_y_axis - The number of pages on Y Axis. +// // Return value: -// TRUE for success, FALSE for failure. -DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, - FPDF_DOCUMENT src_doc); +// A handle to the created document, or NULL on failure. +// +// Comments: +// number of pages per page = num_pages_on_x_axis * num_pages_on_y_axis +// +FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV +FPDF_ImportNPagesToOne(FPDF_DOCUMENT src_doc, + float output_width, + float output_height, + size_t num_pages_on_x_axis, + size_t num_pages_on_y_axis); + +// Experimental API. +// Create a template to generate form xobjects from |src_doc|'s page at +// |src_page_index|, for use in |dest_doc|. +// +// Returns a handle on success, or NULL on failure. Caller owns the newly +// created object. +FPDF_EXPORT FPDF_XOBJECT FPDF_CALLCONV +FPDF_NewXObjectFromPage(FPDF_DOCUMENT dest_doc, + FPDF_DOCUMENT src_doc, + int src_page_index); + +// Experimental API. +// Close an FPDF_XOBJECT handle created by FPDF_NewXObjectFromPage(). +// FPDF_PAGEOBJECTs created from the FPDF_XOBJECT handle are not affected. +FPDF_EXPORT void FPDF_CALLCONV FPDF_CloseXObject(FPDF_XOBJECT xobject); + +// Experimental API. +// Create a new form object from an FPDF_XOBJECT object. +// +// Returns a new form object on success, or NULL on failure. Caller owns the +// newly created object. +FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV +FPDF_NewFormObjectFromXObject(FPDF_XOBJECT xobject); + +// Copy the viewer preferences from |src_doc| into |dest_doc|. +// +// dest_doc - Document to write the viewer preferences into. +// src_doc - Document to read the viewer preferences from. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, FPDF_DOCUMENT src_doc); #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_PPO_H_ diff --git a/src/main/jni/include/fpdf_progressive.h b/src/main/jni/include/fpdf_progressive.h index f352ff9d..0505a54b 100644 --- a/src/main/jni/include/fpdf_progressive.h +++ b/src/main/jni/include/fpdf_progressive.h @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,11 +7,13 @@ #ifndef PUBLIC_FPDF_PROGRESSIVE_H_ #define PUBLIC_FPDF_PROGRESSIVE_H_ +// clang-format off +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" // Flags for progressive process status. -#define FPDF_RENDER_READER 0 -#define FPDF_RENDER_TOBECOUNTINUED 1 +#define FPDF_RENDER_READY 0 +#define FPDF_RENDER_TOBECONTINUED 1 #define FPDF_RENDER_DONE 2 #define FPDF_RENDER_FAILED 3 @@ -21,93 +23,130 @@ extern "C" { // IFPDF_RENDERINFO interface. typedef struct _IFSDK_PAUSE { - /** - * Version number of the interface. Currently must be 1. - **/ + // Version number of the interface. Currently must be 1. int version; - /* - * Method: NeedToPauseNow - * Check if we need to pause a progressive process now. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * Return Value: - * Non-zero for pause now, 0 for continue. - * - */ + // Method: NeedToPauseNow + // Check if we need to pause a progressive process now. + // Interface Version: + // 1 + // Implementation Required: + // yes + // Parameters: + // pThis - Pointer to the interface structure itself + // Return Value: + // Non-zero for pause now, 0 for continue. FPDF_BOOL (*NeedToPauseNow)(struct _IFSDK_PAUSE* pThis); // A user defined data pointer, used by user's application. Can be NULL. void* user; } IFSDK_PAUSE; +// Experimental API. +// Function: FPDF_RenderPageBitmapWithColorScheme_Start +// Start to render page contents to a device independent bitmap +// progressively with a specified color scheme for the content. +// Parameters: +// bitmap - Handle to the device independent bitmap (as the +// output buffer). Bitmap handle can be created by +// FPDFBitmap_Create function. +// page - Handle to the page as returned by FPDF_LoadPage +// function. +// start_x - Left pixel position of the display area in the +// bitmap coordinate. +// start_y - Top pixel position of the display area in the +// bitmap coordinate. +// size_x - Horizontal size (in pixels) for displaying the +// page. +// size_y - Vertical size (in pixels) for displaying the page. +// rotate - Page orientation: 0 (normal), 1 (rotated 90 +// degrees clockwise), 2 (rotated 180 degrees), +// 3 (rotated 90 degrees counter-clockwise). +// flags - 0 for normal display, or combination of flags +// defined in fpdfview.h. With FPDF_ANNOT flag, it +// renders all annotations that does not require +// user-interaction, which are all annotations except +// widget and popup annotations. +// color_scheme - Color scheme to be used in rendering the |page|. +// If null, this function will work similar to +// FPDF_RenderPageBitmap_Start(). +// pause - The IFSDK_PAUSE interface. A callback mechanism +// allowing the page rendering process. +// Return value: +// Rendering Status. See flags for progressive process status for the +// details. +FPDF_EXPORT int FPDF_CALLCONV +FPDF_RenderPageBitmapWithColorScheme_Start(FPDF_BITMAP bitmap, + FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int flags, + const FPDF_COLORSCHEME* color_scheme, + IFSDK_PAUSE* pause); + // Function: FPDF_RenderPageBitmap_Start // Start to render page contents to a device independent bitmap // progressively. // Parameters: // bitmap - Handle to the device independent bitmap (as the -// output buffer). -// Bitmap handle can be created by FPDFBitmap_Create -// function. -// page - Handle to the page. Returned by FPDF_LoadPage -// function. +// output buffer). Bitmap handle can be created by +// FPDFBitmap_Create(). +// page - Handle to the page, as returned by FPDF_LoadPage(). // start_x - Left pixel position of the display area in the -// bitmap coordinate. +// bitmap coordinates. // start_y - Top pixel position of the display area in the bitmap -// coordinate. +// coordinates. // size_x - Horizontal size (in pixels) for displaying the page. // size_y - Vertical size (in pixels) for displaying the page. // rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees -// clockwise), -// 2 (rotated 180 degrees), 3 (rotated 90 degrees -// counter-clockwise). +// clockwise), 2 (rotated 180 degrees), 3 (rotated 90 +// degrees counter-clockwise). // flags - 0 for normal display, or combination of flags -// defined above. +// defined in fpdfview.h. With FPDF_ANNOT flag, it +// renders all annotations that does not require +// user-interaction, which are all annotations except +// widget and popup annotations. // pause - The IFSDK_PAUSE interface.A callback mechanism -// allowing the page rendering process +// allowing the page rendering process // Return value: // Rendering Status. See flags for progressive process status for the // details. -// -DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, - FPDF_PAGE page, - int start_x, - int start_y, - int size_x, - int size_y, - int rotate, - int flags, - IFSDK_PAUSE* pause); +FPDF_EXPORT int FPDF_CALLCONV FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, + FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int flags, + IFSDK_PAUSE* pause); // Function: FPDF_RenderPage_Continue // Continue rendering a PDF page. // Parameters: -// page - Handle to the page. Returned by FPDF_LoadPage -// function. -// pause - The IFSDK_PAUSE interface.A callback mechanism -// allowing the page rendering process -// to be paused before it's finished. This can be NULL -// if you don't want to pause. +// page - Handle to the page, as returned by FPDF_LoadPage(). +// pause - The IFSDK_PAUSE interface (a callback mechanism +// allowing the page rendering process to be paused +// before it's finished). This can be NULL if you +// don't want to pause. // Return value: // The rendering status. See flags for progressive process status for // the details. -DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page, - IFSDK_PAUSE* pause); +FPDF_EXPORT int FPDF_CALLCONV FPDF_RenderPage_Continue(FPDF_PAGE page, + IFSDK_PAUSE* pause); // Function: FPDF_RenderPage_Close // Release the resource allocate during page rendering. Need to be // called after finishing rendering or // cancel the rendering. // Parameters: -// page - Handle to the page. Returned by FPDF_LoadPage -// function. +// page - Handle to the page, as returned by FPDF_LoadPage(). // Return value: -// NULL -DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page); +// None. +FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPage_Close(FPDF_PAGE page); #ifdef __cplusplus } diff --git a/src/main/jni/include/fpdf_save.h b/src/main/jni/include/fpdf_save.h index 4eea054e..800d4e75 100644 --- a/src/main/jni/include/fpdf_save.h +++ b/src/main/jni/include/fpdf_save.h @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,6 +7,8 @@ #ifndef PUBLIC_FPDF_SAVE_H_ #define PUBLIC_FPDF_SAVE_H_ +// clang-format off +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" #ifdef __cplusplus @@ -20,7 +22,6 @@ typedef struct FPDF_FILEWRITE_ { // int version; - // // Method: WriteBlock // Output a block of data in your custom way. // Interface Version: @@ -35,50 +36,47 @@ typedef struct FPDF_FILEWRITE_ { // size - The size of the buffer. // Return value: // Should be non-zero if successful, zero for error. - // int (*WriteBlock)(struct FPDF_FILEWRITE_* pThis, const void* pData, unsigned long size); - } FPDF_FILEWRITE; -/** @brief Incremental. */ + // Flags for FPDF_SaveAsCopy() #define FPDF_INCREMENTAL 1 -/** @brief No Incremental. */ #define FPDF_NO_INCREMENTAL 2 -/** @brief Remove security. */ #define FPDF_REMOVE_SECURITY 3 // Function: FPDF_SaveAsCopy // Saves the copy of specified document in custom way. // Parameters: -// document - Handle to document. Returned by -// FPDF_LoadDocument and FPDF_CreateNewDocument. +// document - Handle to document, as returned by +// FPDF_LoadDocument() or FPDF_CreateNewDocument(). // pFileWrite - A pointer to a custom file write structure. // flags - The creating flags. // Return value: // TRUE for succeed, FALSE for failed. // -DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy(FPDF_DOCUMENT document, - FPDF_FILEWRITE* pFileWrite, - FPDF_DWORD flags); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_SaveAsCopy(FPDF_DOCUMENT document, + FPDF_FILEWRITE* pFileWrite, + FPDF_DWORD flags); // Function: FPDF_SaveWithVersion -// Same as function ::FPDF_SaveAsCopy, except the file version of the -// saved document could be specified by user. +// Same as FPDF_SaveAsCopy(), except the file version of the +// saved document can be specified by the caller. // Parameters: // document - Handle to document. // pFileWrite - A pointer to a custom file write structure. // flags - The creating flags. // fileVersion - The PDF file version. File version: 14 for 1.4, -// 15 for 1.5, ... +// 15 for 1.5, ... // Return value: // TRUE if succeed, FALSE if failed. // -DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, - FPDF_FILEWRITE* pFileWrite, - FPDF_DWORD flags, - int fileVersion); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDF_SaveWithVersion(FPDF_DOCUMENT document, + FPDF_FILEWRITE* pFileWrite, + FPDF_DWORD flags, + int fileVersion); #ifdef __cplusplus } diff --git a/src/main/jni/include/fpdf_searchex.h b/src/main/jni/include/fpdf_searchex.h index a6b6e1bd..9c980dbe 100644 --- a/src/main/jni/include/fpdf_searchex.h +++ b/src/main/jni/include/fpdf_searchex.h @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,26 +7,33 @@ #ifndef PUBLIC_FPDF_SEARCHEX_H_ #define PUBLIC_FPDF_SEARCHEX_H_ +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" #ifdef __cplusplus extern "C" { -#endif - -// Function: FPDFText_GetCharIndexFromTextIndex -// Get the actually char index in text_page's internal char list. -// Parameters: -// text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. -// nTextIndex - The index of the text in the string get from -// FPDFText_GetText. -// Return value: -// The index of the character in internal charlist. -1 for error. -DLLEXPORT int STDCALL +#endif // __cplusplus + +// Get the character index in |text_page| internal character list. +// +// text_page - a text page information structure. +// nTextIndex - index of the text returned from FPDFText_GetText(). +// +// Returns the index of the character in internal character list. -1 for error. +FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetCharIndexFromTextIndex(FPDF_TEXTPAGE text_page, int nTextIndex); +// Get the text index in |text_page| internal character list. +// +// text_page - a text page information structure. +// nCharIndex - index of the character in internal character list. +// +// Returns the index of the text returned from FPDFText_GetText(). -1 for error. +FPDF_EXPORT int FPDF_CALLCONV +FPDFText_GetTextIndexFromCharIndex(FPDF_TEXTPAGE text_page, int nCharIndex); + #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_SEARCHEX_H_ diff --git a/src/main/jni/include/fpdf_signature.h b/src/main/jni/include/fpdf_signature.h new file mode 100644 index 00000000..9a075e5f --- /dev/null +++ b/src/main/jni/include/fpdf_signature.h @@ -0,0 +1,155 @@ +// Copyright 2020 The PDFium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PUBLIC_FPDF_SIGNATURE_H_ +#define PUBLIC_FPDF_SIGNATURE_H_ + +// NOLINTNEXTLINE(build/include) +#include "fpdfview.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Experimental API. +// Function: FPDF_GetSignatureCount +// Get total number of signatures in the document. +// Parameters: +// document - Handle to document. Returned by FPDF_LoadDocument(). +// Return value: +// Total number of signatures in the document on success, -1 on error. +FPDF_EXPORT int FPDF_CALLCONV FPDF_GetSignatureCount(FPDF_DOCUMENT document); + +// Experimental API. +// Function: FPDF_GetSignatureObject +// Get the Nth signature of the document. +// Parameters: +// document - Handle to document. Returned by FPDF_LoadDocument(). +// index - Index into the array of signatures of the document. +// Return value: +// Returns the handle to the signature, or NULL on failure. The caller +// does not take ownership of the returned FPDF_SIGNATURE. Instead, it +// remains valid until FPDF_CloseDocument() is called for the document. +FPDF_EXPORT FPDF_SIGNATURE FPDF_CALLCONV +FPDF_GetSignatureObject(FPDF_DOCUMENT document, int index); + +// Experimental API. +// Function: FPDFSignatureObj_GetContents +// Get the contents of a signature object. +// Parameters: +// signature - Handle to the signature object. Returned by +// FPDF_GetSignatureObject(). +// buffer - The address of a buffer that receives the contents. +// length - The size, in bytes, of |buffer|. +// Return value: +// Returns the number of bytes in the contents on success, 0 on error. +// +// For public-key signatures, |buffer| is either a DER-encoded PKCS#1 binary or +// a DER-encoded PKCS#7 binary. If |length| is less than the returned length, or +// |buffer| is NULL, |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFSignatureObj_GetContents(FPDF_SIGNATURE signature, + void* buffer, + unsigned long length); + +// Experimental API. +// Function: FPDFSignatureObj_GetByteRange +// Get the byte range of a signature object. +// Parameters: +// signature - Handle to the signature object. Returned by +// FPDF_GetSignatureObject(). +// buffer - The address of a buffer that receives the +// byte range. +// length - The size, in ints, of |buffer|. +// Return value: +// Returns the number of ints in the byte range on +// success, 0 on error. +// +// |buffer| is an array of pairs of integers (starting byte offset, +// length in bytes) that describes the exact byte range for the digest +// calculation. If |length| is less than the returned length, or +// |buffer| is NULL, |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFSignatureObj_GetByteRange(FPDF_SIGNATURE signature, + int* buffer, + unsigned long length); + +// Experimental API. +// Function: FPDFSignatureObj_GetSubFilter +// Get the encoding of the value of a signature object. +// Parameters: +// signature - Handle to the signature object. Returned by +// FPDF_GetSignatureObject(). +// buffer - The address of a buffer that receives the encoding. +// length - The size, in bytes, of |buffer|. +// Return value: +// Returns the number of bytes in the encoding name (including the +// trailing NUL character) on success, 0 on error. +// +// The |buffer| is always encoded in 7-bit ASCII. If |length| is less than the +// returned length, or |buffer| is NULL, |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFSignatureObj_GetSubFilter(FPDF_SIGNATURE signature, + char* buffer, + unsigned long length); + +// Experimental API. +// Function: FPDFSignatureObj_GetReason +// Get the reason (comment) of the signature object. +// Parameters: +// signature - Handle to the signature object. Returned by +// FPDF_GetSignatureObject(). +// buffer - The address of a buffer that receives the reason. +// length - The size, in bytes, of |buffer|. +// Return value: +// Returns the number of bytes in the reason on success, 0 on error. +// +// Regardless of the platform, the |buffer| is always in UTF-16LE encoding. The +// string is terminated by a UTF16 NUL character. If |length| is less than the +// returned length, or |buffer| is NULL, |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFSignatureObj_GetReason(FPDF_SIGNATURE signature, + void* buffer, + unsigned long length); + +// Experimental API. +// Function: FPDFSignatureObj_GetTime +// Get the time of signing of a signature object. +// Parameters: +// signature - Handle to the signature object. Returned by +// FPDF_GetSignatureObject(). +// buffer - The address of a buffer that receives the time. +// length - The size, in bytes, of |buffer|. +// Return value: +// Returns the number of bytes in the encoding name (including the +// trailing NUL character) on success, 0 on error. +// +// The |buffer| is always encoded in 7-bit ASCII. If |length| is less than the +// returned length, or |buffer| is NULL, |buffer| will not be modified. +// +// The format of time is expected to be D:YYYYMMDDHHMMSS+XX'YY', i.e. it's +// percision is seconds, with timezone information. This value should be used +// only when the time of signing is not available in the (PKCS#7 binary) +// signature. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFSignatureObj_GetTime(FPDF_SIGNATURE signature, + char* buffer, + unsigned long length); + +// Experimental API. +// Function: FPDFSignatureObj_GetDocMDPPermission +// Get the DocMDP permission of a signature object. +// Parameters: +// signature - Handle to the signature object. Returned by +// FPDF_GetSignatureObject(). +// Return value: +// Returns the permission (1, 2 or 3) on success, 0 on error. +FPDF_EXPORT unsigned int FPDF_CALLCONV +FPDFSignatureObj_GetDocMDPPermission(FPDF_SIGNATURE signature); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // PUBLIC_FPDF_SIGNATURE_H_ diff --git a/src/main/jni/include/fpdf_structtree.h b/src/main/jni/include/fpdf_structtree.h new file mode 100644 index 00000000..ea67fefd --- /dev/null +++ b/src/main/jni/include/fpdf_structtree.h @@ -0,0 +1,524 @@ +// Copyright 2016 The PDFium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef PUBLIC_FPDF_STRUCTTREE_H_ +#define PUBLIC_FPDF_STRUCTTREE_H_ + +// clang-format off +// NOLINTNEXTLINE(build/include) +#include "fpdfview.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Function: FPDF_StructTree_GetForPage +// Get the structure tree for a page. +// Parameters: +// page - Handle to the page, as returned by FPDF_LoadPage(). +// Return value: +// A handle to the structure tree or NULL on error. The caller owns the +// returned handle and must use FPDF_StructTree_Close() to release it. +// The handle should be released before |page| gets released. +FPDF_EXPORT FPDF_STRUCTTREE FPDF_CALLCONV +FPDF_StructTree_GetForPage(FPDF_PAGE page); + +// Function: FPDF_StructTree_Close +// Release a resource allocated by FPDF_StructTree_GetForPage(). +// Parameters: +// struct_tree - Handle to the structure tree, as returned by +// FPDF_StructTree_LoadPage(). +// Return value: +// None. +FPDF_EXPORT void FPDF_CALLCONV +FPDF_StructTree_Close(FPDF_STRUCTTREE struct_tree); + +// Function: FPDF_StructTree_CountChildren +// Count the number of children for the structure tree. +// Parameters: +// struct_tree - Handle to the structure tree, as returned by +// FPDF_StructTree_LoadPage(). +// Return value: +// The number of children, or -1 on error. +FPDF_EXPORT int FPDF_CALLCONV +FPDF_StructTree_CountChildren(FPDF_STRUCTTREE struct_tree); + +// Function: FPDF_StructTree_GetChildAtIndex +// Get a child in the structure tree. +// Parameters: +// struct_tree - Handle to the structure tree, as returned by +// FPDF_StructTree_LoadPage(). +// index - The index for the child, 0-based. +// Return value: +// The child at the n-th index or NULL on error. The caller does not +// own the handle. The handle remains valid as long as |struct_tree| +// remains valid. +// Comments: +// The |index| must be less than the FPDF_StructTree_CountChildren() +// return value. +FPDF_EXPORT FPDF_STRUCTELEMENT FPDF_CALLCONV +FPDF_StructTree_GetChildAtIndex(FPDF_STRUCTTREE struct_tree, int index); + +// Function: FPDF_StructElement_GetAltText +// Get the alt text for a given element. +// Parameters: +// struct_element - Handle to the struct element. +// buffer - A buffer for output the alt text. May be NULL. +// buflen - The length of the buffer, in bytes. May be 0. +// Return value: +// The number of bytes in the alt text, including the terminating NUL +// character. The number of bytes is returned regardless of the +// |buffer| and |buflen| parameters. +// Comments: +// Regardless of the platform, the |buffer| is always in UTF-16LE +// encoding. The string is terminated by a UTF16 NUL character. If +// |buflen| is less than the required length, or |buffer| is NULL, +// |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDF_StructElement_GetAltText(FPDF_STRUCTELEMENT struct_element, + void* buffer, + unsigned long buflen); + +// Experimental API. +// Function: FPDF_StructElement_GetActualText +// Get the actual text for a given element. +// Parameters: +// struct_element - Handle to the struct element. +// buffer - A buffer for output the actual text. May be NULL. +// buflen - The length of the buffer, in bytes. May be 0. +// Return value: +// The number of bytes in the actual text, including the terminating +// NUL character. The number of bytes is returned regardless of the +// |buffer| and |buflen| parameters. +// Comments: +// Regardless of the platform, the |buffer| is always in UTF-16LE +// encoding. The string is terminated by a UTF16 NUL character. If +// |buflen| is less than the required length, or |buffer| is NULL, +// |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDF_StructElement_GetActualText(FPDF_STRUCTELEMENT struct_element, + void* buffer, + unsigned long buflen); + +// Function: FPDF_StructElement_GetID +// Get the ID for a given element. +// Parameters: +// struct_element - Handle to the struct element. +// buffer - A buffer for output the ID string. May be NULL. +// buflen - The length of the buffer, in bytes. May be 0. +// Return value: +// The number of bytes in the ID string, including the terminating NUL +// character. The number of bytes is returned regardless of the +// |buffer| and |buflen| parameters. +// Comments: +// Regardless of the platform, the |buffer| is always in UTF-16LE +// encoding. The string is terminated by a UTF16 NUL character. If +// |buflen| is less than the required length, or |buffer| is NULL, +// |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDF_StructElement_GetID(FPDF_STRUCTELEMENT struct_element, + void* buffer, + unsigned long buflen); + +// Experimental API. +// Function: FPDF_StructElement_GetLang +// Get the case-insensitive IETF BCP 47 language code for an element. +// Parameters: +// struct_element - Handle to the struct element. +// buffer - A buffer for output the lang string. May be NULL. +// buflen - The length of the buffer, in bytes. May be 0. +// Return value: +// The number of bytes in the ID string, including the terminating NUL +// character. The number of bytes is returned regardless of the +// |buffer| and |buflen| parameters. +// Comments: +// Regardless of the platform, the |buffer| is always in UTF-16LE +// encoding. The string is terminated by a UTF16 NUL character. If +// |buflen| is less than the required length, or |buffer| is NULL, +// |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDF_StructElement_GetLang(FPDF_STRUCTELEMENT struct_element, + void* buffer, + unsigned long buflen); + +// Experimental API. +// Function: FPDF_StructElement_GetStringAttribute +// Get a struct element attribute of type "name" or "string". +// Parameters: +// struct_element - Handle to the struct element. +// attr_name - The name of the attribute to retrieve. +// buffer - A buffer for output. May be NULL. +// buflen - The length of the buffer, in bytes. May be 0. +// Return value: +// The number of bytes in the attribute value, including the +// terminating NUL character. The number of bytes is returned +// regardless of the |buffer| and |buflen| parameters. +// Comments: +// Regardless of the platform, the |buffer| is always in UTF-16LE +// encoding. The string is terminated by a UTF16 NUL character. If +// |buflen| is less than the required length, or |buffer| is NULL, +// |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDF_StructElement_GetStringAttribute(FPDF_STRUCTELEMENT struct_element, + FPDF_BYTESTRING attr_name, + void* buffer, + unsigned long buflen); + +// Function: FPDF_StructElement_GetMarkedContentID +// Get the marked content ID for a given element. +// Parameters: +// struct_element - Handle to the struct element. +// Return value: +// The marked content ID of the element. If no ID exists, returns +// -1. +// Comments: +// FPDF_StructElement_GetMarkedContentIdAtIndex() may be able to +// extract more marked content IDs out of |struct_element|. This API +// may be deprecated in the future. +FPDF_EXPORT int FPDF_CALLCONV +FPDF_StructElement_GetMarkedContentID(FPDF_STRUCTELEMENT struct_element); + +// Function: FPDF_StructElement_GetType +// Get the type (/S) for a given element. +// Parameters: +// struct_element - Handle to the struct element. +// buffer - A buffer for output. May be NULL. +// buflen - The length of the buffer, in bytes. May be 0. +// Return value: +// The number of bytes in the type, including the terminating NUL +// character. The number of bytes is returned regardless of the +// |buffer| and |buflen| parameters. +// Comments: +// Regardless of the platform, the |buffer| is always in UTF-16LE +// encoding. The string is terminated by a UTF16 NUL character. If +// |buflen| is less than the required length, or |buffer| is NULL, +// |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDF_StructElement_GetType(FPDF_STRUCTELEMENT struct_element, + void* buffer, + unsigned long buflen); + +// Experimental API. +// Function: FPDF_StructElement_GetObjType +// Get the object type (/Type) for a given element. +// Parameters: +// struct_element - Handle to the struct element. +// buffer - A buffer for output. May be NULL. +// buflen - The length of the buffer, in bytes. May be 0. +// Return value: +// The number of bytes in the object type, including the terminating +// NUL character. The number of bytes is returned regardless of the +// |buffer| and |buflen| parameters. +// Comments: +// Regardless of the platform, the |buffer| is always in UTF-16LE +// encoding. The string is terminated by a UTF16 NUL character. If +// |buflen| is less than the required length, or |buffer| is NULL, +// |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDF_StructElement_GetObjType(FPDF_STRUCTELEMENT struct_element, + void* buffer, + unsigned long buflen); + +// Function: FPDF_StructElement_GetTitle +// Get the title (/T) for a given element. +// Parameters: +// struct_element - Handle to the struct element. +// buffer - A buffer for output. May be NULL. +// buflen - The length of the buffer, in bytes. May be 0. +// Return value: +// The number of bytes in the title, including the terminating NUL +// character. The number of bytes is returned regardless of the +// |buffer| and |buflen| parameters. +// Comments: +// Regardless of the platform, the |buffer| is always in UTF-16LE +// encoding. The string is terminated by a UTF16 NUL character. If +// |buflen| is less than the required length, or |buffer| is NULL, +// |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDF_StructElement_GetTitle(FPDF_STRUCTELEMENT struct_element, + void* buffer, + unsigned long buflen); + +// Function: FPDF_StructElement_CountChildren +// Count the number of children for the structure element. +// Parameters: +// struct_element - Handle to the struct element. +// Return value: +// The number of children, or -1 on error. +FPDF_EXPORT int FPDF_CALLCONV +FPDF_StructElement_CountChildren(FPDF_STRUCTELEMENT struct_element); + +// Function: FPDF_StructElement_GetChildAtIndex +// Get a child in the structure element. +// Parameters: +// struct_element - Handle to the struct element. +// index - The index for the child, 0-based. +// Return value: +// The child at the n-th index or NULL on error. +// Comments: +// If the child exists but is not an element, then this function will +// return NULL. This will also return NULL for out of bounds indices. +// The |index| must be less than the FPDF_StructElement_CountChildren() +// return value. +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. +// The |index| must be less than the FPDF_StructElement_CountChildren() +// return value. +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. +// Parameters: +// struct_element - Handle to the struct element. +// Return value: +// The parent structure element or NULL on error. +// Comments: +// If structure element is StructTreeRoot, then this function will +// return NULL. +FPDF_EXPORT FPDF_STRUCTELEMENT FPDF_CALLCONV +FPDF_StructElement_GetParent(FPDF_STRUCTELEMENT struct_element); + +// Function: FPDF_StructElement_GetAttributeCount +// Count the number of attributes for the structure element. +// Parameters: +// struct_element - Handle to the struct element. +// Return value: +// The number of attributes, or -1 on error. +FPDF_EXPORT int FPDF_CALLCONV +FPDF_StructElement_GetAttributeCount(FPDF_STRUCTELEMENT struct_element); + +// Experimental API. +// Function: FPDF_StructElement_GetAttributeAtIndex +// Get an attribute object in the structure element. +// Parameters: +// struct_element - Handle to the struct element. +// index - The index for the attribute object, 0-based. +// Return value: +// The attribute object at the n-th index or NULL on error. +// Comments: +// If the attribute object exists but is not a dict, then this +// function will return NULL. This will also return NULL for out of +// bounds indices. The caller does not own the handle. The handle +// remains valid as long as |struct_element| remains valid. +// The |index| must be less than the +// FPDF_StructElement_GetAttributeCount() return value. +FPDF_EXPORT FPDF_STRUCTELEMENT_ATTR FPDF_CALLCONV +FPDF_StructElement_GetAttributeAtIndex(FPDF_STRUCTELEMENT struct_element, int index); + +// Experimental API. +// Function: FPDF_StructElement_Attr_GetCount +// Count the number of attributes in a structure element attribute map. +// Parameters: +// struct_attribute - Handle to the struct element attribute. +// Return value: +// The number of attributes, or -1 on error. +FPDF_EXPORT int FPDF_CALLCONV +FPDF_StructElement_Attr_GetCount(FPDF_STRUCTELEMENT_ATTR struct_attribute); + + +// Experimental API. +// Function: FPDF_StructElement_Attr_GetName +// Get the name of an attribute in a structure element attribute map. +// Parameters: +// struct_attribute - Handle to the struct element attribute. +// index - The index of attribute in the map. +// buffer - A buffer for output. May be NULL. This is only +// modified if |buflen| is longer than the length +// of the key. Optional, pass null to just +// retrieve the size of the buffer needed. +// buflen - The length of the buffer. +// out_buflen - A pointer to variable that will receive the +// minimum buffer size to contain the key. Not +// filled if FALSE is returned. +// Return value: +// TRUE if the operation was successful, FALSE otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDF_StructElement_Attr_GetName(FPDF_STRUCTELEMENT_ATTR struct_attribute, + int index, + void* buffer, + unsigned long buflen, + unsigned long* out_buflen); +// Experimental API. +// Function: FPDF_StructElement_Attr_GetValue +// Get a handle to a value for an attribute in a structure element +// attribute map. +// Parameters: +// struct_attribute - Handle to the struct element attribute. +// name - The attribute name. +// Return value: +// Returns a handle to the value associated with the input, if any. +// Returns NULL on failure. The caller does not own the handle. +// The handle remains valid as long as |struct_attribute| remains +// valid. +FPDF_EXPORT FPDF_STRUCTELEMENT_ATTR_VALUE FPDF_CALLCONV +FPDF_StructElement_Attr_GetValue(FPDF_STRUCTELEMENT_ATTR struct_attribute, + FPDF_BYTESTRING name); + +// Experimental API. +// Function: FPDF_StructElement_Attr_GetType +// Get the type of an attribute in a structure element attribute map. +// Parameters: +// value - Handle to the value. +// Return value: +// Returns the type of the value, or FPDF_OBJECT_UNKNOWN in case of +// failure. Note that this will never return FPDF_OBJECT_REFERENCE, as +// references are always dereferenced. +FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV +FPDF_StructElement_Attr_GetType(FPDF_STRUCTELEMENT_ATTR_VALUE value); + +// Experimental API. +// Function: FPDF_StructElement_Attr_GetBooleanValue +// Get the value of a boolean attribute in an attribute map as +// FPDF_BOOL. FPDF_StructElement_Attr_GetType() should have returned +// FPDF_OBJECT_BOOLEAN for this property. +// Parameters: +// value - Handle to the value. +// out_value - A pointer to variable that will receive the value. Not +// filled if false is returned. +// Return value: +// Returns TRUE if the attribute maps to a boolean value, FALSE +// otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDF_StructElement_Attr_GetBooleanValue(FPDF_STRUCTELEMENT_ATTR_VALUE value, + FPDF_BOOL* out_value); + +// Experimental API. +// Function: FPDF_StructElement_Attr_GetNumberValue +// Get the value of a number attribute in an attribute map as float. +// FPDF_StructElement_Attr_GetType() should have returned +// FPDF_OBJECT_NUMBER for this property. +// Parameters: +// value - Handle to the value. +// out_value - A pointer to variable that will receive the value. Not +// filled if false is returned. +// Return value: +// Returns TRUE if the attribute maps to a number value, FALSE +// otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDF_StructElement_Attr_GetNumberValue(FPDF_STRUCTELEMENT_ATTR_VALUE value, + float* out_value); + +// Experimental API. +// Function: FPDF_StructElement_Attr_GetStringValue +// Get the value of a string attribute in an attribute map as string. +// FPDF_StructElement_Attr_GetType() should have returned +// FPDF_OBJECT_STRING or FPDF_OBJECT_NAME for this property. +// Parameters: +// value - Handle to the value. +// buffer - A buffer for holding the returned key in UTF-16LE. +// This is only modified if |buflen| is longer than the +// length of the key. Optional, pass null to just +// retrieve the size of the buffer needed. +// buflen - The length of the buffer. +// out_buflen - A pointer to variable that will receive the minimum +// buffer size to contain the key. Not filled if FALSE is +// returned. +// Return value: +// Returns TRUE if the attribute maps to a string value, FALSE +// otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDF_StructElement_Attr_GetStringValue(FPDF_STRUCTELEMENT_ATTR_VALUE value, + void* buffer, + unsigned long buflen, + unsigned long* out_buflen); + +// Experimental API. +// Function: FPDF_StructElement_Attr_GetBlobValue +// Get the value of a blob attribute in an attribute map as string. +// Parameters: +// value - Handle to the value. +// buffer - A buffer for holding the returned value. This is only +// modified if |buflen| is at least as long as the length +// of the value. Optional, pass null to just retrieve the +// size of the buffer needed. +// buflen - The length of the buffer. +// out_buflen - A pointer to variable that will receive the minimum +// buffer size to contain the key. Not filled if FALSE is +// returned. +// Return value: +// Returns TRUE if the attribute maps to a string value, FALSE +// otherwise. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDF_StructElement_Attr_GetBlobValue(FPDF_STRUCTELEMENT_ATTR_VALUE value, + void* buffer, + unsigned long buflen, + unsigned long* out_buflen); + +// Experimental API. +// Function: FPDF_StructElement_Attr_CountChildren +// Count the number of children values in an attribute. +// Parameters: +// value - Handle to the value. +// Return value: +// The number of children, or -1 on error. +FPDF_EXPORT int FPDF_CALLCONV +FPDF_StructElement_Attr_CountChildren(FPDF_STRUCTELEMENT_ATTR_VALUE value); + +// Experimental API. +// Function: FPDF_StructElement_Attr_GetChildAtIndex +// Get a child from an attribute. +// Parameters: +// value - Handle to the value. +// index - The index for the child, 0-based. +// Return value: +// The child at the n-th index or NULL on error. +// Comments: +// The |index| must be less than the +// FPDF_StructElement_Attr_CountChildren() return value. +FPDF_EXPORT FPDF_STRUCTELEMENT_ATTR_VALUE FPDF_CALLCONV +FPDF_StructElement_Attr_GetChildAtIndex(FPDF_STRUCTELEMENT_ATTR_VALUE value, + int index); + +// Experimental API. +// Function: FPDF_StructElement_GetMarkedContentIdCount +// Get the count of marked content ids for a given element. +// Parameters: +// struct_element - Handle to the struct element. +// Return value: +// The count of marked content ids or -1 if none exists. +FPDF_EXPORT int FPDF_CALLCONV +FPDF_StructElement_GetMarkedContentIdCount(FPDF_STRUCTELEMENT struct_element); + +// Experimental API. +// Function: FPDF_StructElement_GetMarkedContentIdAtIndex +// Get the marked content id at a given index for a given element. +// Parameters: +// struct_element - Handle to the struct element. +// index - The index of the marked content id, 0-based. +// Return value: +// The marked content ID of the element. If no ID exists, returns +// -1. +// Comments: +// The |index| must be less than the +// FPDF_StructElement_GetMarkedContentIdCount() return value. +// This will likely supersede FPDF_StructElement_GetMarkedContentID(). +FPDF_EXPORT int FPDF_CALLCONV +FPDF_StructElement_GetMarkedContentIdAtIndex(FPDF_STRUCTELEMENT struct_element, + int index); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // PUBLIC_FPDF_STRUCTTREE_H_ diff --git a/src/main/jni/include/fpdf_sysfontinfo.h b/src/main/jni/include/fpdf_sysfontinfo.h index c2da74b7..2dac855a 100644 --- a/src/main/jni/include/fpdf_sysfontinfo.h +++ b/src/main/jni/include/fpdf_sysfontinfo.h @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,9 +7,13 @@ #ifndef PUBLIC_FPDF_SYSFONTINFO_H_ #define PUBLIC_FPDF_SYSFONTINFO_H_ +#include + +// clang-format off +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" -/* Character sets for the font */ +// Character sets for the font #define FXFONT_ANSI_CHARSET 0 #define FXFONT_DEFAULT_CHARSET 1 #define FXFONT_SYMBOL_CHARSET 2 @@ -17,13 +21,20 @@ #define FXFONT_HANGEUL_CHARSET 129 #define FXFONT_GB2312_CHARSET 134 #define FXFONT_CHINESEBIG5_CHARSET 136 +#define FXFONT_GREEK_CHARSET 161 +#define FXFONT_VIETNAMESE_CHARSET 163 +#define FXFONT_HEBREW_CHARSET 177 +#define FXFONT_ARABIC_CHARSET 178 +#define FXFONT_CYRILLIC_CHARSET 204 +#define FXFONT_THAI_CHARSET 222 +#define FXFONT_EASTERNEUROPEAN_CHARSET 238 -/* Font pitch and family flags */ -#define FXFONT_FF_FIXEDPITCH 1 +// Font pitch and family flags +#define FXFONT_FF_FIXEDPITCH (1 << 0) #define FXFONT_FF_ROMAN (1 << 4) #define FXFONT_FF_SCRIPT (4 << 4) -/* Typical weight values */ +// Typical weight values #define FXFONT_FW_NORMAL 400 #define FXFONT_FW_BOLD 700 @@ -32,87 +43,74 @@ extern "C" { #endif -/** - * Interface: FPDF_SYSFONTINFO - * Interface for getting system font information and font mapping - */ +// Interface: FPDF_SYSFONTINFO +// Interface for getting system font information and font mapping typedef struct _FPDF_SYSFONTINFO { - /** - * Version number of the interface. Currently must be 1. - **/ + // Version number of the interface. Currently must be 1. int version; - /** - * Method: Release - * Give implementation a chance to release any data after the - * interface is no longer used - * Interface Version: - * 1 - * Implementation Required: - * No - * Comments: - * Called by Foxit SDK during the final cleanup process. - * Parameters: - * pThis - Pointer to the interface structure itself - * Return Value: - * None - */ + // Method: Release + // Give implementation a chance to release any data after the + // interface is no longer used. + // Interface Version: + // 1 + // Implementation Required: + // No + // Parameters: + // pThis - Pointer to the interface structure itself + // Return Value: + // None + // Comments: + // Called by PDFium during the final cleanup process. void (*Release)(struct _FPDF_SYSFONTINFO* pThis); - /** - * Method: EnumFonts - * Enumerate all fonts installed on the system - * Interface Version: - * 1 - * Implementation Required: - * No - * Comments: - * Implementation should call FPDF_AddIntalledFont() function for - * each font found. - * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK. - * Parameters: - * pThis - Pointer to the interface structure itself - * pMapper - An opaque pointer to internal font mapper, used - * when calling FPDF_AddInstalledFont - * Return Value: - * None - */ + // Method: EnumFonts + // Enumerate all fonts installed on the system + // Interface Version: + // 1 + // Implementation Required: + // No + // Parameters: + // pThis - Pointer to the interface structure itself + // pMapper - An opaque pointer to internal font mapper, used + // when calling FPDF_AddInstalledFont(). + // Return Value: + // None + // Comments: + // Implementations should call FPDF_AddInstalledFont() function for + // each font found. Only TrueType/OpenType and Type1 fonts are + // accepted by PDFium. void (*EnumFonts)(struct _FPDF_SYSFONTINFO* pThis, void* pMapper); - /** - * Method: MapFont - * Use the system font mapper to get a font handle from requested - *parameters - * Interface Version: - * 1 - * Implementation Required: - * Yes only if GetFont method is not implemented. - * Comments: - * If the system supports native font mapper (like Windows), - *implementation can implement this method to get a font handle. - * Otherwise, Foxit SDK will do the mapping and then call GetFont - *method. - * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK. - * Parameters: - * pThis - Pointer to the interface structure itself - * weight - Weight of the requested font. 400 is normal and - *700 is bold. - * bItalic - Italic option of the requested font, TRUE or - *FALSE. - * charset - Character set identifier for the requested font. - *See above defined constants. - * pitch_family - A combination of flags. See above defined - *constants. - * face - Typeface name. Currently use system local encoding - *only. - * bExact - Pointer to a boolean value receiving the indicator - *whether mapper found the exact match. - * If mapper is not sure whether it's exact match, - *ignore this paramter. - * Return Value: - * An opaque pointer for font handle, or NULL if system mapping is - *not supported. - **/ + // Method: MapFont + // Use the system font mapper to get a font handle from requested + // parameters. + // Interface Version: + // 1 + // Implementation Required: + // Required if GetFont method is not implemented. + // Parameters: + // pThis - Pointer to the interface structure itself + // weight - Weight of the requested font. 400 is normal and + // 700 is bold. + // bItalic - Italic option of the requested font, TRUE or + // FALSE. + // charset - Character set identifier for the requested font. + // See above defined constants. + // pitch_family - A combination of flags. See above defined + // constants. + // face - Typeface name. Currently use system local encoding + // only. + // bExact - Obsolete: this parameter is now ignored. + // Return Value: + // An opaque pointer for font handle, or NULL if system mapping is + // not supported. + // Comments: + // If the system supports native font mapper (like Windows), + // implementation can implement this method to get a font handle. + // Otherwise, PDFium will do the mapping and then call GetFont + // method. Only TrueType/OpenType and Type1 fonts are accepted + // by PDFium. void* (*MapFont)(struct _FPDF_SYSFONTINFO* pThis, int weight, FPDF_BOOL bItalic, @@ -121,179 +119,196 @@ typedef struct _FPDF_SYSFONTINFO { const char* face, FPDF_BOOL* bExact); - /** - * Method: GetFont - * Get a handle to a particular font by its internal ID - * Interface Version: - * 1 - * Implementation Required: - * Yes only if MapFont method is not implemented. - * Comments: - * If the system mapping not supported, Foxit SDK will do the font - *mapping and use this method to get a font handle. - * Parameters: - * pThis - Pointer to the interface structure itself - * face - Typeface name. Currently use system local encoding - *only. - * Return Value: - * An opaque pointer for font handle. - **/ + // Method: GetFont + // Get a handle to a particular font by its internal ID + // Interface Version: + // 1 + // Implementation Required: + // Required if MapFont method is not implemented. + // Return Value: + // An opaque pointer for font handle. + // Parameters: + // pThis - Pointer to the interface structure itself + // face - Typeface name in system local encoding. + // Comments: + // If the system mapping not supported, PDFium will do the font + // mapping and use this method to get a font handle. void* (*GetFont)(struct _FPDF_SYSFONTINFO* pThis, const char* face); - /** - * Method: GetFontData - * Get font data from a font - * Interface Version: - * 1 - * Implementation Required: - * Yes - * Comments: - * Can read either full font file, or a particular TrueType/OpenType - *table - * Parameters: - * pThis - Pointer to the interface structure itself - * hFont - Font handle returned by MapFont or GetFont method - * table - TrueType/OpenType table identifier (refer to - *TrueType specification). - * 0 for the whole font file. - * buffer - The buffer receiving the font data. Can be NULL if - *not provided - * buf_size - Buffer size, can be zero if not provided - * Return Value: - * Number of bytes needed, if buffer not provided or not large - *enough, - * or number of bytes written into buffer otherwise. - **/ + // Method: GetFontData + // Get font data from a font + // Interface Version: + // 1 + // Implementation Required: + // Yes + // Parameters: + // pThis - Pointer to the interface structure itself + // hFont - Font handle returned by MapFont or GetFont method + // table - TrueType/OpenType table identifier (refer to + // TrueType specification), or 0 for the whole file. + // buffer - The buffer receiving the font data. Can be NULL if + // not provided. + // buf_size - Buffer size, can be zero if not provided. + // Return Value: + // Number of bytes needed, if buffer not provided or not large + // enough, or number of bytes written into buffer otherwise. + // Comments: + // Can read either the full font file, or a particular + // TrueType/OpenType table. unsigned long (*GetFontData)(struct _FPDF_SYSFONTINFO* pThis, void* hFont, unsigned int table, unsigned char* buffer, unsigned long buf_size); - /** - * Method: GetFaceName - * Get face name from a font handle - * Interface Version: - * 1 - * Implementation Required: - * No - * Parameters: - * pThis - Pointer to the interface structure itself - * hFont - Font handle returned by MapFont or GetFont method - * buffer - The buffer receiving the face name. Can be NULL if - *not provided - * buf_size - Buffer size, can be zero if not provided - * Return Value: - * Number of bytes needed, if buffer not provided or not large - *enough, - * or number of bytes written into buffer otherwise. - **/ + // Method: GetFaceName + // Get face name from a font handle + // Interface Version: + // 1 + // Implementation Required: + // No + // Parameters: + // pThis - Pointer to the interface structure itself + // hFont - Font handle returned by MapFont or GetFont method + // buffer - The buffer receiving the face name. Can be NULL if + // not provided + // buf_size - Buffer size, can be zero if not provided + // Return Value: + // Number of bytes needed, if buffer not provided or not large + // enough, or number of bytes written into buffer otherwise. unsigned long (*GetFaceName)(struct _FPDF_SYSFONTINFO* pThis, void* hFont, char* buffer, unsigned long buf_size); - /** - * Method: GetFontCharset - * Get character set information for a font handle - * Interface Version: - * 1 - * Implementation Required: - * No - * Parameters: - * pThis - Pointer to the interface structure itself - * hFont - Font handle returned by MapFont or GetFont method - * Return Value: - * Character set identifier. See defined constants above. - **/ + // Method: GetFontCharset + // Get character set information for a font handle + // Interface Version: + // 1 + // Implementation Required: + // No + // Parameters: + // pThis - Pointer to the interface structure itself + // hFont - Font handle returned by MapFont or GetFont method + // Return Value: + // Character set identifier. See defined constants above. int (*GetFontCharset)(struct _FPDF_SYSFONTINFO* pThis, void* hFont); - /** - * Method: DeleteFont - * Delete a font handle - * Interface Version: - * 1 - * Implementation Required: - * Yes - * Parameters: - * pThis - Pointer to the interface structure itself - * hFont - Font handle returned by MapFont or GetFont method - * Return Value: - * None - **/ + // Method: DeleteFont + // Delete a font handle + // Interface Version: + // 1 + // Implementation Required: + // Yes + // Parameters: + // pThis - Pointer to the interface structure itself + // hFont - Font handle returned by MapFont or GetFont method + // Return Value: + // None void (*DeleteFont)(struct _FPDF_SYSFONTINFO* pThis, void* hFont); } FPDF_SYSFONTINFO; -/** - * Struct: FPDF_CharsetFontMap - * Provides the name of a font to use for a given charset value. - **/ +// Struct: FPDF_CharsetFontMap +// Provides the name of a font to use for a given charset value. typedef struct FPDF_CharsetFontMap_ { int charset; // Character Set Enum value, see FXFONT_*_CHARSET above. const char* fontname; // Name of default font to use with that charset. } FPDF_CharsetFontMap; -/** - * Function: FPDF_GetDefaultTTFMap - * Returns a pointer to the default character set to TT Font name map. The - * map is an array of FPDF_CharsetFontMap structs, with its end indicated - * by a { -1, NULL } entry. - * Parameters: - * None. - * Return Value: - * Pointer to the Charset Font Map. - **/ -DLLEXPORT const FPDF_CharsetFontMap* STDCALL FPDF_GetDefaultTTFMap(); +// Function: FPDF_GetDefaultTTFMap +// Returns a pointer to the default character set to TT Font name map. The +// map is an array of FPDF_CharsetFontMap structs, with its end indicated +// by a { -1, NULL } entry. +// Parameters: +// None. +// Return Value: +// Pointer to the Charset Font Map. +// Note: +// Once FPDF_GetDefaultTTFMapCount() and FPDF_GetDefaultTTFMapEntry() are no +// longer experimental, this API will be marked as deprecated. +// See https://crbug.com/348468114 +FPDF_EXPORT const FPDF_CharsetFontMap* FPDF_CALLCONV FPDF_GetDefaultTTFMap(); + +// Experimental API. +// +// Function: FPDF_GetDefaultTTFMapCount +// Returns the number of entries in the default character set to TT Font name +// map. +// Parameters: +// None. +// Return Value: +// The number of entries in the map. +FPDF_EXPORT size_t FPDF_CALLCONV FPDF_GetDefaultTTFMapCount(); + +// Experimental API. +// +// Function: FPDF_GetDefaultTTFMapEntry +// Returns an entry in the default character set to TT Font name map. +// Parameters: +// index - The index to the entry in the map to retrieve. +// Return Value: +// A pointer to the entry, if it is in the map, or NULL if the index is out +// of bounds. +FPDF_EXPORT const FPDF_CharsetFontMap* FPDF_CALLCONV +FPDF_GetDefaultTTFMapEntry(size_t index); + +// Function: FPDF_AddInstalledFont +// Add a system font to the list in PDFium. +// Comments: +// This function is only called during the system font list building +// process. +// Parameters: +// mapper - Opaque pointer to Foxit font mapper +// face - The font face name +// charset - Font character set. See above defined constants. +// Return Value: +// None. +FPDF_EXPORT void FPDF_CALLCONV FPDF_AddInstalledFont(void* mapper, + const char* face, + int charset); -/** - * Function: FPDF_AddInstalledFont - * Add a system font to the list in Foxit SDK. - * Comments: - * This function is only called during the system font list building - *process. - * Parameters: - * mapper - Opaque pointer to Foxit font mapper - * face - The font face name - * charset - Font character set. See above defined constants. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper, - const char* face, - int charset); +// Function: FPDF_SetSystemFontInfo +// Set the system font info interface into PDFium +// Parameters: +// pFontInfo - Pointer to a FPDF_SYSFONTINFO structure +// Return Value: +// None +// Comments: +// Platform support implementation should implement required methods of +// FFDF_SYSFONTINFO interface, then call this function during PDFium +// initialization process. +// +// Call this with NULL to tell PDFium to stop using a previously set +// |FPDF_SYSFONTINFO|. +FPDF_EXPORT void FPDF_CALLCONV +FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfo); -/** - * Function: FPDF_SetSystemFontInfo - * Set the system font info interface into Foxit SDK - * Comments: - * Platform support implementation should implement required methods of - *FFDF_SYSFONTINFO interface, - * then call this function during SDK initialization process. - * Parameters: - * pFontInfo - Pointer to a FPDF_SYSFONTINFO structure - * Return Value: - * None - **/ -DLLEXPORT void STDCALL FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfo); +// Function: FPDF_GetDefaultSystemFontInfo +// Get default system font info interface for current platform +// Parameters: +// None +// Return Value: +// Pointer to a FPDF_SYSFONTINFO structure describing the default +// interface, or NULL if the platform doesn't have a default interface. +// Application should call FPDF_FreeDefaultSystemFontInfo to free the +// returned pointer. +// Comments: +// For some platforms, PDFium implements a default version of system +// font info interface. The default implementation can be passed to +// FPDF_SetSystemFontInfo(). +FPDF_EXPORT FPDF_SYSFONTINFO* FPDF_CALLCONV FPDF_GetDefaultSystemFontInfo(); -/** - * Function: FPDF_GetDefaultSystemFontInfo - * Get default system font info interface for current platform - * Comments: - * For some platforms Foxit SDK implement a default version of system - *font info interface. - * The default implementation can be used in FPDF_SetSystemFontInfo - *function. - * Parameters: - * None - * Return Value: - * Pointer to a FPDF_SYSFONTINFO structure describing the default - *interface. - * Or NULL if the platform doesn't have a default interface. - * Application should call FPDF_FreeMemory to free the returned - *pointer. - **/ -DLLEXPORT FPDF_SYSFONTINFO* STDCALL FPDF_GetDefaultSystemFontInfo(); +// Function: FPDF_FreeDefaultSystemFontInfo +// Free a default system font info interface +// Parameters: +// pFontInfo - Pointer to a FPDF_SYSFONTINFO structure +// Return Value: +// None +// Comments: +// This function should be called on the output from +// FPDF_GetDefaultSystemFontInfo() once it is no longer needed. +FPDF_EXPORT void FPDF_CALLCONV +FPDF_FreeDefaultSystemFontInfo(FPDF_SYSFONTINFO* pFontInfo); #ifdef __cplusplus } diff --git a/src/main/jni/include/fpdf_text.h b/src/main/jni/include/fpdf_text.h index 32cc1318..fe96ccd5 100644 --- a/src/main/jni/include/fpdf_text.h +++ b/src/main/jni/include/fpdf_text.h @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,6 +7,8 @@ #ifndef PUBLIC_FPDF_TEXT_H_ #define PUBLIC_FPDF_TEXT_H_ +// clang-format off +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" // Exported Functions @@ -18,7 +20,7 @@ extern "C" { // Prepare information about all characters in a page. // Parameters: // page - Handle to the page. Returned by FPDF_LoadPage function -// (in FPDFVIEW module). +// (in FPDFVIEW module). // Return value: // A handle to the text page information structure. // NULL if something goes wrong. @@ -26,24 +28,24 @@ extern "C" { // Application must call FPDFText_ClosePage to release the text page // information. // -DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page); +FPDF_EXPORT FPDF_TEXTPAGE FPDF_CALLCONV FPDFText_LoadPage(FPDF_PAGE page); // Function: FPDFText_ClosePage // Release all resources allocated for a text page information // structure. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // Return Value: // None. // -DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page); +FPDF_EXPORT void FPDF_CALLCONV FPDFText_ClosePage(FPDF_TEXTPAGE text_page); // Function: FPDFText_CountChars // Get number of characters in a page. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // Return value: // Number of characters in the page. Return -1 for error. // Generated characters, like additional space characters, new line @@ -55,13 +57,13 @@ DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page); // first character in the page // has an index value of zero. // -DLLEXPORT int STDCALL FPDFText_CountChars(FPDF_TEXTPAGE text_page); +FPDF_EXPORT int FPDF_CALLCONV FPDFText_CountChars(FPDF_TEXTPAGE text_page); // Function: FPDFText_GetUnicode // Get Unicode of a character in a page. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // index - Zero-based index of the character. // Return value: // The Unicode of the particular character. @@ -69,187 +71,426 @@ DLLEXPORT int STDCALL FPDFText_CountChars(FPDF_TEXTPAGE text_page); // convert to Unicode, // the return value will be zero. // -DLLEXPORT unsigned int STDCALL FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, - int index); +FPDF_EXPORT unsigned int FPDF_CALLCONV +FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, int index); + +// Experimental API. +// Function: FPDFText_GetTextObject +// Get the FPDF_PAGEOBJECT associated with a given character. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// index - Zero-based index of the character. +// Return value: +// The associated text object for the character at |index|, or NULL on +// error. The returned text object, if non-null, is of type +// |FPDF_PAGEOBJ_TEXT|. The caller does not own the returned object. +// +FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV +FPDFText_GetTextObject(FPDF_TEXTPAGE text_page, int index); + +// Experimental API. +// Function: FPDFText_IsGenerated +// Get if a character in a page is generated by PDFium. +// 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 generated by PDFium. +// 0 if the character is not generated by PDFium. +// -1 if there was an error. +// +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. +// 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 has an invalid unicode mapping. +// 0 if the character has no known unicode mapping issues. +// -1 if there was an error. +// +FPDF_EXPORT int FPDF_CALLCONV +FPDFText_HasUnicodeMapError(FPDF_TEXTPAGE text_page, int index); // Function: FPDFText_GetFontSize // Get the font size of a particular character. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // index - Zero-based index of the character. // Return value: // 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"). +// 1/72 inch). This is the typographic size of the font (so called +// "em size"). +// +FPDF_EXPORT double FPDF_CALLCONV FPDFText_GetFontSize(FPDF_TEXTPAGE text_page, + int index); + +// Experimental API. +// Function: FPDFText_GetFontInfo +// Get the font name and flags of a particular character. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// index - Zero-based index of the character. +// buffer - A buffer receiving the font name. +// buflen - The length of |buffer| in bytes. +// flags - Optional pointer to an int receiving the font flags. +// These flags should be interpreted per PDF spec 1.7 +// Section 5.7.1 Font Descriptor Flags. +// Return value: +// On success, return the length of the font name, including the +// trailing NUL character, in bytes. If this length is less than or +// equal to |length|, |buffer| is set to the font name, |flags| is +// set to the font flags. |buffer| is in UTF-8 encoding. Return 0 on +// failure. +// +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFText_GetFontInfo(FPDF_TEXTPAGE text_page, + int index, + void* buffer, + unsigned long buflen, + int* flags); + +// Experimental API. +// Function: FPDFText_GetFontWeight +// Get the font weight of a particular character. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// index - Zero-based index of the character. +// Return value: +// On success, return the font weight of the particular character. If +// |text_page| is invalid, if |index| is out of bounds, or if the +// character's text object is undefined, return -1. +// +FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetFontWeight(FPDF_TEXTPAGE text_page, + int index); + +// Experimental API. +// Function: FPDFText_GetFillColor +// Get the fill color of a particular character. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// index - Zero-based index of the character. +// R - Pointer to an unsigned int number receiving the +// red value of the fill color. +// G - Pointer to an unsigned int number receiving the +// green value of the fill color. +// B - Pointer to an unsigned int number receiving the +// blue value of the fill color. +// A - Pointer to an unsigned int number receiving the +// alpha value of the fill color. +// Return value: +// Whether the call succeeded. If false, |R|, |G|, |B| and |A| are +// unchanged. +// +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFText_GetFillColor(FPDF_TEXTPAGE text_page, + int index, + unsigned int* R, + unsigned int* G, + unsigned int* B, + unsigned int* A); + +// Experimental API. +// Function: FPDFText_GetStrokeColor +// Get the stroke color of a particular character. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// index - Zero-based index of the character. +// R - Pointer to an unsigned int number receiving the +// red value of the stroke color. +// G - Pointer to an unsigned int number receiving the +// green value of the stroke color. +// B - Pointer to an unsigned int number receiving the +// blue value of the stroke color. +// A - Pointer to an unsigned int number receiving the +// alpha value of the stroke color. +// Return value: +// Whether the call succeeded. If false, |R|, |G|, |B| and |A| are +// unchanged. // -DLLEXPORT double STDCALL FPDFText_GetFontSize(FPDF_TEXTPAGE text_page, - int index); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFText_GetStrokeColor(FPDF_TEXTPAGE text_page, + int index, + unsigned int* R, + unsigned int* G, + unsigned int* B, + unsigned int* A); + +// Experimental API. +// Function: FPDFText_GetCharAngle +// Get character rotation angle. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// index - Zero-based index of the character. +// Return Value: +// On success, return the angle value in radian. Value will always be +// greater or equal to 0. If |text_page| is invalid, or if |index| is +// out of bounds, then return -1. +// +FPDF_EXPORT float FPDF_CALLCONV FPDFText_GetCharAngle(FPDF_TEXTPAGE text_page, + int index); // Function: FPDFText_GetCharBox // Get bounding box of a particular character. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // index - Zero-based index of the character. // left - Pointer to a double number receiving left position -// of the character box. +// of the character box. // right - Pointer to a double number receiving right position -// of the character box. +// of the character box. // bottom - Pointer to a double number receiving bottom position -// of the character box. +// of the character box. // top - Pointer to a double number receiving top position of -// the character box. +// the character box. // Return Value: -// None. +// On success, return TRUE and fill in |left|, |right|, |bottom|, and +// |top|. If |text_page| is invalid, or if |index| is out of bounds, +// then return FALSE, and the out parameters remain unmodified. // Comments: // All positions are measured in PDF "user space". // -DLLEXPORT void STDCALL FPDFText_GetCharBox(FPDF_TEXTPAGE text_page, - int index, - double* left, - double* right, - double* bottom, - double* top); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetCharBox(FPDF_TEXTPAGE text_page, + int index, + double* left, + double* right, + double* bottom, + double* top); + +// Experimental API. +// Function: FPDFText_GetLooseCharBox +// Get a "loose" bounding box of a particular character, i.e., covering +// the entire glyph bounds, without taking the actual glyph shape into +// account. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// index - Zero-based index of the character. +// rect - Pointer to a FS_RECTF receiving the character box. +// Return Value: +// On success, return TRUE and fill in |rect|. If |text_page| is +// invalid, or if |index| is out of bounds, then return FALSE, and the +// |rect| out parameter remains unmodified. +// Comments: +// All positions are measured in PDF "user space". +// +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFText_GetLooseCharBox(FPDF_TEXTPAGE text_page, int index, FS_RECTF* rect); + +// Experimental API. +// Function: FPDFText_GetMatrix +// Get the effective transformation matrix for a particular character. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage(). +// index - Zero-based index of the character. +// matrix - Pointer to a FS_MATRIX receiving the transformation +// matrix. +// Return Value: +// On success, return TRUE and fill in |matrix|. If |text_page| is +// invalid, or if |index| is out of bounds, or if |matrix| is NULL, +// then return FALSE, and |matrix| remains unmodified. +// +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetMatrix(FPDF_TEXTPAGE text_page, + int index, + FS_MATRIX* matrix); + +// Function: FPDFText_GetCharOrigin +// Get origin of a particular character. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// index - Zero-based index of the character. +// x - Pointer to a double number receiving x coordinate of +// the character origin. +// y - Pointer to a double number receiving y coordinate of +// the character origin. +// Return Value: +// Whether the call succeeded. If false, x and y are unchanged. +// Comments: +// All positions are measured in PDF "user space". +// +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFText_GetCharOrigin(FPDF_TEXTPAGE text_page, + int index, + double* x, + double* y); // Function: FPDFText_GetCharIndexAtPos // Get the index of a character at or nearby a certain position on the // page. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // x - X position in PDF "user space". // y - Y position in PDF "user space". // xTolerance - An x-axis tolerance value for character hit -// detection, in point unit. +// detection, in point units. // yTolerance - A y-axis tolerance value for character hit -// detection, in point unit. +// detection, in point units. // Return Value: // The zero-based index of the character at, or nearby the point (x,y). // If there is no character at or nearby the point, return value will -// be -1. -// If an error occurs, -3 will be returned. +// be -1. If an error occurs, -3 will be returned. // -DLLEXPORT int STDCALL FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page, - double x, - double y, - double xTolerance, - double yTolerance); +FPDF_EXPORT int FPDF_CALLCONV +FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page, + double x, + double y, + double xTolerance, + double yTolerance); // Function: FPDFText_GetText // Extract unicode text string from the page. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // start_index - Index for the start characters. -// count - Number of characters to be extracted. +// count - Number of UCS-2 values to be extracted. // result - A buffer (allocated by application) receiving the -// extracted unicodes. -// The size of the buffer must be able to hold the -// number of characters plus a terminator. +// extracted UCS-2 values. The buffer must be able to +// hold `count` UCS-2 values plus a terminator. // Return Value: // Number of characters written into the result buffer, including the // trailing terminator. // Comments: -// This function ignores characters without unicode information. +// This function ignores characters without UCS-2 representations. +// It considers all characters on the page, even those that are not +// visible when the page has a cropbox. To filter out the characters +// outside of the cropbox, use FPDF_GetPageBoundingBox() and +// FPDFText_GetCharBox(). // -DLLEXPORT int STDCALL FPDFText_GetText(FPDF_TEXTPAGE text_page, - int start_index, - int count, - unsigned short* result); +FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetText(FPDF_TEXTPAGE text_page, + int start_index, + int count, + unsigned short* result); // Function: FPDFText_CountRects -// Count number of rectangular areas occupied by a segment of texts. +// Counts number of rectangular areas occupied by a segment of text, +// and caches the result for subsequent FPDFText_GetRect() calls. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. -// start_index - Index for the start characters. -// count - Number of characters. +// Returned by FPDFText_LoadPage function. +// start_index - Index for the start character. +// count - Number of characters, or -1 for all remaining. // Return value: -// Number of rectangles. Zero for error. +// Number of rectangles, 0 if text_page is null, or -1 on bad +// start_index. // Comments: // 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. -// FPDFTEXT will automatically merge small character boxes into bigger -// one if those characters -// are on the same line and use same font settings. +// applications to detect the position on the page for a text segment, +// so proper areas can be highlighted. The FPDFText_* functions will +// automatically merge small character boxes into bigger one if those +// characters are on the same line and use same font settings. // -DLLEXPORT int STDCALL FPDFText_CountRects(FPDF_TEXTPAGE text_page, - int start_index, - int count); +FPDF_EXPORT int FPDF_CALLCONV FPDFText_CountRects(FPDF_TEXTPAGE text_page, + int start_index, + int count); // Function: FPDFText_GetRect // Get a rectangular area from the result generated by // FPDFText_CountRects. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // rect_index - Zero-based index for the rectangle. // left - Pointer to a double value receiving the rectangle -// left boundary. +// left boundary. // top - Pointer to a double value receiving the rectangle -// top boundary. +// top boundary. // right - Pointer to a double value receiving the rectangle -// right boundary. +// right boundary. // bottom - Pointer to a double value receiving the rectangle -// bottom boundary. +// bottom boundary. // Return Value: -// None. +// On success, return TRUE and fill in |left|, |top|, |right|, and +// |bottom|. If |text_page| is invalid then return FALSE, and the out +// parameters remain unmodified. If |text_page| is valid but +// |rect_index| is out of bounds, then return FALSE and set the out +// parameters to 0. // -DLLEXPORT void STDCALL FPDFText_GetRect(FPDF_TEXTPAGE text_page, - int rect_index, - double* left, - double* top, - double* right, - double* bottom); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetRect(FPDF_TEXTPAGE text_page, + int rect_index, + double* left, + double* top, + double* right, + double* bottom); // Function: FPDFText_GetBoundedText // Extract unicode text within a rectangular boundary on the page. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // left - Left boundary. // top - Top boundary. // right - Right boundary. // bottom - Bottom boundary. -// buffer - A unicode buffer. -// buflen - Number of characters (not bytes) for the buffer, -// excluding an additional terminator. +// buffer - Caller-allocated buffer to receive UTF-16 values. +// buflen - Number of UTF-16 values (not bytes) that `buffer` +// is capable of holding. // Return Value: -// If buffer is NULL or buflen is zero, return number of characters -// (not bytes) of text present within -// the rectangle, excluding a terminating NUL. Generally you should -// pass a buffer at least one larger -// than this if you want a terminating NUL, which will be provided if -// space is available. -// Otherwise, return number of characters copied into the buffer, -// including the terminating NUL -// when space for it is available. +// If buffer is NULL or buflen is zero, return number of UTF-16 +// values (not bytes) of text present within the rectangle, excluding +// a terminating NUL. Generally you should pass a buffer at least one +// larger than this if you want a terminating NUL, which will be +// provided if space is available. Otherwise, return number of UTF-16 +// values copied into the buffer, including the terminating NUL when +// space for it is available. // Comment: // If the buffer is too small, as much text as will fit is copied into -// it. +// it. May return a split surrogate in that case. // -DLLEXPORT int STDCALL FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page, - double left, - double top, - double right, - double bottom, - unsigned short* buffer, - int buflen); +FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page, + double left, + double top, + double right, + double bottom, + unsigned short* buffer, + int buflen); // Flags used by FPDFText_FindStart function. -#define FPDF_MATCHCASE \ - 0x00000001 // If not set, it will not match case by default. -#define FPDF_MATCHWHOLEWORD \ - 0x00000002 // If not set, it will not match the whole word by default. +// +// If not set, it will not match case by default. +#define FPDF_MATCHCASE 0x00000001 +// If not set, it will not match the whole word by default. +#define FPDF_MATCHWHOLEWORD 0x00000002 +// If not set, it will skip past the current match to look for the next match. +#define FPDF_CONSECUTIVE 0x00000004 // Function: FPDFText_FindStart // Start a search. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // findwhat - A unicode match pattern. // flags - Option flags. // start_index - Start from this character. -1 for end of the page. @@ -257,85 +498,83 @@ DLLEXPORT int STDCALL FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page, // A handle for the search context. FPDFText_FindClose must be called // to release this handle. // -DLLEXPORT FPDF_SCHHANDLE STDCALL FPDFText_FindStart(FPDF_TEXTPAGE text_page, - FPDF_WIDESTRING findwhat, - unsigned long flags, - int start_index); +FPDF_EXPORT FPDF_SCHHANDLE FPDF_CALLCONV +FPDFText_FindStart(FPDF_TEXTPAGE text_page, + FPDF_WIDESTRING findwhat, + unsigned long flags, + int start_index); // Function: FPDFText_FindNext // Search in the direction from page start to end. // Parameters: // handle - A search context handle returned by -// FPDFText_FindStart. +// FPDFText_FindStart. // Return Value: // Whether a match is found. // -DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindNext(FPDF_SCHHANDLE handle); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_FindNext(FPDF_SCHHANDLE handle); // Function: FPDFText_FindPrev // Search in the direction from page end to start. // Parameters: // handle - A search context handle returned by -// FPDFText_FindStart. +// FPDFText_FindStart. // Return Value: // Whether a match is found. // -DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindPrev(FPDF_SCHHANDLE handle); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_FindPrev(FPDF_SCHHANDLE handle); // Function: FPDFText_GetSchResultIndex // Get the starting character index of the search result. // Parameters: // handle - A search context handle returned by -// FPDFText_FindStart. +// FPDFText_FindStart. // Return Value: // Index for the starting character. // -DLLEXPORT int STDCALL FPDFText_GetSchResultIndex(FPDF_SCHHANDLE handle); +FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetSchResultIndex(FPDF_SCHHANDLE handle); // Function: FPDFText_GetSchCount // Get the number of matched characters in the search result. // Parameters: // handle - A search context handle returned by -// FPDFText_FindStart. +// FPDFText_FindStart. // Return Value: // Number of matched characters. // -DLLEXPORT int STDCALL FPDFText_GetSchCount(FPDF_SCHHANDLE handle); +FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetSchCount(FPDF_SCHHANDLE handle); // Function: FPDFText_FindClose // Release a search context. // Parameters: // handle - A search context handle returned by -// FPDFText_FindStart. +// FPDFText_FindStart. // Return Value: // None. // -DLLEXPORT void STDCALL FPDFText_FindClose(FPDF_SCHHANDLE handle); +FPDF_EXPORT void FPDF_CALLCONV FPDFText_FindClose(FPDF_SCHHANDLE handle); // Function: FPDFLink_LoadWebLinks // Prepare information about weblinks in a page. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // Return Value: -// A handle to the page's links information structure. +// A handle to the page's links information structure, or // NULL if something goes wrong. // Comments: // Weblinks are those links implicitly embedded in PDF pages. PDF also -// has a type of -// annotation called "link", FPDFTEXT doesn't deal with that kind of -// link. -// FPDFTEXT weblink feature is useful for automatically detecting links -// in the page -// contents. For example, things like "http://www.foxitsoftware.com" -// will be detected, -// so applications can allow user to click on those characters to -// activate the link, -// even the PDF doesn't come with link annotations. +// has a type of annotation called "link" (FPDFTEXT doesn't deal with +// that kind of link). FPDFTEXT weblink feature is useful for +// automatically detecting links in the page contents. For example, +// things like "https://www.example.com" will be detected, so +// applications can allow user to click on those characters to activate +// the link, even the PDF doesn't come with link annotations. // // FPDFLink_CloseWebLinks must be called to release resources. // -DLLEXPORT FPDF_PAGELINK STDCALL FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page); +FPDF_EXPORT FPDF_PAGELINK FPDF_CALLCONV +FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page); // Function: FPDFLink_CountWebLinks // Count number of detected web links. @@ -344,25 +583,31 @@ DLLEXPORT FPDF_PAGELINK STDCALL FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page); // Return Value: // Number of detected web links. // -DLLEXPORT int STDCALL FPDFLink_CountWebLinks(FPDF_PAGELINK link_page); +FPDF_EXPORT int FPDF_CALLCONV FPDFLink_CountWebLinks(FPDF_PAGELINK link_page); // Function: FPDFLink_GetURL // Fetch the URL information for a detected web link. // Parameters: // link_page - Handle returned by FPDFLink_LoadWebLinks. // link_index - Zero-based index for the link. -// buffer - A unicode buffer. -// buflen - Number of characters (not bytes) for the buffer, -// including an additional terminator. +// buffer - A unicode buffer for the result. +// buflen - Number of 16-bit code units (not bytes) for the +// buffer, including an additional terminator. // Return Value: -// If buffer is NULL or buflen is zero, return number of characters -// (not bytes and an additional terminator is also counted) needed, -// otherwise, return number of characters copied into the buffer. +// If |buffer| is NULL or |buflen| is zero, return the number of 16-bit +// code units (not bytes) needed to buffer the result (an additional +// terminator is included in this count). +// Otherwise, copy the result into |buffer|, truncating at |buflen| if +// the result is too large to fit, and return the number of 16-bit code +// units actually copied into the buffer (the additional terminator is +// also included in this count). +// If |link_index| does not correspond to a valid link, then the result +// is an empty string. // -DLLEXPORT int STDCALL FPDFLink_GetURL(FPDF_PAGELINK link_page, - int link_index, - unsigned short* buffer, - int buflen); +FPDF_EXPORT int FPDF_CALLCONV FPDFLink_GetURL(FPDF_PAGELINK link_page, + int link_index, + unsigned short* buffer, + int buflen); // Function: FPDFLink_CountRects // Count number of rectangular areas for the link. @@ -370,10 +615,11 @@ DLLEXPORT int STDCALL FPDFLink_GetURL(FPDF_PAGELINK link_page, // link_page - Handle returned by FPDFLink_LoadWebLinks. // link_index - Zero-based index for the link. // Return Value: -// Number of rectangular areas for the link. +// Number of rectangular areas for the link. If |link_index| does +// not correspond to a valid link, then 0 is returned. // -DLLEXPORT int STDCALL FPDFLink_CountRects(FPDF_PAGELINK link_page, - int link_index); +FPDF_EXPORT int FPDF_CALLCONV FPDFLink_CountRects(FPDF_PAGELINK link_page, + int link_index); // Function: FPDFLink_GetRect // Fetch the boundaries of a rectangle for a link. @@ -382,23 +628,46 @@ DLLEXPORT int STDCALL FPDFLink_CountRects(FPDF_PAGELINK link_page, // link_index - Zero-based index for the link. // rect_index - Zero-based index for a rectangle. // left - Pointer to a double value receiving the rectangle -// left boundary. +// left boundary. // top - Pointer to a double value receiving the rectangle -// top boundary. +// top boundary. // right - Pointer to a double value receiving the rectangle -// right boundary. +// right boundary. // bottom - Pointer to a double value receiving the rectangle -// bottom boundary. +// bottom boundary. // Return Value: -// None. +// On success, return TRUE and fill in |left|, |top|, |right|, and +// |bottom|. If |link_page| is invalid or if |link_index| does not +// correspond to a valid link, then return FALSE, and the out +// parameters remain unmodified. +// +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFLink_GetRect(FPDF_PAGELINK link_page, + int link_index, + int rect_index, + double* left, + double* top, + double* right, + double* bottom); + +// Experimental API. +// Function: FPDFLink_GetTextRange +// Fetch the start char index and char count for a link. +// Parameters: +// link_page - Handle returned by FPDFLink_LoadWebLinks. +// link_index - Zero-based index for the link. +// start_char_index - pointer to int receiving the start char index +// char_count - pointer to int receiving the char count +// Return Value: +// On success, return TRUE and fill in |start_char_index| and +// |char_count|. if |link_page| is invalid or if |link_index| does +// not correspond to a valid link, then return FALSE and the out +// parameters remain unmodified. // -DLLEXPORT void STDCALL FPDFLink_GetRect(FPDF_PAGELINK link_page, - int link_index, - int rect_index, - double* left, - double* top, - double* right, - double* bottom); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFLink_GetTextRange(FPDF_PAGELINK link_page, + int link_index, + int* start_char_index, + int* char_count); // Function: FPDFLink_CloseWebLinks // Release resources used by weblink feature. @@ -407,7 +676,7 @@ DLLEXPORT void STDCALL FPDFLink_GetRect(FPDF_PAGELINK link_page, // Return Value: // None. // -DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page); +FPDF_EXPORT void FPDF_CALLCONV FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page); #ifdef __cplusplus } diff --git a/src/main/jni/include/fpdf_thumbnail.h b/src/main/jni/include/fpdf_thumbnail.h new file mode 100644 index 00000000..27b6d497 --- /dev/null +++ b/src/main/jni/include/fpdf_thumbnail.h @@ -0,0 +1,59 @@ +// Copyright 2019 The PDFium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PUBLIC_FPDF_THUMBNAIL_H_ +#define PUBLIC_FPDF_THUMBNAIL_H_ + +#include + +// NOLINTNEXTLINE(build/include) +#include "fpdfview.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Experimental API. +// Gets the decoded data from the thumbnail of |page| if it exists. +// This only modifies |buffer| if |buflen| less than or equal to the +// size of the decoded data. Returns the size of the decoded +// data or 0 if thumbnail DNE. Optional, pass null to just retrieve +// the size of the buffer needed. +// +// page - handle to a page. +// buffer - buffer for holding the decoded image data. +// buflen - length of the buffer in bytes. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFPage_GetDecodedThumbnailData(FPDF_PAGE page, + void* buffer, + unsigned long buflen); + +// Experimental API. +// Gets the raw data from the thumbnail of |page| if it exists. +// This only modifies |buffer| if |buflen| is less than or equal to +// the size of the raw data. Returns the size of the raw data or 0 +// if thumbnail DNE. Optional, pass null to just retrieve the size +// of the buffer needed. +// +// page - handle to a page. +// buffer - buffer for holding the raw image data. +// buflen - length of the buffer in bytes. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDFPage_GetRawThumbnailData(FPDF_PAGE page, + void* buffer, + unsigned long buflen); + +// Experimental API. +// Returns the thumbnail of |page| as a FPDF_BITMAP. Returns a nullptr +// if unable to access the thumbnail's stream. +// +// page - handle to a page. +FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV +FPDFPage_GetThumbnailAsBitmap(FPDF_PAGE page); + +#ifdef __cplusplus +} +#endif + +#endif // PUBLIC_FPDF_THUMBNAIL_H_ diff --git a/src/main/jni/include/fpdf_transformpage.h b/src/main/jni/include/fpdf_transformpage.h index 569df2a7..3df743bd 100644 --- a/src/main/jni/include/fpdf_transformpage.h +++ b/src/main/jni/include/fpdf_transformpage.h @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,108 +7,187 @@ #ifndef PUBLIC_FPDF_TRANSFORMPAGE_H_ #define PUBLIC_FPDF_TRANSFORMPAGE_H_ +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" #ifdef __cplusplus extern "C" { #endif -typedef void* FPDF_PAGEARCSAVER; -typedef void* FPDF_PAGEARCLOADER; - -/** -* Set "MediaBox" entry to the page dictionary. -* @param[in] page - Handle to a page. -* @param[in] left - The left of the rectangle. -* @param[in] bottom - The bottom of the rectangle. -* @param[in] right - The right of the rectangle. -* @param[in] top - The top of the rectangle. -* @retval None. -*/ -DLLEXPORT void STDCALL FPDFPage_SetMediaBox(FPDF_PAGE page, - float left, - float bottom, - float right, - float top); - -/** -* Set "CropBox" entry to the page dictionary. -* @param[in] page - Handle to a page. -* @param[in] left - The left of the rectangle. -* @param[in] bottom - The bottom of the rectangle. -* @param[in] right - The right of the rectangle. -* @param[in] top - The top of the rectangle. -* @retval None. -*/ -DLLEXPORT void STDCALL FPDFPage_SetCropBox(FPDF_PAGE page, - float left, - float bottom, - float right, - float top); - -/** Get "MediaBox" entry from the page dictionary. -* @param[in] page - Handle to a page. -* @param[in] left - Pointer to a double value receiving the left of the -* rectangle. -* @param[in] bottom - Pointer to a double value receiving the bottom of the -* rectangle. -* @param[in] right - Pointer to a double value receiving the right of the -* rectangle. -* @param[in] top - Pointer to a double value receiving the top of the -* rectangle. -* @retval True if success,else fail. -*/ -DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetMediaBox(FPDF_PAGE page, - float* left, - float* bottom, - float* right, - float* top); - -/** Get "CropBox" entry from the page dictionary. -* @param[in] page - Handle to a page. -* @param[in] left - Pointer to a double value receiving the left of the -* rectangle. -* @param[in] bottom - Pointer to a double value receiving the bottom of the -* rectangle. -* @param[in] right - Pointer to a double value receiving the right of the -* rectangle. -* @param[in] top - Pointer to a double value receiving the top of the -* rectangle. -* @retval True if success,else fail. -*/ -DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetCropBox(FPDF_PAGE page, - float* left, - float* bottom, - float* right, - float* top); - -/** -* Transform the whole page with a specified matrix, then clip the page content -* region. -* -* @param[in] page - A page handle. -* @param[in] matrix - The transform matrix. -* @param[in] clipRect - A rectangle page area to be clipped. -* @Note. This function will transform the whole page, and would take effect to -* all the objects in the page. -*/ -DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, - FS_MATRIX* matrix, - FS_RECTF* clipRect); - -/** -* Transform (scale, rotate, shear, move) the clip path of page object. -* @param[in] page_object - Handle to a page object. Returned by -* FPDFPageObj_NewImageObj. -* @param[in] a - The coefficient "a" of the matrix. -* @param[in] b - The coefficient "b" of the matrix. -* @param[in] c - The coefficient "c" of the matrix. -* @param[in] d - The coefficient "d" of the matrix. -* @param[in] e - The coefficient "e" of the matrix. -* @param[in] f - The coefficient "f" of the matrix. -* @retval None. -*/ -DLLEXPORT void STDCALL +// Set "MediaBox" entry to the page dictionary. +// +// page - Handle to a page. +// left - The left of the rectangle. +// bottom - The bottom of the rectangle. +// right - The right of the rectangle. +// top - The top of the rectangle. +FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetMediaBox(FPDF_PAGE page, + float left, + float bottom, + float right, + float top); + +// Set "CropBox" entry to the page dictionary. +// +// page - Handle to a page. +// left - The left of the rectangle. +// bottom - The bottom of the rectangle. +// right - The right of the rectangle. +// top - The top of the rectangle. +FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetCropBox(FPDF_PAGE page, + float left, + float bottom, + float right, + float top); + +// Set "BleedBox" entry to the page dictionary. +// +// page - Handle to a page. +// left - The left of the rectangle. +// bottom - The bottom of the rectangle. +// right - The right of the rectangle. +// top - The top of the rectangle. +FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetBleedBox(FPDF_PAGE page, + float left, + float bottom, + float right, + float top); + +// Set "TrimBox" entry to the page dictionary. +// +// page - Handle to a page. +// left - The left of the rectangle. +// bottom - The bottom of the rectangle. +// right - The right of the rectangle. +// top - The top of the rectangle. +FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetTrimBox(FPDF_PAGE page, + float left, + float bottom, + float right, + float top); + +// Set "ArtBox" entry to the page dictionary. +// +// page - Handle to a page. +// left - The left of the rectangle. +// bottom - The bottom of the rectangle. +// right - The right of the rectangle. +// top - The top of the rectangle. +FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetArtBox(FPDF_PAGE page, + float left, + float bottom, + float right, + float top); + +// Get "MediaBox" entry from the page dictionary. +// +// page - Handle to a page. +// left - Pointer to a float value receiving the left of the rectangle. +// bottom - Pointer to a float value receiving the bottom of the rectangle. +// right - Pointer to a float value receiving the right of the rectangle. +// top - Pointer to a float value receiving the top of the rectangle. +// +// On success, return true and write to the out parameters. Otherwise return +// false and leave the out parameters unmodified. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetMediaBox(FPDF_PAGE page, + float* left, + float* bottom, + float* right, + float* top); + +// Get "CropBox" entry from the page dictionary. +// +// page - Handle to a page. +// left - Pointer to a float value receiving the left of the rectangle. +// bottom - Pointer to a float value receiving the bottom of the rectangle. +// right - Pointer to a float value receiving the right of the rectangle. +// top - Pointer to a float value receiving the top of the rectangle. +// +// On success, return true and write to the out parameters. Otherwise return +// false and leave the out parameters unmodified. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetCropBox(FPDF_PAGE page, + float* left, + float* bottom, + float* right, + float* top); + +// Get "BleedBox" entry from the page dictionary. +// +// page - Handle to a page. +// left - Pointer to a float value receiving the left of the rectangle. +// bottom - Pointer to a float value receiving the bottom of the rectangle. +// right - Pointer to a float value receiving the right of the rectangle. +// top - Pointer to a float value receiving the top of the rectangle. +// +// On success, return true and write to the out parameters. Otherwise return +// false and leave the out parameters unmodified. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetBleedBox(FPDF_PAGE page, + float* left, + float* bottom, + float* right, + float* top); + +// Get "TrimBox" entry from the page dictionary. +// +// page - Handle to a page. +// left - Pointer to a float value receiving the left of the rectangle. +// bottom - Pointer to a float value receiving the bottom of the rectangle. +// right - Pointer to a float value receiving the right of the rectangle. +// top - Pointer to a float value receiving the top of the rectangle. +// +// On success, return true and write to the out parameters. Otherwise return +// false and leave the out parameters unmodified. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetTrimBox(FPDF_PAGE page, + float* left, + float* bottom, + float* right, + float* top); + +// Get "ArtBox" entry from the page dictionary. +// +// page - Handle to a page. +// left - Pointer to a float value receiving the left of the rectangle. +// bottom - Pointer to a float value receiving the bottom of the rectangle. +// right - Pointer to a float value receiving the right of the rectangle. +// top - Pointer to a float value receiving the top of the rectangle. +// +// On success, return true and write to the out parameters. Otherwise return +// false and leave the out parameters unmodified. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetArtBox(FPDF_PAGE page, + float* left, + float* bottom, + float* right, + float* top); + +// Apply transforms to |page|. +// +// If |matrix| is provided it will be applied to transform the page. +// If |clipRect| is provided it will be used to clip the resulting page. +// If neither |matrix| or |clipRect| are provided this method returns |false|. +// Returns |true| if transforms are applied. +// +// This function will transform the whole page, and would take effect to all the +// objects in the page. +// +// page - Page handle. +// matrix - Transform matrix. +// clipRect - Clipping rectangle. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPage_TransFormWithClip(FPDF_PAGE page, + const FS_MATRIX* matrix, + const FS_RECTF* clipRect); + +// Transform (scale, rotate, shear, move) the clip path of page object. +// page_object - Handle to a page object. Returned by +// FPDFPageObj_NewImageObj(). +// +// a - The coefficient "a" of the matrix. +// b - The coefficient "b" of the matrix. +// c - The coefficient "c" of the matrix. +// d - The coefficient "d" of the matrix. +// e - The coefficient "e" of the matrix. +// f - The coefficient "f" of the matrix. +FPDF_EXPORT void FPDF_CALLCONV FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object, double a, double b, @@ -117,41 +196,80 @@ FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object, double e, double f); -/** -* Create a new clip path, with a rectangle inserted. -* -* @param[in] left - The left of the clip box. -* @param[in] bottom - The bottom of the clip box. -* @param[in] right - The right of the clip box. -* @param[in] top - The top of the clip box. -* @retval a handle to the clip path. -*/ -DLLEXPORT FPDF_CLIPPATH STDCALL FPDF_CreateClipPath(float left, - float bottom, - float right, - float top); +// Experimental API. +// Get the clip path of the page object. +// +// page object - Handle to a page object. Returned by e.g. +// FPDFPage_GetObject(). +// +// Returns the handle to the clip path, or NULL on failure. The caller does not +// take ownership of the returned FPDF_CLIPPATH. Instead, it remains valid until +// FPDF_ClosePage() is called for the page containing |page_object|. +FPDF_EXPORT FPDF_CLIPPATH FPDF_CALLCONV +FPDFPageObj_GetClipPath(FPDF_PAGEOBJECT page_object); + +// Experimental API. +// Get number of paths inside |clip_path|. +// +// clip_path - handle to a clip_path. +// +// Returns the number of objects in |clip_path| or -1 on failure. +FPDF_EXPORT int FPDF_CALLCONV FPDFClipPath_CountPaths(FPDF_CLIPPATH clip_path); + +// Experimental API. +// Get number of segments inside one path of |clip_path|. +// +// clip_path - handle to a clip_path. +// path_index - index into the array of paths of the clip path. +// +// Returns the number of segments or -1 on failure. +FPDF_EXPORT int FPDF_CALLCONV +FPDFClipPath_CountPathSegments(FPDF_CLIPPATH clip_path, int path_index); + +// Experimental API. +// Get segment in one specific path of |clip_path| at index. +// +// clip_path - handle to a clip_path. +// path_index - the index of a path. +// segment_index - the index of a segment. +// +// Returns the handle to the segment, or NULL on failure. The caller does not +// take ownership of the returned FPDF_PATHSEGMENT. Instead, it remains valid +// until FPDF_ClosePage() is called for the page containing |clip_path|. +FPDF_EXPORT FPDF_PATHSEGMENT FPDF_CALLCONV +FPDFClipPath_GetPathSegment(FPDF_CLIPPATH clip_path, + int path_index, + int segment_index); + +// Create a new clip path, with a rectangle inserted. +// +// Caller takes ownership of the returned FPDF_CLIPPATH. It should be freed with +// FPDF_DestroyClipPath(). +// +// left - The left of the clip box. +// bottom - The bottom of the clip box. +// right - The right of the clip box. +// top - The top of the clip box. +FPDF_EXPORT FPDF_CLIPPATH FPDF_CALLCONV FPDF_CreateClipPath(float left, + float bottom, + float right, + float top); + +// Destroy the clip path. +// +// clipPath - A handle to the clip path. It will be invalid after this call. +FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath); -/** -* Destroy the clip path. -* -* @param[in] clipPath - A handle to the clip path. -* Destroy the clip path. -* @retval None. -*/ -DLLEXPORT void STDCALL FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath); - -/** -* Clip the page content, the page content that outside the clipping region -* become invisible. -* -* @param[in] page - A page handle. -* @param[in] clipPath - A handle to the clip path. -* @Note. A clip path will be inserted before the page content stream or content -* array. In this way, the page content will be clipped -* by this clip path. -*/ -DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page, - FPDF_CLIPPATH clipPath); +// Clip the page content, the page content that outside the clipping region +// become invisible. +// +// A clip path will be inserted before the page content stream or content array. +// In this way, the page content will be clipped by this clip path. +// +// page - A page handle. +// clipPath - A handle to the clip path. (Does not take ownership.) +FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertClipPath(FPDF_PAGE page, + FPDF_CLIPPATH clipPath); #ifdef __cplusplus } diff --git a/src/main/jni/include/fpdfview.h b/src/main/jni/include/fpdfview.h index 87312925..97e055fa 100644 --- a/src/main/jni/include/fpdfview.h +++ b/src/main/jni/include/fpdfview.h @@ -1,62 +1,102 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +// This is the main header file for embedders of PDFium. It provides APIs to +// initialize the library, load documents, and render pages, amongst other +// things. +// +// NOTE: None of the PDFium APIs are thread-safe. They expect to be called +// from a single thread. Barring that, embedders are required to ensure (via +// a mutex or similar) that only a single PDFium call can be made at a time. +// // NOTE: External docs refer to this file as "fpdfview.h", so do not rename -// despite lack of consitency with other public files. +// despite lack of consistency with other public files. #ifndef PUBLIC_FPDFVIEW_H_ #define PUBLIC_FPDFVIEW_H_ +// clang-format off + +#include + #if defined(_WIN32) && !defined(__WINDOWS__) #include #endif #ifdef PDF_ENABLE_XFA -// TODO: remove the #define when XFA is officially in pdfium +// PDF_USE_XFA is set in confirmation that this version of PDFium can support +// XFA forms as requested by the PDF_ENABLE_XFA setting. #define PDF_USE_XFA #endif // PDF_ENABLE_XFA -// PDF types -typedef void* FPDF_ACTION; -typedef void* FPDF_BITMAP; -typedef void* FPDF_BOOKMARK; -typedef void* FPDF_CLIPPATH; -typedef void* FPDF_DEST; -typedef void* FPDF_DOCSCHHANDLE; -typedef void* FPDF_DOCUMENT; -typedef void* FPDF_FONT; -typedef void* FPDF_HMODULE; -typedef void* FPDF_LINK; -typedef void* FPDF_MODULEMGR; -typedef void* FPDF_PAGE; -typedef void* FPDF_PAGELINK; -typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc) -typedef void* FPDF_PAGERANGE; -typedef void* FPDF_PATH; -typedef void* FPDF_SCHHANDLE; -typedef void* FPDF_TEXTPAGE; - -#ifdef PDF_ENABLE_XFA -typedef void* FPDF_STRINGHANDLE; -typedef void* FPDF_WIDGET; -#endif // PDF_ENABLE_XFA +// PDF object types +#define FPDF_OBJECT_UNKNOWN 0 +#define FPDF_OBJECT_BOOLEAN 1 +#define FPDF_OBJECT_NUMBER 2 +#define FPDF_OBJECT_STRING 3 +#define FPDF_OBJECT_NAME 4 +#define FPDF_OBJECT_ARRAY 5 +#define FPDF_OBJECT_DICTIONARY 6 +#define FPDF_OBJECT_STREAM 7 +#define FPDF_OBJECT_NULLOBJ 8 +#define FPDF_OBJECT_REFERENCE 9 + +// PDF text rendering modes +typedef enum { + FPDF_TEXTRENDERMODE_UNKNOWN = -1, + FPDF_TEXTRENDERMODE_FILL = 0, + FPDF_TEXTRENDERMODE_STROKE = 1, + FPDF_TEXTRENDERMODE_FILL_STROKE = 2, + FPDF_TEXTRENDERMODE_INVISIBLE = 3, + FPDF_TEXTRENDERMODE_FILL_CLIP = 4, + FPDF_TEXTRENDERMODE_STROKE_CLIP = 5, + FPDF_TEXTRENDERMODE_FILL_STROKE_CLIP = 6, + FPDF_TEXTRENDERMODE_CLIP = 7, + FPDF_TEXTRENDERMODE_LAST = FPDF_TEXTRENDERMODE_CLIP, +} FPDF_TEXT_RENDERMODE; + +// PDF types - use incomplete types (never completed) to force API type safety. +typedef struct fpdf_action_t__* FPDF_ACTION; +typedef struct fpdf_annotation_t__* FPDF_ANNOTATION; +typedef struct fpdf_attachment_t__* FPDF_ATTACHMENT; +typedef struct fpdf_avail_t__* FPDF_AVAIL; +typedef struct fpdf_bitmap_t__* FPDF_BITMAP; +typedef struct fpdf_bookmark_t__* FPDF_BOOKMARK; +typedef struct fpdf_clippath_t__* FPDF_CLIPPATH; +typedef struct fpdf_dest_t__* FPDF_DEST; +typedef struct fpdf_document_t__* FPDF_DOCUMENT; +typedef struct fpdf_font_t__* FPDF_FONT; +typedef struct fpdf_form_handle_t__* FPDF_FORMHANDLE; +typedef const struct fpdf_glyphpath_t__* FPDF_GLYPHPATH; +typedef struct fpdf_javascript_action_t* FPDF_JAVASCRIPT_ACTION; +typedef struct fpdf_link_t__* FPDF_LINK; +typedef struct fpdf_page_t__* FPDF_PAGE; +typedef struct fpdf_pagelink_t__* FPDF_PAGELINK; +typedef struct fpdf_pageobject_t__* FPDF_PAGEOBJECT; // (text, path, etc.) +typedef struct fpdf_pageobjectmark_t__* FPDF_PAGEOBJECTMARK; +typedef const struct fpdf_pagerange_t__* FPDF_PAGERANGE; +typedef const struct fpdf_pathsegment_t* FPDF_PATHSEGMENT; +typedef struct fpdf_schhandle_t__* FPDF_SCHHANDLE; +typedef const struct fpdf_signature_t__* FPDF_SIGNATURE; +typedef void* FPDF_SKIA_CANVAS; // Passed into Skia as an SkCanvas. +typedef struct fpdf_structelement_t__* FPDF_STRUCTELEMENT; +typedef const struct fpdf_structelement_attr_t__* FPDF_STRUCTELEMENT_ATTR; +typedef const struct fpdf_structelement_attr_value_t__* +FPDF_STRUCTELEMENT_ATTR_VALUE; +typedef struct fpdf_structtree_t__* FPDF_STRUCTTREE; +typedef struct fpdf_textpage_t__* FPDF_TEXTPAGE; +typedef struct fpdf_widget_t__* FPDF_WIDGET; +typedef struct fpdf_xobject_t__* FPDF_XOBJECT; // Basic data types typedef int FPDF_BOOL; -typedef int FPDF_ERROR; +typedef int FPDF_RESULT; typedef unsigned long FPDF_DWORD; typedef float FS_FLOAT; -#ifdef PDF_ENABLE_XFA -typedef void* FPDF_LPVOID; -typedef void const* FPDF_LPCVOID; -typedef char const* FPDF_LPCSTR; -typedef int FPDF_RESULT; -#endif - // Duplex types typedef enum _FPDF_DUPLEXTYPE_ { DuplexUndefined = 0, @@ -67,26 +107,24 @@ typedef enum _FPDF_DUPLEXTYPE_ { // String types typedef unsigned short FPDF_WCHAR; -typedef unsigned char const* FPDF_LPCBYTE; -// FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE -// encoded), and platform dependent string +// The public PDFium API uses three types of strings: byte string, wide string +// (UTF-16LE encoded), and platform dependent string. + +// Public PDFium API type for byte strings. typedef const char* FPDF_BYTESTRING; -// FPDFSDK always uses UTF-16LE encoded wide strings, each character uses 2 -// bytes (except surrogation), with the low byte first. -typedef const unsigned short* FPDF_WIDESTRING; +// The public PDFium API always uses UTF-16LE encoded wide strings, each +// character uses 2 bytes (except surrogation), with the low byte first. +typedef const FPDF_WCHAR* FPDF_WIDESTRING; -#ifdef PDF_ENABLE_XFA -// Structure for a byte string. -// Note, a byte string commonly means a UTF-16LE formated string. -typedef struct _FPDF_BSTR { - // String buffer. - char* str; - // Length of the string, in bytes. - int len; +// Structure for persisting a string beyond the duration of a callback. +// Note: although represented as a char*, string may be interpreted as +// a UTF-16LE formated string. Used only by XFA callbacks. +typedef struct FPDF_BSTR_ { + char* str; // String buffer, manipulate only with FPDF_BStr_* methods. + int len; // Length of the string, in bytes. } FPDF_BSTR; -#endif // PDF_ENABLE_XFA // For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a // Windows unicode string, however, special care needs to be taken if you @@ -95,13 +133,16 @@ typedef struct _FPDF_BSTR { // For Linux/Unix programmers: most compiler/library environments use 4 bytes // for a Unicode character, and you have to convert between FPDF_WIDESTRING and // system wide string by yourself. -#ifdef _WIN32_WCE -typedef const unsigned short* FPDF_STRING; -#else typedef const char* FPDF_STRING; -#endif -// Matrix for transformation. +// Matrix for transformation, in the form [a b c d e f], equivalent to: +// | a b 0 | +// | c d 0 | +// | e f 1 | +// +// Translation is performed with [1 0 0 1 tx ty]. +// Scaling is performed with [sx 0 0 sy 0 0]. +// See PDF Reference 1.7, 4.2.2 Common Transformations for more. typedef struct _FS_MATRIX_ { float a; float b; @@ -126,13 +167,60 @@ typedef struct _FS_RECTF_ { // Const Pointer to FS_RECTF structure. typedef const FS_RECTF* FS_LPCRECTF; -#if defined(_WIN32) && defined(FPDFSDK_EXPORTS) -// On Windows system, functions are exported in a DLL -#define DLLEXPORT __declspec(dllexport) -#define STDCALL __stdcall +// Rectangle size. Coordinate system agnostic. +typedef struct FS_SIZEF_ { + float width; + float height; +} * FS_LPSIZEF, FS_SIZEF; + +// Const Pointer to FS_SIZEF structure. +typedef const FS_SIZEF* FS_LPCSIZEF; + +// 2D Point. Coordinate system agnostic. +typedef struct FS_POINTF_ { + float x; + float y; +} * FS_LPPOINTF, FS_POINTF; + +// Const Pointer to FS_POINTF structure. +typedef const FS_POINTF* FS_LPCPOINTF; + +typedef struct _FS_QUADPOINTSF { + FS_FLOAT x1; + FS_FLOAT y1; + FS_FLOAT x2; + FS_FLOAT y2; + FS_FLOAT x3; + FS_FLOAT y3; + FS_FLOAT x4; + FS_FLOAT y4; +} FS_QUADPOINTSF; + +// Annotation enums. +typedef int FPDF_ANNOTATION_SUBTYPE; +typedef int FPDF_ANNOT_APPEARANCEMODE; + +// Dictionary value types. +typedef int FPDF_OBJECT_TYPE; + +#if defined(WIN32) +#if defined(FPDF_IMPLEMENTATION) +#define FPDF_EXPORT __declspec(dllexport) +#else +#define FPDF_EXPORT __declspec(dllimport) +#endif // defined(FPDF_IMPLEMENTATION) +#else +#if defined(FPDF_IMPLEMENTATION) +#define FPDF_EXPORT __attribute__((visibility("default"))) +#else +#define FPDF_EXPORT +#endif // defined(FPDF_IMPLEMENTATION) +#endif // defined(WIN32) + +#if defined(WIN32) && defined(FPDFSDK_EXPORTS) +#define FPDF_CALLCONV __stdcall #else -#define DLLEXPORT -#define STDCALL +#define FPDF_CALLCONV #endif // Exported Functions @@ -140,20 +228,19 @@ typedef const FS_RECTF* FS_LPCRECTF; extern "C" { #endif -// Function: FPDF_InitLibrary -// Initialize the FPDFSDK library -// Parameters: -// None -// Return value: -// None. -// Comments: -// Convenience function to call FPDF_InitLibraryWithConfig() for -// backwards comatibility purposes. -DLLEXPORT void STDCALL FPDF_InitLibrary(); +// PDF renderer types - Experimental. +// Selection of 2D graphics library to use for rendering to FPDF_BITMAPs. +typedef enum { + // Anti-Grain Geometry - https://sourceforge.net/projects/agg/ + FPDF_RENDERERTYPE_AGG = 0, + // Skia - https://skia.org/ + FPDF_RENDERERTYPE_SKIA = 1, +} FPDF_RENDERER_TYPE; // Process-wide options for initializing the library. typedef struct FPDF_LIBRARY_CONFIG_ { // Version number of the interface. Currently must be 2. + // Support for version 1 will be deprecated in the future. int version; // Array of paths to scan in place of the defaults when using built-in @@ -164,18 +251,33 @@ typedef struct FPDF_LIBRARY_CONFIG_ { // Version 2. - // pointer to the v8::Isolate to use, or NULL to force PDFium to create one. + // Pointer to the v8::Isolate to use, or NULL to force PDFium to create one. void* m_pIsolate; // The embedder data slot to use in the v8::Isolate to store PDFium's - // per-isolate data. The value needs to be between 0 and - // v8::Internals::kNumIsolateDataLots (exclusive). Note that 0 is fine - // for most embedders. + // per-isolate data. The value needs to be in the range + // [0, |v8::Internals::kNumIsolateDataLots|). Note that 0 is fine for most + // embedders. unsigned int m_v8EmbedderSlot; + + // Version 3 - Experimental. + + // Pointer to the V8::Platform to use. + void* m_pPlatform; + + // Version 4 - Experimental. + + // Explicit specification of core renderer to use. |m_RendererType| must be + // a valid value for |FPDF_LIBRARY_CONFIG| versions of this level or higher, + // or else the initialization will fail with an immediate crash. + // Note that use of a specified |FPDF_RENDERER_TYPE| value for which the + // corresponding render library is not included in the build will similarly + // fail with an immediate crash. + FPDF_RENDERER_TYPE m_RendererType; } FPDF_LIBRARY_CONFIG; // Function: FPDF_InitLibraryWithConfig -// Initialize the FPDFSDK library +// Initialize the PDFium library and allocate global resources for it. // Parameters: // config - configuration information as above. // Return value: @@ -183,21 +285,37 @@ typedef struct FPDF_LIBRARY_CONFIG_ { // Comments: // You have to call this function before you can call any PDF // processing functions. -DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig( - const FPDF_LIBRARY_CONFIG* config); +FPDF_EXPORT void FPDF_CALLCONV +FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* config); -// Function: FPDF_DestroyLibary -// Release all resources allocated by the FPDFSDK library. +// Function: FPDF_InitLibrary +// Initialize the PDFium library (alternative form). +// Parameters: +// None +// Return value: +// None. +// Comments: +// Convenience function to call FPDF_InitLibraryWithConfig() with a +// default configuration for backwards compatibility purposes. New +// code should call FPDF_InitLibraryWithConfig() instead. This will +// be deprecated in the future. +FPDF_EXPORT void FPDF_CALLCONV FPDF_InitLibrary(); + +// Function: FPDF_DestroyLibrary +// Release global resources allocated to the PDFium library by +// FPDF_InitLibrary() or FPDF_InitLibraryWithConfig(). // Parameters: // None. // Return value: // None. // Comments: -// You can call this function to release all memory blocks allocated by -// the library. -// After this function is called, you should not call any PDF +// After this function is called, you must not call any PDF // processing functions. -DLLEXPORT void STDCALL FPDF_DestroyLibrary(); +// +// Calling this function does not automatically close other +// objects. It is recommended to close other objects before +// closing the library with this function. +FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyLibrary(); // Policy for accessing the local machine time. #define FPDF_POLICY_MACHINETIME_ACCESS 0 @@ -210,8 +328,37 @@ DLLEXPORT void STDCALL FPDF_DestroyLibrary(); // enable - True to enable, false to disable the policy. // Return value: // None. -DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, - FPDF_BOOL enable); +FPDF_EXPORT void FPDF_CALLCONV FPDF_SetSandBoxPolicy(FPDF_DWORD policy, + FPDF_BOOL enable); + +#if defined(_WIN32) +// Experimental API. +// Function: FPDF_SetPrintMode +// Set printing mode when printing on Windows. +// Parameters: +// mode - FPDF_PRINTMODE_EMF to output EMF (default) +// FPDF_PRINTMODE_TEXTONLY to output text only (for charstream +// devices) +// FPDF_PRINTMODE_POSTSCRIPT2 to output level 2 PostScript into +// EMF as a series of GDI comments. +// FPDF_PRINTMODE_POSTSCRIPT3 to output level 3 PostScript into +// EMF as a series of GDI comments. +// FPDF_PRINTMODE_POSTSCRIPT2_PASSTHROUGH to output level 2 +// PostScript via ExtEscape() in PASSTHROUGH mode. +// FPDF_PRINTMODE_POSTSCRIPT3_PASSTHROUGH to output level 3 +// PostScript via ExtEscape() in PASSTHROUGH mode. +// FPDF_PRINTMODE_EMF_IMAGE_MASKS to output EMF, with more +// efficient processing of documents containing image masks. +// FPDF_PRINTMODE_POSTSCRIPT3_TYPE42 to output level 3 +// PostScript with embedded Type 42 fonts, when applicable, into +// EMF as a series of GDI comments. +// FPDF_PRINTMODE_POSTSCRIPT3_TYPE42_PASSTHROUGH to output level +// 3 PostScript with embedded Type 42 fonts, when applicable, +// via ExtEscape() in PASSTHROUGH mode. +// Return value: +// True if successful, false if unsuccessful (typically invalid input). +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_SetPrintMode(int mode); +#endif // defined(_WIN32) // Function: FPDF_LoadDocument // Open and load a PDF document. @@ -219,14 +366,23 @@ DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, // file_path - Path to the PDF file (including extension). // password - A string used as the password for the PDF file. // If no password is needed, empty or NULL can be used. +// See comments below regarding the encoding. // Return value: // A handle to the loaded document, or NULL on failure. // Comments: // Loaded document can be closed by FPDF_CloseDocument(). // If this function fails, you can use FPDF_GetLastError() to retrieve // the reason why it failed. -DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, - FPDF_BYTESTRING password); +// +// The encoding for |file_path| is UTF-8. +// +// The encoding for |password| can be either UTF-8 or Latin-1. PDFs, +// depending on the security handler revision, will only accept one or +// the other encoding. If |password|'s encoding and the PDF's expected +// encoding do not match, FPDF_LoadDocument() will automatically +// convert |password| to the other encoding. +FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV +FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BYTESTRING password); // Function: FPDF_LoadMemDocument // Open and load a PDF document from memory. @@ -242,13 +398,42 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, // The loaded document can be closed by FPDF_CloseDocument. // If this function fails, you can use FPDF_GetLastError() to retrieve // the reason why it failed. +// +// See the comments for FPDF_LoadDocument() regarding the encoding for +// |password|. +// Notes: +// If PDFium is built with the XFA module, the application should call +// FPDF_LoadXFA() function after the PDF document loaded to support XFA +// fields defined in the fpdfformfill.h file. +FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV +FPDF_LoadMemDocument(const void* data_buf, int size, FPDF_BYTESTRING password); + +// Experimental API. +// Function: FPDF_LoadMemDocument64 +// Open and load a PDF document from memory. +// Parameters: +// data_buf - Pointer to a buffer containing the PDF document. +// size - Number of bytes in the PDF document. +// password - A string used as the password for the PDF file. +// If no password is needed, empty or NULL can be used. +// Return value: +// A handle to the loaded document, or NULL on failure. +// Comments: +// The memory buffer must remain valid when the document is open. +// The loaded document can be closed by FPDF_CloseDocument. +// If this function fails, you can use FPDF_GetLastError() to retrieve +// the reason why it failed. +// +// See the comments for FPDF_LoadDocument() regarding the encoding for +// |password|. // Notes: // If PDFium is built with the XFA module, the application should call // FPDF_LoadXFA() function after the PDF document loaded to support XFA // fields defined in the fpdfformfill.h file. -DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, - int size, - FPDF_BYTESTRING password); +FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV +FPDF_LoadMemDocument64(const void* data_buf, + size_t size, + FPDF_BYTESTRING password); // Structure for custom file access. typedef struct { @@ -257,8 +442,9 @@ typedef struct { // A function pointer for getting a block of data from a specific position. // Position is specified by byte offset from the beginning of the file. + // The pointer to the buffer is never NULL and the size is never 0. // The position and size will never go out of range of the file length. - // It may be possible for FPDFSDK to call this function multiple times for + // It may be possible for PDFium to call this function multiple times for // the same position. // Return value: should be non-zero if successful, zero for error. int (*m_GetBlock)(void* param, @@ -271,87 +457,86 @@ typedef struct { void* m_Param; } FPDF_FILEACCESS; -#ifdef PDF_ENABLE_XFA -/** - * @brief Structure for file reading or writing (I/O). - * - * @note This is a handler and should be implemented by callers. - */ -typedef struct _FPDF_FILEHANDLER { - /** - * @brief User-defined data. - * @note Callers can use this field to track controls. - */ - FPDF_LPVOID clientData; - /** - * @brief Callback function to release the current file stream object. - * - * @param[in] clientData Pointer to user-defined data. - * - * @return None. - */ - void (*Release)(FPDF_LPVOID clientData); - /** - * @brief Callback function to retrieve the current file stream size. - * - * @param[in] clientData Pointer to user-defined data. - * - * @return Size of file stream. - */ - FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData); - /** - * @brief Callback function to read data from the current file stream. - * - * @param[in] clientData Pointer to user-defined data. - * @param[in] offset Offset position starts from the beginning of file - * stream. This parameter indicates reading position. - * @param[in] buffer Memory buffer to store data which are read from - * file stream. This parameter should not be NULL. - * @param[in] size Size of data which should be read from file - * stream, in bytes. The buffer indicated by the parameter buffer - * should be enough to store specified data. - * - * @return 0 for success, other value for failure. - */ - FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPVOID buffer, FPDF_DWORD size); - /** - * @brief Callback function to write data into the current file stream. - * - * @param[in] clientData Pointer to user-defined data. - * @param[in] offset Offset position starts from the beginning of file - * stream. This parameter indicates writing position. - * @param[in] buffer Memory buffer contains data which is written into - * file stream. This parameter should not be NULL. - * @param[in] size Size of data which should be written into file - * stream, in bytes. - * - * @return 0 for success, other value for failure. - */ - FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPCVOID buffer, FPDF_DWORD size); - /** - * @brief Callback function to flush all internal accessing buffers. - * - * @param[in] clientData Pointer to user-defined data. - * - * @return 0 for success, other value for failure. - */ - FPDF_RESULT (*Flush)(FPDF_LPVOID clientData); - /** - * @brief Callback function to change file size. - * - * @details This function is called under writing mode usually. Implementer - * can determine whether to realize it based on application requests. - * - * @param[in] clientData Pointer to user-defined data. - * @param[in] size New size of file stream, in bytes. - * - * @return 0 for success, other value for failure. - */ - FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size); - -} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER; +// Structure for file reading or writing (I/O). +// +// Note: This is a handler and should be implemented by callers, +// and is only used from XFA. +typedef struct FPDF_FILEHANDLER_ { + // User-defined data. + // Note: Callers can use this field to track controls. + void* clientData; + + // Callback function to release the current file stream object. + // + // Parameters: + // clientData - Pointer to user-defined data. + // Returns: + // None. + void (*Release)(void* clientData); + + // Callback function to retrieve the current file stream size. + // + // Parameters: + // clientData - Pointer to user-defined data. + // Returns: + // Size of file stream. + FPDF_DWORD (*GetSize)(void* clientData); + + // Callback function to read data from the current file stream. + // + // Parameters: + // clientData - Pointer to user-defined data. + // offset - Offset position starts from the beginning of file + // stream. This parameter indicates reading position. + // buffer - Memory buffer to store data which are read from + // file stream. This parameter should not be NULL. + // size - Size of data which should be read from file stream, + // in bytes. The buffer indicated by |buffer| must be + // large enough to store specified data. + // Returns: + // 0 for success, other value for failure. + FPDF_RESULT (*ReadBlock)(void* clientData, + FPDF_DWORD offset, + void* buffer, + FPDF_DWORD size); + + // Callback function to write data into the current file stream. + // + // Parameters: + // clientData - Pointer to user-defined data. + // offset - Offset position starts from the beginning of file + // stream. This parameter indicates writing position. + // buffer - Memory buffer contains data which is written into + // file stream. This parameter should not be NULL. + // size - Size of data which should be written into file + // stream, in bytes. + // Returns: + // 0 for success, other value for failure. + FPDF_RESULT (*WriteBlock)(void* clientData, + FPDF_DWORD offset, + const void* buffer, + FPDF_DWORD size); + // Callback function to flush all internal accessing buffers. + // + // Parameters: + // clientData - Pointer to user-defined data. + // Returns: + // 0 for success, other value for failure. + FPDF_RESULT (*Flush)(void* clientData); + + // Callback function to change file size. + // + // Description: + // This function is called under writing mode usually. Implementer + // can determine whether to realize it based on application requests. + // Parameters: + // clientData - Pointer to user-defined data. + // size - New size of file stream, in bytes. + // Returns: + // 0 for success, other value for failure. + FPDF_RESULT (*Truncate)(void* clientData, FPDF_DWORD size); +} FPDF_FILEHANDLER; -#endif // Function: FPDF_LoadCustomDocument // Load PDF document from a custom access descriptor. // Parameters: @@ -360,15 +545,19 @@ typedef struct _FPDF_FILEHANDLER { // Return value: // A handle to the loaded document, or NULL on failure. // Comments: -// The application must keep the file resources valid until the PDF -// document is closed. +// The application must keep the file resources |pFileAccess| points to +// valid until the returned FPDF_DOCUMENT is closed. |pFileAccess| +// itself does not need to outlive the FPDF_DOCUMENT. // -// The loaded document can be closed with FPDF_CloseDocument. +// The loaded document can be closed with FPDF_CloseDocument(). +// +// See the comments for FPDF_LoadDocument() regarding the encoding for +// |password|. // Notes: // If PDFium is built with the XFA module, the application should call // FPDF_LoadXFA() function after the PDF document loaded to support XFA // fields defined in the fpdfformfill.h file. -DLLEXPORT FPDF_DOCUMENT STDCALL +FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password); // Function: FPDF_GetFileVersion @@ -382,8 +571,8 @@ FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password); // Comments: // If the document was created by FPDF_CreateNewDocument, // then this function will always fail. -DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, - int* fileVersion); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetFileVersion(FPDF_DOCUMENT doc, + int* fileVersion); #define FPDF_ERR_SUCCESS 0 // No error. #define FPDF_ERR_UNKNOWN 1 // Unknown error. @@ -405,18 +594,66 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, // A 32-bit integer indicating error code as defined above. // Comments: // If the previous SDK call succeeded, the return value of this -// function is not defined. -DLLEXPORT unsigned long STDCALL FPDF_GetLastError(); +// function is not defined. This function only works in conjunction +// with APIs that mention FPDF_GetLastError() in their documentation. +FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetLastError(); -// Function: FPDF_GetDocPermission +// Experimental API. +// Function: FPDF_DocumentHasValidCrossReferenceTable +// Whether the document's cross reference table is valid or not. +// Parameters: +// document - Handle to a document. Returned by FPDF_LoadDocument. +// Return value: +// True if the PDF parser did not encounter problems parsing the cross +// reference table. False if the parser could not parse the cross +// reference table and the table had to be rebuild from other data +// within the document. +// Comments: +// The return value can change over time as the PDF parser evolves. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDF_DocumentHasValidCrossReferenceTable(FPDF_DOCUMENT document); + +// Experimental API. +// Function: FPDF_GetTrailerEnds +// Get the byte offsets of trailer ends. +// Parameters: +// document - Handle to document. Returned by FPDF_LoadDocument(). +// buffer - The address of a buffer that receives the +// byte offsets. +// length - The size, in ints, of |buffer|. +// Return value: +// Returns the number of ints in the buffer on success, 0 on error. +// +// |buffer| is an array of integers that describes the exact byte offsets of the +// trailer ends in the document. If |length| is less than the returned length, +// or |document| or |buffer| is NULL, |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDF_GetTrailerEnds(FPDF_DOCUMENT document, + unsigned int* buffer, + unsigned long length); + +// 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. -DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document); +// 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. @@ -426,7 +663,8 @@ DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document); // The security handler revision number. Please refer to the PDF // Reference for a detailed description. If the document is not // protected, -1 will be returned. -DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document); +FPDF_EXPORT int FPDF_CALLCONV +FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document); // Function: FPDF_GetPageCount // Get total number of pages in the document. @@ -434,7 +672,7 @@ DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document); // document - Handle to document. Returned by FPDF_LoadDocument. // Return value: // Total number of pages in the document. -DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document); +FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageCount(FPDF_DOCUMENT document); // Function: FPDF_LoadPage // Load a page inside the document. @@ -446,8 +684,18 @@ DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document); // Comments: // The loaded page can be rendered to devices using FPDF_RenderPage. // The loaded page can be closed using FPDF_ClosePage. -DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, - int page_index); +FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDF_LoadPage(FPDF_DOCUMENT document, + int page_index); + +// Experimental API +// Function: FPDF_GetPageWidthF +// Get page width. +// Parameters: +// page - Handle to the page. Returned by FPDF_LoadPage(). +// Return value: +// Page width (excluding non-displayable area) measured in points. +// One point is 1/72 inch (around 0.3528 mm). +FPDF_EXPORT float FPDF_CALLCONV FPDF_GetPageWidthF(FPDF_PAGE page); // Function: FPDF_GetPageWidth // Get page width. @@ -456,7 +704,20 @@ DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, // Return value: // Page width (excluding non-displayable area) measured in points. // One point is 1/72 inch (around 0.3528 mm). -DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page); +// Note: +// Prefer FPDF_GetPageWidthF() above. This will be deprecated in the +// future. +FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageWidth(FPDF_PAGE page); + +// Experimental API +// Function: FPDF_GetPageHeightF +// Get page height. +// Parameters: +// page - Handle to the page. Returned by FPDF_LoadPage(). +// Return value: +// Page height (excluding non-displayable area) measured in points. +// One point is 1/72 inch (around 0.3528 mm) +FPDF_EXPORT float FPDF_CALLCONV FPDF_GetPageHeightF(FPDF_PAGE page); // Function: FPDF_GetPageHeight // Get page height. @@ -465,7 +726,38 @@ DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page); // Return value: // Page height (excluding non-displayable area) measured in points. // One point is 1/72 inch (around 0.3528 mm) -DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page); +// Note: +// Prefer FPDF_GetPageHeightF() above. This will be deprecated in the +// future. +FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageHeight(FPDF_PAGE page); + +// Experimental API. +// Function: FPDF_GetPageBoundingBox +// Get the bounding box of the page. This is the intersection between +// its media box and its crop box. +// Parameters: +// page - Handle to the page. Returned by FPDF_LoadPage. +// rect - Pointer to a rect to receive the page bounding box. +// On an error, |rect| won't be filled. +// Return value: +// True for success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetPageBoundingBox(FPDF_PAGE page, + FS_RECTF* rect); + +// Experimental API. +// Function: FPDF_GetPageSizeByIndexF +// Get the size of the page at the given index. +// Parameters: +// document - Handle to document. Returned by FPDF_LoadDocument(). +// page_index - Page index, zero for the first page. +// size - Pointer to a FS_SIZEF to receive the page size. +// (in points). +// Return value: +// Non-zero for success. 0 for error (document or page not found). +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDF_GetPageSizeByIndexF(FPDF_DOCUMENT document, + int page_index, + FS_SIZEF* size); // Function: FPDF_GetPageSizeByIndex // Get the size of the page at the given index. @@ -478,24 +770,28 @@ DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page); // (in points). // Return value: // Non-zero for success. 0 for error (document or page not found). -DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, - int page_index, - double* width, - double* height); +// Note: +// Prefer FPDF_GetPageSizeByIndexF() above. This will be deprecated in +// the future. +FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, + int page_index, + double* width, + double* height); // Page rendering flags. They can be combined with bit-wise OR. // // Set if annotations are to be rendered. #define FPDF_ANNOT 0x01 -// Set if using text rendering optimized for LCD display. +// Set if using text rendering optimized for LCD display. This flag will only +// take effect if anti-aliasing is enabled for text. #define FPDF_LCD_TEXT 0x02 // Don't use the native text output available on some platforms #define FPDF_NO_NATIVETEXT 0x04 // Grayscale output. #define FPDF_GRAYSCALE 0x08 -// Set if you want to get some debug info. +// Obsolete, has no effect, retained for compatibility. #define FPDF_DEBUG_INFO 0x80 -// Set if you don't want to catch exceptions. +// Obsolete, has no effect, retained for compatibility. #define FPDF_NO_CATCH 0x100 // Limit image cache size. #define FPDF_RENDER_LIMITEDIMAGECACHE 0x200 @@ -503,7 +799,8 @@ DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, #define FPDF_RENDER_FORCEHALFTONE 0x400 // Render for printing. #define FPDF_PRINTING 0x800 -// Set to disable anti-aliasing on text. +// Set to disable anti-aliasing on text. This flag will also disable LCD +// optimization for text rendering. #define FPDF_RENDER_NO_SMOOTHTEXT 0x1000 // Set to disable anti-aliasing on images. #define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000 @@ -512,6 +809,19 @@ DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, // Set whether to render in a reverse Byte order, this flag is only used when // rendering to a bitmap. #define FPDF_REVERSE_BYTE_ORDER 0x10 +// Set whether fill paths need to be stroked. This flag is only used when +// FPDF_COLORSCHEME is passed in, since with a single fill color for paths the +// boundaries of adjacent fill paths are less visible. +#define FPDF_CONVERT_FILL_TO_STROKE 0x20 + +// Struct for color scheme. +// Each should be a 32-bit value specifying the color, in 8888 ARGB format. +typedef struct FPDF_COLORSCHEME_ { + FPDF_DWORD path_fill_color; + FPDF_DWORD path_stroke_color; + FPDF_DWORD text_fill_color; + FPDF_DWORD text_stroke_color; +} FPDF_COLORSCHEME; #ifdef _WIN32 // Function: FPDF_RenderPage @@ -534,15 +844,16 @@ DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, // flags - 0 for normal display, or combination of flags // defined above. // Return value: -// None. -DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, - FPDF_PAGE page, - int start_x, - int start_y, - int size_x, - int size_y, - int rotate, - int flags); +// Returns true if the page is rendered successfully, false otherwise. + +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_RenderPage(HDC dc, + FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int flags); #endif // Function: FPDF_RenderPageBitmap @@ -550,7 +861,8 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, // Parameters: // bitmap - Handle to the device independent bitmap (as the // output buffer). The bitmap handle can be created -// by FPDFBitmap_Create. +// by FPDFBitmap_Create or retrieved from an image +// object by FPDFImageObj_GetBitmap. // page - Handle to the page. Returned by FPDF_LoadPage // start_x - Left pixel position of the display area in // bitmap coordinates. @@ -563,18 +875,63 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, // 1 (rotated 90 degrees clockwise) // 2 (rotated 180 degrees) // 3 (rotated 90 degrees counter-clockwise) -// flags - 0 for normal display, or combination of flags -// defined above. +// flags - 0 for normal display, or combination of the Page +// Rendering flags defined above. With the FPDF_ANNOT +// flag, it renders all annotations that do not require +// user-interaction, which are all annotations except +// widget and popup annotations. +// Return value: +// None. +FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, + FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int flags); + +// Function: FPDF_RenderPageBitmapWithMatrix +// Render contents of a page to a device independent bitmap. +// Parameters: +// bitmap - Handle to the device independent bitmap (as the +// output buffer). The bitmap handle can be created +// by FPDFBitmap_Create or retrieved by +// FPDFImageObj_GetBitmap. +// page - Handle to the page. Returned by FPDF_LoadPage. +// matrix - The transform matrix, which must be invertible. +// See PDF Reference 1.7, 4.2.2 Common Transformations. +// clipping - The rect to clip to in device coords. +// flags - 0 for normal display, or combination of the Page +// Rendering flags defined above. With the FPDF_ANNOT +// flag, it renders all annotations that do not require +// user-interaction, which are all annotations except +// widget and popup annotations. +// Return value: +// None. Note that behavior is undefined if det of |matrix| is 0. +FPDF_EXPORT void FPDF_CALLCONV +FPDF_RenderPageBitmapWithMatrix(FPDF_BITMAP bitmap, + FPDF_PAGE page, + const FS_MATRIX* matrix, + const FS_RECTF* clipping, + int flags); + +#if defined(PDF_USE_SKIA) +// Experimental API. +// Function: FPDF_RenderPageSkia +// Render contents of a page to a Skia SkCanvas. +// Parameters: +// canvas - SkCanvas to render to. +// page - Handle to the page. +// size_x - Horizontal size (in pixels) for displaying the page. +// size_y - Vertical size (in pixels) for displaying the page. // Return value: // None. -DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, - 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_RenderPageSkia(FPDF_SKIA_CANVAS canvas, + FPDF_PAGE page, + int size_x, + int size_y); +#endif // Function: FPDF_ClosePage // Close a loaded PDF page. @@ -582,7 +939,7 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, // page - Handle to the loaded page. // Return value: // None. -DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page); +FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page); // Function: FPDF_CloseDocument // Close a loaded PDF document. @@ -590,7 +947,7 @@ DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page); // document - Handle to the loaded document. // Return value: // None. -DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document); +FPDF_EXPORT void FPDF_CALLCONV FPDF_CloseDocument(FPDF_DOCUMENT document); // Function: FPDF_DeviceToPage // Convert the screen coordinates of a point to page coordinates. @@ -614,7 +971,8 @@ DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document); // page_y - A pointer to a double receiving the converted Y // value in page coordinates. // Return value: -// None. +// Returns true if the conversion succeeds, and |page_x| and |page_y| +// successfully receives the converted coordinates. // Comments: // The page coordinate system has its origin at the left-bottom corner // of the page, with the X-axis on the bottom going to the right, and @@ -632,16 +990,16 @@ DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document); // You must make sure the start_x, start_y, size_x, size_y // and rotate parameters have exactly same values as you used in // the FPDF_RenderPage() function call. -DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, - int start_x, - int start_y, - int size_x, - int size_y, - int rotate, - int device_x, - int device_y, - double* page_x, - double* page_y); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_DeviceToPage(FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int device_x, + int device_y, + double* page_x, + double* page_y); // Function: FPDF_PageToDevice // Convert the page coordinates of a point to screen coordinates. @@ -665,19 +1023,20 @@ DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, // device_y - A pointer to an integer receiving the result Y // value in device coordinates. // Return value: -// None. +// Returns true if the conversion succeeds, and |device_x| and +// |device_y| successfully receives the converted coordinates. // Comments: // See comments for FPDF_DeviceToPage(). -DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, - int start_x, - int start_y, - int size_x, - int size_y, - int rotate, - double page_x, - double page_y, - int* device_x, - int* device_y); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_PageToDevice(FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + double page_x, + double page_y, + int* device_x, + int* device_y); // Function: FPDFBitmap_Create // Create a device independent bitmap (FXDIB). @@ -707,12 +1066,15 @@ DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, // // This function allocates enough memory for holding all pixels in the // bitmap, but it doesn't initialize the buffer. Applications can use -// FPDFBitmap_FillRect to fill the bitmap using any color. -DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, - int height, - int alpha); +// FPDFBitmap_FillRect() to fill the bitmap using any color. If the OS +// allows it, this function can allocate up to 4 GB of memory. +FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_Create(int width, + int height, + int alpha); // More DIB formats +// Unknown or unsupported format. +#define FPDFBitmap_Unknown 0 // Gray scale bitmap, one byte per pixel. #define FPDFBitmap_Gray 1 // 3 bytes per pixel, byte order: blue, green, red. @@ -733,9 +1095,15 @@ DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, // above. // first_scan - A pointer to the first byte of the first line if // using an external buffer. If this parameter is NULL, -// then the a new buffer will be created. -// stride - Number of bytes for each scan line, for external -// buffer only. +// then a new buffer will be created. +// stride - Number of bytes for each scan line. The value must +// be 0 or greater. When the value is 0, +// FPDFBitmap_CreateEx() will automatically calculate +// the appropriate value using |width| and |format|. +// When using an external buffer, it is recommended for +// the caller to pass in the value. +// When not using an external buffer, it is recommended +// for the caller to pass in 0. // Return value: // The bitmap handle, or NULL if parameter error or out of memory. // Comments: @@ -744,14 +1112,28 @@ DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, // function can be used in any place that a FPDF_BITMAP handle is // required. // -// If an external buffer is used, then the application should destroy -// the buffer by itself. FPDFBitmap_Destroy function will not destroy -// the buffer. -DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, - int height, - int format, - void* first_scan, - int stride); +// If an external buffer is used, then the caller should destroy the +// buffer. FPDFBitmap_Destroy() will not destroy the buffer. +// +// It is recommended to use FPDFBitmap_GetStride() to get the stride +// value. +FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_CreateEx(int width, + int height, + int format, + void* first_scan, + int stride); + +// Function: FPDFBitmap_GetFormat +// Get the format of the bitmap. +// Parameters: +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create +// or FPDFImageObj_GetBitmap. +// Return value: +// The format of the bitmap. +// Comments: +// Only formats supported by FPDFBitmap_CreateEx are supported by this +// function; see the list of such formats above. +FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetFormat(FPDF_BITMAP bitmap); // Function: FPDFBitmap_FillRect // Fill a rectangle in a bitmap. @@ -767,7 +1149,7 @@ DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, // color - A 32-bit value specifing the color, in 8888 ARGB // format. // Return value: -// None. +// Returns whether the operation succeeded or not. // Comments: // This function sets the color and (optionally) alpha value in the // specified region of the bitmap. @@ -777,17 +1159,18 @@ DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, // background will be replaced by the source color and the alpha. // // If the alpha channel is not used, the alpha parameter is ignored. -DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, - int left, - int top, - int width, - int height, - FPDF_DWORD color); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFBitmap_FillRect(FPDF_BITMAP bitmap, + int left, + int top, + int width, + int height, + FPDF_DWORD color); // Function: FPDFBitmap_GetBuffer // Get data buffer of a bitmap. // Parameters: -// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create +// or FPDFImageObj_GetBitmap. // Return value: // The pointer to the first byte of the bitmap buffer. // Comments: @@ -797,46 +1180,49 @@ DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, // then manipulate any color and/or alpha values for any pixels in the // bitmap. // -// The data is in BGRA format. Where the A maybe unused if alpha was -// not specified. -DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap); +// Use FPDFBitmap_GetFormat() to find out the format of the data. +FPDF_EXPORT void* FPDF_CALLCONV FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap); // Function: FPDFBitmap_GetWidth // Get width of a bitmap. // Parameters: -// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create +// or FPDFImageObj_GetBitmap. // Return value: // The width of the bitmap in pixels. -DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap); +FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetWidth(FPDF_BITMAP bitmap); // Function: FPDFBitmap_GetHeight // Get height of a bitmap. // Parameters: -// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create +// or FPDFImageObj_GetBitmap. // Return value: // The height of the bitmap in pixels. -DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap); +FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetHeight(FPDF_BITMAP bitmap); // Function: FPDFBitmap_GetStride // Get number of bytes for each line in the bitmap buffer. // Parameters: -// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create +// or FPDFImageObj_GetBitmap. // Return value: // The number of bytes for each line in the bitmap buffer. // Comments: // The stride may be more than width * number of bytes per pixel. -DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap); +FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetStride(FPDF_BITMAP bitmap); // Function: FPDFBitmap_Destroy // Destroy a bitmap and release all related buffers. // Parameters: -// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create +// or FPDFImageObj_GetBitmap. // Return value: // None. // Comments: // This function will not destroy any external buffers provided when // the bitmap was created. -DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap); +FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_Destroy(FPDF_BITMAP bitmap); // Function: FPDF_VIEWERREF_GetPrintScaling // Whether the PDF document prefers to be scaled or not. @@ -844,7 +1230,7 @@ DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap); // document - Handle to the loaded document. // Return value: // None. -DLLEXPORT FPDF_BOOL STDCALL +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document); // Function: FPDF_VIEWERREF_GetNumCopies @@ -853,7 +1239,8 @@ FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document); // document - Handle to the loaded document. // Return value: // The number of copies to be printed. -DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document); +FPDF_EXPORT int FPDF_CALLCONV +FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document); // Function: FPDF_VIEWERREF_GetPrintPageRange // Page numbers to initialize print dialog box when file is printed. @@ -861,9 +1248,31 @@ DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document); // document - Handle to the loaded document. // Return value: // The print page range to be used for printing. -DLLEXPORT FPDF_PAGERANGE STDCALL +FPDF_EXPORT FPDF_PAGERANGE FPDF_CALLCONV FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document); +// Experimental API. +// Function: FPDF_VIEWERREF_GetPrintPageRangeCount +// Returns the number of elements in a FPDF_PAGERANGE. +// Parameters: +// pagerange - Handle to the page range. +// Return value: +// The number of elements in the page range. Returns 0 on error. +FPDF_EXPORT size_t FPDF_CALLCONV +FPDF_VIEWERREF_GetPrintPageRangeCount(FPDF_PAGERANGE pagerange); + +// Experimental API. +// Function: FPDF_VIEWERREF_GetPrintPageRangeElement +// Returns an element from a FPDF_PAGERANGE. +// Parameters: +// pagerange - Handle to the page range. +// index - Index of the element. +// Return value: +// The value of the element in the page range at a given index. +// Returns -1 on error. +FPDF_EXPORT int FPDF_CALLCONV +FPDF_VIEWERREF_GetPrintPageRangeElement(FPDF_PAGERANGE pagerange, size_t index); + // Function: FPDF_VIEWERREF_GetDuplex // Returns the paper handling option to be used when printing from // the print dialog. @@ -871,16 +1280,38 @@ FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document); // document - Handle to the loaded document. // Return value: // The paper handling option to be used when printing. -DLLEXPORT FPDF_DUPLEXTYPE STDCALL +FPDF_EXPORT FPDF_DUPLEXTYPE FPDF_CALLCONV FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document); +// Function: FPDF_VIEWERREF_GetName +// Gets the contents for a viewer ref, with a given key. The value must +// be of type "name". +// Parameters: +// document - Handle to the loaded document. +// key - Name of the key in the viewer pref dictionary, +// encoded in UTF-8. +// buffer - Caller-allocate buffer to receive the key, or NULL +// - to query the required length. +// length - Length of the buffer. +// Return value: +// The number of bytes in the contents, including the NULL terminator. +// Thus if the return value is 0, then that indicates an error, such +// as when |document| is invalid. If |length| is less than the required +// length, or |buffer| is NULL, |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document, + FPDF_BYTESTRING key, + char* buffer, + unsigned long length); + // Function: FPDF_CountNamedDests // Get the count of named destinations in the PDF document. // Parameters: // document - Handle to a document // Return value: // The count of named destinations. -DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document); +FPDF_EXPORT FPDF_DWORD FPDF_CALLCONV +FPDF_CountNamedDests(FPDF_DOCUMENT document); // Function: FPDF_GetNamedDestByName // Get a the destination handle for the given name. @@ -889,8 +1320,8 @@ DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document); // name - The name of a destination. // Return value: // The handle to the destination. -DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document, - FPDF_BYTESTRING name); +FPDF_EXPORT FPDF_DEST FPDF_CALLCONV +FPDF_GetNamedDestByName(FPDF_DOCUMENT document, FPDF_BYTESTRING name); // Function: FPDF_GetNamedDest // Get the named destination by index. @@ -913,25 +1344,115 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document, // // If buflen is not sufficiently large, it will be set to -1 upon // return. -DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, - int index, - void* buffer, - long* buflen); +FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDF_GetNamedDest(FPDF_DOCUMENT document, + int index, + void* buffer, + long* buflen); + +// Experimental API. +// Function: FPDF_GetXFAPacketCount +// Get the number of valid packets in the XFA entry. +// Parameters: +// document - Handle to the document. +// Return value: +// The number of valid packets, or -1 on error. +FPDF_EXPORT int FPDF_CALLCONV FPDF_GetXFAPacketCount(FPDF_DOCUMENT document); + +// Experimental API. +// Function: FPDF_GetXFAPacketName +// Get the name of a packet in the XFA array. +// Parameters: +// document - Handle to the document. +// index - Index number of the packet. 0 for the first packet. +// buffer - Buffer for holding the name of the XFA packet. +// buflen - Length of |buffer| in bytes. +// Return value: +// The length of the packet name in bytes, or 0 on error. +// +// |document| must be valid and |index| must be in the range [0, N), where N is +// the value returned by FPDF_GetXFAPacketCount(). +// |buffer| is only modified if it is non-NULL and |buflen| is greater than or +// equal to the length of the packet name. The packet name includes a +// terminating NUL character. |buffer| is unmodified on error. +FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetXFAPacketName( + FPDF_DOCUMENT document, + int index, + void* buffer, + unsigned long buflen); + +// Experimental API. +// Function: FPDF_GetXFAPacketContent +// Get the content of a packet in the XFA array. +// Parameters: +// document - Handle to the document. +// index - Index number of the packet. 0 for the first packet. +// buffer - Buffer for holding the content of the XFA packet. +// buflen - Length of |buffer| in bytes. +// out_buflen - Pointer to the variable that will receive the minimum +// buffer size needed to contain the content of the XFA +// packet. +// Return value: +// Whether the operation succeeded or not. +// +// |document| must be valid and |index| must be in the range [0, N), where N is +// the value returned by FPDF_GetXFAPacketCount(). |out_buflen| must not be +// NULL. When the aforementioned arguments are valid, the operation succeeds, +// and |out_buflen| receives the content size. |buffer| is only modified if +// |buffer| is non-null and long enough to contain the content. Callers must +// check both the return value and the input |buflen| is no less than the +// returned |out_buflen| before using the data in |buffer|. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetXFAPacketContent( + FPDF_DOCUMENT document, + int index, + void* buffer, + unsigned long buflen, + unsigned long* out_buflen); + +#ifdef PDF_ENABLE_V8 +// Function: FPDF_GetRecommendedV8Flags +// Returns a space-separated string of command line flags that are +// recommended to be passed into V8 via V8::SetFlagsFromString() +// prior to initializing the PDFium library. +// Parameters: +// None. +// Return value: +// NUL-terminated string of the form "--flag1 --flag2". +// The caller must not attempt to modify or free the result. +FPDF_EXPORT const char* FPDF_CALLCONV FPDF_GetRecommendedV8Flags(); + +// Experimental API. +// Function: FPDF_GetArrayBufferAllocatorSharedInstance() +// Helper function for initializing V8 isolates that will +// use PDFium's internal memory management. +// Parameters: +// None. +// Return Value: +// Pointer to a suitable v8::ArrayBuffer::Allocator, returned +// as void for C compatibility. +// Notes: +// Use is optional, but allows external creation of isolates +// matching the ones PDFium will make when none is provided +// via |FPDF_LIBRARY_CONFIG::m_pIsolate|. +// +// Can only be called when the library is in an uninitialized or +// destroyed state. +FPDF_EXPORT void* FPDF_CALLCONV FPDF_GetArrayBufferAllocatorSharedInstance(); +#endif // PDF_ENABLE_V8 #ifdef PDF_ENABLE_XFA // Function: FPDF_BStr_Init -// Helper function to initialize a byte string. -DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str); +// Helper function to initialize a FPDF_BSTR. +FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Init(FPDF_BSTR* bstr); // Function: FPDF_BStr_Set -// Helper function to set string data. -DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str, - FPDF_LPCSTR bstr, - int length); +// Helper function to copy string data into the FPDF_BSTR. +FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Set(FPDF_BSTR* bstr, + const char* cstr, + int length); // Function: FPDF_BStr_Clear -// Helper function to clear a byte string. -DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str); +// Helper function to clear a FPDF_BSTR. +FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Clear(FPDF_BSTR* bstr); #endif // PDF_ENABLE_XFA #ifdef __cplusplus diff --git a/src/main/jni/lib/arm64-v8a/libjniPdfium.so b/src/main/jni/lib/arm64-v8a/libjniPdfium.so new file mode 100644 index 00000000..ec8a0a4f Binary files /dev/null and b/src/main/jni/lib/arm64-v8a/libjniPdfium.so differ diff --git a/src/main/jni/lib/arm64-v8a/libmodft2.so b/src/main/jni/lib/arm64-v8a/libmodft2.so index b28c461a..a1c52fe3 100755 Binary files a/src/main/jni/lib/arm64-v8a/libmodft2.so and b/src/main/jni/lib/arm64-v8a/libmodft2.so differ diff --git a/src/main/jni/lib/arm64-v8a/libmodpdfium.so b/src/main/jni/lib/arm64-v8a/libmodpdfium.so old mode 100755 new mode 100644 index 898326b5..c7a9eca0 Binary files a/src/main/jni/lib/arm64-v8a/libmodpdfium.so and b/src/main/jni/lib/arm64-v8a/libmodpdfium.so differ diff --git a/src/main/jni/lib/arm64-v8a/libmodpng.so b/src/main/jni/lib/arm64-v8a/libmodpng.so index 65410615..39beca00 100755 Binary files a/src/main/jni/lib/arm64-v8a/libmodpng.so and b/src/main/jni/lib/arm64-v8a/libmodpng.so differ diff --git a/src/main/jni/lib/armeabi-v7a/libjniPdfium.so b/src/main/jni/lib/armeabi-v7a/libjniPdfium.so new file mode 100644 index 00000000..971198f6 Binary files /dev/null and b/src/main/jni/lib/armeabi-v7a/libjniPdfium.so differ diff --git a/src/main/jni/lib/armeabi-v7a/libmodft2.so b/src/main/jni/lib/armeabi-v7a/libmodft2.so index 80ec5265..96515520 100755 Binary files a/src/main/jni/lib/armeabi-v7a/libmodft2.so and b/src/main/jni/lib/armeabi-v7a/libmodft2.so differ diff --git a/src/main/jni/lib/armeabi-v7a/libmodpdfium.so b/src/main/jni/lib/armeabi-v7a/libmodpdfium.so old mode 100755 new mode 100644 index bc89f3dd..544bb221 Binary files a/src/main/jni/lib/armeabi-v7a/libmodpdfium.so and b/src/main/jni/lib/armeabi-v7a/libmodpdfium.so differ diff --git a/src/main/jni/lib/armeabi-v7a/libmodpng.so b/src/main/jni/lib/armeabi-v7a/libmodpng.so index 42249c5b..840968bb 100755 Binary files a/src/main/jni/lib/armeabi-v7a/libmodpng.so and b/src/main/jni/lib/armeabi-v7a/libmodpng.so differ diff --git a/src/main/jni/lib/x86/libjniPdfium.so b/src/main/jni/lib/x86/libjniPdfium.so new file mode 100644 index 00000000..764f681c Binary files /dev/null and b/src/main/jni/lib/x86/libjniPdfium.so differ diff --git a/src/main/jni/lib/x86/libmodft2.so b/src/main/jni/lib/x86/libmodft2.so index e6712e3d..d6a48604 100755 Binary files a/src/main/jni/lib/x86/libmodft2.so and b/src/main/jni/lib/x86/libmodft2.so differ diff --git a/src/main/jni/lib/x86/libmodpdfium.so b/src/main/jni/lib/x86/libmodpdfium.so old mode 100755 new mode 100644 index 5b937530..f0054ac2 Binary files a/src/main/jni/lib/x86/libmodpdfium.so and b/src/main/jni/lib/x86/libmodpdfium.so differ diff --git a/src/main/jni/lib/x86/libmodpng.so b/src/main/jni/lib/x86/libmodpng.so index 5cbaf78d..4d6e7757 100755 Binary files a/src/main/jni/lib/x86/libmodpng.so and b/src/main/jni/lib/x86/libmodpng.so differ diff --git a/src/main/jni/lib/x86_64/libc++_shared.so b/src/main/jni/lib/x86_64/libc++_shared.so index 4fe5affd..d9ba9cf8 100755 Binary files a/src/main/jni/lib/x86_64/libc++_shared.so and b/src/main/jni/lib/x86_64/libc++_shared.so differ diff --git a/src/main/jni/lib/x86_64/libjniPdfium.so b/src/main/jni/lib/x86_64/libjniPdfium.so new file mode 100644 index 00000000..1d71371d Binary files /dev/null and b/src/main/jni/lib/x86_64/libjniPdfium.so differ diff --git a/src/main/jni/lib/x86_64/libmodft2.so b/src/main/jni/lib/x86_64/libmodft2.so index 57bec3ca..906fedb8 100755 Binary files a/src/main/jni/lib/x86_64/libmodft2.so and b/src/main/jni/lib/x86_64/libmodft2.so differ diff --git a/src/main/jni/lib/x86_64/libmodpdfium.so b/src/main/jni/lib/x86_64/libmodpdfium.so old mode 100755 new mode 100644 index 4edc2c27..e93993a0 Binary files a/src/main/jni/lib/x86_64/libmodpdfium.so and b/src/main/jni/lib/x86_64/libmodpdfium.so differ diff --git a/src/main/jni/lib/x86_64/libmodpng.so b/src/main/jni/lib/x86_64/libmodpng.so index 3833468f..642d1161 100755 Binary files a/src/main/jni/lib/x86_64/libmodpng.so and b/src/main/jni/lib/x86_64/libmodpng.so differ diff --git a/src/main/jni/src/mainJNILib.cpp b/src/main/jni/src/mainJNILib.cpp index a888e69f..dccb652f 100644 --- a/src/main/jni/src/mainJNILib.cpp +++ b/src/main/jni/src/mainJNILib.cpp @@ -618,7 +618,7 @@ JNI_FUNC(jlong, PdfiumCore, nativeGetBookmarkDestIndex)(JNI_ARGS, jlong docPtr, if (dest == NULL) { return -1; } - return (jlong) FPDFDest_GetPageIndex(doc->pdfDocument, dest); + return (jlong) FPDFDest_GetDestPageIndex(doc->pdfDocument, dest); } JNI_FUNC(jlongArray, PdfiumCore, nativeGetPageLinks)(JNI_ARGS, jlong pagePtr) { @@ -642,7 +642,7 @@ JNI_FUNC(jobject, PdfiumCore, nativeGetDestPageIndex)(JNI_ARGS, jlong docPtr, jl if (dest == NULL) { return NULL; } - unsigned long index = FPDFDest_GetPageIndex(doc->pdfDocument, dest); + unsigned long index = FPDFDest_GetDestPageIndex(doc->pdfDocument, dest); return NewInteger(env, (jint) index); }