diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index abac30e..358a1a6 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -70,7 +70,10 @@ android {
buildTypes {
release {
- signingConfig = signingConfigs.getByName("release")
+ val storePath = localProperties.getProperty("MYAPP_RELEASE_STORE_FILE")
+ if (!storePath.isNullOrEmpty()) {
+ signingConfig = signingConfigs.getByName("release")
+ }
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
@@ -168,8 +171,6 @@ dependencies {
implementation("io.coil-kt:coil-compose:2.7.0")
implementation("io.coil-kt:coil-svg:2.6.0")
- implementation(project(":pdfiumandroid"))
-
implementation("androidx.media3:media3-exoplayer:1.8.0")
implementation("androidx.media3:media3-session:1.8.0")
implementation("androidx.media3:media3-ui:1.8.0")
@@ -198,6 +199,8 @@ dependencies {
implementation("androidx.documentfile:documentfile:1.0.1")
implementation("androidx.browser:browser:1.8.0")
+
+ implementation("io.legere:pdfiumandroid:1.0.35")
}
spotless {
diff --git a/app/src/main/java/com/aryan/reader/pdf/PdfPageComposable.kt b/app/src/main/java/com/aryan/reader/pdf/PdfPageComposable.kt
index 65f5bbf..c936fd7 100644
--- a/app/src/main/java/com/aryan/reader/pdf/PdfPageComposable.kt
+++ b/app/src/main/java/com/aryan/reader/pdf/PdfPageComposable.kt
@@ -1,22 +1,3 @@
-/*
- * Episteme Reader - A native Android document reader.
- * Copyright (C) 2026 Episteme
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *
- * mail: epistemereader@gmail.com
- */
// PdfPageComposable
@file:Suppress(
"RemoveRedundantQualifierName", "COMPOSE_APPLIER_CALL_MISMATCH", "UnusedVariable", "unused"
@@ -137,7 +118,6 @@ import com.aryan.reader.pdf.data.PdfTextBox
import com.aryan.reader.pdf.data.VirtualPage
import com.aryan.reader.pdf.ocr.OcrElement
import com.aryan.reader.pdf.ocr.OcrResult
-import io.legere.pdfiumandroid.PdfPageObjectType
import io.legere.pdfiumandroid.suspend.PdfDocumentKt
import io.legere.pdfiumandroid.suspend.PdfPageKt
import io.legere.pdfiumandroid.suspend.PdfTextPageKt
@@ -351,7 +331,6 @@ data class PageStaticData(
val targetWidth: Int,
val targetHeight: Int,
val colorFilter: StableHolder,
- val imageScreenRects: StableHolder>,
val isDarkMode: Boolean
)
@@ -630,7 +609,6 @@ internal fun PdfPageComposable(
var highlightedTextScreenRects by remember { mutableStateOf>(emptyList()) }
val ttsHighlightColor = Color(0xFFFFECB3).copy(alpha = 0.4f)
- var imageScreenRects by remember { mutableStateOf>(emptyList()) }
var allTextPageHighlightRects by remember { mutableStateOf>(emptyList()) }
@@ -1132,44 +1110,6 @@ internal fun PdfPageComposable(
}
}
- LaunchedEffect(pageIndex, pdfDocumentItem, actualBitmapWidthPx, actualBitmapHeightPx, virtualPage) {
- if (!isPdfPage) {
- imageScreenRects = emptyList()
- return@LaunchedEffect
- }
-
- if (actualBitmapWidthPx == 0 || actualBitmapHeightPx == 0) {
- imageScreenRects = emptyList()
- return@LaunchedEffect
- }
-
- withContext(Dispatchers.IO) {
- try {
- pdfDocumentItem.openPage(pdfPageIndex).use { page ->
- val objects = page.getPageObjects()
- val foundImageRects =
- objects.filter { it.type == PdfPageObjectType.IMAGE }.mapNotNull { obj ->
- val pdfRect = obj.bounds
- val screenRect = page.mapRectToDevice(
- startX = 0,
- startY = 0,
- sizeX = actualBitmapWidthPx,
- sizeY = actualBitmapHeightPx,
- rotate = currentPageRotation,
- coords = pdfRect
- )
- if (screenRect.width() > 0 && screenRect.height() > 0) screenRect
- else null
- }
- imageScreenRects = foundImageRects
- }
- } catch (e: Exception) {
- Timber.e(e, "Error fetching image objects for page $pageIndex")
- imageScreenRects = emptyList()
- }
- }
- }
-
var searchFocusedRects by remember { mutableStateOf>(emptyList()) }
var searchAllRects by remember { mutableStateOf>(emptyList()) }
@@ -3244,8 +3184,6 @@ internal fun PdfPageComposable(
bitmapState != null && actualBitmapWidthPx > 0 && actualBitmapHeightPx > 0 -> {
val stableBitmapState = remember(bitmapState) { StableHolder(bitmapState) }
val stableTiles = remember(tiles) { StableHolder(tiles) }
- val stableImageScreenRects =
- remember(imageScreenRects) { StableHolder(imageScreenRects) }
val stableColorFilter = remember(colorFilter) { StableHolder(colorFilter) }
val staticData = remember(
@@ -3259,7 +3197,6 @@ internal fun PdfPageComposable(
actualBitmapWidthPx,
actualBitmapHeightPx,
stableColorFilter,
- stableImageScreenRects,
isDarkMode
) {
Timber.tag("PdfDrawPerf").v(
@@ -3276,7 +3213,6 @@ internal fun PdfPageComposable(
targetWidth = actualBitmapWidthPx,
targetHeight = actualBitmapHeightPx,
colorFilter = stableColorFilter,
- imageScreenRects = stableImageScreenRects,
isDarkMode = isDarkMode
)
}
@@ -3576,7 +3512,6 @@ private fun PdfBitmapLayer(
targetWidth: Int,
targetHeight: Int,
colorFilter: ColorFilter? = null,
- imageScreenRects: List = emptyList(),
isDarkMode: Boolean = false
) {
SideEffect {
@@ -3605,34 +3540,6 @@ private fun PdfBitmapLayer(
colorFilter = colorFilter
)
- // 2. If Dark Mode, draw Images ON TOP without filter
- if (isDarkMode && imageScreenRects.isNotEmpty()) {
- imageScreenRects.forEach { rect ->
- val scaleX = bitmapState.width.toFloat() / dstW.toFloat()
- val scaleY = bitmapState.height.toFloat() / dstH.toFloat()
-
- val srcLeft = (rect.left * scaleX).toInt().coerceAtLeast(0)
- val srcTop = (rect.top * scaleY).toInt().coerceAtLeast(0)
- val srcRight = (rect.right * scaleX).toInt().coerceAtMost(bitmapState.width)
- val srcBottom =
- (rect.bottom * scaleY).toInt().coerceAtMost(bitmapState.height)
-
- val w = srcRight - srcLeft
- val h = srcBottom - srcTop
-
- if (w > 0 && h > 0) {
- drawImage(
- image = bitmapState.asImageBitmap(),
- srcOffset = IntOffset(srcLeft, srcTop),
- srcSize = IntSize(w, h),
- dstOffset = IntOffset(rect.left, rect.top),
- dstSize = IntSize(rect.width(), rect.height()),
- colorFilter = null
- )
- }
- }
- }
-
// 3. Draw Tiles
if (effectiveScale > 1f) {
tiles.forEach { tile ->
@@ -3647,52 +3554,6 @@ private fun PdfBitmapLayer(
),
colorFilter = colorFilter
)
-
- // Draw Tile Images (Original Colors)
- if (isDarkMode && imageScreenRects.isNotEmpty()) {
- imageScreenRects.forEach { imgRect ->
- if (Rect.intersects(imgRect, tile.renderRect)) {
- val intersectLeft =
- maxOf(imgRect.left, tile.renderRect.left)
- val intersectTop = maxOf(imgRect.top, tile.renderRect.top)
- val intersectRight =
- minOf(imgRect.right, tile.renderRect.right)
- val intersectBottom =
- minOf(imgRect.bottom, tile.renderRect.bottom)
-
- val width = intersectRight - intersectLeft
- val height = intersectBottom - intersectTop
-
- if (width > 0 && height > 0) {
- val tileRelX = intersectLeft - tile.renderRect.left
- val tileRelY = intersectTop - tile.renderRect.top
- val tileScaleX =
- tile.bitmap.width.toFloat() / tile.renderRect.width()
- .toFloat()
- val tileScaleY =
- tile.bitmap.height.toFloat() / tile.renderRect.height()
- .toFloat()
- val srcX = (tileRelX * tileScaleX).toInt()
- val srcY = (tileRelY * tileScaleY).toInt()
- val srcW = (width * tileScaleX).toInt()
- val srcH = (height * tileScaleY).toInt()
-
- if (srcW > 0 && srcH > 0) {
- drawImage(
- image = tile.bitmap.asImageBitmap(),
- srcOffset = IntOffset(srcX, srcY),
- srcSize = IntSize(srcW, srcH),
- dstOffset = IntOffset(
- intersectLeft, intersectTop
- ),
- dstSize = IntSize(width, height),
- colorFilter = null // Original Colors
- )
- }
- }
- }
- }
- }
}
}
}
@@ -4198,7 +4059,6 @@ private fun PdfPageStaticLayer(data: PageStaticData) {
targetWidth = data.targetWidth,
targetHeight = data.targetHeight,
colorFilter = data.colorFilter.item,
- imageScreenRects = data.imageScreenRects.item,
isDarkMode = data.isDarkMode
)
}
@@ -4467,28 +4327,7 @@ private fun PdfPageRenderer(
// Layer 4: Page Number Indicator
if (totalPages > 0) {
- @Suppress("KotlinConstantConditions") val isOverImage = remember(
- staticData.imageScreenRects,
- staticData.targetWidth,
- staticData.targetHeight,
- density
- ) {
- val w = staticData.targetWidth
- val h = staticData.targetHeight
- if (w > 0 && h > 0) {
- val checkOffsetPx = with(density) { 20.dp.toPx().toInt() }
- val checkX = w - checkOffsetPx
- val checkY = h - checkOffsetPx
-
- staticData.imageScreenRects.item.any { rect ->
- rect.contains(checkX, checkY)
- }
- } else {
- false
- }
- }
-
- val pageNumColor = if (staticData.isDarkMode && !isOverImage) {
+ val pageNumColor = if (staticData.isDarkMode) {
Color.White
} else {
Color.Black
diff --git a/pdfiumandroid/.gitignore b/pdfiumandroid/.gitignore
deleted file mode 100644
index 42afabf..0000000
--- a/pdfiumandroid/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
\ No newline at end of file
diff --git a/pdfiumandroid/arrow/.gitignore b/pdfiumandroid/arrow/.gitignore
deleted file mode 100644
index 42afabf..0000000
--- a/pdfiumandroid/arrow/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
\ No newline at end of file
diff --git a/pdfiumandroid/arrow/build.gradle.kts b/pdfiumandroid/arrow/build.gradle.kts
deleted file mode 100644
index c5bc41f..0000000
--- a/pdfiumandroid/arrow/build.gradle.kts
+++ /dev/null
@@ -1,193 +0,0 @@
-import org.jetbrains.kotlin.gradle.dsl.JvmTarget
-import org.jreleaser.model.Active
-import org.jreleaser.model.Signing
-
-
-plugins {
- id("com.android.library")
- alias(libs.plugins.kotlin.android)
- alias(libs.plugins.detekt)
- alias(libs.plugins.kover)
- alias(libs.plugins.ktlint)
- alias(libs.plugins.jreleaser)
- `maven-publish`
- signing
-}
-kotlin {
- compilerOptions {
- jvmTarget.set(JvmTarget.JVM_17)
- }
-}
-
-android {
- namespace = "io.legere.pdfiumandroid.arrow"
- compileSdk = 35
-
- defaultConfig {
- minSdk = 23
-
- testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
- consumerProguardFiles("consumer-rules.pro")
- }
- publishing {
- singleVariant("release") {
- }
- }
-
- buildTypes {
- release {
- isMinifyEnabled = false
- proguardFiles(
- getDefaultProguardFile("proguard-android-optimize.txt"),
- "proguard-rules.pro",
- )
- }
- }
- compileOptions {
- sourceCompatibility(JavaVersion.VERSION_17)
- targetCompatibility(JavaVersion.VERSION_17)
- }
-}
-
-dependencies {
- implementation(project(":pdfiumandroid"))
- implementation(libs.kotlinx.coroutines.android)
- implementation(libs.arrow.core)
- implementation(libs.androidx.runner)
- testImplementation(libs.junit)
- androidTestImplementation(libs.androidx.junit)
- androidTestImplementation(libs.androidx.espresso.core)
- androidTestImplementation(libs.truth)
- androidTestImplementation(libs.kotlinx.coroutines.test)
- androidTestImplementation(libs.androidx.core.testing)
- androidTestImplementation(libs.arrow.fx.coroutines)
-}
-
-fun isReleaseBuild(): Boolean = !findProject("VERSION_NAME").toString().contains("SNAPSHOT")
-
-fun getReleaseRepositoryUrl(): String =
- if (rootProject.hasProperty("RELEASE_REPOSITORY_URL")) {
- rootProject.properties["RELEASE_REPOSITORY_URL"] as String
- } else {
- "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
- }
-
-fun getSnapshotRepositoryUrl(): String =
- if (rootProject.hasProperty("SNAPSHOT_REPOSITORY_URL")) {
- rootProject.properties["SNAPSHOT_REPOSITORY_URL"] as String
- } else {
- "https://oss.sonatype.org/content/repositories/snapshots/"
- }
-
-fun getRepositoryUrl(): String = if (isReleaseBuild()) getReleaseRepositoryUrl() else getSnapshotRepositoryUrl()
-
-fun getRepositoryUsername(): String =
- if (rootProject.hasProperty("JRELEASER_MAVENCENTRAL_USERNAME")) {
- rootProject.properties["JRELEASER_MAVENCENTRAL_USERNAME"] as String
- } else {
- ""
- }
-
-fun getRepositoryPassword(): String =
- if (rootProject.hasProperty("JRELEASER_MAVENCENTRAL_TOKEN")) {
- rootProject.properties["JRELEASER_MAVENCENTRAL_TOKEN"] as String
- } else {
- ""
- }
-
-publishing {
- publications {
- create("maven") {
- groupId = "io.legere"
- artifactId = "pdfium-android-kt-arrow"
- version = project.property("VERSION_NAME") as String
-
- pom {
- name.set("pdfiumandroid.arrow")
- description.set("Arrow support for PdfiumAndroid")
- url.set(rootProject.properties["POM_URL"] as String)
- licenses {
- license {
- name.set(rootProject.properties["POM_LICENCE_NAME"] as String)
- url.set(rootProject.properties["POM_LICENCE_URL"] as String)
- distribution.set(rootProject.properties["POM_LICENCE_DIST"] as String)
- }
- }
- developers {
- developer {
- id.set(rootProject.properties["POM_DEVELOPER_ID"] as String)
- name.set(rootProject.properties["POM_DEVELOPER_NAME"] as String)
- }
- }
- scm {
- connection.set(rootProject.properties["POM_SCM_CONNECTION"] as String)
- developerConnection.set(rootProject.properties["POM_SCM_DEV_CONNECTION"] as String)
- url.set(rootProject.properties["POM_SCM_URL"] as String)
- }
- }
- afterEvaluate {
- from(components["release"])
- }
- }
- }
- repositories {
- maven {
- url =
- uri(layout.buildDirectory.dir("target/staging-deploy"))
- }
- }
-}
-
-jreleaser {
- project {
- inceptionYear = "2023"
- author("@johngray1965")
- description = "Arrow support for PdfiumAndroid"
- version = rootProject.properties["VERSION_NAME"] as String
- license = "http://www.apache.org/licenses/LICENSE-2.0.txt"
- links {
- homepage = "https://github.com/johngray1965/PdfiumAndroidKt"
- license = "http://www.apache.org/licenses/LICENSE-2.0.txt"
- }
- }
- gitRootSearch = true
- signing {
- active = Active.ALWAYS
- mode = Signing.Mode.COMMAND
- armored = true
- verify = false
- command {
- executable = "gpg"
- keyName = "4BBF8FAB"
- publicKeyring = "/Users/gray/.gnupg/secring.gpg"
- }
- }
- release {
- github {
- skipRelease = true
- }
- }
-// distributions {
-// create("pdfiumandroid.arrow") {
-// artifact {
-// path = file("build/distributions/{{distributionName}}-{{projectVersion}}.zip")
-// }
-// }
-// }
- deploy {
- maven {
- mavenCentral.create("sonatype") {
- active = Active.ALWAYS
- verifyPom = false
- url = "https://central.sonatype.com/api/v1/publisher"
- stagingRepository(
- layout.buildDirectory
- .dir("target/staging-deploy")
- .get()
- .toString(),
- )
- username = getRepositoryUsername()
- }
- }
- }
-}
diff --git a/pdfiumandroid/arrow/consumer-rules.pro b/pdfiumandroid/arrow/consumer-rules.pro
deleted file mode 100644
index e69de29..0000000
diff --git a/pdfiumandroid/arrow/gradle.properties b/pdfiumandroid/arrow/gradle.properties
deleted file mode 100644
index 15ec3e1..0000000
--- a/pdfiumandroid/arrow/gradle.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-POM_NAME=pdfiumandroid
-POM_ARTIFACT_ID=pdfiumandroid
-POM_PACKAGING=aar
-
diff --git a/pdfiumandroid/arrow/proguard-rules.pro b/pdfiumandroid/arrow/proguard-rules.pro
deleted file mode 100644
index 481bb43..0000000
--- a/pdfiumandroid/arrow/proguard-rules.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-# Add project specific ProGuard rules here.
-# You can control the set of applied configuration files using the
-# proguardFiles setting in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/pdfiumandroid/arrow/src/androidTest/assets/f01.pdf b/pdfiumandroid/arrow/src/androidTest/assets/f01.pdf
deleted file mode 100644
index ecfcea3..0000000
Binary files a/pdfiumandroid/arrow/src/androidTest/assets/f01.pdf and /dev/null differ
diff --git a/pdfiumandroid/arrow/src/androidTest/assets/pdf-test.pdf b/pdfiumandroid/arrow/src/androidTest/assets/pdf-test.pdf
deleted file mode 100644
index f46dbe5..0000000
Binary files a/pdfiumandroid/arrow/src/androidTest/assets/pdf-test.pdf and /dev/null differ
diff --git a/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/PdfDocumentKtFTest.kt b/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/PdfDocumentKtFTest.kt
deleted file mode 100644
index 8f9848a..0000000
--- a/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/PdfDocumentKtFTest.kt
+++ /dev/null
@@ -1,135 +0,0 @@
-package io.legere.pdfiumandroid.arrow
-
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import arrow.core.raise.either
-import com.google.common.truth.Truth.assertThat
-import io.legere.pdfiumandroid.PdfWriteCallback
-import io.legere.pdfiumandroid.arrow.base.BasePDFTest
-import junit.framework.TestCase
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.runBlocking
-import kotlinx.coroutines.test.runTest
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class PdfDocumentKtFTest : BasePDFTest() {
- private lateinit var pdfDocument: PdfDocumentKtF
- private var pdfBytes: ByteArray? = null
-
- @Before
- fun setUp() =
- runBlocking {
- pdfBytes = getPdfBytes("f01.pdf")
-
- assertThat(pdfBytes).isNotNull()
-
- pdfDocument = PdfiumCoreKtF(Dispatchers.Unconfined).newDocument(pdfBytes).getOrNull()!!
- }
-
- @After
- fun tearDown() =
- runTest {
- pdfDocument.close()
- }
-
- @Test
- fun getPageCount() =
- runTest {
- either {
- val pageCount = pdfDocument.getPageCount().bind()
-
- assertThat(pageCount).isEqualTo(4)
- }
- }
-
- @Test
- fun openPage() =
- runTest {
- either {
- val page = pdfDocument.openPage(0).bind()
-
- assertThat(page).isNotNull()
- }
- }
-
- @Test
- fun openPages() =
- runTest {
- either {
- val page = pdfDocument.openPages(0, 3).bind()
-
- assertThat(page.size).isEqualTo(4)
- }
- }
-
- @Test
- fun getDocumentMeta() =
- runTest {
- either {
- val meta = pdfDocument.getDocumentMeta().bind()
-
- assertThat(meta).isNotNull()
- }
- }
-
- @Test
- fun getTableOfContents() =
- runTest {
- either {
- // I don't think this test document has a table of contents
- val toc = pdfDocument.getTableOfContents().bind()
-
- TestCase.assertNotNull(toc)
- assertThat(toc.size).isEqualTo(0)
- }
- }
-
- @Test
- fun openTextPage() =
- runTest {
- either {
- val page = pdfDocument.openPage(0).bind()
- val textPage = page.openTextPage().bind()
- assertThat(textPage).isNotNull()
- }
- }
-
- @Test
- fun openTextPages() =
- runTest {
- either {
- val textPages = pdfDocument.openTextPages(0, 3).bind()
- assertThat(textPages.size).isEqualTo(4)
- }
- }
-
- @Test
- fun saveAsCopy() =
- runTest {
- pdfDocument.saveAsCopy(
- object : PdfWriteCallback {
- override fun WriteBlock(data: ByteArray?): Int {
- // Truth.assertThat(data?.size).isEqualTo(pdfBytes?.size)
- // Truth.assertThat(data).isEqualTo(pdfBytes)
- return data?.size ?: 0
- }
- },
- )
- }
-
- fun close() =
- runTest {
- either {
- var documentAfterClose: PdfDocumentKtF?
- PdfiumCoreKtF(Dispatchers.Unconfined).newDocument(pdfBytes).bind().use {
- documentAfterClose = it
- }
- documentAfterClose?.openPage(0)
- }.mapLeft {
- assertThat(it).isInstanceOf(PdfiumKtFErrors.AlreadyClosed::class.java)
- }
- }
-}
diff --git a/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/PdfPageKtFTest.kt b/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/PdfPageKtFTest.kt
deleted file mode 100644
index 483e5d5..0000000
--- a/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/PdfPageKtFTest.kt
+++ /dev/null
@@ -1,316 +0,0 @@
-package io.legere.pdfiumandroid.arrow
-
-import android.graphics.Bitmap
-import android.graphics.Point
-import android.graphics.PointF
-import android.graphics.Rect
-import android.graphics.RectF
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import arrow.core.raise.either
-import com.google.common.truth.Truth.assertThat
-import io.legere.pdfiumandroid.arrow.base.BasePDFTest
-import io.legere.pdfiumandroid.util.Size
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.runBlocking
-import kotlinx.coroutines.test.runTest
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class PdfPageKtFTest : BasePDFTest() {
- private lateinit var pdfDocument: PdfDocumentKtF
- private var pdfBytes: ByteArray? = null
-
- @Before
- fun setUp() =
- runBlocking {
- pdfBytes = getPdfBytes("f01.pdf")
-
- assertThat(pdfBytes).isNotNull()
-
- pdfDocument = PdfiumCoreKtF(Dispatchers.Unconfined).newDocument(pdfBytes).getOrNull()!!
- }
-
- @After
- fun tearDown() {
- pdfDocument.close()
- }
-
- @Test
- fun getPageWidth() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val pageWidth = page.getPageWidth(72).bind()
-
- assertThat(pageWidth).isEqualTo(612) // 8.5 inches * 72 dpi
- }
- }
- }
-
- @Test
- fun getPageHeight() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val pageWidth = page.getPageHeight(72).bind()
-
- assertThat(pageWidth).isEqualTo(792) // 11 inches * 72 dpi
- }
- }
- }
-
- @Test
- fun getPageWidthPoint() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val pageWidth = page.getPageWidthPoint().bind()
-
- assertThat(pageWidth).isEqualTo(612) // 11 inches * 72 dpi
- }
- }
- }
-
- @Test
- fun getPageHeightPoint() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val pageWidth = page.getPageHeightPoint().bind()
-
- assertThat(pageWidth).isEqualTo(792) // 11 inches * 72 dpi
- }
- }
- }
-
- @Test
- fun getPageCropBox() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val cropBox = page.getPageCropBox().bind()
-
- assertThat(cropBox).isEqualTo(noResultRect)
- }
- }
- }
-
- @Test
- fun getPageMediaBox() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val mediaBox = page.getPageMediaBox().bind()
-
- assertThat(mediaBox).isEqualTo(RectF(0.0f, 0.0f, 612.0f, 792.0f))
- }
- }
- }
-
- @Test
- fun getPageBleedBox() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val bleedBox = page.getPageBleedBox().bind()
-
- assertThat(bleedBox).isEqualTo(noResultRect)
- }
- }
- }
-
- @Test
- fun getPageTrimBox() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val trimBox = page.getPageTrimBox().bind()
-
- assertThat(trimBox).isEqualTo(noResultRect)
- }
- }
- }
-
- @Test
- fun getPageArtBox() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val artBox = page.getPageArtBox().bind()
-
- assertThat(artBox).isEqualTo(noResultRect)
- }
- }
- }
-
- @Test
- fun getPageBoundingBox() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val artBox = page.getPageBoundingBox().bind()
-
- assertThat(artBox).isEqualTo(RectF(0f, 792f, 612f, 0f))
- }
- }
- }
-
- @Test
- fun getPageSize() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val size = page.getPageSize(72).bind()
-
- assertThat(size).isEqualTo(Size(612, 792))
- }
- }
- }
-
- @Test
- fun renderPage() =
- runTest {
- // I really don't know how to test it
- }
-
- @Test
- fun testRenderPage() =
- runTest {
- // I really don't know how to test it
- }
-
- @Test
- fun renderPageBitmap() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
-
- val conf = Bitmap.Config.RGB_565 // see other conf types
-
- val bmp = Bitmap.createBitmap(612, 792, conf) // this creates a MUTABLE bitmap
-
- page.renderPageBitmap(bmp, 0, 0, 612, 792)
-
- // How to verify that it's correct?
- // Even if we don't verify the bitmap, we can check that it doesn't crash
- }
- }
- }
-
- @Test
- fun testRenderPageBitmap() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
-
- val conf = Bitmap.Config.RGB_565 // see other conf types
-
- val bmp = Bitmap.createBitmap(612, 792, conf) // this creates a MUTABLE bitmap
-
- page.renderPageBitmap(bmp, 0, 0, 612, 792, renderAnnot = true, textMask = true)
-
- // How to verify that it's correct?
- // Even if we don't verify the bitmap, we can check that it doesn't crash
- }
- }
- }
-
- @Test
- fun getPageLinks() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val links = page.getPageLinks().bind()
-
- assertThat(links.size).isEqualTo(0) // The test doc doesn't have links
- }
- }
- }
-
- @Test
- fun mapPageCoordsToDevice() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val devicePt = page.mapPageCoordsToDevice(0, 0, 100, 100, 0, 0.0, 0.0).bind()
-
- assertThat(devicePt).isEqualTo(Point(0, 100))
- }
- }
- }
-
- @Test
- fun mapDeviceCoordsToPage() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val devicePt = page.mapDeviceCoordsToPage(0, 0, 100, 100, 0, 0, 0).bind()
-
- assertThat(devicePt).isEqualTo(PointF(0f, 792.00006f))
- }
- }
- }
-
- @Test
- fun mapRectToDevice() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val devicePt = page.mapRectToDevice(0, 0, 100, 100, 0, RectF(0f, 0f, 100f, 100f)).bind()
-
- assertThat(devicePt).isEqualTo(
- Rect(
- // 0f in coords to 0f in device
- 0,
- // 0f in corrds in at the bottom, the bottom of the device is 100f
- 100,
- // 100f in coords = 100f/(8.5*72) * 100f = 16f
- 16,
- // 100f in coords = 100 - 100f/(11*72) * 100f = 87f
- 87,
- ),
- )
- }
- }
- }
-
- @Test
- fun mapRectToPage() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- val devicePt = page.mapRectToPage(0, 0, 100, 100, 0, Rect(0, 0, 100, 100)).bind()
-
- assertThat(devicePt).isEqualTo(
- RectF(0.0f, 792.00006f, 612.0f, 0.0f),
- )
- }
- }
- }
-
- fun close() =
- runTest {
- either {
- var pageAfterClose: PdfPageKtF?
- pdfDocument.openPage(0).bind().use { page ->
- pageAfterClose = page
- }
- pageAfterClose!!.getPageWidth(72)
- }.mapLeft {
- assertThat(it).isInstanceOf(PdfiumKtFErrors.AlreadyClosed::class.java)
- }
- }
-
- @Test
- fun getPage() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- assertThat(page).isNotNull()
- }
- }
- }
-}
diff --git a/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/PdfPageLinkKtFTest.kt b/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/PdfPageLinkKtFTest.kt
deleted file mode 100644
index cec4e17..0000000
--- a/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/PdfPageLinkKtFTest.kt
+++ /dev/null
@@ -1,114 +0,0 @@
-package io.legere.pdfiumandroid.arrow
-
-import android.graphics.RectF
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import arrow.core.raise.either
-import com.google.common.truth.Truth
-import io.legere.pdfiumandroid.arrow.base.BasePDFTest
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.runBlocking
-import kotlinx.coroutines.test.TestResult
-import kotlinx.coroutines.test.runTest
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class PdfPageLinkKtFTest : BasePDFTest() {
- private lateinit var pdfDocument: PdfDocumentKtF
- private lateinit var pdfPage: PdfPageKtF
- private lateinit var pdfTextPage: PdfTextPageKtF
- private var pdfBytes: ByteArray? = null
-
- @Before
- fun setUp() =
- runBlocking {
- pdfBytes = getPdfBytes("pdf-test.pdf")
-
- Truth.assertThat(pdfBytes).isNotNull()
-
- pdfDocument = PdfiumCoreKtF(Dispatchers.Unconfined).newDocument(pdfBytes).getOrNull()!!
- pdfPage = pdfDocument.openPage(0).getOrNull()!!
- pdfTextPage = pdfPage.openTextPage().getOrNull()!!
- }
-
- @After
- fun tearDown() {
- pdfTextPage.close()
- pdfPage.close()
- pdfDocument.close()
- }
-
- @Test
- fun testLink(): TestResult =
- runTest {
- either {
- pdfTextPage.loadWebLink().bind().use { links ->
- Truth.assertThat(links).isNotNull()
- }
- }
- }
-
- @Test
- fun testCountWebLinks(): TestResult =
- runTest {
- either {
- pdfTextPage.loadWebLink().bind().use { links ->
- Truth.assertThat(links).isNotNull()
- Truth.assertThat(links.countWebLinks().bind()).isEqualTo(1)
- }
- }
- }
-
- @Test
- fun testGetTextRange(): TestResult =
- runTest {
- either {
- pdfTextPage.loadWebLink().bind().use { links ->
- Truth.assertThat(links).isNotNull()
- Truth.assertThat(links.getTextRange(0).bind()).isEqualTo(Pair(351, 31))
- }
- }
- }
-
- @Test
- fun testGetUrl(): TestResult =
- runTest {
- either {
- pdfTextPage.loadWebLink().bind().use { links ->
- Truth.assertThat(links).isNotNull()
- val (_, count) = links.getTextRange(0).bind()
- Truth
- .assertThat(links.getURL(0, count).bind())
- .isEqualTo("http://www.education.gov.yk.ca/")
- }
- }
- }
-
- @Test
- fun testCountRects(): TestResult =
- runTest {
- either {
- pdfTextPage.loadWebLink().bind().use { links ->
- Truth.assertThat(links).isNotNull()
- val count = links.countRects(0).bind()
- Truth.assertThat(count).isEqualTo(1)
- }
- }
- }
-
- @Test
- fun testGetRect(): TestResult =
- runTest {
- either {
- pdfTextPage.loadWebLink().bind().use { links ->
- Truth.assertThat(links).isNotNull()
- val count = links.getRect(0, 0).bind()
- Truth
- .assertThat(count)
- .isEqualTo(RectF(221.46f, 480.624f, 389.66394f, 469.152f))
- }
- }
- }
-}
diff --git a/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/PdfTextPageKtTest.kt b/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/PdfTextPageKtTest.kt
deleted file mode 100644
index d091d7a..0000000
--- a/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/PdfTextPageKtTest.kt
+++ /dev/null
@@ -1,235 +0,0 @@
-package io.legere.pdfiumandroid.arrow
-
-import android.graphics.RectF
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import arrow.core.raise.either
-import com.google.common.truth.Truth.assertThat
-import io.legere.pdfiumandroid.arrow.base.BasePDFTest
-import junit.framework.TestCase
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.runBlocking
-import kotlinx.coroutines.test.TestResult
-import kotlinx.coroutines.test.runTest
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class PdfTextPageKtTest : BasePDFTest() {
- private lateinit var pdfDocument: PdfDocumentKtF
- private var pdfBytes: ByteArray? = null
-
- @Before
- fun setUp() =
- runBlocking {
- pdfBytes = getPdfBytes("f01.pdf")
-
- TestCase.assertNotNull(pdfBytes)
-
- pdfDocument = PdfiumCoreKtF(Dispatchers.Unconfined).newDocument(pdfBytes).getOrNull()!!
- }
-
- @After
- fun tearDown() {
- pdfDocument.close()
- }
-
- @Test
- fun textPageCountChars() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- page.openTextPage().bind().use { textPage ->
- val charCount = textPage.textPageCountChars().bind()
-
- assertThat(charCount).isEqualTo(3468)
- }
- }
- }
- }
-
- @Test
- fun textPageGetText() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- page.openTextPage().bind().use { textPage ->
- val text = textPage.textPageGetText(0, 100).bind()
-
- assertThat(text?.length).isEqualTo(100)
- }
- }
- }
- }
-
- @Test
- fun textPageGetUnicode() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- page.openTextPage().bind().use { textPage ->
- val char = textPage.textPageGetUnicode(0).bind()
-
- assertThat(char).isEqualTo('T')
- }
- }
- }
- }
-
- @Test
- fun textPageGetCharBox() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- page.openTextPage().bind().use { textPage ->
- val rect = textPage.textPageGetCharBox(0).bind()
-
- assertThat(rect)
- .isEqualTo(RectF(90.314415f, 715.3187f, 103.44171f, 699.1206f))
- }
- }
- }
- }
-
- @Test
- fun textPageGetCharIndexAtPos() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- page.openTextPage().bind().use { textPage ->
- val characterToLookup = 0
- val rect = textPage.textPageGetCharBox(characterToLookup).bind()
-
- val pos =
- textPage
- .textPageGetCharIndexAtPos(
- rect?.centerX()?.toDouble() ?: 0.0,
- rect?.centerY()?.toDouble() ?: 0.0,
- // Shouldn't need much since we're in the middle of the rect
- 1.0,
- 1.0,
- ).bind()
-
- assertThat(pos).isEqualTo(characterToLookup)
- }
- }
- }
- }
-
- @Test
- fun textPageCountRects() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- page.openTextPage().bind().use { textPage ->
- val rectCount = textPage.textPageCountRects(0, 100).bind()
-
- assertThat(rectCount).isEqualTo(4)
- }
- }
- }
- }
-
- @Test
- fun textPageGetRect() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- page.openTextPage().bind().use { textPage ->
- val rect = textPage.textPageGetRect(0).bind()
-
- assertThat(rect).isEqualTo(RectF(0f, 0f, 0f, 0f))
- }
- }
- }
- }
-
- @Test
- fun textPageGetBoundedText() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- page.openTextPage().bind().use { textPage ->
- val text = textPage.textPageGetBoundedText(RectF(0f, 97f, 100f, 100f), 100).bind()
-
- assertThat(text).isEqualTo("Do")
- }
- }
- }
- }
-
- @Test
- fun getFontSize() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- page.openTextPage().bind().use { textPage ->
- val fontSize = textPage.getFontSize(0).bind()
-
- assertThat(fontSize).isEqualTo(22.559999465942383)
- }
- }
- }
- }
-
- @Test
- fun findStart(): TestResult =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- page.openTextPage().bind().use { textPage ->
- val findWhat = "children's"
- val startIndex = 0
- textPage.findStart(findWhat, emptySet(), startIndex).bind().use { findHandle ->
- var result = findHandle.findNext()
- assertThat(result.bind()).isTrue()
- var index = findHandle.getSchResultIndex().bind()
- var count = findHandle.getSchCount().bind()
- var text = textPage.textPageGetText(index, count).bind()
- assertThat(index).isEqualTo(1525)
- assertThat(count).isEqualTo(10)
- assertThat(text).isEqualTo(findWhat)
- result = findHandle.findNext()
- assertThat(result.bind()).isTrue()
- index = findHandle.getSchResultIndex().bind()
- count = findHandle.getSchCount().bind()
- text = textPage.textPageGetText(index, count).bind()
- assertThat(index).isEqualTo(2761)
- assertThat(count).isEqualTo(10)
- assertThat(text).isEqualTo(findWhat)
- result = findHandle.findNext()
- assertThat(result.bind()).isFalse()
- }
- }
- }
- }
- }
-
- fun close() =
- runTest {
- either {
- var pageAfterClose: PdfTextPageKtF?
- pdfDocument.openPage(0).bind().use { page ->
- page.openTextPage().bind().use { textPage ->
- pageAfterClose = textPage
- }
- }
- pageAfterClose!!.textPageCountChars()
- }.mapLeft {
- assertThat(it).isInstanceOf(PdfiumKtFErrors.AlreadyClosed::class.java)
- }
- }
-
- @Test
- fun getPage() =
- runTest {
- either {
- pdfDocument.openPage(0).bind().use { page ->
- page.openTextPage().bind().use { textPage ->
- assertThat(textPage.page).isNotNull()
- }
- }
- }
- }
-}
diff --git a/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/PdfiumCoreKtFTest.kt b/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/PdfiumCoreKtFTest.kt
deleted file mode 100644
index 79724b0..0000000
--- a/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/PdfiumCoreKtFTest.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-package io.legere.pdfiumandroid.arrow
-
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.google.common.truth.Truth.assertThat
-import io.legere.pdfiumandroid.arrow.base.BasePDFTest
-import io.legere.pdfiumandroid.arrow.base.ByteArrayPdfiumSource
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.test.runTest
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class PdfiumCoreKtFTest : BasePDFTest() {
- @Test
- fun newDocument() =
- runTest {
- val pdfBytes = getPdfBytes("f01.pdf")
-
- assertThat(pdfBytes).isNotNull()
-
- val pdfiumCore = PdfiumCoreKtF(Dispatchers.Unconfined)
- val pdfDocument = pdfiumCore.newDocument(pdfBytes)
-
- assertThat(pdfDocument).isNotNull()
- }
-
- @Test
- fun newDocumentWithCustomSource() =
- runTest {
- val pdfBytes = getPdfBytes("f01.pdf")
-
- assertThat(pdfBytes).isNotNull()
-
- val pdfiumCore = PdfiumCoreKtF(Dispatchers.Unconfined)
- val pdfDocument = pdfiumCore.newDocument(ByteArrayPdfiumSource(pdfBytes!!))
-
- assertThat(pdfDocument).isNotNull()
- }
-}
diff --git a/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/base/BasePDFTest.kt b/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/base/BasePDFTest.kt
deleted file mode 100644
index 05960c7..0000000
--- a/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/base/BasePDFTest.kt
+++ /dev/null
@@ -1,27 +0,0 @@
-package io.legere.pdfiumandroid.arrow.base
-
-import android.graphics.RectF
-import android.util.Log
-import androidx.test.platform.app.InstrumentationRegistry
-
-@Suppress("unused")
-open class BasePDFTest {
- // set to true to skip tests that are not implemented yet
- // set to false to force unimplemented tests to fail
- val notImplementedAssetValue = false
-
- val noResultRect = RectF(-1f, -1f, -1f, -1f)
-
- fun getPdfBytes(filename: String): ByteArray? {
- val appContext = InstrumentationRegistry.getInstrumentation().context
- val assetManager = appContext.assets
- try {
- val input = assetManager.open(filename)
- return input.readBytes()
- } catch (e: Exception) {
- Log.e(BasePDFTest::class.simpleName, "Ugh", e)
- }
- assetManager.close()
- return null
- }
-}
diff --git a/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/base/ByteArrayPdfiumSource.kt b/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/base/ByteArrayPdfiumSource.kt
deleted file mode 100644
index b876da1..0000000
--- a/pdfiumandroid/arrow/src/androidTest/java/io/legere/pdfiumandroid/arrow/base/ByteArrayPdfiumSource.kt
+++ /dev/null
@@ -1,28 +0,0 @@
-package io.legere.pdfiumandroid.arrow.base
-
-import io.legere.pdfiumandroid.PdfiumSource
-
-class ByteArrayPdfiumSource(
- private val array: ByteArray,
-) : PdfiumSource {
- override val length: Long
- get() = array.size.toLong()
-
- override fun read(
- position: Long,
- buffer: ByteArray,
- size: Int,
- ): Int {
- array.copyInto(
- destination = buffer,
- destinationOffset = 0,
- startIndex = position.toInt(),
- endIndex = position.toInt() + size,
- )
- return size
- }
-
- override fun close() {
- // nothing to close
- }
-}
diff --git a/pdfiumandroid/arrow/src/main/AndroidManifest.xml b/pdfiumandroid/arrow/src/main/AndroidManifest.xml
deleted file mode 100644
index 5c3d365..0000000
--- a/pdfiumandroid/arrow/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
diff --git a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/FindResultKtF.kt b/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/FindResultKtF.kt
deleted file mode 100644
index 49b90a9..0000000
--- a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/FindResultKtF.kt
+++ /dev/null
@@ -1,42 +0,0 @@
-package io.legere.pdfiumandroid.arrow
-
-import arrow.core.Either
-import io.legere.pdfiumandroid.FindResult
-import kotlinx.coroutines.CoroutineDispatcher
-import java.io.Closeable
-
-@Suppress("unused")
-class FindResultKtF(
- private val findResult: FindResult,
- private val dispatcher: CoroutineDispatcher,
-) : Closeable {
- suspend fun findNext(): Either =
- wrapEither(dispatcher) {
- findResult.findNext()
- }
-
- suspend fun findPrev(): Either =
- wrapEither(dispatcher) {
- findResult.findPrev()
- }
-
- suspend fun getSchResultIndex(): Either =
- wrapEither(dispatcher) {
- findResult.getSchResultIndex()
- }
-
- suspend fun getSchCount(): Either =
- wrapEither(dispatcher) {
- findResult.getSchCount()
- }
-
- suspend fun closeFind() {
- wrapEither(dispatcher) {
- findResult.closeFind()
- }
- }
-
- override fun close() {
- findResult.closeFind()
- }
-}
diff --git a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfDocumentKtF.kt b/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfDocumentKtF.kt
deleted file mode 100644
index 633814f..0000000
--- a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfDocumentKtF.kt
+++ /dev/null
@@ -1,150 +0,0 @@
-@file:Suppress("unused", "CanBeVal")
-
-package io.legere.pdfiumandroid.arrow
-
-import android.graphics.Matrix
-import android.graphics.RectF
-import android.view.Surface
-import arrow.core.Either
-import io.legere.pdfiumandroid.PdfDocument
-import io.legere.pdfiumandroid.PdfWriteCallback
-import kotlinx.coroutines.CoroutineDispatcher
-import kotlinx.coroutines.withContext
-import java.io.Closeable
-
-/**
- * PdfDocumentKtF represents a PDF file and allows you to load pages from it.
- * @property document the [PdfDocument] to wrap
- * @property dispatcher the [CoroutineDispatcher] to use for suspending calls
- * @constructor create a [PdfDocumentKtF] from a [PdfDocument]
- */
-@Suppress("TooManyFunctions", "CanBeVal")
-class PdfDocumentKtF(
- val document: PdfDocument,
- private val dispatcher: CoroutineDispatcher,
-) : Closeable {
- /**
- * suspend version of [PdfDocument.getPageCount]
- */
- suspend fun getPageCount(): Either =
- wrapEither(dispatcher) {
- document.getPageCount()
- }
-
- /**
- * suspend version of [PdfDocument.getPageCharCounts]
- */
- suspend fun getPageCharCounts(): Either =
- wrapEither(dispatcher) {
- document.getPageCharCounts()
- }
-
- /**
- * suspend version of [PdfDocument.openPage]
- */
- suspend fun openPage(pageIndex: Int): Either =
- wrapEither(dispatcher) {
- PdfPageKtF(document.openPage(pageIndex), dispatcher)
- }
-
- /**
- * suspend version of [PdfDocument.openPages]
- */
- suspend fun openPages(
- fromIndex: Int,
- toIndex: Int,
- ): Either> =
- wrapEither(dispatcher) {
- document.openPages(fromIndex, toIndex).map { PdfPageKtF(it, dispatcher) }
- }
-
- /**
- * suspend version of [PdfDocument.renderPages]
- */
- @Suppress("LongParameterList", "ComplexMethod", "ComplexCondition")
- suspend fun renderPages(
- surface: Surface?,
- pages: List,
- matrices: List,
- clipRects: List,
- renderAnnot: Boolean = false,
- textMask: Boolean = false,
- canvasColor: Int = 0xFF848484.toInt(),
- pageBackgroundColor: Int = 0xFFFFFFFF.toInt(),
- renderCoroutinesDispatcher: CoroutineDispatcher,
- ): Boolean {
- return withContext(renderCoroutinesDispatcher) {
- return@withContext surface
- ?.let {
- document.renderPages(
- surface,
- pages.map { page -> page.page },
- matrices,
- clipRects,
- renderAnnot,
- textMask,
- canvasColor,
- pageBackgroundColor,
- )
- } ?: false
- }
- }
-
- /**
- * suspend version of [PdfDocument.deletePage]
- */
- suspend fun deletePage(pageIndex: Int): Unit =
- withContext(dispatcher) {
- document.deletePage(pageIndex)
- }
-
- /**
- * suspend version of [PdfDocument.getDocumentMeta]
- */
- suspend fun getDocumentMeta(): Either =
- wrapEither(dispatcher) {
- document.getDocumentMeta()
- }
-
- /**
- * suspend version of [PdfDocument.getTableOfContents]
- */
- suspend fun getTableOfContents(): Either> =
- wrapEither(dispatcher) {
- document.getTableOfContents()
- }
-
- /**
- * suspend version of [PdfDocument.openTextPages]
- */
- suspend fun openTextPages(
- fromIndex: Int,
- toIndex: Int,
- ): Either> =
- wrapEither(dispatcher) {
- document.openTextPages(fromIndex, toIndex).map { PdfTextPageKtF(it, dispatcher) }
- }
-
- /**
- * suspend version of [PdfDocument.saveAsCopy]
- */
- suspend fun saveAsCopy(callback: PdfWriteCallback): Either =
- wrapEither(dispatcher) {
- document.saveAsCopy(callback)
- }
-
- /**
- * Close the document
- * @throws IllegalArgumentException if document is closed
- */
- override fun close() {
- document.close()
- }
-
- fun safeClose(): Either =
- Either
- .catch {
- document.close()
- true
- }.mapLeft { exceptionToPdfiumKtFError(it) }
-}
diff --git a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfPageKtF.kt b/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfPageKtF.kt
deleted file mode 100644
index 636dc09..0000000
--- a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfPageKtF.kt
+++ /dev/null
@@ -1,384 +0,0 @@
-@file:Suppress("unused")
-
-package io.legere.pdfiumandroid.arrow
-
-import android.graphics.Bitmap
-import android.graphics.Matrix
-import android.graphics.Point
-import android.graphics.PointF
-import android.graphics.Rect
-import android.graphics.RectF
-import android.view.Surface
-import arrow.core.Either
-import arrow.core.left
-import arrow.core.right
-import io.legere.pdfiumandroid.Logger
-import io.legere.pdfiumandroid.PdfDocument
-import io.legere.pdfiumandroid.PdfPage
-import io.legere.pdfiumandroid.PdfiumCore
-import io.legere.pdfiumandroid.util.Size
-import kotlinx.coroutines.CoroutineDispatcher
-import kotlinx.coroutines.sync.withLock
-import kotlinx.coroutines.withContext
-import java.io.Closeable
-
-/**
- * PdfPageKtF represents a single page of a PDF file.
- * @property page the [PdfPage] to wrap
- * @property dispatcher the [CoroutineDispatcher] to use for suspending calls
- */
-@Suppress("TooManyFunctions")
-class PdfPageKtF(
- val page: PdfPage,
- private val dispatcher: CoroutineDispatcher,
-) : Closeable {
- /**
- * Open a text page
- * @throws IllegalArgumentException if document is closed or the page cannot be loaded
- */
- suspend fun openTextPage(): Either =
- wrapEither(dispatcher) {
- PdfTextPageKtF(page.openTextPage(), dispatcher)
- }
-
- /**
- * suspend version of [PdfPage.getPageWidth]
- */
- suspend fun getPageWidth(screenDpi: Int): Either =
- wrapEither(dispatcher) {
- page.getPageWidth(screenDpi)
- }
-
- /**
- * suspend version of [PdfPage.getPageHeight]
- */
- suspend fun getPageHeight(screenDpi: Int): Either =
- wrapEither(dispatcher) {
- page.getPageHeight(screenDpi)
- }
-
- /**
- * suspend version of [PdfPage.getPageWidthPoint]
- */
- suspend fun getPageWidthPoint(): Either =
- wrapEither(dispatcher) {
- page.getPageWidthPoint()
- }
-
- /**
- * suspend version of [PdfPage.getPageHeightPoint]
- */
- suspend fun getPageHeightPoint(): Either =
- wrapEither(dispatcher) {
- page.getPageHeightPoint()
- }
-
- /**
- * suspend version of [PdfPage.getPageMatrix]
- */
- suspend fun getPageMatrix(): Either =
- wrapEither(dispatcher) {
- page.getPageMatrix() ?: error("Page matrix is null")
- }
-
- /**
- * suspend version of [PdfPage.getPageRotation]
- */
- suspend fun getPageRotation(): Either =
- withContext(dispatcher) {
- Either
- .catch {
- val rotation = page.getPageRotation()
- if (rotation < 0) {
- error("Invalid rotation: $rotation")
- }
- rotation
- }.mapLeft {
- exceptionToPdfiumKtFError(it)
- }
- }
-
- /**
- * suspend version of [PdfPage.getPageCropBox]
- */
- suspend fun getPageCropBox(): Either =
- wrapEither(dispatcher) {
- page.getPageCropBox()
- }
-
- /**
- * suspend version of [PdfPage.getPageMediaBox]
- */
- suspend fun getPageMediaBox(): Either =
- wrapEither(dispatcher) {
- page.getPageMediaBox()
- }
-
- /**
- * suspend version of [PdfPage.getPageBleedBox]
- */
- suspend fun getPageBleedBox(): Either =
- wrapEither(dispatcher) {
- page.getPageBleedBox()
- }
-
- /**
- * suspend version of [PdfPage.getPageTrimBox]
- */
- suspend fun getPageTrimBox(): Either =
- wrapEither(dispatcher) {
- page.getPageTrimBox()
- }
-
- /**
- * suspend version of [PdfPage.getPageArtBox]
- */
- suspend fun getPageArtBox(): Either =
- wrapEither(dispatcher) {
- page.getPageArtBox()
- }
-
- /**
- * suspend version of [PdfPage.getPageBoundingBox]
- */
- suspend fun getPageBoundingBox(): Either =
- wrapEither(dispatcher) {
- page.getPageBoundingBox()
- }
-
- /**
- * suspend version of [PdfPage.getPageSize]
- */
- suspend fun getPageSize(screenDpi: Int): Either =
- wrapEither(dispatcher) {
- page.getPageSize(screenDpi)
- }
-
- /**
- * suspend version of [PdfPage.renderPage]
- */
- @Suppress("LongParameterList", "ComplexCondition")
- suspend fun renderPage(
- surface: Surface?,
- startX: Int,
- startY: Int,
- drawSizeX: Int,
- drawSizeY: Int,
- canvasColor: Int = 0xFF848484.toInt(),
- pageBackgroundColor: Int = 0xFFFFFFFF.toInt(),
- renderCoroutinesDispatcher: CoroutineDispatcher,
- ): Either {
- val sizes = IntArray(2)
- val pointers = LongArray(2)
- return withContext(renderCoroutinesDispatcher) {
- surface?.let {
- PdfPage.lockSurface(
- it,
- sizes,
- pointers,
- )
- val nativeWindow = pointers[0]
- val bufferPtr = pointers[1]
- val surfaceWidth = sizes[0]
- val surfaceHeight = sizes[1]
- Logger.d(
- "PdfPageKtF",
- "page: ${page.pageIndex}, surfaceWidth: $surfaceWidth, " +
- "surfaceHeight: $surfaceHeight, nativeWindow: $nativeWindow, " +
- "bufferPtr: $bufferPtr, nativeWindow: $nativeWindow",
- )
- if (bufferPtr == 0L || bufferPtr == -1L || nativeWindow == 0L || nativeWindow == -1L) {
- PdfiumKtFErrors.ConstraintError.left()
- }
- val result =
- page.renderPage(
- bufferPtr,
- startX,
- startY,
- drawSizeX,
- drawSizeY,
- canvasColor = canvasColor,
- pageBackgroundColor = pageBackgroundColor,
- )
- PdfPage.unlockSurface(longArrayOf(nativeWindow, bufferPtr))
- if (!result) {
- PdfiumKtFErrors.ConstraintError.left()
- }
- true.right()
- } ?: PdfiumKtFErrors.ConstraintError.left()
- }
- }
-
- /**
- * suspend version of [PdfPage.renderPage]
- */
- @Suppress("LongParameterList")
- suspend fun renderPage(
- surface: Surface?,
- matrix: Matrix,
- clipRect: RectF,
- renderAnnot: Boolean = false,
- textMask: Boolean = false,
- canvasColor: Int = 0xFF848484.toInt(),
- pageBackgroundColor: Int = 0xFFFFFFFF.toInt(),
- renderCoroutinesDispatcher: CoroutineDispatcher,
- ): Either {
- return PdfiumCore.surfaceMutex.withLock {
- withContext(renderCoroutinesDispatcher) {
- return@withContext surface?.let {
- val retValue =
- page.renderPage(
- surface,
- matrix,
- clipRect,
- renderAnnot,
- textMask,
- canvasColor,
- pageBackgroundColor,
- )
- if (!retValue) {
- PdfiumKtFErrors.ConstraintError.left()
- } else {
- true.right()
- }
- } ?: PdfiumKtFErrors.ConstraintError.left()
- }
- }
- }
-
- @Suppress("LongParameterList")
- /**
- * suspend version of [PdfPage.renderPageBitmap]
- */
- suspend fun renderPageBitmap(
- bitmap: Bitmap,
- startX: Int,
- startY: Int,
- drawSizeX: Int,
- drawSizeY: Int,
- renderAnnot: Boolean = false,
- textMask: Boolean = false,
- canvasColor: Int = 0xFF848484.toInt(),
- pageBackgroundColor: Int = 0xFFFFFFFF.toInt(),
- ): Either =
- wrapEither(dispatcher) {
- page.renderPageBitmap(
- bitmap,
- startX,
- startY,
- drawSizeX,
- drawSizeY,
- renderAnnot,
- textMask,
- canvasColor,
- pageBackgroundColor,
- )
- true
- }
-
- @Suppress("LongParameterList")
- /**
- * suspend version of [PdfPage.renderPageBitmap]
- */
- suspend fun renderPageBitmap(
- bitmap: Bitmap?,
- matrix: Matrix,
- clipRect: RectF,
- renderAnnot: Boolean = false,
- textMask: Boolean = false,
- canvasColor: Int = 0xFF848484.toInt(),
- pageBackgroundColor: Int = 0xFFFFFFFF.toInt(),
- ): Either =
- wrapEither(dispatcher) {
- page.renderPageBitmap(bitmap, matrix, clipRect, renderAnnot, textMask, canvasColor, pageBackgroundColor)
- true
- }
-
- /**
- * suspend version of [PdfPage.getPageLinks]
- */
- suspend fun getPageLinks(): Either> =
- wrapEither(dispatcher) {
- page.getPageLinks()
- }
-
- /**
- * suspend version of [PdfPage.mapPageCoordsToDevice]
- */
- @Suppress("LongParameterList")
- suspend fun mapPageCoordsToDevice(
- startX: Int,
- startY: Int,
- sizeX: Int,
- sizeY: Int,
- rotate: Int,
- pageX: Double,
- pageY: Double,
- ): Either =
- wrapEither(dispatcher) {
- page.mapPageCoordsToDevice(startX, startY, sizeX, sizeY, rotate, pageX, pageY)
- }
-
- @Suppress("LongParameterList")
- /**
- * suspend version of [PdfPage.mapDeviceCoordsToPage]
- */
- suspend fun mapDeviceCoordsToPage(
- startX: Int,
- startY: Int,
- sizeX: Int,
- sizeY: Int,
- rotate: Int,
- deviceX: Int,
- deviceY: Int,
- ): Either =
- wrapEither(dispatcher) {
- page.mapDeviceCoordsToPage(startX, startY, sizeX, sizeY, rotate, deviceX, deviceY)
- }
-
- @Suppress("LongParameterList")
- /**
- * suspend version of [PdfPage.mapRectToDevice]
- */
- suspend fun mapRectToDevice(
- startX: Int,
- startY: Int,
- sizeX: Int,
- sizeY: Int,
- rotate: Int,
- coords: RectF,
- ): Either =
- wrapEither(dispatcher) {
- page.mapRectToDevice(startX, startY, sizeX, sizeY, rotate, coords)
- }
-
- @Suppress("LongParameterList")
- /**
- * suspend version of [PdfPage.mapRectToPage]
- */
- suspend fun mapRectToPage(
- startX: Int,
- startY: Int,
- sizeX: Int,
- sizeY: Int,
- rotate: Int,
- coords: Rect,
- ): Either =
- wrapEither(dispatcher) {
- page.mapRectToPage(startX, startY, sizeX, sizeY, rotate, coords)
- }
-
- /**
- * Closes the page
- */
- override fun close() {
- page.close()
- }
-
- fun safeClose(): Either =
- Either
- .catch {
- page.close()
- true
- }.mapLeft { exceptionToPdfiumKtFError(it) }
-}
diff --git a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfPageLinkKtF.kt b/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfPageLinkKtF.kt
deleted file mode 100644
index d2e2930..0000000
--- a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfPageLinkKtF.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-package io.legere.pdfiumandroid.arrow
-
-import android.graphics.RectF
-import arrow.core.Either
-import io.legere.pdfiumandroid.PdfPageLink
-import kotlinx.coroutines.CoroutineDispatcher
-import java.io.Closeable
-
-class PdfPageLinkKtF(
- val pageLink: PdfPageLink,
- private val dispatcher: CoroutineDispatcher,
-) : Closeable {
- suspend fun countWebLinks(): Either =
- wrapEither(dispatcher) {
- pageLink.countWebLinks()
- }
-
- suspend fun getURL(
- index: Int,
- length: Int,
- ): Either =
- wrapEither(dispatcher) {
- pageLink.getURL(index, length)
- }
-
- suspend fun countRects(index: Int): Either =
- wrapEither(dispatcher) {
- pageLink.countRects(index)
- }
-
- suspend fun getRect(
- linkIndex: Int,
- rectIndex: Int,
- ): Either =
- wrapEither(dispatcher) {
- pageLink.getRect(linkIndex, rectIndex)
- }
-
- suspend fun getTextRange(index: Int): Either> =
- wrapEither(dispatcher) {
- pageLink.getTextRange(index)
- }
-
- override fun close() {
- pageLink.close()
- }
-}
diff --git a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfTextPageKtF.kt b/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfTextPageKtF.kt
deleted file mode 100644
index 64b0f9e..0000000
--- a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfTextPageKtF.kt
+++ /dev/null
@@ -1,149 +0,0 @@
-@file:Suppress("unused")
-
-package io.legere.pdfiumandroid.arrow
-
-import android.graphics.RectF
-import arrow.core.Either
-import io.legere.pdfiumandroid.FindFlags
-import io.legere.pdfiumandroid.PdfTextPage
-import io.legere.pdfiumandroid.WordRangeRect
-import kotlinx.coroutines.CoroutineDispatcher
-import java.io.Closeable
-
-/**
- * PdfTextPageKtF represents a single text page of a PDF file.
- * @property page the [PdfTextPage] to wrap
- * @property dispatcher the [CoroutineDispatcher] to use for suspending calls
- */
-@Suppress("TooManyFunctions")
-class PdfTextPageKtF(
- val page: PdfTextPage,
- private val dispatcher: CoroutineDispatcher,
-) : Closeable {
- /**
- * suspend version of [PdfTextPage.textPageCountChars]
- */
- suspend fun textPageCountChars(): Either =
- wrapEither(dispatcher) {
- page.textPageCountChars()
- }
-
- /**
- * suspend version of [PdfTextPage.textPageGetText]
- */
- suspend fun textPageGetText(
- startIndex: Int,
- length: Int,
- ): Either =
- wrapEither(dispatcher) {
- page.textPageGetText(startIndex, length)
- }
-
- /**
- * suspend version of [PdfTextPage.textPageGetUnicode]
- */
- suspend fun textPageGetUnicode(index: Int): Either =
- wrapEither(dispatcher) {
- page.textPageGetUnicode(index)
- }
-
- /**
- * suspend version of [PdfTextPage.textPageGetCharBox]
- */
- suspend fun textPageGetCharBox(index: Int): Either =
- wrapEither(dispatcher) {
- page.textPageGetCharBox(index)
- }
-
- /**
- * suspend version of [PdfTextPage.textPageGetCharIndexAtPos]
- */
- suspend fun textPageGetCharIndexAtPos(
- x: Double,
- y: Double,
- xTolerance: Double,
- yTolerance: Double,
- ): Either =
- wrapEither(dispatcher) {
- page.textPageGetCharIndexAtPos(x, y, xTolerance, yTolerance)
- }
-
- /**
- * suspend version of [PdfTextPage.textPageCountRects]
- */
- suspend fun textPageCountRects(
- startIndex: Int,
- count: Int,
- ): Either =
- wrapEither(dispatcher) {
- page.textPageCountRects(startIndex, count)
- }
-
- /**
- * suspend version of [PdfTextPage.textPageGetRect]
- */
- suspend fun textPageGetRect(rectIndex: Int): Either =
- wrapEither(dispatcher) {
- page.textPageGetRect(rectIndex)
- }
-
- /**
- * suspend version of [PdfTextPage.textPageGetRectsForRanges]
- */
- suspend fun textPageGetRectsForRanges(wordRanges: IntArray): Either?> =
- wrapEither(dispatcher) {
- page.textPageGetRectsForRanges(wordRanges)
- }
-
- /**
- * suspend version of [PdfTextPage.textPageGetBoundedText]
- */
- suspend fun textPageGetBoundedText(
- rect: RectF,
- length: Int,
- ): Either =
- wrapEither(dispatcher) {
- page.textPageGetBoundedText(rect, length)
- }
-
- /**
- * suspend version of [PdfTextPage.getFontSize]
- */
- suspend fun getFontSize(charIndex: Int): Either =
- wrapEither(dispatcher) {
- page.getFontSize(charIndex)
- }
-
- suspend fun findStart(
- findWhat: String,
- flags: Set,
- startIndex: Int,
- ): Either =
- wrapEither(dispatcher) {
- val findResult = page.findStart(findWhat, flags, startIndex)
- if (findResult == null) {
- error("findResult is null")
- } else {
- FindResultKtF(findResult, dispatcher)
- }
- }
-
- suspend fun loadWebLink(): Either =
- wrapEither(dispatcher) {
- PdfPageLinkKtF(page.loadWebLink(), dispatcher)
- }
-
- /**
- * Close the page and free all resources.
- */
- override fun close() {
- page.close()
- }
-
- fun safeClose(): Either =
- Either
- .catch {
- page.close()
- true
- }.mapLeft { exceptionToPdfiumKtFError(it) }
-}
diff --git a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfiumArrorwExt.kt b/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfiumArrorwExt.kt
deleted file mode 100644
index 3ce4b3e..0000000
--- a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfiumArrorwExt.kt
+++ /dev/null
@@ -1,18 +0,0 @@
-package io.legere.pdfiumandroid.arrow
-
-import arrow.core.Either
-import kotlinx.coroutines.CoroutineDispatcher
-import kotlinx.coroutines.withContext
-
-suspend inline fun wrapEither(
- dispatcher: CoroutineDispatcher,
- crossinline block: () -> T,
-): Either =
- withContext(dispatcher) {
- Either
- .catch {
- block()
- }.mapLeft {
- exceptionToPdfiumKtFError(it)
- }
- }
diff --git a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfiumCoreKtF.kt b/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfiumCoreKtF.kt
deleted file mode 100644
index 1a94080..0000000
--- a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfiumCoreKtF.kt
+++ /dev/null
@@ -1,79 +0,0 @@
-@file:Suppress("unused")
-
-package io.legere.pdfiumandroid.arrow
-
-import android.os.ParcelFileDescriptor
-import arrow.core.Either
-import io.legere.pdfiumandroid.PdfiumCore
-import io.legere.pdfiumandroid.PdfiumSource
-import io.legere.pdfiumandroid.util.Config
-import kotlinx.coroutines.CoroutineDispatcher
-
-/**
- * PdfiumCoreKtF is the main entry-point for access to the PDFium API.
- * @property dispatcher the [CoroutineDispatcher] to use for suspending calls
- * @constructor create a [PdfiumCoreKtF] from a [PdfiumCore]
- */
-class PdfiumCoreKtF(
- private val dispatcher: CoroutineDispatcher,
- config: Config = Config(),
-) {
- private val coreInternal = PdfiumCore(config = config)
-
- /**
- * suspend version of [PdfiumCore.newDocument]
- */
- suspend fun newDocument(fd: ParcelFileDescriptor): Either =
- wrapEither(dispatcher) {
- PdfDocumentKtF(coreInternal.newDocument(fd), dispatcher)
- }
-
- /**
- * suspend version of [PdfiumCore.newDocument]
- */
- suspend fun newDocument(
- fd: ParcelFileDescriptor,
- password: String?,
- ): Either =
- wrapEither(dispatcher) {
- PdfDocumentKtF(coreInternal.newDocument(fd, password), dispatcher)
- }
-
- /**
- * suspend version of [PdfiumCore.newDocument]
- */
- suspend fun newDocument(data: ByteArray?): Either =
- wrapEither(dispatcher) {
- PdfDocumentKtF(coreInternal.newDocument(data), dispatcher)
- }
-
- /**
- * suspend version of [PdfiumCore.newDocument]
- */
- suspend fun newDocument(
- data: ByteArray?,
- password: String?,
- ): Either =
- wrapEither(dispatcher) {
- PdfDocumentKtF(coreInternal.newDocument(data, password), dispatcher)
- }
-
- /**
- * suspend version of [PdfiumCore.newDocument]
- */
- suspend fun newDocument(data: PdfiumSource): Either =
- wrapEither(dispatcher) {
- PdfDocumentKtF(coreInternal.newDocument(data), dispatcher)
- }
-
- /**
- * suspend version of [PdfiumCore.newDocument]
- */
- suspend fun newDocument(
- data: PdfiumSource,
- password: String?,
- ): Either =
- wrapEither(dispatcher) {
- PdfDocumentKtF(coreInternal.newDocument(data, password), dispatcher)
- }
-}
diff --git a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfiumKtFErrors.kt b/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfiumKtFErrors.kt
deleted file mode 100644
index 1a50468..0000000
--- a/pdfiumandroid/arrow/src/main/java/io/legere/pdfiumandroid/arrow/PdfiumKtFErrors.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-package io.legere.pdfiumandroid.arrow
-
-sealed class PdfiumKtFErrors {
- data class RuntimeException(
- val message: String,
- ) : PdfiumKtFErrors()
-
- data class AlreadyClosed(
- val message: String,
- ) : PdfiumKtFErrors()
-
- data object ConstraintError : PdfiumKtFErrors()
-}
-
-fun exceptionToPdfiumKtFError(e: Throwable): PdfiumKtFErrors =
- if (e is IllegalStateException && e.message?.contains("Already closed") == true) {
- PdfiumKtFErrors.AlreadyClosed(e.message ?: "Unknown error")
- } else {
- PdfiumKtFErrors.RuntimeException(e.message ?: "Unknown error")
- }
diff --git a/pdfiumandroid/build.gradle.kts b/pdfiumandroid/build.gradle.kts
deleted file mode 100644
index 45f29bf..0000000
--- a/pdfiumandroid/build.gradle.kts
+++ /dev/null
@@ -1,224 +0,0 @@
-import org.jetbrains.kotlin.gradle.dsl.JvmTarget
-import org.jreleaser.model.Active
-import org.jreleaser.model.Signing
-
-
-plugins {
- id("com.android.library")
- alias(libs.plugins.kotlin.android)
- alias(libs.plugins.detekt)
- alias(libs.plugins.kover)
- alias(libs.plugins.ktlint)
- alias(libs.plugins.jreleaser)
- `maven-publish`
- signing
-}
-kotlin {
- compilerOptions {
- jvmTarget.set(JvmTarget.JVM_17)
- freeCompilerArgs.add("-Xstring-concat=inline")
- }
-}
-
-android {
- namespace = "io.legere.pdfiumandroid"
- compileSdk = 35
-
- ndkVersion = "28.0.12674087"
-
- defaultConfig {
- minSdk = 23
- testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
- consumerProguardFiles("consumer-rules.pro")
- @Suppress("UnstableApiUsage")
- externalNativeBuild {
- cmake {
- cppFlags("")
- }
- }
- }
- buildFeatures {
- buildConfig = true
- }
-
- buildTypes {
- release {
- isMinifyEnabled = false
- proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
- }
-// maybeCreate("qa")
-// getByName("qa") {
-// matchingFallbacks += listOf("release")
-// isMinifyEnabled = true
-// signingConfig = signingConfigs.getByName("debug")
-// }
- }
- externalNativeBuild {
- cmake {
- path = file("src/main/cpp/CMakeLists.txt")
- version = "3.22.1"
- }
- }
- compileOptions {
- sourceCompatibility(JavaVersion.VERSION_17)
- targetCompatibility(JavaVersion.VERSION_17)
- }
- publishing {
- singleVariant("release") {
- // if you don't want sources/javadoc, remove these lines
- withSourcesJar()
- withJavadocJar()
- }
- }
-}
-
-dependencies {
-
- implementation(libs.kotlinx.coroutines.android)
- implementation(libs.androidx.annotation.jvm)
-
- testImplementation(libs.junit)
-
- testImplementation(libs.androidx.junit)
- testImplementation(libs.androidx.espresso.core)
- testImplementation(libs.truth)
- testImplementation(libs.kotlinx.coroutines.test)
- testImplementation(libs.androidx.core.testing)
-
- androidTestImplementation(libs.androidx.junit)
- androidTestImplementation(libs.androidx.espresso.core)
- androidTestImplementation(libs.truth)
- androidTestImplementation(libs.kotlinx.coroutines.test)
- androidTestImplementation(libs.androidx.core.testing)
-}
-
-fun isReleaseBuild(): Boolean = !findProject("VERSION_NAME").toString().contains("SNAPSHOT")
-
-fun getReleaseRepositoryUrl(): String =
- if (rootProject.hasProperty("RELEASE_REPOSITORY_URL")) {
- rootProject.properties["RELEASE_REPOSITORY_URL"] as String
- } else {
- "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
- }
-
-fun getSnapshotRepositoryUrl(): String =
- if (rootProject.hasProperty("SNAPSHOT_REPOSITORY_URL")) {
- rootProject.properties["SNAPSHOT_REPOSITORY_URL"] as String
- } else {
- "https://oss.sonatype.org/content/repositories/snapshots/"
- }
-
-fun getRepositoryUrl(): String = if (isReleaseBuild()) getReleaseRepositoryUrl() else getSnapshotRepositoryUrl()
-
-fun getRepositoryUsername(): String =
- if (rootProject.hasProperty("JRELEASER_MAVENCENTRAL_USERNAME")) {
- rootProject.properties["JRELEASER_MAVENCENTRAL_USERNAME"] as String
- } else {
- ""
- }
-
-fun getRepositoryPassword(): String =
- if (rootProject.hasProperty("JRELEASER_MAVENCENTRAL_TOKEN")) {
- rootProject.properties["JRELEASER_MAVENCENTRAL_TOKEN"] as String
- } else {
- ""
- }
-
-publishing {
- publications {
- create("maven") {
- groupId = "io.legere"
- artifactId = "pdfiumandroid"
- version = project.property("VERSION_NAME") as String
-
- pom {
- name.set("pdfiumandroid")
-// packaging = rootProject.properties["POM_PACKAGING"] as String
- description = rootProject.properties["POM_DESCRIPTION"] as String
- url.set(rootProject.properties["POM_URL"] as String)
- licenses {
- license {
- name.set(rootProject.properties["POM_LICENCE_NAME"] as String)
- url.set(rootProject.properties["POM_LICENCE_URL"] as String)
- distribution.set(rootProject.properties["POM_LICENCE_DIST"] as String)
- }
- }
- developers {
- developer {
- id.set(rootProject.properties["POM_DEVELOPER_ID"] as String)
- name.set(rootProject.properties["POM_DEVELOPER_NAME"] as String)
- }
- }
- scm {
- connection.set(rootProject.properties["POM_SCM_CONNECTION"] as String)
- developerConnection.set(rootProject.properties["POM_SCM_DEV_CONNECTION"] as String)
- url.set(rootProject.properties["POM_SCM_URL"] as String)
- }
- }
- afterEvaluate {
- from(components["release"])
- }
- }
- }
- repositories {
- maven {
- url =
- uri(layout.buildDirectory.dir("target/staging-deploy"))
- }
- }
-}
-
-jreleaser {
- project {
- inceptionYear = "2023"
- author("@johngray1965")
- description = rootProject.properties["POM_DESCRIPTION"] as String
- version = rootProject.properties["VERSION_NAME"] as String
- }
- gitRootSearch = true
- signing {
- active = Active.ALWAYS
- mode = Signing.Mode.COMMAND
- armored = true
- verify = false
- command {
- executable = "gpg"
- keyName = "4BBF8FAB"
- publicKeyring = "/Users/gray/.gnupg/secring.gpg"
- }
- }
- release {
- github {
- skipRelease = true
- }
- }
-// distributions {
-// create("zip") {
-// artifacts {
-// add(
-// layout.buildDirectory
-// .dir("libs")
-// .map {
-// it.file("pdfiumandroid.zip")
-// }
-// )
-// }
-// }
-// }
- deploy {
- maven {
- mavenCentral.create("sonatype") {
- active = Active.ALWAYS
- verifyPom = false
- url = "https://central.sonatype.com/api/v1/publisher"
- stagingRepository(
- layout.buildDirectory
- .dir("target/staging-deploy")
- .get()
- .toString(),
- )
- username = getRepositoryUsername()
- }
- }
- }
-}
diff --git a/pdfiumandroid/consumer-rules.pro b/pdfiumandroid/consumer-rules.pro
deleted file mode 100644
index 5bdc057..0000000
--- a/pdfiumandroid/consumer-rules.pro
+++ /dev/null
@@ -1,45 +0,0 @@
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
--keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
-
--keep class io.legere.pdfiumandroid.** { *; }
-
--keep interface io.legere.pdfiumandroid.** { public *; }
-
--keepclasseswithmembernames class io.legere.pdfiumandroid.** {
- public ;
-}
-
--keep class * extends io.legere.pdfiumandroid.LoggerInterface { *; }
--keep class io.legere.pdfiumandroid.suspend.PdfDocumentKt { *; }
--keepclassmembers public class io.legere.pdfiumandroid.suspend.PdfDocumentKt {
- public (...);
-}
--keep class io.legere.pdfiumandroid.suspend.PdfPageKt { *; }
--keepclassmembers public class io.legere.pdfiumandroid.suspend.PdfPageKt {
- public (...);
-}
--keep class io.legere.pdfiumandroid.suspend.PdfTextPageKt { *; }
--keepclassmembers public class io.legere.pdfiumandroid.suspend.PdfTextPageKt {
- public (...);
-}
--keep class io.legere.pdfiumandroid.suspend.PdfiumCoreKt { *; }
--keepclassmembers public class io.legere.pdfiumandroid.suspend.PdfiumCoreKt {
- public (...);
-}
--keep class io.legere.pdfiumandroid.util.AlreadyClosedBehavior { *; }
--keepclassmembers public class io.legere.pdfiumandroid.util.AlreadyClosedBehavior {
- public (...);
-}
--keep class io.legere.pdfiumandroid.util.Config { *; }
--keepclassmembers public class io.legere.pdfiumandroid.util.Config {
- public (...);
-}
--keep class io.legere.pdfiumandroid.util.Size { *; }
--keepclassmembers public class io.legere.pdfiumandroid.util.Size {
- public (...);
-}
diff --git a/pdfiumandroid/gradle.properties b/pdfiumandroid/gradle.properties
deleted file mode 100644
index 15ec3e1..0000000
--- a/pdfiumandroid/gradle.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-POM_NAME=pdfiumandroid
-POM_ARTIFACT_ID=pdfiumandroid
-POM_PACKAGING=aar
-
diff --git a/pdfiumandroid/proguard-rules.pro b/pdfiumandroid/proguard-rules.pro
deleted file mode 100644
index 345025f..0000000
--- a/pdfiumandroid/proguard-rules.pro
+++ /dev/null
@@ -1,59 +0,0 @@
-# Add project specific ProGuard rules here.
-# You can control the set of applied configuration files using the
-# proguardFiles setting in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
--keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
-
--keep class io.legere.pdfiumandroid.** { *; }
-
--keep interface io.legere.pdfiumandroid.** { public *; }
--keep class * extends io.legere.pdfiumandroid.LoggerInterface { *; }
--dontwarn java.lang.invoke.StringConcatFactory
--keepclasseswithmembernames class io.legere.pdfiumandroid.** {
- public ;
-}
-
--keep class io.legere.pdfiumandroid.suspend.PdfDocumentKt { *; }
--keepclassmembers public class io.legere.pdfiumandroid.suspend.PdfDocumentKt {
- public (...);
-}
--keep class io.legere.pdfiumandroid.suspend.PdfPageKt { *; }
--keepclassmembers public class io.legere.pdfiumandroid.suspend.PdfPageKt {
- public (...);
-}
--keep class io.legere.pdfiumandroid.suspend.PdfTextPageKt { *; }
--keepclassmembers public class io.legere.pdfiumandroid.suspend.PdfTextPageKt {
- public (...);
-}
--keep class io.legere.pdfiumandroid.suspend.PdfiumCoreKt { *; }
--keepclassmembers public class io.legere.pdfiumandroid.suspend.PdfiumCoreKt {
- public (...);
-}
--keep class io.legere.pdfiumandroid.util.AlreadyClosedBehavior { *; }
--keepclassmembers public class io.legere.pdfiumandroid.util.AlreadyClosedBehavior {
- public (...);
-}
--keep class io.legere.pdfiumandroid.util.Config { *; }
--keepclassmembers public class io.legere.pdfiumandroid.util.Config {
- public (...);
-}
--keep class io.legere.pdfiumandroid.util.Size { *; }
--keepclassmembers public class io.legere.pdfiumandroid.util.Size {
- public (...);
-}
diff --git a/pdfiumandroid/src/androidTest/assets/f01.pdf b/pdfiumandroid/src/androidTest/assets/f01.pdf
deleted file mode 100644
index ecfcea3..0000000
Binary files a/pdfiumandroid/src/androidTest/assets/f01.pdf and /dev/null differ
diff --git a/pdfiumandroid/src/androidTest/assets/pdf-test.pdf b/pdfiumandroid/src/androidTest/assets/pdf-test.pdf
deleted file mode 100644
index f46dbe5..0000000
Binary files a/pdfiumandroid/src/androidTest/assets/pdf-test.pdf and /dev/null differ
diff --git a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/FastNativeTest.kt b/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/FastNativeTest.kt
deleted file mode 100644
index 5bb47db..0000000
--- a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/FastNativeTest.kt
+++ /dev/null
@@ -1,447 +0,0 @@
-package io.legere.pdfiumandroid
-
-import android.content.Context
-import android.graphics.Bitmap
-import android.graphics.BitmapFactory
-import android.graphics.Matrix
-import android.graphics.Rect
-import android.graphics.RectF
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.platform.app.InstrumentationRegistry
-import com.google.common.truth.Truth.assertThat
-import io.legere.pdfiumandroid.base.BasePDFTest
-import io.legere.pdfiumandroid.util.Size
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import kotlin.system.measureNanoTime
-import kotlin.time.Duration.Companion.nanoseconds
-import kotlin.time.measureTime
-
-@RunWith(AndroidJUnit4::class)
-class FastNativeTest : BasePDFTest() {
- private lateinit var pdfDocument: PdfDocument
- private var pdfBytes: ByteArray? = null
-
- @Before
- fun setUp() {
- pdfBytes = getPdfBytes("f01.pdf")
-
- assertThat(pdfBytes).isNotNull()
-
- pdfDocument = PdfiumCore().newDocument(pdfBytes)
- }
-
- @After
- fun tearDown() {
- pdfDocument.close()
- }
-
- @Test
- fun getPagAttributesOpenEveryPass() {
- val time =
- measureTime {
- repeat(10_000) {
- pdfDocument.openPage(0).use { page ->
- testPageAttributes(page)
- }
- }
- }
- val averageDuration = (time / 10_000)
- println("Total Time: $time, Average Time: $averageDuration")
- }
-
- @Test
- fun getPagAttributesSingleOpen() {
- val time =
- measureTime {
- pdfDocument.openPage(0).use { page ->
- repeat(10_000) {
- testPageAttributes(page)
- }
- }
- }
- val averageDuration = (time / 10_000)
- println("Total Time: $time, Average Time: $averageDuration")
- }
-
- @Test
- fun getPagAttributesTimeAttributesOnly() {
- pdfDocument.openPage(0).use { page ->
- val time =
- measureTime {
- repeat(10_000) {
- testPageAttributes(page)
- }
- }
- val averageDuration = (time / 10_000)
- println("Total Time: $time, Average Time: $averageDuration")
- }
- }
-
- @Test
- fun getTextPagAttributesOpenEveryPass() {
- val time =
- measureTime {
- repeat(10_000) {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- testTextPageAttributes(textPage)
- }
- }
- }
- }
- val averageDuration = (time / 10_000)
- println("Total Time: $time, Average Time: $averageDuration")
- }
-
- @Test
- fun getPTextPagAttributesSingleOpen() {
- val time =
- measureTime {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- repeat(10_000) {
- testTextPageAttributes(textPage)
- }
- }
- }
- }
- val averageDuration = (time / 10_000)
- println("Total Time: $time, Average Time: $averageDuration")
- }
-
- @Test
- fun getTextPagAttributesTimeAttributesOnly() {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val time =
- measureTime {
- repeat(10_000) {
- testTextPageAttributes(textPage)
- }
- }
- val averageDuration = (time / 10_000)
- println("Total Time: $time, Average Time: $averageDuration")
- }
- }
- }
-
- @Test
- fun getPagBitmapOpenEveryPass() {
- val iterations = 1_000
- val bitmap = Bitmap.createBitmap(612, 792, Bitmap.Config.RGB_565)
- val time =
- measureTime {
- repeat(iterations) {
- pdfDocument.openPage(0).use { page ->
- page.renderPageBitmap(
- bitmap,
- 0,
- 0,
- 612,
- 792,
- )
- }
- }
- }
- val averageDuration = time / iterations
- println("Total Time: $time, Average Time: $averageDuration")
- }
-
- @Test
- fun getPagBitmapSingleOpen() {
- val iterations = 1_000
- val bitmap = Bitmap.createBitmap(612, 792, Bitmap.Config.RGB_565)
- val time =
- measureTime {
- pdfDocument.openPage(0).use { page ->
- repeat(iterations) {
- page.renderPageBitmap(
- bitmap,
- 0,
- 0,
- 612,
- 792,
- )
- }
- }
- }
- val averageDuration = (time / iterations)
- println("Total Time: $time, Average Time: $averageDuration")
- }
-
- @Test
- fun getPagBitmapViaMatrixOpenEveryPass() {
- val iterations = 1_000
- val bitmap = Bitmap.createBitmap(612, 792, Bitmap.Config.RGB_565)
- val rect = RectF(0f, 0f, 612f, 792f)
- val matrix = Matrix()
- val time =
- measureNanoTime {
- repeat(iterations) {
- pdfDocument.openPage(0).use { page ->
- page.renderPageBitmap(
- bitmap,
- matrix,
- rect,
- )
- }
- }
- }
- val totalDuration = time.nanoseconds
- val averageDuration = (time / iterations).nanoseconds
- println("Total Time: $totalDuration, Average Time: $averageDuration")
- }
-
- @Test
- fun getPagBitmapViaMatrixSingleOpen() {
- val iterations = 1_000
- val bitmap = Bitmap.createBitmap(612, 792, Bitmap.Config.RGB_565)
- val rect = RectF(0f, 0f, 612f, 792f)
- val matrix = Matrix()
- val time =
- measureTime {
- pdfDocument.openPage(0).use { page ->
- repeat(iterations) {
- page.renderPageBitmap(
- bitmap,
- matrix,
- rect,
- )
- }
- }
- }
- val averageDuration = (time / iterations)
- println("Total Time: $time, Average Time: $averageDuration")
- }
-
- @Test
- fun getPagBitmapViaMatrixSingleOpen8x() {
- val iterations = 100
- val (bitmap, rect, matrix) = commonParams8X(Bitmap.Config.RGB_565)
- val time =
- measureTime {
- pdfDocument.openPage(0).use { page ->
- repeat(iterations) {
- page.renderPageBitmap(
- bitmap,
- matrix,
- rect,
- )
- }
- }
- }
- val averageDuration = (time / iterations)
- println("Total Time: $time, Average Time: $averageDuration")
- }
-
- @Test
- fun getPagBitmapViaMatrixSingleOpen8xARGB_8888() {
- val iterations = 100
- val (bitmap, rect, matrix) = commonParams8X(Bitmap.Config.ARGB_8888)
- val time =
- measureTime {
- pdfDocument.openPage(0).use { page ->
- repeat(iterations) {
- page.renderPageBitmap(
- bitmap,
- matrix,
- rect,
- )
- }
- }
- }
- val averageDuration = (time / iterations)
- println("Total Time: $time, Average Time: $averageDuration")
- }
-
- fun findWordRanges(text: String): List> {
- val boundaries = Regex("\\b").findAll(text).map { it.range.first }.toMutableList()
- boundaries.add(text.length)
- return boundaries.zipWithNext { start, end -> Pair(start, end - start) }.filter { it.first < text.length }
- }
-
- @Test
- fun gettextPageGetRectsForRanges() {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val textCharCount =
- textPage.textPageCountChars()
- if (textCharCount > 0) {
- val pageText =
- textPage.textPageGetText(
- 0,
- textCharCount,
- )
- ?: ""
- val wordBoundaries = findWordRanges(pageText)
- val wordRangesArray =
- wordBoundaries
- .flatMap { listOf(it.first, it.second) }
- .toIntArray()
- val iterations = 100
- val time =
- measureTime {
- repeat(iterations) {
- val result = textPage.textPageGetRectsForRanges(wordRangesArray)
- assertThat(result).isNotNull()
- assertThat(result?.size).isEqualTo(1238)
- }
- }
- val averageDuration = (time / iterations)
- println("Total Time: $time, Average Time: $averageDuration")
- }
- }
- }
- }
-
- @Test
- fun gettextPageGetRects() {
- val iterations = 100
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val textCharCount =
- textPage.textPageCountChars()
- if (textCharCount > 0) {
- val pageText =
- textPage.textPageGetText(
- 0,
- textCharCount,
- )
- ?: ""
- val wordBoundaries = findWordRanges(pageText)
- val time =
- measureTime {
- repeat(iterations) {
- val list = mutableListOf()
- wordBoundaries.forEach {
- val count = textPage.textPageCountRects(it.first, it.second)
- repeat(count) {
- textPage.textPageGetRect(it)?.let { rect ->
- list.add(rect)
- }
- }
-// println("list: ${it.first} ${it.second} $list")
- }
- assertThat(list).isNotNull()
- assertThat(list.size).isEqualTo(1238)
- }
- }
- val averageDuration = (time / iterations)
- println("Total Time: $time, Average Time: $averageDuration")
- }
- }
- }
- }
-
- @Test
- fun getPagBitmapViaMatrixSingleOpen8xARGB_8888ReadFromDisk() {
- val iterations = 100
- val (bitmap, rect, matrix) = commonParams8X(Bitmap.Config.ARGB_8888)
- pdfDocument.openPage(0).use { page ->
- repeat(iterations) {
- page.renderPageBitmap(
- bitmap,
- matrix,
- rect,
- )
- }
- }
- val targetCtx: Context = InstrumentationRegistry.getInstrumentation().targetContext
- targetCtx.openFileOutput("test.png", Context.MODE_PRIVATE).use {
- bitmap.compress(Bitmap.CompressFormat.PNG, 100, it)
- }
-
- val bitmapOptios =
- BitmapFactory.Options().apply {
- inPreferredConfig = Bitmap.Config.ARGB_8888
- inJustDecodeBounds = false
- inBitmap = bitmap
- inSampleSize = 1
- }
- val time =
- measureTime {
- repeat(iterations) {
- val bitmapFromDisk = BitmapFactory.decodeFile(targetCtx.filesDir.path + "/test.png", bitmapOptios)
- assertThat(bitmapFromDisk).isNotNull()
- }
- }
- val averageDuration = (time / iterations)
- println("Total Time: $time, Average Time: $averageDuration")
- }
-
- private fun commonParams8X(bitmapConfig: Bitmap.Config): Triple {
- val scaleFactor = (1080f / 612) * 8
- val width = 1080 * 3
- val height = 2280 * 3
- val bitmap =
- Bitmap.createBitmap(
- width,
- height,
- bitmapConfig,
- )
- val rect = RectF(0f, 0f, width.toFloat(), height.toFloat())
- val matrix = Matrix()
- matrix.postScale(scaleFactor, scaleFactor)
- return Triple(bitmap, rect, matrix)
- }
-
- private fun testTextPageAttributes(page: PdfTextPage) {
- val textPageCountChars = page.textPageCountChars()
- val textPageCountRects = page.textPageCountRects(0, textPageCountChars)
- assertThat(textPageCountChars).isEqualTo(3468)
- val textPageGetText = page.textPageGetText(0, textPageCountChars)
- assertThat(textPageGetText).startsWith("The 50 Best Videos For Kids")
- val textPageGetUnicode = page.textPageGetUnicode(0)
- assertThat(textPageGetUnicode).isEqualTo('T')
- val textPageGetCharBox = page.textPageGetCharBox(0)
- assertThat(textPageGetCharBox).isEqualTo(RectF(90.314415f, 715.3187f, 103.44171f, 699.1206f))
-
- repeat(textPageCountRects) {
- val textPageGetRect = page.textPageGetRect(it)
- }
- }
-
- private fun testPageAttributes(page: PdfPage) {
- val pageWidth = page.getPageWidth(72)
- val pageHeight = page.getPageHeight(72)
- val pageWidthPoint = page.getPageWidthPoint()
- val pageHeightPoint = page.getPageHeightPoint()
- val cropBox = page.getPageCropBox()
- val mediaBox = page.getPageMediaBox()
- val bleedBox = page.getPageBleedBox()
- val trimBox = page.getPageTrimBox()
- val artBox = page.getPageArtBox()
- val boundingBox = page.getPageBoundingBox()
- val size = page.getPageSize(72)
- val links = page.getPageLinks()
- val devicePt = page.mapRectToDevice(0, 0, 100, 100, 0, RectF(0f, 0f, 100f, 100f))
-
- assertThat(pageWidth).isEqualTo(612) // 8.5 inches * 72 dpi
- assertThat(pageHeight).isEqualTo(792) // 11 inches * 72 dpi
- assertThat(pageWidthPoint).isEqualTo(612) // 11 inches * 72 dpi
- assertThat(pageHeightPoint).isEqualTo(792) // 11 inches * 72 dpi
- assertThat(cropBox).isEqualTo(noResultRect)
- assertThat(mediaBox).isEqualTo(RectF(0.0f, 0.0f, 612.0f, 792.0f))
- assertThat(bleedBox).isEqualTo(noResultRect)
- assertThat(trimBox).isEqualTo(noResultRect)
- assertThat(artBox).isEqualTo(noResultRect)
- assertThat(boundingBox).isEqualTo(RectF(0f, 792f, 612f, 0f))
- assertThat(size).isEqualTo(Size(612, 792))
- assertThat(links.size).isEqualTo(0) // The test doc doesn't have links
- assertThat(devicePt).isEqualTo(
- Rect(
- // 0f in coords to 0f in device
- 0,
- // 0f in corrds in at the bottom, the bottom of the device is 100f
- 100,
- // 100f in coords = 100f/(8.5*72) * 100f = 16f
- 16,
- // 100f in coords = 100 - 100f/(11*72) * 100f = 87f
- 87,
- ),
- )
- }
-}
diff --git a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/PdfDocumentTest.kt b/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/PdfDocumentTest.kt
deleted file mode 100644
index 2fff811..0000000
--- a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/PdfDocumentTest.kt
+++ /dev/null
@@ -1,104 +0,0 @@
-package io.legere.pdfiumandroid
-
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.google.common.truth.Truth.assertThat
-import io.legere.pdfiumandroid.base.BasePDFTest
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class PdfDocumentTest : BasePDFTest() {
- private lateinit var pdfDocument: PdfDocument
- private var pdfBytes: ByteArray? = null
-
- @Before
- fun setUp() {
- pdfBytes = getPdfBytes("f01.pdf")
-
- assertThat(pdfBytes).isNotNull()
-
- pdfDocument = PdfiumCore().newDocument(pdfBytes)
- }
-
- @After
- fun tearDown() {
- pdfDocument.close()
- }
-
- @Test
- fun getPageCount() {
- val pageCount = pdfDocument.getPageCount()
-
- assertThat(pageCount).isEqualTo(4)
- }
-
- @Test
- fun openPage() {
- val page = pdfDocument.openPage(0)
-
- assertThat(page).isNotNull()
- }
-
- @Test
- fun openPages() {
- val page = pdfDocument.openPages(0, 3)
-
- assertThat(page.size).isEqualTo(4)
- }
-
- @Test
- fun getDocumentMeta() {
- val meta = pdfDocument.getDocumentMeta()
-
- assertThat(meta).isNotNull()
- }
-
- @Test
- fun getTableOfContents() {
- // I don't think this test document has a table of contents
- val toc = pdfDocument.getTableOfContents()
-
- assertThat(toc).isNotNull()
- assertThat(toc.size).isEqualTo(0)
- }
-
- @Test
- fun openTextPage() {
- val page = pdfDocument.openPage(0)
- val textPage = page.openTextPage()
- assertThat(textPage).isNotNull()
- }
-
-// @Test
-// fun openTextPages() {
-// val textPages = pdfDocument.openTextPages(0, 3)
-// assertThat(textPages.size).isEqualTo(4)
-// }
-
- @Test
- fun saveAsCopy() {
- pdfDocument.saveAsCopy(
- object : PdfWriteCallback {
- override fun WriteBlock(data: ByteArray?): Int {
- // assertThat(data?.size).isEqualTo(pdfBytes?.size)
- // assertThat(data).isEqualTo(pdfBytes)
- return data?.size ?: 0
- }
- },
- )
- }
-
- @Test(expected = IllegalStateException::class)
- fun closeDocument() {
- var shouldBeClosed: PdfDocument?
- PdfiumCore().newDocument(pdfBytes).use { pdfDocument ->
- assertThat(pdfDocument).isNotNull()
- shouldBeClosed = pdfDocument
- }
-
- // Now it should be closed
- shouldBeClosed?.openPage(0) // This should throw an exception
- }
-}
diff --git a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/PdfPageLinkTest.kt b/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/PdfPageLinkTest.kt
deleted file mode 100644
index f8186ed..0000000
--- a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/PdfPageLinkTest.kt
+++ /dev/null
@@ -1,87 +0,0 @@
-package io.legere.pdfiumandroid
-
-import android.graphics.RectF
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.google.common.truth.Truth.assertThat
-import io.legere.pdfiumandroid.base.BasePDFTest
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class PdfPageLinkTest : BasePDFTest() {
- private lateinit var pdfDocument: PdfDocument
- private lateinit var pdfPage: PdfPage
- private lateinit var pdfTextPage: PdfTextPage
- private var pdfBytes: ByteArray? = null
-
- @Before
- fun setUp() {
- pdfBytes = getPdfBytes("pdf-test.pdf")
-
- assertThat(pdfBytes).isNotNull()
-
- pdfDocument = PdfiumCore().newDocument(pdfBytes)
-
- pdfPage = pdfDocument.openPage(0)
- pdfTextPage = pdfPage.openTextPage()
- }
-
- @After
- fun tearDown() {
- pdfTextPage.close()
- pdfPage.close()
- pdfDocument.close()
- }
-
- @Test
- fun testLink() {
- val links = pdfTextPage.loadWebLink()
- assertThat(links).isNotNull()
- links.close()
- }
-
- @Test
- fun testCountWebLinks() {
- val links = pdfTextPage.loadWebLink()
- assertThat(links).isNotNull()
- assertThat(links.countWebLinks()).isEqualTo(1)
- links.close()
- }
-
- @Test
- fun testGetTextRange() {
- val links = pdfTextPage.loadWebLink()
- assertThat(links).isNotNull()
- assertThat(links.getTextRange(0)).isEqualTo(Pair(351, 31))
- links.close()
- }
-
- @Test
- fun testGetUrl() {
- val links = pdfTextPage.loadWebLink()
- assertThat(links).isNotNull()
- val (_, count) = links.getTextRange(0)
- assertThat(links.getURL(0, count)).isEqualTo("http://www.education.gov.yk.ca/")
- links.close()
- }
-
- @Test
- fun testCountRects() {
- val links = pdfTextPage.loadWebLink()
- assertThat(links).isNotNull()
- val count = links.countRects(0)
- assertThat(count).isEqualTo(1)
- links.close()
- }
-
- @Test
- fun testGetRect() {
- val links = pdfTextPage.loadWebLink()
- assertThat(links).isNotNull()
- val count = links.getRect(0, 0)
- assertThat(count).isEqualTo(RectF(221.46f, 480.624f, 389.66394f, 469.152f))
- links.close()
- }
-}
diff --git a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/PdfPageTest.kt b/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/PdfPageTest.kt
deleted file mode 100644
index 7c43c94..0000000
--- a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/PdfPageTest.kt
+++ /dev/null
@@ -1,232 +0,0 @@
-package io.legere.pdfiumandroid
-
-import android.graphics.Bitmap
-import android.graphics.Point
-import android.graphics.PointF
-import android.graphics.Rect
-import android.graphics.RectF
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.google.common.truth.Truth.assertThat
-import io.legere.pdfiumandroid.base.BasePDFTest
-import io.legere.pdfiumandroid.util.Size
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class PdfPageTest : BasePDFTest() {
- private lateinit var pdfDocument: PdfDocument
- private var pdfBytes: ByteArray? = null
-
- @Before
- fun setUp() {
- pdfBytes = getPdfBytes("f01.pdf")
-
- assertThat(pdfBytes).isNotNull()
-
- pdfDocument = PdfiumCore().newDocument(pdfBytes)
- }
-
- @After
- fun tearDown() {
- pdfDocument.close()
- }
-
- @Test
- fun getPageWidth() {
- pdfDocument.openPage(0).use { page ->
- val pageWidth = page.getPageWidth(72)
-
- assertThat(pageWidth).isEqualTo(612) // 8.5 inches * 72 dpi
- }
- }
-
- @Test
- fun getPageHeight() {
- pdfDocument.openPage(0).use { page ->
- val pageHeight = page.getPageHeight(72)
-
- assertThat(pageHeight).isEqualTo(792) // 11 inches * 72 dpi
- }
- }
-
- @Test
- fun getPageWidthPoint() {
- pdfDocument.openPage(0).use { page ->
- val pageWidthPoint = page.getPageWidthPoint()
-
- assertThat(pageWidthPoint).isEqualTo(612) // 11 inches * 72 dpi
- }
- }
-
- @Test
- fun getPageHeightPoint() {
- pdfDocument.openPage(0).use { page ->
- val pageHeightPoint = page.getPageHeightPoint()
-
- assertThat(pageHeightPoint).isEqualTo(792) // 11 inches * 72 dpi
- }
- }
-
- @Test
- fun getPageCropBox() {
- pdfDocument.openPage(0).use { page ->
- val cropBox = page.getPageCropBox()
-
- assertThat(cropBox).isEqualTo(noResultRect)
- }
- }
-
- @Test
- fun getPageMediaBox() {
- pdfDocument.openPage(0).use { page ->
- val mediaBox = page.getPageMediaBox()
-
- assertThat(mediaBox).isEqualTo(RectF(0.0f, 0.0f, 612.0f, 792.0f))
- }
- }
-
- @Test
- fun getPageBleedBox() {
- pdfDocument.openPage(0).use { page ->
- val bleedBox = page.getPageBleedBox()
-
- assertThat(bleedBox).isEqualTo(noResultRect)
- }
- }
-
- @Test
- fun getPageTrimBox() {
- pdfDocument.openPage(0).use { page ->
- val trimBox = page.getPageTrimBox()
-
- assertThat(trimBox).isEqualTo(noResultRect)
- }
- }
-
- @Test
- fun getPageArtBox() {
- pdfDocument.openPage(0).use { page ->
- val artBox = page.getPageArtBox()
-
- assertThat(artBox).isEqualTo(noResultRect)
- }
- }
-
- @Test
- fun getPageBoundingBox() {
- pdfDocument.openPage(0).use { page ->
- val boundingBox = page.getPageBoundingBox()
-
- // Note, that looks incorrect, but pdfs coordinate systems starts from bottom left corner
- assertThat(boundingBox).isEqualTo(RectF(0f, 792f, 612f, 0f))
- }
- }
-
- @Test
- fun getPageSize() {
- pdfDocument.openPage(0).use { page ->
- val size = page.getPageSize(72)
-
- assertThat(size).isEqualTo(Size(612, 792))
- }
- }
-
- @Test
- fun renderPageBitmap() {
- pdfDocument.openPage(0).use { page ->
-
- val conf = Bitmap.Config.RGB_565 // see other conf types
-
- val bmp = Bitmap.createBitmap(612, 792, conf) // this creates a MUTABLE bitmap
-
- page.renderPageBitmap(bmp, 0, 0, 612, 792, true)
-
- // How to verify that it's correct?
- // Even if we don't verify the bitmap, we can check that it doesn't crash
- }
- }
-
- @Test
- fun testRenderPageBitmap() {
- pdfDocument.openPage(0).use { page ->
-
- val conf = Bitmap.Config.RGB_565 // see other conf types
-
- val bmp = Bitmap.createBitmap(612, 792, conf) // this creates a MUTABLE bitmap
-
- page.renderPageBitmap(bmp, 0, 0, 612, 792, renderAnnot = true, textMask = true)
-
- // How to verify that it's correct?
- // Even if we don't verify the bitmap, we can check that it doesn't crash
- }
- }
-
- @Test
- fun getPageLinks() {
- pdfDocument.openPage(0).use { page ->
- val links = page.getPageLinks()
-
- assertThat(links.size).isEqualTo(0) // The test doc doesn't have links
- }
- }
-
- @Test
- fun mapPageCoordsToDevice() {
- pdfDocument.openPage(0).use { page ->
- val devicePt = page.mapPageCoordsToDevice(0, 0, 100, 100, 0, 0.0, 0.0)
-
- assertThat(devicePt).isEqualTo(Point(0, 100))
- }
- }
-
- @Test
- fun mapDeviceCoordsToPage() {
- pdfDocument.openPage(0).use { page ->
- val devicePt = page.mapDeviceCoordsToPage(0, 0, 100, 100, 0, 0, 0)
-
- assertThat(devicePt).isEqualTo(PointF(0f, 792.00006f))
- }
- }
-
- @Test
- fun mapRectToDevice() {
- pdfDocument.openPage(0).use { page ->
- val devicePt = page.mapRectToDevice(0, 0, 100, 100, 0, RectF(0f, 0f, 100f, 100f))
-
- assertThat(devicePt).isEqualTo(
- Rect(
- // 0f in coords to 0f in device
- 0,
- // 0f in corrds in at the bottom, the bottom of the device is 100f
- 100,
- // 100f in coords = 100f/(8.5*72) * 100f = 16f
- 16,
- // 100f in coords = 100 - 100f/(11*72) * 100f = 87f
- 87,
- ),
- )
- }
- }
-
- @Test
- fun mapRectToPage() {
- pdfDocument.openPage(0).use { page ->
- val devicePt = page.mapRectToPage(0, 0, 100, 100, 0, Rect(0, 0, 100, 100))
-
- assertThat(devicePt).isEqualTo(
- RectF(0.0f, 792.00006f, 612.0f, 0.0f),
- )
- }
- }
-
- @Test(expected = IllegalStateException::class)
- fun close() {
- var pageAfterClose: PdfPage?
- pdfDocument.openPage(0).use { page ->
- pageAfterClose = page
- }
- pageAfterClose!!.getPageWidth(72)
- }
-}
diff --git a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/PdfTextPageTest.kt b/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/PdfTextPageTest.kt
deleted file mode 100644
index 2d6ed9b..0000000
--- a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/PdfTextPageTest.kt
+++ /dev/null
@@ -1,207 +0,0 @@
-package io.legere.pdfiumandroid
-
-import android.graphics.RectF
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.google.common.truth.Truth.assertThat
-import io.legere.pdfiumandroid.base.BasePDFTest
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class PdfTextPageTest : BasePDFTest() {
- private lateinit var pdfDocument: PdfDocument
- private var pdfBytes: ByteArray? = null
-
- @Before
- fun setUp() {
- pdfBytes = getPdfBytes("f01.pdf")
-
- assertThat(pdfBytes).isNotNull()
-
- pdfDocument = PdfiumCore().newDocument(pdfBytes)
- }
-
- @After
- fun tearDown() {
- pdfDocument.close()
- }
-
- @Test
- fun textPageCountChars() {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val charCount = textPage.textPageCountChars()
-
- assertThat(charCount).isEqualTo(3468)
- }
- }
- }
-
- @Test
- fun textPageGetText() {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val text = textPage.textPageGetText(0, 100)
-
- assertThat(text?.length).isEqualTo(100)
- }
- }
- }
-
- @Test
- fun textPageGetUnicode() {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val char = textPage.textPageGetUnicode(0)
- assertThat(char).isEqualTo('T')
- }
- }
- }
-
- @Test
- fun textPageGetCharBox() {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val rect = textPage.textPageGetCharBox(0)
-
- assertThat(rect).isEqualTo(RectF(90.314415f, 715.3187f, 103.44171f, 699.1206f))
- }
- }
- }
-
- @Test
- fun textPageGetCharIndexAtPos() {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val characterToLookup = 0
- val rect = textPage.textPageGetCharBox(characterToLookup)
-
- val pos =
- textPage.textPageGetCharIndexAtPos(
- rect?.centerX()?.toDouble() ?: 0.0,
- rect?.centerY()?.toDouble() ?: 0.0,
- // Shouldn't need much since we're in the middle of the rect
- 1.0,
- 1.0,
- )
-
- assertThat(pos).isEqualTo(characterToLookup)
- }
- }
- }
-
- @Test
- fun textPageCountRects() {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val rectCount = textPage.textPageCountRects(0, 100)
-
- assertThat(rectCount).isEqualTo(4)
- }
- }
- }
-
- @Test
- fun textPageGetRect() {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val rect = textPage.textPageGetRect(0)
-
- assertThat(rect).isEqualTo(RectF(0f, 0f, 0f, 0f))
- }
- }
- }
-
- @Test
- fun textPageGetBoundedText() {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val text = textPage.textPageGetBoundedText(RectF(0f, 97f, 100f, 100f), 100)
-
- assertThat(text).isEqualTo("Do")
- }
- }
- }
-
- @Test
- fun getFontSize() {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val fontSize = textPage.getFontSize(0)
-
- // We get 0, but that doesn't seem right
- assertThat(fontSize).isEqualTo(22.559999465942383)
- }
- }
- }
-
- @Test
- fun findStart() {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val findWhat = "children's"
- val startIndex = 0
- textPage.findStart(findWhat, emptySet(), startIndex)?.use { findHandle ->
- var result = findHandle.findNext()
- assertThat(result).isTrue()
- var index = findHandle.getSchResultIndex()
- var count = findHandle.getSchCount()
- var text = textPage.textPageGetText(index, count)
- assertThat(index).isEqualTo(1525)
- assertThat(count).isEqualTo(10)
- assertThat(text).isEqualTo(findWhat)
- result = findHandle.findNext()
- assertThat(result).isTrue()
- index = findHandle.getSchResultIndex()
- count = findHandle.getSchCount()
- text = textPage.textPageGetText(index, count)
- assertThat(index).isEqualTo(2761)
- assertThat(count).isEqualTo(10)
- assertThat(text).isEqualTo(findWhat)
- result = findHandle.findNext()
- assertThat(result).isFalse()
- }
- }
- }
- }
-
- @Test(expected = IllegalStateException::class)
- fun close() {
- var pageAfterClose: PdfTextPage?
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- pageAfterClose = textPage
- }
- pageAfterClose!!.textPageCountChars()
- }
- }
-
- @Test
- fun getDoc() {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- assertThat(textPage.doc).isNotNull()
- }
- }
- }
-
- @Test
- fun getPageIndex() {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- assertThat(textPage.pageIndex).isEqualTo(0)
- }
- }
- }
-
- @Test
- fun getPagePtr() {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- assertThat(textPage.pagePtr).isNotNull()
- }
- }
- }
-}
diff --git a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/PdfiumCoreTest.kt b/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/PdfiumCoreTest.kt
deleted file mode 100644
index f46ae1b..0000000
--- a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/PdfiumCoreTest.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-package io.legere.pdfiumandroid
-
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.google.common.truth.Truth.assertThat
-import io.legere.pdfiumandroid.base.BasePDFTest
-import io.legere.pdfiumandroid.base.ByteArrayPdfiumSource
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class PdfiumCoreTest : BasePDFTest() {
- @Test
- fun newDocument() {
- val pdfBytes = getPdfBytes("f01.pdf")
-
- assertThat(pdfBytes).isNotNull()
-
- val pdfiumCore = PdfiumCore()
- val pdfDocument = pdfiumCore.newDocument(pdfBytes)
-
- assertThat(pdfDocument).isNotNull()
- }
-
- @Test
- fun newDocumentWithCustomSource() {
- val pdfBytes = getPdfBytes("f01.pdf")
-
- assertThat(pdfBytes).isNotNull()
-
- val pdfiumCore = PdfiumCore()
- val pdfDocument = pdfiumCore.newDocument(ByteArrayPdfiumSource(pdfBytes!!))
-
- assertThat(pdfDocument).isNotNull()
- }
-}
diff --git a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/base/BasePDFTest.kt b/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/base/BasePDFTest.kt
deleted file mode 100644
index b5e16da..0000000
--- a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/base/BasePDFTest.kt
+++ /dev/null
@@ -1,28 +0,0 @@
-package io.legere.pdfiumandroid.base
-
-import android.graphics.RectF
-import android.util.Log
-import androidx.test.platform.app.InstrumentationRegistry
-import io.legere.pdfiumandroid.PdfiumCoreTest
-
-@Suppress("unused")
-open class BasePDFTest {
- // set to true to skip tests that are not implemented yet
- // set to false to force unimplemented tests to fail
- val notImplementedAssetValue = false
-
- val noResultRect = RectF(-1f, -1f, -1f, -1f)
-
- fun getPdfBytes(filename: String): ByteArray? {
- val appContext = InstrumentationRegistry.getInstrumentation().context
- val assetManager = appContext.assets
- try {
- val input = assetManager.open(filename)
- return input.readBytes()
- } catch (e: Exception) {
- Log.e(PdfiumCoreTest::class.simpleName, "Ugh", e)
- }
- assetManager.close()
- return null
- }
-}
diff --git a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/base/ByteArrayPdfiumSource.kt b/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/base/ByteArrayPdfiumSource.kt
deleted file mode 100644
index 2bcecd0..0000000
--- a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/base/ByteArrayPdfiumSource.kt
+++ /dev/null
@@ -1,28 +0,0 @@
-package io.legere.pdfiumandroid.base
-
-import io.legere.pdfiumandroid.PdfiumSource
-
-class ByteArrayPdfiumSource(
- private val array: ByteArray,
-) : PdfiumSource {
- override val length: Long
- get() = array.size.toLong()
-
- override fun read(
- position: Long,
- buffer: ByteArray,
- size: Int,
- ): Int {
- array.copyInto(
- destination = buffer,
- destinationOffset = 0,
- startIndex = position.toInt(),
- endIndex = position.toInt() + size,
- )
- return size
- }
-
- override fun close() {
- // nothing to close
- }
-}
diff --git a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/suspend/PdfDocumentKtTest.kt b/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/suspend/PdfDocumentKtTest.kt
deleted file mode 100644
index f572163..0000000
--- a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/suspend/PdfDocumentKtTest.kt
+++ /dev/null
@@ -1,117 +0,0 @@
-package io.legere.pdfiumandroid.suspend
-
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.google.common.truth.Truth
-import io.legere.pdfiumandroid.PdfWriteCallback
-import io.legere.pdfiumandroid.base.BasePDFTest
-import junit.framework.TestCase
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.runBlocking
-import kotlinx.coroutines.test.runTest
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class PdfDocumentKtTest : BasePDFTest() {
- private lateinit var pdfDocument: PdfDocumentKt
- private var pdfBytes: ByteArray? = null
-
- @Before
- fun setUp() =
- runBlocking {
- pdfBytes = getPdfBytes("f01.pdf")
-
- TestCase.assertNotNull(pdfBytes)
-
- pdfDocument = PdfiumCoreKt(Dispatchers.Unconfined).newDocument(pdfBytes)
- }
-
- @After
- fun tearDown() =
- runTest {
- pdfDocument.close()
- }
-
- @Test
- fun getPageCount() =
- runTest {
- val pageCount = pdfDocument.getPageCount()
-
- assert(pageCount == 4) { "Page count should be 4" }
- }
-
- @Test
- fun openPage() =
- runTest {
- val page = pdfDocument.openPage(0)
-
- TestCase.assertNotNull(page)
- }
-
- @Test
- fun openPages() =
- runTest {
- val page = pdfDocument.openPages(0, 3)
-
- assert(page.size == 4) { "Page count should be 4" }
- }
-
- @Test
- fun getDocumentMeta() =
- runTest {
- val meta = pdfDocument.getDocumentMeta()
-
- TestCase.assertNotNull(meta)
- }
-
- @Test
- fun getTableOfContents() =
- runTest {
- // I don't think this test document has a table of contents
- val toc = pdfDocument.getTableOfContents()
-
- TestCase.assertNotNull(toc)
- Truth.assertThat(toc.size).isEqualTo(0)
- }
-
- @Test
- fun openTextPage() =
- runTest {
- val page = pdfDocument.openPage(0)
- val textPage = page.openTextPage()
- TestCase.assertNotNull(textPage)
- }
-
- @Test
- fun openTextPages() =
- runTest {
- val textPages = pdfDocument.openTextPages(0, 3)
- Truth.assertThat(textPages.size).isEqualTo(4)
- }
-
- @Test
- fun saveAsCopy() =
- runTest {
- pdfDocument.saveAsCopy(
- object : PdfWriteCallback {
- override fun WriteBlock(data: ByteArray?): Int {
- // Truth.assertThat(data?.size).isEqualTo(pdfBytes?.size)
- // Truth.assertThat(data).isEqualTo(pdfBytes)
- return data?.size ?: 0
- }
- },
- )
- }
-
- @Test(expected = IllegalStateException::class)
- fun close() =
- runTest {
- var documentAfterClose: PdfDocumentKt?
- PdfiumCoreKt(Dispatchers.Unconfined).newDocument(pdfBytes).use {
- documentAfterClose = it
- }
- documentAfterClose?.openPage(0)
- }
-}
diff --git a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/suspend/PdfPageKtTest.kt b/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/suspend/PdfPageKtTest.kt
deleted file mode 100644
index 54d731b..0000000
--- a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/suspend/PdfPageKtTest.kt
+++ /dev/null
@@ -1,275 +0,0 @@
-package io.legere.pdfiumandroid.suspend
-
-import android.graphics.Bitmap
-import android.graphics.Point
-import android.graphics.PointF
-import android.graphics.Rect
-import android.graphics.RectF
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.google.common.truth.Truth.assertThat
-import io.legere.pdfiumandroid.base.BasePDFTest
-import io.legere.pdfiumandroid.util.Size
-import junit.framework.TestCase
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.runBlocking
-import kotlinx.coroutines.test.runTest
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class PdfPageKtTest : BasePDFTest() {
- private lateinit var pdfDocument: PdfDocumentKt
- private var pdfBytes: ByteArray? = null
-
- @Before
- fun setUp() =
- runBlocking {
- pdfBytes = getPdfBytes("f01.pdf")
-
- TestCase.assertNotNull(pdfBytes)
-
- pdfDocument = PdfiumCoreKt(Dispatchers.Unconfined).newDocument(pdfBytes)
- }
-
- @After
- fun tearDown() {
- pdfDocument.close()
- }
-
- @Test
- fun getPageWidth() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val pageWidth = page.getPageWidth(72)
-
- assertThat(pageWidth).isEqualTo(612) // 8.5 inches * 72 dpi
- }
- }
-
- @Test
- fun getPageHeight() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val pageWidth = page.getPageHeight(72)
-
- assertThat(pageWidth).isEqualTo(792) // 11 inches * 72 dpi
- }
- }
-
- @Test
- fun getPageWidthPoint() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val pageWidth = page.getPageWidthPoint()
-
- assertThat(pageWidth).isEqualTo(612) // 11 inches * 72 dpi
- }
- }
-
- @Test
- fun getPageHeightPoint() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val pageWidth = page.getPageHeightPoint()
-
- assertThat(pageWidth).isEqualTo(792) // 11 inches * 72 dpi
- }
- }
-
- @Test
- fun getPageCropBox() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val cropBox = page.getPageCropBox()
-
- assertThat(cropBox).isEqualTo(noResultRect)
- }
- }
-
- @Test
- fun getPageMediaBox() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val mediaBox = page.getPageMediaBox()
-
- assertThat(mediaBox).isEqualTo(RectF(0.0f, 0.0f, 612.0f, 792.0f))
- }
- }
-
- @Test
- fun getPageBleedBox() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val bleedBox = page.getPageBleedBox()
-
- assertThat(bleedBox).isEqualTo(noResultRect)
- }
- }
-
- @Test
- fun getPageTrimBox() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val trimBox = page.getPageTrimBox()
-
- assertThat(trimBox).isEqualTo(noResultRect)
- }
- }
-
- @Test
- fun getPageArtBox() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val artBox = page.getPageArtBox()
-
- assertThat(artBox).isEqualTo(noResultRect)
- }
- }
-
- @Test
- fun getPageBoundingBox() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val artBox = page.getPageBoundingBox()
-
- assertThat(artBox).isEqualTo(RectF(0f, 792f, 612f, 0f))
- }
- }
-
- @Test
- fun getPageSize() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val size = page.getPageSize(72)
-
- assertThat(size).isEqualTo(Size(612, 792))
- }
- }
-
- @Test
- fun renderPage() =
- runTest {
- // I really don't know how to test it
- }
-
- @Test
- fun testRenderPage() =
- runTest {
- // I really don't know how to test it
- }
-
- @Test
- fun renderPageBitmap() =
- runTest {
- pdfDocument.openPage(0).use { page ->
-
- val conf = Bitmap.Config.RGB_565 // see other conf types
-
- val bmp = Bitmap.createBitmap(612, 792, conf) // this creates a MUTABLE bitmap
-
- page.renderPageBitmap(bmp, 0, 0, 612, 792)
-
- // How to verify that it's correct?
- // Even if we don't verify the bitmap, we can check that it doesn't crash
- }
- }
-
- @Test
- fun testRenderPageBitmap() =
- runTest {
- pdfDocument.openPage(0).use { page ->
-
- val conf = Bitmap.Config.RGB_565 // see other conf types
-
- val bmp = Bitmap.createBitmap(612, 792, conf) // this creates a MUTABLE bitmap
-
- page.renderPageBitmap(bmp, 0, 0, 612, 792, renderAnnot = true, textMask = true)
-
- // How to verify that it's correct?
- // Even if we don't verify the bitmap, we can check that it doesn't crash
- }
- }
-
- @Test
- fun getPageLinks() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val links = page.getPageLinks()
-
- assertThat(links.size).isEqualTo(0) // The test doc doesn't have links
- }
- }
-
- @Test
- fun mapPageCoordsToDevice() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val devicePt = page.mapPageCoordsToDevice(0, 0, 100, 100, 0, 0.0, 0.0)
-
- assertThat(devicePt).isEqualTo(Point(0, 100))
- }
- }
-
- @Test
- fun mapDeviceCoordsToPage() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val devicePt = page.mapDeviceCoordsToPage(0, 0, 100, 100, 0, 0, 0)
-
- assertThat(devicePt).isEqualTo(PointF(0f, 792.00006f))
- }
- }
-
- @Test
- fun mapRectToDevice() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val devicePt = page.mapRectToDevice(0, 0, 100, 100, 0, RectF(0f, 0f, 100f, 100f))
-
- assertThat(devicePt).isEqualTo(
- Rect(
- // 0f in coords to 0f in device
- 0,
- // 0f in corrds in at the bottom, the bottom of the device is 100f
- 100,
- // 100f in coords = 100f/(8.5*72) * 100f = 16f
- 16,
- // 100f in coords = 100 - 100f/(11*72) * 100f = 87f
- 87,
- ),
- )
- }
- }
-
- @Test
- fun mapRectToPage() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- val devicePt = page.mapRectToPage(0, 0, 100, 100, 0, Rect(0, 0, 100, 100))
-
- assertThat(devicePt).isEqualTo(
- RectF(0.0f, 792.00006f, 612.0f, 0.0f),
- )
- }
- }
-
- @Test(expected = IllegalStateException::class)
- fun close() =
- runTest {
- var pageAfterClose: PdfPageKt?
- pdfDocument.openPage(0).use { page ->
- pageAfterClose = page
- }
- pageAfterClose!!.getPageWidth(72)
- }
-
- @Test
- fun getPage() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- assertThat(page).isNotNull()
- }
- }
-}
diff --git a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/suspend/PdfPageLinkKtTest.kt b/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/suspend/PdfPageLinkKtTest.kt
deleted file mode 100644
index ec7f5a9..0000000
--- a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/suspend/PdfPageLinkKtTest.kt
+++ /dev/null
@@ -1,99 +0,0 @@
-package io.legere.pdfiumandroid.suspend
-
-import android.graphics.RectF
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.google.common.truth.Truth.assertThat
-import io.legere.pdfiumandroid.base.BasePDFTest
-import junit.framework.TestCase
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.runBlocking
-import kotlinx.coroutines.test.TestResult
-import kotlinx.coroutines.test.runTest
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class PdfPageLinkKtTest : BasePDFTest() {
- private lateinit var pdfDocument: PdfDocumentKt
- private lateinit var pdfPage: PdfPageKt
- private lateinit var pdfTextPage: PdfTextPageKt
-
- private var pdfBytes: ByteArray? = null
-
- @Before
- fun setUp() =
- runBlocking {
- pdfBytes = getPdfBytes("pdf-test.pdf")
-
- TestCase.assertNotNull(pdfBytes)
-
- pdfDocument = PdfiumCoreKt(Dispatchers.Unconfined).newDocument(pdfBytes)
- pdfPage = pdfDocument.openPage(0)
- pdfTextPage = pdfPage.openTextPage()
- }
-
- @After
- fun tearDown() {
- pdfTextPage.close()
- pdfPage.close()
- pdfDocument.close()
- }
-
- @Test
- fun testLink(): TestResult =
- runTest {
- val links = pdfTextPage.loadWebLink()
- assertThat(links).isNotNull()
- links.close()
- }
-
- @Test
- fun testCountWebLinks(): TestResult =
- runTest {
- val links = pdfTextPage.loadWebLink()
- assertThat(links).isNotNull()
- assertThat(links.countWebLinks()).isEqualTo(1)
- links.close()
- }
-
- @Test
- fun testGetTextRange(): TestResult =
- runTest {
- val links = pdfTextPage.loadWebLink()
- assertThat(links).isNotNull()
- assertThat(links.getTextRange(0)).isEqualTo(Pair(351, 31))
- links.close()
- }
-
- @Test
- fun testGetUrl(): TestResult =
- runTest {
- val links = pdfTextPage.loadWebLink()
- assertThat(links).isNotNull()
- val (_, count) = links.getTextRange(0)
- assertThat(links.getURL(0, count)).isEqualTo("http://www.education.gov.yk.ca/")
- links.close()
- }
-
- @Test
- fun testCountRects(): TestResult =
- runTest {
- val links = pdfTextPage.loadWebLink()
- assertThat(links).isNotNull()
- val count = links.countRects(0)
- assertThat(count).isEqualTo(1)
- links.close()
- }
-
- @Test
- fun testGetRect(): TestResult =
- runTest {
- val links = pdfTextPage.loadWebLink()
- assertThat(links).isNotNull()
- val count = links.getRect(0, 0)
- assertThat(count).isEqualTo(RectF(221.46f, 480.624f, 389.66394f, 469.152f))
- links.close()
- }
-}
diff --git a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/suspend/PdfTextPageKtTest.kt b/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/suspend/PdfTextPageKtTest.kt
deleted file mode 100644
index 408c327..0000000
--- a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/suspend/PdfTextPageKtTest.kt
+++ /dev/null
@@ -1,178 +0,0 @@
-package io.legere.pdfiumandroid.suspend
-
-import android.graphics.RectF
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.google.common.truth.Truth
-import io.legere.pdfiumandroid.base.BasePDFTest
-import junit.framework.TestCase
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.runBlocking
-import kotlinx.coroutines.test.runTest
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class PdfTextPageKtTest : BasePDFTest() {
- private lateinit var pdfDocument: PdfDocumentKt
- private var pdfBytes: ByteArray? = null
-
- @Before
- fun setUp() =
- runBlocking {
- pdfBytes = getPdfBytes("f01.pdf")
-
- TestCase.assertNotNull(pdfBytes)
-
- pdfDocument = PdfiumCoreKt(Dispatchers.Unconfined).newDocument(pdfBytes)
- }
-
- @After
- fun tearDown() {
- pdfDocument.close()
- }
-
- @Test
- fun textPageCountChars() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val charCount = textPage.textPageCountChars()
-
- Truth.assertThat(charCount).isEqualTo(3468)
- }
- }
- }
-
- @Test
- fun textPageGetText() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val text = textPage.textPageGetText(0, 100)
-
- Truth.assertThat(text?.length).isEqualTo(100)
- }
- }
- }
-
- @Test
- fun textPageGetUnicode() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val char = textPage.textPageGetUnicode(0)
-
- Truth.assertThat(char).isEqualTo('T')
- }
- }
- }
-
- @Test
- fun textPageGetCharBox() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val rect = textPage.textPageGetCharBox(0)
-
- Truth
- .assertThat(rect)
- .isEqualTo(RectF(90.314415f, 715.3187f, 103.44171f, 699.1206f))
- }
- }
- }
-
- @Test
- fun textPageGetCharIndexAtPos() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val characterToLookup = 0
- val rect = textPage.textPageGetCharBox(characterToLookup)
-
- val pos =
- textPage.textPageGetCharIndexAtPos(
- rect?.centerX()?.toDouble() ?: 0.0,
- rect?.centerY()?.toDouble() ?: 0.0,
- // Shouldn't need much since we're in the middle of the rect
- 1.0,
- 1.0,
- )
-
- Truth.assertThat(pos).isEqualTo(characterToLookup)
- }
- }
- }
-
- @Test
- fun textPageCountRects() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val rectCount = textPage.textPageCountRects(0, 100)
-
- Truth.assertThat(rectCount).isEqualTo(4)
- }
- }
- }
-
- @Test
- fun textPageGetRect() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val rect = textPage.textPageGetRect(0)
-
- Truth.assertThat(rect).isEqualTo(RectF(0f, 0f, 0f, 0f))
- }
- }
- }
-
- @Test
- fun textPageGetBoundedText() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val text = textPage.textPageGetBoundedText(RectF(0f, 97f, 100f, 100f), 100)
-
- Truth.assertThat(text).isEqualTo("Do")
- }
- }
- }
-
- @Test
- fun getFontSize() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- val fontSize = textPage.getFontSize(0)
-
- Truth.assertThat(fontSize).isEqualTo(22.559999465942383)
- }
- }
- }
-
- @Test(expected = IllegalStateException::class)
- fun close() =
- runTest {
- var pageAfterClose: PdfTextPageKt?
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
- pageAfterClose = textPage
- }
- }
- pageAfterClose!!.textPageCountChars()
- }
-
- @Test
- fun getPage() =
- runTest {
- pdfDocument.openPage(0).use { page ->
- page.openTextPage().use { textPage ->
-
- Truth.assertThat(textPage.page).isNotNull()
- }
- }
- }
-}
diff --git a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/suspend/PdfiumCoreKtTest.kt b/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/suspend/PdfiumCoreKtTest.kt
deleted file mode 100644
index 95bea60..0000000
--- a/pdfiumandroid/src/androidTest/java/io/legere/pdfiumandroid/suspend/PdfiumCoreKtTest.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-package io.legere.pdfiumandroid.suspend
-
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.google.common.truth.Truth.assertThat
-import io.legere.pdfiumandroid.base.BasePDFTest
-import io.legere.pdfiumandroid.base.ByteArrayPdfiumSource
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.test.runTest
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class PdfiumCoreKtTest : BasePDFTest() {
- @Test
- fun newDocument() =
- runTest {
- val pdfBytes = getPdfBytes("f01.pdf")
-
- assertThat(pdfBytes).isNotNull()
-
- val pdfiumCore = PdfiumCoreKt(Dispatchers.Unconfined)
- val pdfDocument = pdfiumCore.newDocument(pdfBytes)
-
- assertThat(pdfDocument).isNotNull()
- }
-
- @Test
- fun newDocumentWitCustomSource() =
- runTest {
- val pdfBytes = getPdfBytes("f01.pdf")
-
- assertThat(pdfBytes).isNotNull()
-
- val pdfiumCore = PdfiumCoreKt(Dispatchers.Unconfined)
- val pdfDocument = pdfiumCore.newDocument(ByteArrayPdfiumSource(pdfBytes!!))
-
- assertThat(pdfDocument).isNotNull()
- }
-}
diff --git a/pdfiumandroid/src/main/AndroidManifest.xml b/pdfiumandroid/src/main/AndroidManifest.xml
deleted file mode 100644
index a5918e6..0000000
--- a/pdfiumandroid/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/pdfiumandroid/src/main/cpp/CMakeLists.txt b/pdfiumandroid/src/main/cpp/CMakeLists.txt
deleted file mode 100644
index e24ff7c..0000000
--- a/pdfiumandroid/src/main/cpp/CMakeLists.txt
+++ /dev/null
@@ -1,72 +0,0 @@
-# For more information about using CMake with Android Studio, read the
-# documentation: https://d.android.com/studio/projects/add-native-code.html
-
-# Sets the minimum version of CMake required to build the native library.
-
-cmake_minimum_required(VERSION 3.22.1)
-
-# Declares and names the project.
-
-project("pdfiumandroid")
-
-# Creates and names a library, sets it as either STATIC
-# or SHARED, and provides the relative paths to its source code.
-# You can define multiple libraries, and CMake builds them for you.
-# Gradle automatically packages shared libraries with your APK.
-
-add_library( # Sets the name of the library.
- pdfiumandroid
-
- # Sets the library as a shared library.
- SHARED
-
- # Provides a relative path to your source file(s).
- pdfiumandroid.cpp)
-
-# Searches for a specified prebuilt library and stores the path as a
-# variable. Because CMake includes system libraries in the search path by
-# default, you only need to specify the name of the public NDK library
-# you want to add. CMake verifies that the library exists before
-# completing its build.
-
-find_library( # Sets the name of the path variable.
- log-lib
-
- # Specifies the name of the NDK library that
- # you want CMake to locate.
- log)
-
-find_library( # Sets the name of the path variable.
- android-lib
-
- # Specifies the name of the NDK library that
- # you want CMake to locate.
- android)
-
-find_library( # Sets the name of the path variable.
- jnigraphics-lib
-
- # Specifies the name of the NDK library that
- # you want CMake to locate.
- jnigraphics)
-
-# Specifies libraries CMake should link to your target library. You
-# can link multiple libraries, such as libraries you define in this
-# build script, prebuilt third-party libraries, or system libraries.
-
-target_link_libraries( # Specifies the target library.
- pdfiumandroid
-
- libpdfium
-
- # Links the target library to the log library
- # included in the NDK.
- ${log-lib}
- ${android-lib}
- ${jnigraphics-lib}
- )
-
-
-add_library( libpdfium SHARED IMPORTED )
-
-set_target_properties( libpdfium PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libpdfium.so)
diff --git a/pdfiumandroid/src/main/cpp/include/cpp/fpdf_deleters.h b/pdfiumandroid/src/main/cpp/include/cpp/fpdf_deleters.h
deleted file mode 100644
index 55b85d9..0000000
--- a/pdfiumandroid/src/main/cpp/include/cpp/fpdf_deleters.h
+++ /dev/null
@@ -1,86 +0,0 @@
-// 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/pdfiumandroid/src/main/cpp/include/cpp/fpdf_scopers.h b/pdfiumandroid/src/main/cpp/include/cpp/fpdf_scopers.h
deleted file mode 100644
index 34cf9c4..0000000
--- a/pdfiumandroid/src/main/cpp/include/cpp/fpdf_scopers.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// 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/pdfiumandroid/src/main/cpp/include/fpdf_annot.h b/pdfiumandroid/src/main/cpp/include/fpdf_annot.h
deleted file mode 100644
index ef30d9a..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_annot.h
+++ /dev/null
@@ -1,1012 +0,0 @@
-// 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/pdfiumandroid/src/main/cpp/include/fpdf_attachment.h b/pdfiumandroid/src/main/cpp/include/fpdf_attachment.h
deleted file mode 100644
index d25bdda..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_attachment.h
+++ /dev/null
@@ -1,179 +0,0 @@
-// 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/pdfiumandroid/src/main/cpp/include/fpdf_catalog.h b/pdfiumandroid/src/main/cpp/include/fpdf_catalog.h
deleted file mode 100644
index 033cca5..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_catalog.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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/pdfiumandroid/src/main/cpp/include/fpdf_dataavail.h b/pdfiumandroid/src/main/cpp/include/fpdf_dataavail.h
deleted file mode 100644
index 004d9be..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_dataavail.h
+++ /dev/null
@@ -1,204 +0,0 @@
-// 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
-
-#ifndef PUBLIC_FPDF_DATAAVAIL_H_
-#define PUBLIC_FPDF_DATAAVAIL_H_
-
-#include
-
-// NOLINTNEXTLINE(build/include)
-#include "fpdfview.h"
-
-#define PDF_LINEARIZATION_UNKNOWN -1
-#define PDF_NOT_LINEARIZED 0
-#define PDF_LINEARIZED 1
-
-#define PDF_DATA_ERROR -1
-#define PDF_DATA_NOTAVAIL 0
-#define PDF_DATA_AVAIL 1
-
-#define PDF_FORM_ERROR -1
-#define PDF_FORM_NOTAVAIL 0
-#define PDF_FORM_AVAIL 1
-#define PDF_FORM_NOTEXIST 2
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-// Interface for checking whether sections of the file are available.
-typedef struct _FX_FILEAVAIL {
- // Version number of the interface. Must be 1.
- int version;
-
- // 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;
-
-// 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. Must be 1.
- int version;
-
- // 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;
-
-// 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
-} // extern "C"
-#endif // __cplusplus
-
-#endif // PUBLIC_FPDF_DATAAVAIL_H_
diff --git a/pdfiumandroid/src/main/cpp/include/fpdf_doc.h b/pdfiumandroid/src/main/cpp/include/fpdf_doc.h
deleted file mode 100644
index 2dc22d9..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_doc.h
+++ /dev/null
@@ -1,438 +0,0 @@
-// 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
-
-#ifndef PUBLIC_FPDF_DOC_H_
-#define PUBLIC_FPDF_DOC_H_
-
-// NOLINTNEXTLINE(build/include)
-#include "fpdfview.h"
-
-#ifdef __cplusplus
-extern "C" {
-#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);
-
-// 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);
-
-// 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);
-
-// 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
-} // extern "C"
-#endif // __cplusplus
-
-#endif // PUBLIC_FPDF_DOC_H_
diff --git a/pdfiumandroid/src/main/cpp/include/fpdf_edit.h b/pdfiumandroid/src/main/cpp/include/fpdf_edit.h
deleted file mode 100644
index cf67e97..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_edit.h
+++ /dev/null
@@ -1,1564 +0,0 @@
-// 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
-
-#ifndef PUBLIC_FPDF_EDIT_H_
-#define PUBLIC_FPDF_EDIT_H_
-
-#include
-
-// NOLINTNEXTLINE(build/include)
-#include "fpdfview.h"
-
-#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))
-
-// 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
-
-// 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);
-
-// 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 longer than the length of the name.
-// Optional, pass null to just retrieve the size of the buffer
-// needed.
-// buflen - length of the buffer.
-// out_buflen - pointer to variable that will receive the minimum buffer size
-// to contain the name. 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,
- void* 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 longer than the length of the key.
-// Optional, pass null to just retrieve the size of the buffer
-// needed.
-// buflen - length of the buffer.
-// out_buflen - pointer to variable that will receive the minimum buffer size
-// to contain the key. 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,
- void* 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 longer than the length of the
-// value.
-// Optional, pass null to just retrieve the size of the buffer
-// needed.
-// buflen - length of the buffer.
-// out_buflen - pointer to variable that will receive the minimum buffer size
-// to contain the value. 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,
- void* 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 at least as long as the length of the value.
-// Optional, pass null to just retrieve the size of the buffer
-// needed.
-// buflen - length of the buffer.
-// out_buflen - pointer to variable that will receive the minimum buffer size
-// to contain the value. 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,
- void* 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,
- void* 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 count,
- FPDF_PAGEOBJECT image_object,
- 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);
-
-// 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 aryan '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
-} // extern "C"
-#endif // __cplusplus
-
-#endif // PUBLIC_FPDF_EDIT_H_
diff --git a/pdfiumandroid/src/main/cpp/include/fpdf_ext.h b/pdfiumandroid/src/main/cpp/include/fpdf_ext.h
deleted file mode 100644
index 068a977..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_ext.h
+++ /dev/null
@@ -1,119 +0,0 @@
-// 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
-
-#ifndef PUBLIC_FPDF_EXT_H_
-#define PUBLIC_FPDF_EXT_H_
-
-#include
-
-// NOLINTNEXTLINE(build/include)
-#include "fpdfview.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-// 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. Must be 1.
- int version;
-
- // 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;
-
-// 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);
-
-// 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
-// Document outline, and thumbnails hidden.
-#define PAGEMODE_USENONE 0
-// Document outline visible.
-#define PAGEMODE_USEOUTLINES 1
-// Thumbnail images visible.
-#define PAGEMODE_USETHUMBS 2
-// Full-screen mode, no menu bar, window controls, or other decorations visible.
-#define PAGEMODE_FULLSCREEN 3
-// Optional content group panel visible.
-#define PAGEMODE_USEOC 4
-// Attachments panel visible.
-#define PAGEMODE_USEATTACHMENTS 5
-
-// 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
-} // extern "C"
-#endif // __cplusplus
-
-#endif // PUBLIC_FPDF_EXT_H_
diff --git a/pdfiumandroid/src/main/cpp/include/fpdf_flatten.h b/pdfiumandroid/src/main/cpp/include/fpdf_flatten.h
deleted file mode 100644
index aba5186..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_flatten.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// 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
-
-#ifndef PUBLIC_FPDF_FLATTEN_H_
-#define PUBLIC_FPDF_FLATTEN_H_
-
-// NOLINTNEXTLINE(build/include)
-#include "fpdfview.h"
-
-// Flatten operation failed.
-#define FLATTEN_FAIL 0
-// Flatten operation succeed.
-#define FLATTEN_SUCCESS 1
-// Nothing to be flattened.
-#define FLATTEN_NOTHINGTODO 2
-
-// Flatten for normal display.
-#define FLAT_NORMALDISPLAY 0
-// Flatten for print.
-#define FLAT_PRINT 1
-
-#ifdef __cplusplus
-extern "C" {
-#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
-} // extern "C"
-#endif // __cplusplus
-
-#endif // PUBLIC_FPDF_FLATTEN_H_
diff --git a/pdfiumandroid/src/main/cpp/include/fpdf_formfill.h b/pdfiumandroid/src/main/cpp/include/fpdf_formfill.h
deleted file mode 100644
index 9e36853..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_formfill.h
+++ /dev/null
@@ -1,2007 +0,0 @@
-// 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
-
-#ifndef PUBLIC_FPDF_FORMFILL_H_
-#define PUBLIC_FPDF_FORMFILL_H_
-
-// clang-format off
-// NOLINTNEXTLINE(build/include_directory)
-#include "fpdfview.h"
-
-// 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
-extern "C" {
-#endif
-
-typedef struct _IPDF_JsPlatform {
- /*
- * 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 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, 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
- * 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,
- FPDF_WIDESTRING Default,
- FPDF_WIDESTRING cLabel,
- FPDF_BOOL bPassword,
- 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 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.
- */
- void (*Doc_mail)(struct _IPDF_JsPlatform* pThis,
- void* mailData,
- int length,
- FPDF_BOOL bUI,
- FPDF_WIDESTRING To,
- FPDF_WIDESTRING Subject,
- FPDF_WIDESTRING CC,
- 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.
- * Return Value:
- * None.
- */
- void (*Doc_print)(struct _IPDF_JsPlatform* pThis,
- FPDF_BOOL bUI,
- int nStart,
- int nEnd,
- FPDF_BOOL bSilent,
- FPDF_BOOL bShrinkToFit,
- FPDF_BOOL bPrintAsImage,
- 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.
- */
- 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.
- *
- */
- 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, in bytes. Can be 0.
- * Return Value:
- * Number of bytes the filePath consumes, including trailing zeros.
- * Comments:
- * The filePath shoule always be provided in local encoding.
- */
- int (*Field_browse)(struct _IPDF_JsPlatform* pThis,
- void* filePath,
- int length);
-
- /*
- * 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. */
-
- 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
-#define FXCT_ARROW 0
-#define FXCT_NESW 1
-#define FXCT_NWSE 2
-#define FXCT_VBEAM 3
-#define FXCT_HBEAM 4
-#define FXCT_HAND 5
-
-/*
- * 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.
- */
-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] */
-} FPDF_SYSTEMTIME;
-
-#ifdef PDF_ENABLE_XFA
-
-// 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.
- * 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 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().
- * 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,
- double top,
- double right,
- double bottom);
-
- /*
- * 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,
- double top,
- 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 details.
- * Return value:
- * None.
- */
- void (*FFI_SetCursor)(struct _FPDF_FORMFILLINFO* pThis, int nCursorType);
-
- /*
- * 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 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:
- * 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 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 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 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);
- /*
- * 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
- * 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 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.
- * 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;
-
- /* 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,
- double left,
- double top,
- double right,
- double bottom);
-
- /*
- * 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:
- * 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 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:
- * 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_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
- * 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,
- FPDF_WIDESTRING pSubject,
- FPDF_WIDESTRING pCC,
- FPDF_WIDESTRING pBcc,
- FPDF_WIDESTRING pMsg);
-
- /*
- * 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:
- * 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:
- * 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:
- * 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
- * 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
- * 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 focussed 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 focussed 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.
-#define FPDF_FORMFIELD_RADIOBUTTON 3 // radio button type.
-#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 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
-
-#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
-#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
-
-#endif // PUBLIC_FPDF_FORMFILL_H_
diff --git a/pdfiumandroid/src/main/cpp/include/fpdf_fwlevent.h b/pdfiumandroid/src/main/cpp/include/fpdf_fwlevent.h
deleted file mode 100644
index e61606d..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_fwlevent.h
+++ /dev/null
@@ -1,207 +0,0 @@
-// 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
-
-#ifndef PUBLIC_FPDF_FWLEVENT_H_
-#define PUBLIC_FPDF_FWLEVENT_H_
-
-// NOLINTNEXTLINE(build/include)
-#include "fpdfview.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-// Key flags.
-typedef enum {
- FWL_EVENTFLAG_ShiftKey = 1 << 0,
- FWL_EVENTFLAG_ControlKey = 1 << 1,
- FWL_EVENTFLAG_AltKey = 1 << 2,
- FWL_EVENTFLAG_MetaKey = 1 << 3,
- FWL_EVENTFLAG_KeyPad = 1 << 4,
- FWL_EVENTFLAG_AutoRepeat = 1 << 5,
- FWL_EVENTFLAG_LeftButtonDown = 1 << 6,
- FWL_EVENTFLAG_MiddleButtonDown = 1 << 7,
- FWL_EVENTFLAG_RightButtonDown = 1 << 8,
-} FWL_EVENTFLAG;
-
-// 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,
- FWL_VKEY_Control = 0x11,
- FWL_VKEY_Menu = 0x12,
- FWL_VKEY_Pause = 0x13,
- FWL_VKEY_Capital = 0x14,
- FWL_VKEY_Kana = 0x15,
- FWL_VKEY_Hangul = 0x15,
- FWL_VKEY_Junja = 0x17,
- FWL_VKEY_Final = 0x18,
- FWL_VKEY_Hanja = 0x19,
- FWL_VKEY_Kanji = 0x19,
- FWL_VKEY_Escape = 0x1B,
- FWL_VKEY_Convert = 0x1C,
- FWL_VKEY_NonConvert = 0x1D,
- FWL_VKEY_Accept = 0x1E,
- FWL_VKEY_ModeChange = 0x1F,
- FWL_VKEY_Space = 0x20,
- FWL_VKEY_Prior = 0x21,
- FWL_VKEY_Next = 0x22,
- FWL_VKEY_End = 0x23,
- FWL_VKEY_Home = 0x24,
- FWL_VKEY_Left = 0x25,
- FWL_VKEY_Up = 0x26,
- FWL_VKEY_Right = 0x27,
- FWL_VKEY_Down = 0x28,
- FWL_VKEY_Select = 0x29,
- FWL_VKEY_Print = 0x2A,
- FWL_VKEY_Execute = 0x2B,
- FWL_VKEY_Snapshot = 0x2C,
- FWL_VKEY_Insert = 0x2D,
- FWL_VKEY_Delete = 0x2E,
- FWL_VKEY_Help = 0x2F,
- FWL_VKEY_0 = 0x30,
- FWL_VKEY_1 = 0x31,
- FWL_VKEY_2 = 0x32,
- FWL_VKEY_3 = 0x33,
- FWL_VKEY_4 = 0x34,
- FWL_VKEY_5 = 0x35,
- FWL_VKEY_6 = 0x36,
- FWL_VKEY_7 = 0x37,
- FWL_VKEY_8 = 0x38,
- FWL_VKEY_9 = 0x39,
- FWL_VKEY_A = 0x41,
- FWL_VKEY_B = 0x42,
- FWL_VKEY_C = 0x43,
- FWL_VKEY_D = 0x44,
- FWL_VKEY_E = 0x45,
- FWL_VKEY_F = 0x46,
- FWL_VKEY_G = 0x47,
- FWL_VKEY_H = 0x48,
- FWL_VKEY_I = 0x49,
- FWL_VKEY_J = 0x4A,
- FWL_VKEY_K = 0x4B,
- FWL_VKEY_L = 0x4C,
- FWL_VKEY_M = 0x4D,
- FWL_VKEY_N = 0x4E,
- FWL_VKEY_O = 0x4F,
- FWL_VKEY_P = 0x50,
- FWL_VKEY_Q = 0x51,
- FWL_VKEY_R = 0x52,
- FWL_VKEY_S = 0x53,
- FWL_VKEY_T = 0x54,
- FWL_VKEY_U = 0x55,
- FWL_VKEY_V = 0x56,
- FWL_VKEY_W = 0x57,
- FWL_VKEY_X = 0x58,
- FWL_VKEY_Y = 0x59,
- FWL_VKEY_Z = 0x5A,
- FWL_VKEY_LWin = 0x5B,
- FWL_VKEY_Command = 0x5B,
- FWL_VKEY_RWin = 0x5C,
- FWL_VKEY_Apps = 0x5D,
- FWL_VKEY_Sleep = 0x5F,
- FWL_VKEY_NumPad0 = 0x60,
- FWL_VKEY_NumPad1 = 0x61,
- FWL_VKEY_NumPad2 = 0x62,
- FWL_VKEY_NumPad3 = 0x63,
- FWL_VKEY_NumPad4 = 0x64,
- FWL_VKEY_NumPad5 = 0x65,
- FWL_VKEY_NumPad6 = 0x66,
- FWL_VKEY_NumPad7 = 0x67,
- FWL_VKEY_NumPad8 = 0x68,
- FWL_VKEY_NumPad9 = 0x69,
- FWL_VKEY_Multiply = 0x6A,
- FWL_VKEY_Add = 0x6B,
- FWL_VKEY_Separator = 0x6C,
- FWL_VKEY_Subtract = 0x6D,
- FWL_VKEY_Decimal = 0x6E,
- FWL_VKEY_Divide = 0x6F,
- FWL_VKEY_F1 = 0x70,
- FWL_VKEY_F2 = 0x71,
- FWL_VKEY_F3 = 0x72,
- FWL_VKEY_F4 = 0x73,
- FWL_VKEY_F5 = 0x74,
- FWL_VKEY_F6 = 0x75,
- FWL_VKEY_F7 = 0x76,
- FWL_VKEY_F8 = 0x77,
- FWL_VKEY_F9 = 0x78,
- FWL_VKEY_F10 = 0x79,
- FWL_VKEY_F11 = 0x7A,
- FWL_VKEY_F12 = 0x7B,
- FWL_VKEY_F13 = 0x7C,
- FWL_VKEY_F14 = 0x7D,
- FWL_VKEY_F15 = 0x7E,
- FWL_VKEY_F16 = 0x7F,
- FWL_VKEY_F17 = 0x80,
- FWL_VKEY_F18 = 0x81,
- FWL_VKEY_F19 = 0x82,
- FWL_VKEY_F20 = 0x83,
- FWL_VKEY_F21 = 0x84,
- FWL_VKEY_F22 = 0x85,
- FWL_VKEY_F23 = 0x86,
- FWL_VKEY_F24 = 0x87,
- FWL_VKEY_NunLock = 0x90,
- FWL_VKEY_Scroll = 0x91,
- FWL_VKEY_LShift = 0xA0,
- FWL_VKEY_RShift = 0xA1,
- FWL_VKEY_LControl = 0xA2,
- FWL_VKEY_RControl = 0xA3,
- FWL_VKEY_LMenu = 0xA4,
- FWL_VKEY_RMenu = 0xA5,
- FWL_VKEY_BROWSER_Back = 0xA6,
- FWL_VKEY_BROWSER_Forward = 0xA7,
- FWL_VKEY_BROWSER_Refresh = 0xA8,
- FWL_VKEY_BROWSER_Stop = 0xA9,
- FWL_VKEY_BROWSER_Search = 0xAA,
- FWL_VKEY_BROWSER_Favorites = 0xAB,
- FWL_VKEY_BROWSER_Home = 0xAC,
- FWL_VKEY_VOLUME_Mute = 0xAD,
- FWL_VKEY_VOLUME_Down = 0xAE,
- FWL_VKEY_VOLUME_Up = 0xAF,
- FWL_VKEY_MEDIA_NEXT_Track = 0xB0,
- FWL_VKEY_MEDIA_PREV_Track = 0xB1,
- FWL_VKEY_MEDIA_Stop = 0xB2,
- FWL_VKEY_MEDIA_PLAY_Pause = 0xB3,
- FWL_VKEY_MEDIA_LAUNCH_Mail = 0xB4,
- FWL_VKEY_MEDIA_LAUNCH_MEDIA_Select = 0xB5,
- FWL_VKEY_MEDIA_LAUNCH_APP1 = 0xB6,
- FWL_VKEY_MEDIA_LAUNCH_APP2 = 0xB7,
- FWL_VKEY_OEM_1 = 0xBA,
- FWL_VKEY_OEM_Plus = 0xBB,
- FWL_VKEY_OEM_Comma = 0xBC,
- FWL_VKEY_OEM_Minus = 0xBD,
- FWL_VKEY_OEM_Period = 0xBE,
- FWL_VKEY_OEM_2 = 0xBF,
- FWL_VKEY_OEM_3 = 0xC0,
- FWL_VKEY_OEM_4 = 0xDB,
- FWL_VKEY_OEM_5 = 0xDC,
- FWL_VKEY_OEM_6 = 0xDD,
- FWL_VKEY_OEM_7 = 0xDE,
- FWL_VKEY_OEM_8 = 0xDF,
- FWL_VKEY_OEM_102 = 0xE2,
- FWL_VKEY_ProcessKey = 0xE5,
- FWL_VKEY_Packet = 0xE7,
- FWL_VKEY_Attn = 0xF6,
- FWL_VKEY_Crsel = 0xF7,
- FWL_VKEY_Exsel = 0xF8,
- FWL_VKEY_Ereof = 0xF9,
- FWL_VKEY_Play = 0xFA,
- FWL_VKEY_Zoom = 0xFB,
- FWL_VKEY_NoName = 0xFC,
- FWL_VKEY_PA1 = 0xFD,
- FWL_VKEY_OEM_Clear = 0xFE,
- FWL_VKEY_Unknown = 0,
-} FWL_VKEYCODE;
-
-#ifdef __cplusplus
-} // extern "C"
-#endif // __cplusplus
-
-#endif // PUBLIC_FPDF_FWLEVENT_H_
diff --git a/pdfiumandroid/src/main/cpp/include/fpdf_javascript.h b/pdfiumandroid/src/main/cpp/include/fpdf_javascript.h
deleted file mode 100644
index 2b02405..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_javascript.h
+++ /dev/null
@@ -1,77 +0,0 @@
-// 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/pdfiumandroid/src/main/cpp/include/fpdf_ppo.h b/pdfiumandroid/src/main/cpp/include/fpdf_ppo.h
deleted file mode 100644
index 1734bc6..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_ppo.h
+++ /dev/null
@@ -1,115 +0,0 @@
-// 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
-
-#ifndef PUBLIC_FPDF_PPO_H_
-#define PUBLIC_FPDF_PPO_H_
-
-// NOLINTNEXTLINE(build/include)
-#include "fpdfview.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// 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:
-// 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
-} // extern "C"
-#endif // __cplusplus
-
-#endif // PUBLIC_FPDF_PPO_H_
diff --git a/pdfiumandroid/src/main/cpp/include/fpdf_progressive.h b/pdfiumandroid/src/main/cpp/include/fpdf_progressive.h
deleted file mode 100644
index b146d48..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_progressive.h
+++ /dev/null
@@ -1,159 +0,0 @@
-// 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
-
-#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_READY 0
-#define FPDF_RENDER_TOBECONTINUED 1
-#define FPDF_RENDER_DONE 2
-#define FPDF_RENDER_FAILED 3
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// IFPDF_RENDERINFO interface.
-typedef struct _IFSDK_PAUSE {
- /*
- * 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.
- */
- 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().
-// page - Handle to the page, as returned by FPDF_LoadPage().
-// start_x - Left pixel position of the display area in the
-// bitmap coordinates.
-// start_y - Top pixel position of the display area in the bitmap
-// 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 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
-// Return value:
-// Rendering Status. See flags for progressive process status for the
-// details.
-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, 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.
-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, as returned by FPDF_LoadPage().
-// Return value:
-// None.
-FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPage_Close(FPDF_PAGE page);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // PUBLIC_FPDF_PROGRESSIVE_H_
diff --git a/pdfiumandroid/src/main/cpp/include/fpdf_save.h b/pdfiumandroid/src/main/cpp/include/fpdf_save.h
deleted file mode 100644
index 800d4e7..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_save.h
+++ /dev/null
@@ -1,85 +0,0 @@
-// 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
-
-#ifndef PUBLIC_FPDF_SAVE_H_
-#define PUBLIC_FPDF_SAVE_H_
-
-// clang-format off
-// NOLINTNEXTLINE(build/include)
-#include "fpdfview.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Structure for custom file write
-typedef struct FPDF_FILEWRITE_ {
- //
- // Version number of the interface. Currently must be 1.
- //
- int version;
-
- // Method: WriteBlock
- // Output a block of data in your custom way.
- // Interface Version:
- // 1
- // Implementation Required:
- // Yes
- // Comments:
- // Called by function FPDF_SaveDocument
- // Parameters:
- // pThis - Pointer to the structure itself
- // pData - Pointer to a buffer to output
- // 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;
-
- // Flags for FPDF_SaveAsCopy()
-#define FPDF_INCREMENTAL 1
-#define FPDF_NO_INCREMENTAL 2
-#define FPDF_REMOVE_SECURITY 3
-
-// Function: FPDF_SaveAsCopy
-// Saves the copy of specified document in custom way.
-// Parameters:
-// 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.
-//
-FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_SaveAsCopy(FPDF_DOCUMENT document,
- FPDF_FILEWRITE* pFileWrite,
- FPDF_DWORD flags);
-
-// Function: FPDF_SaveWithVersion
-// 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, ...
-// Return value:
-// TRUE if succeed, FALSE if failed.
-//
-FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
-FPDF_SaveWithVersion(FPDF_DOCUMENT document,
- FPDF_FILEWRITE* pFileWrite,
- FPDF_DWORD flags,
- int fileVersion);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // PUBLIC_FPDF_SAVE_H_
diff --git a/pdfiumandroid/src/main/cpp/include/fpdf_searchex.h b/pdfiumandroid/src/main/cpp/include/fpdf_searchex.h
deleted file mode 100644
index 9c980db..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_searchex.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// 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
-
-#ifndef PUBLIC_FPDF_SEARCHEX_H_
-#define PUBLIC_FPDF_SEARCHEX_H_
-
-// NOLINTNEXTLINE(build/include)
-#include "fpdfview.h"
-
-#ifdef __cplusplus
-extern "C" {
-#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
-} // extern "C"
-#endif // __cplusplus
-
-#endif // PUBLIC_FPDF_SEARCHEX_H_
diff --git a/pdfiumandroid/src/main/cpp/include/fpdf_signature.h b/pdfiumandroid/src/main/cpp/include/fpdf_signature.h
deleted file mode 100644
index 9a075e5..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_signature.h
+++ /dev/null
@@ -1,155 +0,0 @@
-// 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/pdfiumandroid/src/main/cpp/include/fpdf_structtree.h b/pdfiumandroid/src/main/cpp/include/fpdf_structtree.h
deleted file mode 100644
index ea67fef..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_structtree.h
+++ /dev/null
@@ -1,524 +0,0 @@
-// 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/pdfiumandroid/src/main/cpp/include/fpdf_sysfontinfo.h b/pdfiumandroid/src/main/cpp/include/fpdf_sysfontinfo.h
deleted file mode 100644
index 2dac855..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_sysfontinfo.h
+++ /dev/null
@@ -1,317 +0,0 @@
-// 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
-
-#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
-#define FXFONT_ANSI_CHARSET 0
-#define FXFONT_DEFAULT_CHARSET 1
-#define FXFONT_SYMBOL_CHARSET 2
-#define FXFONT_SHIFTJIS_CHARSET 128
-#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 << 0)
-#define FXFONT_FF_ROMAN (1 << 4)
-#define FXFONT_FF_SCRIPT (4 << 4)
-
-// Typical weight values
-#define FXFONT_FW_NORMAL 400
-#define FXFONT_FW_BOLD 700
-
-// Exported Functions
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// 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.
- 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
- // 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
- // 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:
- // 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,
- int charset,
- int pitch_family,
- const char* face,
- FPDF_BOOL* bExact);
-
- // 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
- // 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.
- 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.
- 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
- 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.
-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.
-// 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_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_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_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
-}
-#endif
-
-#endif // PUBLIC_FPDF_SYSFONTINFO_H_
diff --git a/pdfiumandroid/src/main/cpp/include/fpdf_text.h b/pdfiumandroid/src/main/cpp/include/fpdf_text.h
deleted file mode 100644
index 42bb1a5..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_text.h
+++ /dev/null
@@ -1,685 +0,0 @@
-// 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
-
-#ifndef PUBLIC_FPDF_TEXT_H_
-#define PUBLIC_FPDF_TEXT_H_
-
-// clang-format off
-// NOLINTNEXTLINE(build/include)
-#include "fpdfview.h"
-
-// Exported Functions
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Function: FPDFText_LoadPage
-// Prepare information about all characters in a page.
-// Parameters:
-// page - Handle to the page. Returned by FPDF_LoadPage function
-// (in FPDFVIEW module).
-// Return value:
-// A handle to the text page information structure.
-// NULL if something goes wrong.
-// Comments:
-// Application must call FPDFText_ClosePage to release the text page
-// information.
-//
-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.
-// Return Value:
-// None.
-//
-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.
-// Return value:
-// Number of characters in the page. Return -1 for error.
-// Generated characters, like additional space characters, new line
-// characters, are also counted.
-// Comments:
-// Characters in a page form a "stream", inside the stream, each
-// character has an index.
-// We will use the index parameters in many of FPDFTEXT functions. The
-// first character in the page
-// has an index value of zero.
-//
-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.
-// index - Zero-based index of the character.
-// Return value:
-// The Unicode of the particular character.
-// If a character is not encoded in Unicode and Foxit engine can't
-// convert to Unicode,
-// the return value will be zero.
-//
-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.
-// 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").
-//
-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.
-//
-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.
-// index - Zero-based index of the character.
-// left - Pointer to a double number receiving left position
-// of the character box.
-// right - Pointer to a double number receiving right position
-// of the character box.
-// bottom - Pointer to a double number receiving bottom position
-// of the character box.
-// top - Pointer to a double number receiving top position of
-// the character box.
-// Return Value:
-// 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".
-//
-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.
-// 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 units.
-// yTolerance - A y-axis tolerance value for character hit
-// 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.
-//
-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.
-// start_index - Index for the start characters.
-// count - Number of UCS-2 values to be extracted.
-// result - A buffer (allocated by application) receiving the
-// 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 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().
-//
-FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetText(FPDF_TEXTPAGE text_page,
- int start_index,
- int count,
- unsigned short* result);
-
-// Function: FPDFText_CountRects
-// 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 character.
-// count - Number of characters, or -1 for all remaining.
-// Return value:
-// 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. 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.
-//
-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.
-// rect_index - Zero-based index for the rectangle.
-// left - Pointer to a double value receiving the rectangle
-// left boundary.
-// top - Pointer to a double value receiving the rectangle
-// top boundary.
-// right - Pointer to a double value receiving the rectangle
-// right boundary.
-// bottom - Pointer to a double value receiving the rectangle
-// bottom boundary.
-// Return Value:
-// 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.
-//
-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.
-// left - Left boundary.
-// top - Top boundary.
-// right - Right boundary.
-// bottom - Bottom boundary.
-// 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 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. May return a split surrogate in that case.
-//
-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.
-//
-// 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.
-// findwhat - A unicode match pattern.
-// flags - Option flags.
-// start_index - Start from this character. -1 for end of the page.
-// Return Value:
-// A handle for the search context. FPDFText_FindClose must be called
-// to release this handle.
-//
-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.
-// Return Value:
-// Whether a match is found.
-//
-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.
-// Return Value:
-// Whether a match is found.
-//
-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.
-// Return Value:
-// Index for the starting character.
-//
-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.
-// Return Value:
-// Number of matched characters.
-//
-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.
-// Return Value:
-// None.
-//
-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.
-// Return Value:
-// 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 aryan,
-// 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.
-//
-FPDF_EXPORT FPDF_PAGELINK FPDF_CALLCONV
-FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page);
-
-// Function: FPDFLink_CountWebLinks
-// Count number of detected web links.
-// Parameters:
-// link_page - Handle returned by FPDFLink_LoadWebLinks.
-// Return Value:
-// Number of detected web links.
-//
-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 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 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.
-//
-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.
-// Parameters:
-// link_page - Handle returned by FPDFLink_LoadWebLinks.
-// link_index - Zero-based index for the link.
-// Return Value:
-// Number of rectangular areas for the link. If |link_index| does
-// not correspond to a valid link, then 0 is returned.
-//
-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.
-// Parameters:
-// link_page - Handle returned by FPDFLink_LoadWebLinks.
-// 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.
-// top - Pointer to a double value receiving the rectangle
-// top boundary.
-// right - Pointer to a double value receiving the rectangle
-// right boundary.
-// bottom - Pointer to a double value receiving the rectangle
-// bottom boundary.
-// Return Value:
-// 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.
-//
-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.
-// Parameters:
-// link_page - Handle returned by FPDFLink_LoadWebLinks.
-// Return Value:
-// None.
-//
-FPDF_EXPORT void FPDF_CALLCONV FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // PUBLIC_FPDF_TEXT_H_
diff --git a/pdfiumandroid/src/main/cpp/include/fpdf_thumbnail.h b/pdfiumandroid/src/main/cpp/include/fpdf_thumbnail.h
deleted file mode 100644
index 27b6d49..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_thumbnail.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// 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/pdfiumandroid/src/main/cpp/include/fpdf_transformpage.h b/pdfiumandroid/src/main/cpp/include/fpdf_transformpage.h
deleted file mode 100644
index d5c5daa..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdf_transformpage.h
+++ /dev/null
@@ -1,308 +0,0 @@
-// 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
-
-#ifndef PUBLIC_FPDF_TRANSFORMPAGE_H_
-#define PUBLIC_FPDF_TRANSFORMPAGE_H_
-
-// NOLINTNEXTLINE(build/include)
-#include "fpdfview.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * 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,
- double c,
- double d,
- double e,
- double f);
-
-// 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);
-
-/**
- * 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
-}
-#endif
-
-#endif // PUBLIC_FPDF_TRANSFORMPAGE_H_
diff --git a/pdfiumandroid/src/main/cpp/include/fpdfview.h b/pdfiumandroid/src/main/cpp/include/fpdfview.h
deleted file mode 100644
index 7fd1975..0000000
--- a/pdfiumandroid/src/main/cpp/include/fpdfview.h
+++ /dev/null
@@ -1,1461 +0,0 @@
-// 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 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
-// 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 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_RESULT;
-typedef unsigned long FPDF_DWORD;
-typedef float FS_FLOAT;
-
-// Duplex types
-typedef enum _FPDF_DUPLEXTYPE_ {
- DuplexUndefined = 0,
- Simplex,
- DuplexFlipShortEdge,
- DuplexFlipLongEdge
-} FPDF_DUPLEXTYPE;
-
-// String types
-typedef unsigned short FPDF_WCHAR;
-
-// 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;
-
-// 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;
-
-// 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;
-
-// 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
-// expect to process Unicode larger than 0xffff.
-//
-// 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.
-typedef const char* FPDF_STRING;
-
-// 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;
- float c;
- float d;
- float e;
- float f;
-} FS_MATRIX;
-
-// Rectangle area(float) in device or page coordinate system.
-typedef struct _FS_RECTF_ {
- // The x-coordinate of the left-top corner.
- float left;
- // The y-coordinate of the left-top corner.
- float top;
- // The x-coordinate of the right-bottom corner.
- float right;
- // The y-coordinate of the right-bottom corner.
- float bottom;
-} * FS_LPRECTF, FS_RECTF;
-
-// Const Pointer to FS_RECTF structure.
-typedef const FS_RECTF* FS_LPCRECTF;
-
-// 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 FPDF_CALLCONV
-#endif
-
-// Exported Functions
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// 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
- // FXGE font loading code. The array is terminated by a NULL pointer.
- // The Array may be NULL itself to use the default paths. May be ignored
- // entirely depending upon the platform.
- const char** m_pUserFontPaths;
-
- // Version 2.
-
- // 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 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 PDFium library and allocate global resources for it.
-// Parameters:
-// config - configuration information as above.
-// Return value:
-// None.
-// Comments:
-// You have to call this function before you can call any PDF
-// processing functions.
-FPDF_EXPORT void FPDF_CALLCONV
-FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* config);
-
-// 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:
-// After this function is called, you must not call any PDF
-// processing functions.
-//
-// 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
-
-// Function: FPDF_SetSandBoxPolicy
-// Set the policy for the sandbox environment.
-// Parameters:
-// policy - The specified policy for setting, for aryan:
-// FPDF_POLICY_MACHINETIME_ACCESS.
-// enable - True to enable, false to disable the policy.
-// Return value:
-// None.
-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.
-// Parameters:
-// 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.
-//
-// 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.
-// 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.
-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.
-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 {
- // File length, in bytes.
- unsigned long m_FileLen;
-
- // 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 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,
- unsigned long position,
- unsigned char* pBuf,
- unsigned long size);
-
- // A custom pointer for all implementation specific data. This pointer will
- // be used as the first parameter to the m_GetBlock callback.
- void* m_Param;
-} FPDF_FILEACCESS;
-
-// 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;
-
-// Function: FPDF_LoadCustomDocument
-// Load PDF document from a custom access descriptor.
-// Parameters:
-// pFileAccess - A structure for accessing the file.
-// password - Optional password for decrypting the PDF file.
-// Return value:
-// A handle to the loaded document, or NULL on failure.
-// Comments:
-// 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().
-//
-// 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_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password);
-
-// Function: FPDF_GetFileVersion
-// Get the file version of the given PDF document.
-// Parameters:
-// doc - Handle to a document.
-// fileVersion - The PDF file version. File version: 14 for 1.4, 15
-// for 1.5, ...
-// Return value:
-// True if succeeds, false otherwise.
-// Comments:
-// If the document was created by FPDF_CreateNewDocument,
-// then this function will always fail.
-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.
-#define FPDF_ERR_FILE 2 // File not found or could not be opened.
-#define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
-#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
-#define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
-#define FPDF_ERR_PAGE 6 // Page not found or content error.
-#ifdef PDF_ENABLE_XFA
-#define FPDF_ERR_XFALOAD 7 // Load XFA error.
-#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
-#endif // PDF_ENABLE_XFA
-
-// Function: FPDF_GetLastError
-// Get last error code when a function fails.
-// Parameters:
-// None.
-// Return value:
-// 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. This function only works in conjunction
-// with APIs that mention FPDF_GetLastError() in their documentation.
-FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetLastError();
-
-// 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 or was unlocked by the owner, 0xffffffff will be returned.
-FPDF_EXPORT unsigned long FPDF_CALLCONV
-FPDF_GetDocPermissions(FPDF_DOCUMENT document);
-
-// Function: FPDF_GetDocUserPermissions
-// Get user file permission flags of the document.
-// Parameters:
-// document - Handle to a document. Returned by FPDF_LoadDocument.
-// Return value:
-// A 32-bit integer indicating permission flags. Please refer to the
-// PDF Reference for detailed descriptions. If the document is not
-// protected, 0xffffffff will be returned. Always returns user
-// permissions, even if the document was unlocked by the owner.
-FPDF_EXPORT unsigned long FPDF_CALLCONV
-FPDF_GetDocUserPermissions(FPDF_DOCUMENT document);
-
-// Function: FPDF_GetSecurityHandlerRevision
-// Get the revision for the security handler.
-// Parameters:
-// document - Handle to a document. Returned by FPDF_LoadDocument.
-// Return value:
-// 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.
-FPDF_EXPORT int FPDF_CALLCONV
-FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document);
-
-// Function: FPDF_GetPageCount
-// Get total number of pages in the document.
-// Parameters:
-// document - Handle to document. Returned by FPDF_LoadDocument.
-// Return value:
-// Total number of pages in the document.
-FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageCount(FPDF_DOCUMENT document);
-
-// Function: FPDF_LoadPage
-// Load a page inside the document.
-// Parameters:
-// document - Handle to document. Returned by FPDF_LoadDocument
-// page_index - Index number of the page. 0 for the first page.
-// Return value:
-// A handle to the loaded page, or NULL if page load fails.
-// Comments:
-// The loaded page can be rendered to devices using FPDF_RenderPage.
-// The loaded page can be closed using FPDF_ClosePage.
-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.
-// 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).
-// 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.
-// 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)
-// 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.
-// Parameters:
-// document - Handle to document. Returned by FPDF_LoadDocument.
-// page_index - Page index, zero for the first page.
-// width - Pointer to a double to receive the page width
-// (in points).
-// height - Pointer to a double to receive the page height
-// (in points).
-// Return value:
-// Non-zero for success. 0 for error (document or page not found).
-// 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. 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
-// Obsolete, has no effect, retained for compatibility.
-#define FPDF_DEBUG_INFO 0x80
-// Obsolete, has no effect, retained for compatibility.
-#define FPDF_NO_CATCH 0x100
-// Limit image cache size.
-#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200
-// Always use halftone for image stretching.
-#define FPDF_RENDER_FORCEHALFTONE 0x400
-// Render for printing.
-#define FPDF_PRINTING 0x800
-// 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
-// Set to disable anti-aliasing on paths.
-#define FPDF_RENDER_NO_SMOOTHPATH 0x4000
-// 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
-// Render contents of a page to a device (screen, bitmap, or printer).
-// This function is only supported on Windows.
-// Parameters:
-// dc - Handle to the device context.
-// page - Handle to the page. Returned by FPDF_LoadPage.
-// start_x - Left pixel position of the display area in
-// device coordinates.
-// start_y - Top pixel position of the display area in 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.
-FPDF_EXPORT void 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
-// 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 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.
-// start_y - Top pixel position of the display area in bitmap
-// 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 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.
-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.
-// Parameters:
-// page - Handle to the loaded page.
-// Return value:
-// None.
-FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page);
-
-// Function: FPDF_CloseDocument
-// Close a loaded PDF document.
-// Parameters:
-// document - Handle to the loaded document.
-// Return value:
-// None.
-FPDF_EXPORT void FPDF_CALLCONV FPDF_CloseDocument(FPDF_DOCUMENT document);
-
-// Function: FPDF_DeviceToPage
-// Convert the screen coordinates of a point to page coordinates.
-// Parameters:
-// page - Handle to the page. Returned by FPDF_LoadPage.
-// start_x - Left pixel position of the display area in
-// device coordinates.
-// start_y - Top pixel position of the display area in 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)
-// device_x - X value in device coordinates to be converted.
-// device_y - Y value in device coordinates to be converted.
-// page_x - A pointer to a double receiving the converted X
-// value in page coordinates.
-// page_y - A pointer to a double receiving the converted Y
-// value in page coordinates.
-// Return value:
-// 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
-// the Y-axis on the left side going up.
-//
-// NOTE: this coordinate system can be altered when you zoom, scroll,
-// or rotate a page, however, a point on the page should always have
-// the same coordinate values in the page coordinate system.
-//
-// The device coordinate system is device dependent. For screen device,
-// its origin is at the left-top corner of the window. However this
-// origin can be altered by the Windows coordinate transformation
-// utilities.
-//
-// 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.
-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.
-// Parameters:
-// page - Handle to the page. Returned by FPDF_LoadPage.
-// start_x - Left pixel position of the display area in
-// device coordinates.
-// start_y - Top pixel position of the display area in 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)
-// page_x - X value in page coordinates.
-// page_y - Y value in page coordinate.
-// device_x - A pointer to an integer receiving the result X
-// value in device coordinates.
-// device_y - A pointer to an integer receiving the result Y
-// value in device coordinates.
-// Return value:
-// Returns true if the conversion succeeds, and |device_x| and
-// |device_y| successfully receives the converted coordinates.
-// Comments:
-// See comments for FPDF_DeviceToPage().
-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).
-// Parameters:
-// width - The number of pixels in width for the bitmap.
-// Must be greater than 0.
-// height - The number of pixels in height for the bitmap.
-// Must be greater than 0.
-// alpha - A flag indicating whether the alpha channel is used.
-// Non-zero for using alpha, zero for not using.
-// Return value:
-// The created bitmap handle, or NULL if a parameter error or out of
-// memory.
-// Comments:
-// The bitmap always uses 4 bytes per pixel. The first byte is always
-// double word aligned.
-//
-// The byte order is BGRx (the last byte unused if no alpha channel) or
-// BGRA.
-//
-// The pixels in a horizontal line are stored side by side, with the
-// left most pixel stored first (with lower memory address).
-// Each line uses width * 4 bytes.
-//
-// Lines are stored one after another, with the top most line stored
-// first. There is no gap between adjacent lines.
-//
-// 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. 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.
-#define FPDFBitmap_BGR 2
-// 4 bytes per pixel, byte order: blue, green, red, unused.
-#define FPDFBitmap_BGRx 3
-// 4 bytes per pixel, byte order: blue, green, red, alpha.
-#define FPDFBitmap_BGRA 4
-
-// Function: FPDFBitmap_CreateEx
-// Create a device independent bitmap (FXDIB)
-// Parameters:
-// width - The number of pixels in width for the bitmap.
-// Must be greater than 0.
-// height - The number of pixels in height for the bitmap.
-// Must be greater than 0.
-// format - A number indicating for bitmap format, as defined
-// above.
-// first_scan - A pointer to the first byte of the first line if
-// using an external buffer. If this parameter is NULL,
-// 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:
-// Similar to FPDFBitmap_Create function, but allows for more formats
-// and an external buffer is supported. The bitmap created by this
-// function can be used in any place that a FPDF_BITMAP handle is
-// required.
-//
-// 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.
-// Parameters:
-// bitmap - The handle to the bitmap. Returned by
-// FPDFBitmap_Create.
-// left - The left position. Starting from 0 at the
-// left-most pixel.
-// top - The top position. Starting from 0 at the
-// top-most line.
-// width - Width in pixels to be filled.
-// height - Height in pixels to be filled.
-// color - A 32-bit value specifing the color, in 8888 ARGB
-// format.
-// Return value:
-// Returns whether the operation succeeded or not.
-// Comments:
-// This function sets the color and (optionally) alpha value in the
-// specified region of the bitmap.
-//
-// NOTE: If the alpha channel is used, this function does NOT
-// composite the background with the source color, instead the
-// background will be replaced by the source color and the alpha.
-//
-// If the alpha channel is not used, the alpha parameter is ignored.
-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
-// or FPDFImageObj_GetBitmap.
-// Return value:
-// The pointer to the first byte of the bitmap buffer.
-// Comments:
-// The stride may be more than width * number of bytes per pixel
-//
-// Applications can use this function to get the bitmap buffer pointer,
-// then manipulate any color and/or alpha values for any pixels in the
-// 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
-// or FPDFImageObj_GetBitmap.
-// Return value:
-// The width of the bitmap in pixels.
-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
-// or FPDFImageObj_GetBitmap.
-// Return value:
-// The height of the bitmap in pixels.
-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
-// 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.
-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
-// or FPDFImageObj_GetBitmap.
-// Return value:
-// None.
-// Comments:
-// This function will not destroy any external buffers provided when
-// the bitmap was created.
-FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_Destroy(FPDF_BITMAP bitmap);
-
-// Function: FPDF_VIEWERREF_GetPrintScaling
-// Whether the PDF document prefers to be scaled or not.
-// Parameters:
-// document - Handle to the loaded document.
-// Return value:
-// None.
-FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
-FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document);
-
-// Function: FPDF_VIEWERREF_GetNumCopies
-// Returns the number of copies to be printed.
-// Parameters:
-// document - Handle to the loaded document.
-// Return value:
-// The number of copies to be printed.
-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.
-// Parameters:
-// document - Handle to the loaded document.
-// Return value:
-// The print page range to be used for printing.
-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.
-// Parameters:
-// document - Handle to the loaded document.
-// Return value:
-// The paper handling option to be used when printing.
-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.
-FPDF_EXPORT FPDF_DWORD FPDF_CALLCONV
-FPDF_CountNamedDests(FPDF_DOCUMENT document);
-
-// Function: FPDF_GetNamedDestByName
-// Get a the destination handle for the given name.
-// Parameters:
-// document - Handle to the loaded document.
-// name - The name of a destination.
-// Return value:
-// The handle to the destination.
-FPDF_EXPORT FPDF_DEST FPDF_CALLCONV
-FPDF_GetNamedDestByName(FPDF_DOCUMENT document, FPDF_BYTESTRING name);
-
-// Function: FPDF_GetNamedDest
-// Get the named destination by index.
-// Parameters:
-// document - Handle to a document
-// index - The index of a named destination.
-// buffer - The buffer to store the destination name,
-// used as wchar_t*.
-// buflen [in/out] - Size of the buffer in bytes on input,
-// length of the result in bytes on output
-// or -1 if the buffer is too small.
-// Return value:
-// The destination handle for a given index, or NULL if there is no
-// named destination corresponding to |index|.
-// Comments:
-// Call this function twice to get the name of the named destination:
-// 1) First time pass in |buffer| as NULL and get buflen.
-// 2) Second time pass in allocated |buffer| and buflen to retrieve
-// |buffer|, which should be used as wchar_t*.
-//
-// If buflen is not sufficiently large, it will be set to -1 upon
-// return.
-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 FPDF_BSTR.
-FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Init(FPDF_BSTR* bstr);
-
-// Function: FPDF_BStr_Set
-// 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 FPDF_BSTR.
-FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Clear(FPDF_BSTR* bstr);
-#endif // PDF_ENABLE_XFA
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // PUBLIC_FPDFVIEW_H_
diff --git a/pdfiumandroid/src/main/cpp/include/utils/Errors.h b/pdfiumandroid/src/main/cpp/include/utils/Errors.h
deleted file mode 100644
index 46173db..0000000
--- a/pdfiumandroid/src/main/cpp/include/utils/Errors.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_ERRORS_H
-#define ANDROID_ERRORS_H
-
-#include
-#include
-
-namespace android {
-
-// use this type to return error codes
-#ifdef HAVE_MS_C_RUNTIME
-typedef int status_t;
-#else
-typedef int32_t status_t;
-#endif
-
-/* the MS C runtime lacks a few error codes */
-
-/*
- * Error codes.
- * All error codes are negative values.
- */
-
-// Win32 #defines NO_ERROR as well. It has the same value, so there's no
-// real conflict, though it's a bit awkward.
-#ifdef _WIN32
-# undef NO_ERROR
-#endif
-
-enum {
- OK = 0, // Everything's swell.
- NO_ERROR = 0, // No errors.
-
- UNKNOWN_ERROR = (-2147483647-1), // INT32_MIN value
-
- NO_MEMORY = -ENOMEM,
- INVALID_OPERATION = -ENOSYS,
- BAD_VALUE = -EINVAL,
- BAD_TYPE = (UNKNOWN_ERROR + 1),
- NAME_NOT_FOUND = -ENOENT,
- PERMISSION_DENIED = -EPERM,
- NO_INIT = -ENODEV,
- ALREADY_EXISTS = -EEXIST,
- DEAD_OBJECT = -EPIPE,
- FAILED_TRANSACTION = (UNKNOWN_ERROR + 2),
- JPARKS_BROKE_IT = -EPIPE,
-#if !defined(HAVE_MS_C_RUNTIME)
- BAD_INDEX = -EOVERFLOW,
- NOT_ENOUGH_DATA = -ENODATA,
- WOULD_BLOCK = -EWOULDBLOCK,
- TIMED_OUT = -ETIMEDOUT,
- UNKNOWN_TRANSACTION = -EBADMSG,
-#else
- BAD_INDEX = -E2BIG,
- NOT_ENOUGH_DATA = (UNKNOWN_ERROR + 3),
- WOULD_BLOCK = (UNKNOWN_ERROR + 4),
- TIMED_OUT = (UNKNOWN_ERROR + 5),
- UNKNOWN_TRANSACTION = (UNKNOWN_ERROR + 6),
-#endif
- FDS_NOT_ALLOWED = (UNKNOWN_ERROR + 7),
-};
-
-// Restore define; enumeration is in "android" namespace, so the value defined
-// there won't work for Win32 code in a different namespace.
-#ifdef _WIN32
-# define NO_ERROR 0L
-#endif
-
-}; // namespace android
-
-// ---------------------------------------------------------------------------
-
-#endif // ANDROID_ERRORS_H
diff --git a/pdfiumandroid/src/main/cpp/include/utils/Mutex.h b/pdfiumandroid/src/main/cpp/include/utils/Mutex.h
deleted file mode 100644
index 4f85add..0000000
--- a/pdfiumandroid/src/main/cpp/include/utils/Mutex.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _LIBS_UTILS_MUTEX_H
-#define _LIBS_UTILS_MUTEX_H
-
-#include
-#include
-#include
-
-#if defined(HAVE_PTHREADS)
-# include
-#endif
-
-#include "Errors.h"
-
-// ---------------------------------------------------------------------------
-namespace android {
-// ---------------------------------------------------------------------------
-
-class Condition;
-
-/*
- * Simple mutex class. The implementation is system-dependent.
- *
- * The mutex must be unlocked by the thread that locked it. They are not
- * recursive, i.e. the same thread can't lock it multiple times.
- */
-class Mutex {
-public:
- enum {
- PRIVATE = 0,
- SHARED = 1
- };
-
- Mutex();
- Mutex(const char* name);
- Mutex(int type, const char* name = NULL);
- ~Mutex();
-
- // lock or unlock the mutex
- status_t lock();
- void unlock();
-
- // lock if possible; returns 0 on success, error otherwise
- status_t tryLock();
-
- // Manages the mutex automatically. It'll be locked when Autolock is
- // constructed and released when Autolock goes out of scope.
- class Autolock {
- public:
- inline Autolock(Mutex& mutex) : mLock(mutex) { mLock.lock(); }
- inline Autolock(Mutex* mutex) : mLock(*mutex) { mLock.lock(); }
- inline ~Autolock() { mLock.unlock(); }
- private:
- Mutex& mLock;
- };
-
-private:
- friend class Condition;
-
- // A mutex cannot be copied
- Mutex(const Mutex&);
- Mutex& operator = (const Mutex&);
-
-#if defined(HAVE_PTHREADS)
- pthread_mutex_t mMutex;
-#else
- void _init();
- void* mState;
-#endif
-};
-
-// ---------------------------------------------------------------------------
-
-#if defined(HAVE_PTHREADS)
-
-inline Mutex::Mutex() {
- pthread_mutex_init(&mMutex, NULL);
-}
-inline Mutex::Mutex(__attribute__((unused)) const char* name) {
- pthread_mutex_init(&mMutex, NULL);
-}
-inline Mutex::Mutex(int type, __attribute__((unused)) const char* name) {
- if (type == SHARED) {
- pthread_mutexattr_t attr;
- pthread_mutexattr_init(&attr);
- pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
- pthread_mutex_init(&mMutex, &attr);
- pthread_mutexattr_destroy(&attr);
- } else {
- pthread_mutex_init(&mMutex, NULL);
- }
-}
-inline Mutex::~Mutex() {
- pthread_mutex_destroy(&mMutex);
-}
-inline status_t Mutex::lock() {
- return -pthread_mutex_lock(&mMutex);
-}
-inline void Mutex::unlock() {
- pthread_mutex_unlock(&mMutex);
-}
-inline status_t Mutex::tryLock() {
- return -pthread_mutex_trylock(&mMutex);
-}
-
-#endif // HAVE_PTHREADS
-
-// ---------------------------------------------------------------------------
-
-/*
- * Automatic mutex. Declare one of these at the top of a function.
- * When the function returns, it will go out of scope, and release the
- * mutex.
- */
-
-typedef Mutex::Autolock AutoMutex;
-
-// ---------------------------------------------------------------------------
-}; // namespace android
-// ---------------------------------------------------------------------------
-
-#endif // _LIBS_UTILS_MUTEX_H
diff --git a/pdfiumandroid/src/main/cpp/pdfiumandroid.cpp b/pdfiumandroid/src/main/cpp/pdfiumandroid.cpp
deleted file mode 100644
index 59ec241..0000000
--- a/pdfiumandroid/src/main/cpp/pdfiumandroid.cpp
+++ /dev/null
@@ -1,3675 +0,0 @@
-#include
-#include
-
-
-extern "C" {
-#include
-#include
-#include
-#include
-#include
-}
-
-#include
-#include
-#include
-#include
-
-
-#include "include/fpdfview.h"
-#include "include/fpdf_doc.h"
-#include "include/fpdf_text.h"
-#include "include/fpdf_save.h"
-#include "include/fpdf_transformpage.h"
-#include "include/utils/Mutex.h"
-#include "util.h"
-#include "include/fpdf_edit.h"
-#include "include/fpdf_formfill.h"
-#include
-#include
-
-static std::mutex sLibraryLock;
-
-static int sLibraryReferenceCount = 0;
-
-static void initLibraryIfNeed(){
- const std::lock_guard lock(sLibraryLock);
- if(sLibraryReferenceCount == 0){
- LOGD("Init FPDF library");
- FPDF_InitLibrary();
- }
- sLibraryReferenceCount++;
- sLibraryLock.unlock();
-}
-
-static void destroyLibraryIfNeed(){
- const std::lock_guard lock(sLibraryLock);
- sLibraryReferenceCount--;
- LOGD("sLibraryReferenceCount %d", sLibraryReferenceCount);
- if(sLibraryReferenceCount == 0){
- LOGD("Destroy FPDF library");
- FPDF_DestroyLibrary();
- }
-}
-
-struct rgb {
- uint8_t red;
- uint8_t green;
- uint8_t blue;
-};
-
-JavaVM* javaVm;
-
-bool jniAttachCurrentThread(JNIEnv **env, bool *attachedOut) {
- JavaVMAttachArgs jvmArgs;
- jvmArgs.version = JNI_VERSION_1_6;
-
- bool attached = false;
- if (javaVm->GetEnv((void **) env, JNI_VERSION_1_6) == JNI_EDETACHED) {
- if (javaVm->AttachCurrentThread(env, &jvmArgs) != JNI_OK) {
- LOGE("Cannot attach current thread");
- return false;
- }
- attached = true;
- } else {
- attached = false;
- }
- *attachedOut = attached;
- return true;
-}
-
-bool jniDetachCurrentThread(bool attached) {
- if (attached && javaVm->DetachCurrentThread() != JNI_OK) {
- LOGE("Cannot detach current thread");
- return false;
- }
- return true;
-}
-
-class DocumentFile {
-
-public:
- FPDF_DOCUMENT pdfDocument = nullptr;
-
-public:
- jobject nativeSourceBridgeGlobalRef = nullptr;
- jbyte *cDataCopy = nullptr;
-
- DocumentFile() { initLibraryIfNeed(); }
- ~DocumentFile();
-};
-
-DocumentFile::~DocumentFile(){
- if(pdfDocument != nullptr){
- FPDF_CloseDocument(pdfDocument);
- pdfDocument = nullptr;
- }
- if(cDataCopy != nullptr){
- free(cDataCopy);
- cDataCopy = nullptr;
- }
- if(nativeSourceBridgeGlobalRef != nullptr){
- JNIEnv *env;
- bool attached;
- if(jniAttachCurrentThread(&env, &attached)){
- env->DeleteGlobalRef(nativeSourceBridgeGlobalRef);
- jniDetachCurrentThread(attached);
- }
- }
- destroyLibraryIfNeed();
-}
-
-template
-inline typename string_type::value_type* WriteInto(string_type* str, size_t length_with_null) {
- str->reserve(length_with_null);
- str->resize(length_with_null - 1);
- return &((*str)[0]);
-}
-
-inline long getFileSize(int fd){
- struct stat file_state{};
-
- if(fstat(fd, &file_state) >= 0){
- return (long)(file_state.st_size);
- }else{
- LOGE("Error getting file size");
- return 0;
- }
-}
-
-static char* getErrorDescription(const unsigned long error) {
- char* description = nullptr;
- switch(error) {
- case FPDF_ERR_SUCCESS:
- asprintf(&description, "No error.");
- break;
- case FPDF_ERR_FILE:
- asprintf(&description, "File not found or could not be opened.");
- break;
- case FPDF_ERR_FORMAT:
- asprintf(&description, "File not in PDF format or corrupted.");
- break;
- case FPDF_ERR_PASSWORD:
- asprintf(&description, "Incorrect password.");
- break;
- case FPDF_ERR_SECURITY:
- asprintf(&description, "Unsupported security scheme.");
- break;
- case FPDF_ERR_PAGE:
- asprintf(&description, "Page not found or content error.");
- break;
- default:
- asprintf(&description, "Unknown error.");
- }
-
- return description;
-}
-
-int jniThrowException(JNIEnv* env, const char* className, const char* message) {
- jclass exClass = env->FindClass(className);
- if (exClass == nullptr) {
- LOGE("Unable to find exception class %s", className);
- return -1;
- }
-
- if(env->ThrowNew(exClass, message ) != JNI_OK) {
- LOGE("Failed throwing '%s' '%s'", className, message);
- return -1;
- }
-
- return 0;
-}
-
-int jniThrowExceptionFmt(JNIEnv* env, const char* className, const char* fmt, ...) {
- char msgBuf[1024];
-
- va_list args;
- va_start(args, fmt);
- vsnprintf(msgBuf, sizeof(msgBuf), fmt, args);
- va_end(args);
-
- jclass exceptionClass = env->FindClass(className);
- return env->ThrowNew(exceptionClass, msgBuf);
-}
-
-
-//jobject NewLong(JNIEnv* env, jlong value) {
-// jclass cls = env->FindClass("java/lang/Long");
-// jmethodID methodID = env->GetMethodID(cls, "", "(J)V");
-// return env->NewObject(cls, methodID, value);
-//}
-//
-//jobject NewInteger(JNIEnv* env, jint value) {
-// jclass cls = env->FindClass("java/lang/Integer");
-// jmethodID methodID = env->GetMethodID(cls, "", "(I)V");
-// return env->NewObject(cls, methodID, value);
-//}
-
-uint16_t rgbTo565(rgb *color) {
- return ((color->red >> 3) << 11) | ((color->green >> 2) << 5) | (color->blue >> 3);
-}
-
-void rgbBitmapTo565(void *source, int sourceStride, void *dest, AndroidBitmapInfo *info) {
- rgb *srcLine;
- uint16_t *dstLine;
- int y, x;
- for (y = 0; y < info->height; y++) {
- srcLine = (rgb*) source;
- dstLine = (uint16_t*) dest;
- for (x = 0; x < info->width; x++) {
- dstLine[x] = rgbTo565(&srcLine[x]);
- }
- source = (char*) source + sourceStride;
- dest = (char*) dest + info->stride;
- }
-}
-
-jlong loadTextPageInternal(JNIEnv *env, DocumentFile *doc, jlong pagePtr) {
- try {
- if (doc == nullptr) throw std::runtime_error("Get page document null");
-
- auto page = reinterpret_cast(pagePtr);
- if (page != nullptr) {
- FPDF_TEXTPAGE textPage = FPDFText_LoadPage(page);
- if (textPage == nullptr) {
- throw std::runtime_error("Loaded text page is null");
- }
- return reinterpret_cast(textPage);
- } else {
- throw std::runtime_error("Load page null");
- }
- } catch (const char *msg) {
- LOGE("%s", msg);
-
- jniThrowException(env, "java/lang/IllegalStateException",
- "cannot load text page");
-
- return -1;
- }
-}
-
-jfieldID dataBuffer;
-jmethodID readMethod;
-
-extern "C"
-int getBlock(void* param, unsigned long position, unsigned char* outBuffer,
- unsigned long size) {
- const int fd = reinterpret_cast(param);
- const int readCount = pread(fd, outBuffer, size, (long) position);
- if (readCount < 0) {
- LOGE("Cannot read from file descriptor. Error:%d", errno);
- return 0;
- }
- return 1;
-}
-
-extern "C"
-int getBlockFromCustomSource(void* param, unsigned long position, unsigned char* outBuffer,
- unsigned long size) {
- JNIEnv *env = nullptr;
- bool attached;
- if (!jniAttachCurrentThread(&env, &attached)) {
- return 0;
- }
-
- auto nativeSourceBridge = reinterpret_cast(param);
- jint bytesRead = env->CallIntMethod(nativeSourceBridge, readMethod, (jlong) position, (jlong) size);
-
- if (bytesRead == 0) {
- LOGE("Cannot read from custom source");
- if (!jniDetachCurrentThread(attached)) {
- // ignore. we're going to return anyway on the next line
- }
- return 0;
- }
-
- auto buffer = (jbyteArray) env->GetObjectField(nativeSourceBridge, dataBuffer);
- env->GetByteArrayRegion(buffer, 0, bytesRead, (jbyte*) outBuffer);
-
- if (!jniDetachCurrentThread(attached)) {
- return 0;
- }
- return bytesRead;
-}
-
-extern "C"
-JNIEXPORT jlong JNICALL
-Java_io_legere_pdfiumandroid_PdfiumCore_nativeOpenDocument(JNIEnv *env, jobject, jint fd,
- jstring password) {
- auto fileLength = (size_t)getFileSize(fd);
- if(fileLength <= 0) {
- jniThrowException(env, "java/io/IOException",
- "File is empty");
- return -1;
- }
-
- auto *docFile = new DocumentFile();
-
- FPDF_FILEACCESS loader;
- loader.m_FileLen = fileLength;
- loader.m_Param = reinterpret_cast(intptr_t(fd));
- loader.m_GetBlock = &getBlock;
-
- const char *cpassword = nullptr;
- if(password != nullptr) {
- cpassword = env->GetStringUTFChars(password, nullptr);
- }
-
- FPDF_DOCUMENT document = FPDF_LoadCustomDocument(&loader, cpassword);
-
- if(cpassword != nullptr) {
- env->ReleaseStringUTFChars(password, cpassword);
- }
-
- if (!document) {
- delete docFile;
-
- const unsigned long errorNum = FPDF_GetLastError();
- if(errorNum == FPDF_ERR_PASSWORD) {
- jniThrowException(env, "io/legere/pdfiumandroid/PdfPasswordException",
- "Password required or incorrect password.");
- } else {
- char* error = getErrorDescription(errorNum);
- jniThrowExceptionFmt(env, "java/io/IOException",
- "cannot create document: %s", error);
-
- free(error);
- }
-
- return -1;
- }
-
- docFile->pdfDocument = document;
-
- return reinterpret_cast(docFile);
-}
-
-extern "C"
-JNIEXPORT jlong JNICALL
-Java_io_legere_pdfiumandroid_PdfiumCore_nativeOpenMemDocument(JNIEnv *env, jobject,
- jbyteArray data, jstring password) {
- auto *docFile = new DocumentFile();
-
- const char *cpassword = nullptr;
- if(password != nullptr) {
- cpassword = env->GetStringUTFChars(password, nullptr);
- }
-
- int size = (int) env->GetArrayLength(data);
- auto *cDataCopy = new jbyte[size];
- env->GetByteArrayRegion(data, 0, size, cDataCopy);
- FPDF_DOCUMENT document = FPDF_LoadMemDocument( reinterpret_cast(cDataCopy),
- size, cpassword);
-
- if(cpassword != nullptr) {
- env->ReleaseStringUTFChars(password, cpassword);
- }
-
- if (!document) {
- delete docFile;
-
- const unsigned long errorNum = FPDF_GetLastError();
- if(errorNum == FPDF_ERR_PASSWORD) {
- jniThrowException(env, "io/legere/pdfiumandroid/PdfPasswordException",
- "Password required or incorrect password.");
- } else {
- char* error = getErrorDescription(errorNum);
- jniThrowExceptionFmt(env, "java/io/IOException",
- "cannot create document: %s", error);
-
- free(error);
- }
-
- return -1;
- }
-
- docFile->pdfDocument = document;
- docFile->cDataCopy = cDataCopy;
- return reinterpret_cast(docFile);
-}
-
-
-extern "C"
-JNIEXPORT jlong JNICALL
-Java_io_legere_pdfiumandroid_PdfiumCore_nativeOpenCustomDocument(JNIEnv *env, jobject, jobject nativeSourceBridge, jstring password, jlong dataLength) {
- if(dataLength <= 0) {
- jniThrowException(env, "java/io/IOException",
- "File is empty");
- return -1;
- }
-
- auto *docFile = new DocumentFile();
- docFile->nativeSourceBridgeGlobalRef = env->NewGlobalRef(nativeSourceBridge);
-
- FPDF_FILEACCESS loader;
- loader.m_FileLen = dataLength;
- loader.m_Param = reinterpret_cast(docFile->nativeSourceBridgeGlobalRef);
- loader.m_GetBlock = &getBlockFromCustomSource;
-
- const char *cpassword = nullptr;
- if(password != nullptr) {
- cpassword = env->GetStringUTFChars(password, nullptr);
- }
-
- FPDF_DOCUMENT document = FPDF_LoadCustomDocument(&loader, cpassword);
-
- if(cpassword != nullptr) {
- env->ReleaseStringUTFChars(password, cpassword);
- }
-
- if (!document) {
- delete docFile;
-
- const unsigned long errorNum = FPDF_GetLastError();
- if(errorNum == FPDF_ERR_PASSWORD) {
- jniThrowException(env, "io/legere/pdfiumandroid/PdfPasswordException",
- "Password required or incorrect password.");
- } else {
- char* error = getErrorDescription(errorNum);
- jniThrowExceptionFmt(env, "java/io/IOException",
- "cannot create document: %s", error);
-
- free(error);
- }
-
- return -1;
- }
-
- docFile->pdfDocument = document;
-
- return reinterpret_cast(docFile);
-}
-
-static jlong loadPageInternal(JNIEnv *env, DocumentFile *doc, int pageIndex){
- try{
- if(doc == nullptr) throw std::runtime_error( "Get page document null");
-
- FPDF_DOCUMENT pdfDoc = doc->pdfDocument;
- if(pdfDoc != nullptr){
- FPDF_PAGE page = FPDF_LoadPage(pdfDoc, pageIndex);
- if (page == nullptr) {
- throw std::runtime_error("Loaded page is null");
- }
- return reinterpret_cast(page);
- }else{
- throw std::runtime_error("Get page pdf document null");
- }
-
- }catch(const char *msg){
- LOGE("%s", msg);
-
- jniThrowException(env, "java/lang/IllegalStateException",
- "cannot load page");
-
- return -1;
- }
-}
-
-static void closePageInternal(jlong pagePtr) {
- FPDF_ClosePage(reinterpret_cast(pagePtr));
-}
-
-static void renderPageInternal( FPDF_PAGE page,
- ANativeWindow_Buffer *windowBuffer,
- int startX, int startY,
- int canvasHorSize, int canvasVerSize,
- int drawSizeHor, int drawSizeVer,
- bool renderAnnot, FPDF_DWORD canvasColor, FPDF_DWORD pageBackgroundColor){
-
- FPDF_BITMAP pdfBitmap = FPDFBitmap_CreateEx( canvasHorSize, canvasVerSize,
- FPDFBitmap_BGRA,
- windowBuffer->bits, (int)(windowBuffer->stride) * 4);
-
- if ((drawSizeHor < canvasHorSize || drawSizeVer < canvasVerSize) && canvasColor != 0){
- FPDFBitmap_FillRect( pdfBitmap, 0, 0, canvasHorSize, canvasVerSize,
- canvasColor); //Gray
- }
-
- int baseHorSize = (canvasHorSize < drawSizeHor)? canvasHorSize : drawSizeHor;
- int baseVerSize = (canvasVerSize < drawSizeVer)? canvasVerSize : drawSizeVer;
- int baseX = (startX < 0)? 0 : startX;
- int baseY = (startY < 0)? 0 : startY;
- int flags = FPDF_REVERSE_BYTE_ORDER;
- if (startX + baseHorSize > drawSizeHor) {
- baseHorSize = drawSizeHor - startX;
- }
- if (startY + baseVerSize > drawSizeVer) {
- baseVerSize = drawSizeVer - startY;
- }
- if (startX + drawSizeHor > canvasHorSize) {
- drawSizeHor = canvasHorSize - startX;
- }
- if (startY + drawSizeVer > canvasVerSize) {
- drawSizeVer = canvasVerSize - startY;
- }
-
- if(renderAnnot) {
- flags |= FPDF_ANNOT;
- }
-
- if (pageBackgroundColor != 0) {
- FPDFBitmap_FillRect(pdfBitmap, baseX, baseY, baseHorSize, baseVerSize,
- pageBackgroundColor);
- }
-
- FPDF_RenderPageBitmap( pdfBitmap, page,
- startX, startY,
- drawSizeHor, drawSizeVer,
- 0, flags );
-}
-
-extern "C"
-JNIEXPORT jfloatArray JNICALL
-Java_io_legere_pdfiumandroid_PdfiumCore_nativeGetLinkRect(JNIEnv *env, jobject,
- jlong link_ptr) {
- try {
- auto link = reinterpret_cast(link_ptr);
- FS_RECTF fsRectF;
- FPDF_BOOL retVal = FPDFLink_GetAnnotRect(link, &fsRectF);
-
- jfloatArray result = env->NewFloatArray(4);
- if (result == nullptr) {
- return nullptr;
- }
- jfloat array[4];
- array[0] = fsRectF.left;
- array[1] = fsRectF.top;
- array[2] = fsRectF.right;
- array[3] = fsRectF.bottom;
-
- env->SetFloatArrayRegion(result, 0, 4, array);
- return result;
- } catch (const char *msg) {
- LOGE("%s", msg);
-
- jniThrowException(env, "java/lang/IllegalStateException",
- "cannot get link rect");
-
- return nullptr;
- }
-}
-
-class FileWrite : public FPDF_FILEWRITE {
-public:
- jobject callbackObject;
- jmethodID callbackMethodID;
- _JNIEnv *env;
-
- static int WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, const void* data, unsigned long size) {
- auto* pThis = reinterpret_cast(pFileWrite);
- _JNIEnv *env = pThis->env;
- //Convert the native array to Java array.
- jbyteArray a = env->NewByteArray((int) size);
- if (a != nullptr) {
- env->SetByteArrayRegion(a, 0, (int) size, (const jbyte *)data);
- return env->CallIntMethod(pThis->callbackObject, pThis->callbackMethodID, a);
- }
- return -1;
- }
-};
-
-void raise_java_oom_exception(JNIEnv *pEnv, std::bad_alloc &alloc);
-
-void raise_java_runtime_exception(JNIEnv *pEnv, std::runtime_error &error);
-
-void raise_java_invalid_arg_exception(JNIEnv *pEnv, std::invalid_argument &argument);
-
-void raise_java_exception(JNIEnv *pEnv, std::exception &exception);
-
-void handleUnexpected(JNIEnv *pEnv, char const *name);
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeGetPageCount(JNIEnv *env, jobject,
- jlong doc_ptr) {
- try {
- auto *doc = reinterpret_cast(doc_ptr);
- return (jint)FPDF_GetPageCount(doc->pdfDocument);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-extern "C"
-JNIEXPORT jlong JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeLoadPage(JNIEnv *env, jobject, jlong doc_ptr,
- jint page_index) {
- try {
- auto *doc = reinterpret_cast(doc_ptr);
- return loadPageInternal(env, doc, (int) page_index);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT void JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeClosePage(JNIEnv *env, jclass , jlong page_ptr) {
- try {
- closePageInternal(page_ptr);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
-}
-
-extern "C"
-JNIEXPORT void JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeDeletePage(JNIEnv *env, jobject, jlong doc_ptr,
- jint page_index) {
- try {
- auto *doc = reinterpret_cast(doc_ptr);
- if(doc == nullptr) throw std::runtime_error( "Get page document null");
-
- FPDF_DOCUMENT pdfDoc = doc->pdfDocument;
- if(pdfDoc != nullptr) {
- FPDFPage_Delete(pdfDoc, (int) page_index);
- }
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
-}
-
-extern "C"
-JNIEXPORT void JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeCloseDocument(JNIEnv *env, jobject,
- jlong doc_ptr) {
- try {
- auto *doc = reinterpret_cast(doc_ptr);
- // The destructor will close the document
- delete doc;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
-
-}
-
-extern "C"
-JNIEXPORT jlongArray JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeLoadPages(JNIEnv *env, jobject, jlong doc_ptr,
- jint from_index, jint to_index) {
- try {
- auto *doc = reinterpret_cast(doc_ptr);
-
- if(to_index < from_index) return nullptr;
- jlong pages[ to_index - from_index + 1 ];
-
- int i;
- for(i = 0; i <= (to_index - from_index); i++){
- pages[i] = loadPageInternal(env, doc, (int)(i + from_index));
- }
-
- jlongArray javaPages = env -> NewLongArray( (jsize)(to_index - from_index + 1) );
- env -> SetLongArrayRegion(javaPages, 0, (jsize)(to_index - from_index + 1), (const jlong*)pages);
-
- return javaPages;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-
-}
-
-extern "C"
-JNIEXPORT jstring JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeGetDocumentMetaText(JNIEnv *env, jobject,
- jlong doc_ptr, jstring tag) {
- try {
- const char *ctag = env->GetStringUTFChars(tag, nullptr);
- if (ctag == nullptr) {
- return env->NewStringUTF("");
- }
- auto *doc = reinterpret_cast(doc_ptr);
-
- int bufferLen = (int) FPDF_GetMetaText(doc->pdfDocument, ctag, nullptr, 0);
- if (bufferLen <= 2) {
- return env->NewStringUTF("");
- }
- std::wstring text;
- FPDF_GetMetaText(doc->pdfDocument, ctag, WriteInto(&text, bufferLen + 1), bufferLen);
- env->ReleaseStringUTFChars(tag, ctag);
- return env->NewString((jchar*) text.c_str(), bufferLen / 2 - 1);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jlong JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeGetFirstChildBookmark(JNIEnv *env, jobject,
- jlong doc_ptr,
- jlong bookmark_ptr) {
- try {
- auto *doc = reinterpret_cast(doc_ptr);
- FPDF_BOOKMARK parent;
- if(bookmark_ptr == 0) {
- parent = nullptr;
- } else {
- parent = reinterpret_cast(bookmark_ptr);
- }
- FPDF_BOOKMARK bookmark = FPDFBookmark_GetFirstChild(doc->pdfDocument, parent);
- if (bookmark == nullptr) {
- return 0;
- }
- return reinterpret_cast(bookmark);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return 0;
-}
-
-extern "C"
-JNIEXPORT jlong JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeGetSiblingBookmark(JNIEnv *env, jobject,
- jlong doc_ptr,
- jlong bookmark_ptr) {
- try {
- auto *doc = reinterpret_cast(doc_ptr);
- auto parent = reinterpret_cast(bookmark_ptr);
- FPDF_BOOKMARK bookmark = FPDFBookmark_GetNextSibling(doc->pdfDocument, parent);
- if (bookmark == nullptr) {
- return 0;
- }
- return reinterpret_cast(bookmark);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return 0;
-}
-
-extern "C"
-JNIEXPORT jlong JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeLoadTextPage(JNIEnv *env, jobject,
- jlong doc_ptr, jlong page_ptr) {
- try {
- auto *doc = reinterpret_cast(doc_ptr);
- return loadTextPageInternal(env, doc, page_ptr);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT jstring JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeGetBookmarkTitle(JNIEnv *env, jobject,
- jlong bookmark_ptr) {
- try {
- auto bookmark = reinterpret_cast(bookmark_ptr);
- int bufferLen = (int) FPDFBookmark_GetTitle(bookmark, nullptr, 0);
- if (bufferLen <= 2) {
- return env->NewStringUTF("");
- }
- std::wstring title;
- FPDFBookmark_GetTitle(bookmark, WriteInto(&title, bufferLen + 1), bufferLen);
- return env->NewString((jchar*) title.c_str(), bufferLen / 2 - 1);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeGetDestPageIndex(JNIEnv *env, jobject,
- jlong doc_ptr, jlong link_ptr) {
- try {
- auto *doc = reinterpret_cast(doc_ptr);
- auto link = reinterpret_cast(link_ptr);
- FPDF_DEST dest = FPDFLink_GetDest(doc->pdfDocument, link);
- if (dest == nullptr) {
- return -1;
- }
- unsigned long index = FPDFDest_GetDestPageIndex(doc->pdfDocument, dest);
- return (jint) index;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT jboolean JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeSaveAsCopy(JNIEnv *env, jobject, jlong doc_ptr,
- jobject callback, jint flags) {
- try {
- jclass callbackClass = env->FindClass("io/legere/pdfiumandroid/PdfWriteCallback");
- if (callback != nullptr && env->IsInstanceOf(callback, callbackClass)) {
- //Setup the callback to Java.
- FileWrite fw = FileWrite();
- fw.version = 1;
- fw.FPDF_FILEWRITE::WriteBlock = FileWrite::WriteBlockCallback;
- fw.callbackObject = callback;
- fw.callbackMethodID = env->GetMethodID(callbackClass, "WriteBlock", "([B)I");
- fw.env = env;
-
- auto *doc = reinterpret_cast(doc_ptr);
- return (jboolean) FPDF_SaveAsCopy(doc->pdfDocument, &fw, flags);
- }
- return false;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return false;
-}
-
-extern "C"
-JNIEXPORT void JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeClosePages(JNIEnv *env, jclass ,
- jlongArray pages_ptr) {
- try {
- int length = (int) (env->GetArrayLength(pages_ptr));
- jlong *pages = env->GetLongArrayElements(pages_ptr, nullptr);
-
- int i;
- for (i = 0; i < length; i++) { closePageInternal(pages[i]); }
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageWidthPixel(JNIEnv *env, jclass,
- jlong page_ptr, jint dpi) {
- try {
- auto page = reinterpret_cast(page_ptr);
- return (jint) (FPDF_GetPageWidth(page) * dpi / 72);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageHeightPixel(JNIEnv *env, jclass,
- jlong page_ptr, jint dpi) {
- try {
- auto page = reinterpret_cast(page_ptr);
- return (jint)(FPDF_GetPageHeight(page) * dpi / 72);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch(std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageWidthPoint(JNIEnv *env, jclass,
- jlong page_ptr) {
- try {
- auto page = reinterpret_cast(page_ptr);
- return (jint)FPDF_GetPageWidth(page);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch(std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageHeightPoint(JNIEnv *env, jclass,
- jlong page_ptr) {
- try {
- auto page = reinterpret_cast(page_ptr);
- return (jint)FPDF_GetPageHeight(page);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch(std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT jdouble JNICALL
-Java_io_legere_pdfiumandroid_PdfTextPage_nativeGetFontSize(JNIEnv *env, jclass, jlong page_ptr,
- jint char_index) {
- try {
- auto textPage = reinterpret_cast(page_ptr);
- return (jdouble) FPDFText_GetFontSize(textPage, char_index);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch(std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return 0;
-}
-
-extern "C"
-JNIEXPORT jfloatArray JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageMediaBox(JNIEnv *env, jclass ,
- jlong page_ptr) {
- try {
- auto page = reinterpret_cast(page_ptr);
- jfloatArray result = env->NewFloatArray(4);
- if (result == nullptr) {
- return nullptr;
- }
-
- float rect[4];
- if (!FPDFPage_GetMediaBox(page, &rect[0], &rect[1], &rect[2], &rect[3])) {
- rect[0] = -1.0f;
- rect[1] = -1.0f;
- rect[2] = -1.0f;
- rect[3] = -1.0f;
- }
-
- env->SetFloatArrayRegion(result, 0, 4, (jfloat *) rect);
- return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch(std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jfloatArray JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageCropBox(JNIEnv *env, jclass,
- jlong page_ptr) {
- try {
- auto page = reinterpret_cast(page_ptr);
- jfloatArray result = env->NewFloatArray(4);
- if (result == nullptr) {
- return nullptr;
- }
-
- float rect[4];
- if (!FPDFPage_GetCropBox(page, &rect[0], &rect[1], &rect[2], &rect[3])) {
- rect[0] = -1.0f;
- rect[1] = -1.0f;
- rect[2] = -1.0f;
- rect[3] = -1.0f;
- }
-
- env->SetFloatArrayRegion(result, 0, 4, (jfloat *) rect);
- return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch(std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jfloatArray JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageBleedBox(JNIEnv *env, jclass,
- jlong page_ptr) {
- try {
- auto page = reinterpret_cast(page_ptr);
- jfloatArray result = env->NewFloatArray(4);
- if (result == nullptr) {
- return nullptr;
- }
-
- float rect[4];
- if (!FPDFPage_GetBleedBox(page, &rect[0], &rect[1], &rect[2], &rect[3])) {
- rect[0] = -1.0f;
- rect[1] = -1.0f;
- rect[2] = -1.0f;
- rect[3] = -1.0f;
- }
-
- env->SetFloatArrayRegion(result, 0, 4, (jfloat *) rect);
- return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch(std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jfloatArray JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageTrimBox(JNIEnv *env, jclass,
- jlong page_ptr) {
- try {
- auto page = reinterpret_cast(page_ptr);
- jfloatArray result = env->NewFloatArray(4);
- if (result == nullptr) {
- return nullptr;
- }
-
- float rect[4];
- if (!FPDFPage_GetTrimBox(page, &rect[0], &rect[1], &rect[2], &rect[3])) {
- rect[0] = -1.0f;
- rect[1] = -1.0f;
- rect[2] = -1.0f;
- rect[3] = -1.0f;
- }
-
- env->SetFloatArrayRegion(result, 0, 4, (jfloat*)rect);
- return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch(std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jfloatArray JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageArtBox(JNIEnv *env, jclass,
- jlong page_ptr) {
- try {
- auto page = reinterpret_cast(page_ptr);
- jfloatArray result = env->NewFloatArray(4);
- if (result == nullptr) {
- return nullptr;
- }
-
- float rect[4];
- if (!FPDFPage_GetArtBox(page, &rect[0], &rect[1], &rect[2], &rect[3])) {
- rect[0] = -1.0f;
- rect[1] = -1.0f;
- rect[2] = -1.0f;
- rect[3] = -1.0f;
- }
-
- env->SetFloatArrayRegion(result, 0, 4, (jfloat*)rect);
- return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch(std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jfloatArray JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageBoundingBox(JNIEnv *env, jclass,
- jlong page_ptr) {
- try {
- auto page = reinterpret_cast(page_ptr);
- jfloatArray result = env->NewFloatArray(4);
- if (result == nullptr) {
- return nullptr;
- }
-
- float rect[4];
- FS_RECTF fsRect;
- if (!FPDF_GetPageBoundingBox(page, &fsRect)) {
- rect[0] = -1.0f;
- rect[1] = -1.0f;
- rect[2] = -1.0f;
- rect[3] = -1.0f;
- } else {
- rect[0] = fsRect.left;
- rect[1] = fsRect.top;
- rect[2] = fsRect.right;
- rect[3] = fsRect.bottom;
- }
-
- env->SetFloatArrayRegion(result, 0, 4, (jfloat*)rect);
- return result;
-
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jfloatArray JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageMatrix(JNIEnv *env, jclass,
- jlong page_ptr) {
- try {
- auto page = reinterpret_cast(page_ptr);
- jfloatArray result = env->NewFloatArray(6);
- if (result == nullptr) {
- return nullptr;
- }
-// auto count = FPDFPage_CountObjects(page);
-// int index;
-// for (index = 0; index < count; index++) {
-// FPDF_PAGEOBJECT pageObject = FPDFPage_GetObject(page, index);
-// auto objectType = FPDFPageObj_GetType(pageObject);
-//// LOGD("objectType: %d, index: %d", objectType, index);
-// float matrix[6];
-// FS_MATRIX fsMatrix;
-// FPDFPageObj_GetMatrix(pageObject, &fsMatrix);
-//// LOGD("fsMatrix.a: %f", fsMatrix.a);
-//// LOGD("fsMatrix.b: %f", fsMatrix.b);
-//// LOGD("fsMatrix.c: %f", fsMatrix.c);
-//// LOGD("fsMatrix.d: %f", fsMatrix.d);
-//// LOGD("fsMatrix.e: %f", fsMatrix.e);
-//// LOGD("fsMatrix.f: %f", fsMatrix.f);
-// }
- FPDF_PAGEOBJECT pageObject = FPDFPage_GetObject(page, 0);
-
- float matrix[6];
- FS_MATRIX fsMatrix;
- if (!FPDFPageObj_GetMatrix(pageObject, &fsMatrix)) {
- matrix[0] = -1.0f;
- matrix[1] = -1.0f;
- matrix[2] = -1.0f;
- matrix[3] = -1.0f;
- matrix[4] = -1.0f;
- matrix[5] = -1.0f;
- } else {
- matrix[0] = fsMatrix.a;
- matrix[1] = fsMatrix.b;
- matrix[2] = fsMatrix.c;
- matrix[3] = fsMatrix.d;
- matrix[4] = fsMatrix.e;
- matrix[5] = fsMatrix.f;
- }
-
- free(pageObject);
-
- env->SetFloatArrayRegion(result, 0, 6, (jfloat*)matrix);
- return result;
-
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jfloatArray JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageObjectsInformation(JNIEnv *env, jclass, jlong page_ptr) {
- try {
- auto page = reinterpret_cast(page_ptr);
- if (page == nullptr) return nullptr;
-
- int count = FPDFPage_CountObjects(page);
- if (count <= 0) return nullptr;
-
- // 5 floats per object: type, left, top, right, bottom
- std::vector data;
- data.reserve(count * 5);
-
- for (int i = 0; i < count; i++) {
- FPDF_PAGEOBJECT pageObject = FPDFPage_GetObject(page, i);
- if (pageObject == nullptr) continue;
-
- int type = FPDFPageObj_GetType(pageObject);
- float left, bottom, right, top;
-
- // FPDFPageObj_GetBounds fills: left, bottom, right, top
- if (FPDFPageObj_GetBounds(pageObject, &left, &bottom, &right, &top)) {
- data.push_back((float)type);
- data.push_back(left);
- data.push_back(top); // Store as 'top' for RectF constructor
- data.push_back(right);
- data.push_back(bottom); // Store as 'bottom' for RectF constructor
- }
- }
-
- if (data.empty()) return nullptr;
-
- jfloatArray result = env->NewFloatArray((jsize)data.size());
- if (result == nullptr) return nullptr;
-
- env->SetFloatArrayRegion(result, 0, (jsize)data.size(), data.data());
- return result;
-
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (...) {
- return nullptr;
- }
-}
-
-extern "C"
-JNIEXPORT jboolean JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeLockSurface(JNIEnv *env, jclass clazz, jobject surface, jintArray widthHeightArray, jlongArray ptrsArray) {
- LOGD("nativeLockSurface");
- ANativeWindow *nativeWindow = ANativeWindow_fromSurface(env, surface);
- if (nativeWindow == nullptr) {
- LOGE("native window pointer null");
- return false;
- }
- auto widthHeightValues = env->GetIntArrayElements(widthHeightArray, nullptr);
- if (widthHeightValues == nullptr) {
- // Handle error
- LOGE("widthHeightValues is null");
- return false;
- }
- auto ptrValues = env->GetLongArrayElements(ptrsArray, nullptr);
- if (ptrValues == nullptr) {
- // Handle error
- LOGE("ptrValues is null");
- return static_cast(0);
- }
-
- auto width = ANativeWindow_getWidth(nativeWindow);
- auto height = ANativeWindow_getHeight(nativeWindow);
-
- widthHeightValues[0] = width; // Modify the integer value
- widthHeightValues[1] = height;
-
- if (ANativeWindow_getFormat(nativeWindow) != WINDOW_FORMAT_RGBA_8888) {
- LOGD("Set format to RGBA_8888");
- ANativeWindow_setBuffersGeometry(nativeWindow,
- width,
- height,
- WINDOW_FORMAT_RGBA_8888);
- }
- env->ReleaseIntArrayElements(widthHeightArray, widthHeightValues, JNI_OK);
-
- auto *buffer = new ANativeWindow_Buffer();
- int ret;
- if ((ret = ANativeWindow_lock(nativeWindow, buffer, nullptr)) != 0) {
- LOGE("Locking native window failed: %s", strerror(ret * -1));
- return false;
- }
- ptrValues[0] = reinterpret_cast(nativeWindow);
- ptrValues[1] = reinterpret_cast(buffer);
- env->ReleaseLongArrayElements(ptrsArray, ptrValues, JNI_OK);
- return true;
-}
-extern "C"
-JNIEXPORT void JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeUnlockSurface(JNIEnv *env, jclass clazz,
- jlongArray ptrsArray) {
- LOGD("nativeUnlockSurface");
- jboolean isCopyPtrs;
- auto ptrValues = env->GetLongArrayElements(ptrsArray, &isCopyPtrs);
- if (ptrValues == nullptr) {
- // Handle error
- return;
- }
- auto nativeWindow = reinterpret_cast(ptrValues[0]);
-
- auto buffer = reinterpret_cast(ptrValues[1]);
-
- delete buffer;
-
-
-
- ANativeWindow_unlockAndPost(nativeWindow);
- ANativeWindow_release(nativeWindow);
- if (isCopyPtrs) {
- env->ReleaseLongArrayElements(ptrsArray, ptrValues, JNI_ABORT);
- }
-
-}
-
-extern "C"
-JNIEXPORT jboolean JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeRenderPage(JNIEnv *env, jclass, jlong page_ptr,
- jlong buffer_ptr, jint start_x,
- jint start_y, jint draw_size_hor,
- jint draw_size_ver, jboolean render_annot,
- jint canvasColor, jint pageBackgroundColor) {
- try {
- auto page = reinterpret_cast(page_ptr);
-
- if (page == nullptr) {
- LOGE("Render page pointers invalid");
- return false;
- }
-
- auto buffer = reinterpret_cast(buffer_ptr);
-
- renderPageInternal(page, buffer,
- (int) start_x, (int) start_y,
- buffer->width, buffer->height,
- (int) draw_size_hor, (int) draw_size_ver,
- (bool) render_annot, canvasColor, pageBackgroundColor);
- return true;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return false;
-}
-
-extern "C"
-JNIEXPORT jboolean JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeRenderPageWithMatrix(JNIEnv *env, jclass,
- jlong page_ptr, jlong buffer_ptr,
- jint draw_size_hor, jint draw_size_ver,
- jfloatArray matrixValues,
- jfloatArray clipRect,
- jboolean render_annot,
- jboolean,
- jint canvasColor, jint pageBackgroundColor) {
- try {
- auto page = reinterpret_cast(page_ptr);
-
- if (page == nullptr) {
- LOGE("Render page pointers invalid");
- return false;
- }
-
- auto bufferPtr = reinterpret_cast(buffer_ptr);
- auto buffer = *bufferPtr;
-
-
- jboolean isCopyClipRect;
- auto clipRectFloats = env->GetFloatArrayElements(clipRect, &isCopyClipRect);
- auto leftClip = clipRectFloats[0];
- auto topClip = clipRectFloats[1];
- auto rightClip = clipRectFloats[2];
- auto bottomClip = clipRectFloats[3];
-
- auto canvasHorSize = draw_size_hor;
- auto canvasVerSize = draw_size_ver;
-
- auto drawSizeHor = (int) (rightClip - leftClip);
- auto drawSizeVer = (int) (bottomClip - topClip);
-
- FPDF_BITMAP pdfBitmap = FPDFBitmap_CreateEx(canvasHorSize, canvasVerSize,
- FPDFBitmap_BGRA,
- buffer.bits, (int)(buffer.stride) * 4);
-
- if((drawSizeHor < canvasHorSize || drawSizeVer < canvasVerSize) && canvasColor != 0) {
- FPDFBitmap_FillRect( pdfBitmap, 0, 0, canvasHorSize, canvasVerSize,
- canvasColor); //Gray
- }
-
- auto startX = (int) leftClip;
- auto startY = (int) topClip;
- int baseHorSize = (canvasHorSize < drawSizeHor)? canvasHorSize : drawSizeHor;
- int baseVerSize = (canvasVerSize < drawSizeVer)? canvasVerSize : drawSizeVer;
- int baseX = (startX < 0)? 0 : startX;
- int baseY = (startY < 0)? 0 : startY;
- if (startX + baseHorSize > canvasHorSize) {
- baseHorSize = canvasHorSize - startX;
- }
- if (startY + baseVerSize > canvasVerSize) {
- baseVerSize = canvasVerSize - startY;
- }
-
- int flags = FPDF_REVERSE_BYTE_ORDER;
-
- if (render_annot) {
- flags |= FPDF_ANNOT;
- }
-
-
-
- if (pageBackgroundColor != 0) {
- FPDFBitmap_FillRect(pdfBitmap, baseX, baseY, baseHorSize, baseVerSize,
- pageBackgroundColor); //White
- }
-
- jboolean isCopy;
- auto matrixFloats = env->GetFloatArrayElements(matrixValues, &isCopy);
-
- auto matrix = FS_MATRIX();
- matrix.a = matrixFloats[0];
- matrix.b = 0;
- matrix.c = 0;
- matrix.d = matrixFloats[1];
- matrix.e = matrixFloats[2];
- matrix.f = matrixFloats[3];
- auto clip = FS_RECTF();
- clip.left = leftClip;
- clip.top = topClip;
- clip.right = rightClip;
- clip.bottom = bottomClip;
-
- FPDF_RenderPageBitmapWithMatrix(pdfBitmap, page, &matrix, &clip, flags);
-
-
- if (isCopyClipRect) {
- env->ReleaseFloatArrayElements(clipRect, (jfloat *) clipRectFloats, JNI_ABORT);
- }
- if (isCopy) {
- env->ReleaseFloatArrayElements(matrixValues, (jfloat *) matrixFloats, JNI_ABORT);
- }
- return true;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return false;
-}
-
-extern "C"
-JNIEXPORT jboolean JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeRenderPageSurface(JNIEnv *env, jclass, jlong page_ptr,
- jobject surface, jint start_x,
- jint start_y, jboolean render_annot,
- jint canvasColor, jint pageBackgroundColor) {
- try {
- auto page = reinterpret_cast(page_ptr);
-
- if (page == nullptr) {
- LOGE("Render page pointers invalid");
- return false;
- }
- ANativeWindow *nativeWindow = ANativeWindow_fromSurface(env, surface);
- if (nativeWindow == nullptr) {
- LOGE("native window pointer null");
- return false;
- }
- auto width = ANativeWindow_getWidth(nativeWindow);
- auto height = ANativeWindow_getHeight(nativeWindow);
-
- if (ANativeWindow_getFormat(nativeWindow) != WINDOW_FORMAT_RGBA_8888) {
- LOGD("Set format to RGBA_8888");
- ANativeWindow_setBuffersGeometry(nativeWindow,
- width,
- height,
- WINDOW_FORMAT_RGBA_8888);
- }
-
- auto *buffer = new ANativeWindow_Buffer();
- int ret;
- if ((ret = ANativeWindow_lock(nativeWindow, buffer, nullptr)) != 0) {
- LOGE("Locking native window failed: %s", strerror(ret * -1));
- return false;
- }
-
- renderPageInternal(page, buffer,
- (int) start_x, (int) start_y,
- width, height,
- (int) width, (int) height,
- (bool) render_annot, canvasColor, pageBackgroundColor);
- ANativeWindow_unlockAndPost(nativeWindow);
- ANativeWindow_release(nativeWindow);
-
- return true;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return false;
-}
-
-extern "C"
-JNIEXPORT jboolean JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeRenderPageSurfaceWithMatrix(JNIEnv *env, jclass,
- jlong page_ptr, jobject surface,
- jfloatArray matrixValues,
- jfloatArray clipRect,
- jboolean render_annot,
- jboolean,
- jint canvasColor, jint pageBackgroundColor) {
- try {
- auto page = reinterpret_cast(page_ptr);
-
- if (page == nullptr) {
- LOGE("Render page pointers invalid");
- return false;
- }
-
- ANativeWindow *nativeWindow = ANativeWindow_fromSurface(env, surface);
- if (nativeWindow == nullptr) {
- LOGE("native window pointer null");
- return false;
- }
- auto width = ANativeWindow_getWidth(nativeWindow);
- auto height = ANativeWindow_getHeight(nativeWindow);
-
- if (ANativeWindow_getFormat(nativeWindow) != WINDOW_FORMAT_RGBA_8888) {
- LOGD("Set format to RGBA_8888");
- ANativeWindow_setBuffersGeometry(nativeWindow,
- width,
- height,
- WINDOW_FORMAT_RGBA_8888);
- }
-
- auto *buffer = new ANativeWindow_Buffer();
- int ret;
- if ((ret = ANativeWindow_lock(nativeWindow, buffer, nullptr)) != 0) {
- LOGE("Locking native window failed: %s", strerror(ret * -1));
- return false;
- }
-
-
- auto clipRectFloats = env->GetFloatArrayElements(clipRect, nullptr);
- auto leftClip = clipRectFloats[0];
- auto topClip = clipRectFloats[1];
- auto rightClip = clipRectFloats[2];
- auto bottomClip = clipRectFloats[3];
-
- auto drawSizeHor = (int) (rightClip - leftClip);
- auto drawSizeVer = (int) (bottomClip - topClip);
- auto startX = (int) leftClip;
- auto startY = (int) topClip;
-
- int baseHorSize = (width < drawSizeHor)? width : drawSizeHor;
- int baseVerSize = (height < drawSizeVer)? height : drawSizeVer;
- int baseX = (startX < 0)? 0 : startX;
- int baseY = (startY < 0)? 0 : startY;
- if (startX + baseHorSize > width) {
- baseHorSize = width - startX;
- }
- if (startY + baseVerSize > height) {
- baseVerSize = height - startY;
- }
-
- if (leftClip < 0) {
- leftClip = 0;
- }
- if (topClip < 0) {
- topClip = 0;
- }
- auto fWidth = (float) width;
- auto fHeight = (float) height;
-
- if (rightClip > fWidth) {
- rightClip = fWidth;
- baseHorSize = width - startX;
- }
- if (bottomClip > fHeight) {
- bottomClip = fHeight;
- baseVerSize = height - startY;
- }
-
- FPDF_BITMAP pdfBitmap = FPDFBitmap_CreateEx(width, height,
- FPDFBitmap_BGRA,
- buffer->bits, (int)(buffer->stride) * 4);
-
- if((drawSizeHor < width || drawSizeVer < height) && canvasColor != 0) {
- FPDFBitmap_FillRect( pdfBitmap, 0, 0, width, height,
- canvasColor); //Gray
- }
-
- int flags = FPDF_REVERSE_BYTE_ORDER;
-
- if (render_annot) {
- flags |= FPDF_ANNOT;
- }
-
- if (pageBackgroundColor != 0) {
- FPDFBitmap_FillRect(pdfBitmap, baseX, baseY, baseHorSize, baseVerSize,
- pageBackgroundColor); //White
- }
-
- auto matrixFloats = env->GetFloatArrayElements(matrixValues, nullptr);
-
- auto matrix = FS_MATRIX();
- matrix.a = matrixFloats[0];
- matrix.b = 0;
- matrix.c = 0;
- matrix.d = matrixFloats[1];
- matrix.e = matrixFloats[2];
- matrix.f = matrixFloats[3];
- auto clip = FS_RECTF();
- clip.left = leftClip;
- clip.top = topClip;
- clip.right = rightClip;
- clip.bottom = bottomClip;
-
- LOGD("FPDF_RenderPageBitmapWithMatrix");
- FPDF_RenderPageBitmapWithMatrix(pdfBitmap, page, &matrix, &clip, flags);
-
- LOGD("ANativeWindow_unlockAndPost");
- ANativeWindow_unlockAndPost(nativeWindow);
- ANativeWindow_release(nativeWindow);
-
- env->ReleaseFloatArrayElements(clipRect, (jfloat *) clipRectFloats, 0);
- env->ReleaseFloatArrayElements(matrixValues, (jfloat *) matrixFloats, 0);
-
- return true;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return false;
-}
-
-extern "C"
-JNIEXPORT jboolean JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeRenderPagesSurfaceWithMatrix(JNIEnv *env,
- jobject thiz,
- jlongArray pages,
- jobject surface,
- jfloatArray matrices,
- jfloatArray clipRect,
- jboolean render_annot,
- jboolean text_mask,
- jint canvasColor,
- jint pageBackgroundColor) {
- try {
- ANativeWindow *nativeWindow = ANativeWindow_fromSurface(env, surface);
- if (nativeWindow == nullptr) {
- LOGE("native window pointer null");
- return false;
- }
- auto width = ANativeWindow_getWidth(nativeWindow);
- auto height = ANativeWindow_getHeight(nativeWindow);
-
- if (ANativeWindow_getFormat(nativeWindow) != WINDOW_FORMAT_RGBA_8888) {
- LOGD("Set format to RGBA_8888");
- ANativeWindow_setBuffersGeometry(nativeWindow,
- width,
- height,
- WINDOW_FORMAT_RGBA_8888);
- }
-
- LOGD("nativeRenderPagesSurfaceWithMatrix width %d, height %d", width, height);
-
- auto *buffer = new ANativeWindow_Buffer();
- int ret;
- if ((ret = ANativeWindow_lock(nativeWindow, buffer, nullptr)) != 0) {
- LOGE("Locking native window failed: %s", strerror(ret * -1));
- ANativeWindow_release(nativeWindow);
- return false;
- }
-
- auto pagePtrs = env->GetLongArrayElements(pages, nullptr);
- auto numPages = env->GetArrayLength(pages);
-
- auto clipRectFloats = env->GetFloatArrayElements(clipRect, nullptr);
-
- auto matrixFloats = env->GetFloatArrayElements(matrices, nullptr);
-
-
- FPDF_BITMAP pdfBitmap = FPDFBitmap_CreateEx(width, height,
- FPDFBitmap_BGRA,
- buffer->bits, (int)(buffer->stride) * 4);
-
- if(canvasColor != 0) {
- FPDFBitmap_FillRect( pdfBitmap, 0, 0, width, height,
- canvasColor); //Gray
- }
-
- int flags = FPDF_REVERSE_BYTE_ORDER;
-
- if (render_annot) {
- flags |= FPDF_ANNOT;
- }
-
- /* from here we process each page */
- for (int pageIndex = 0; pageIndex < numPages; ++pageIndex) {
-
- auto page = reinterpret_cast(pagePtrs[pageIndex]);
-
- if (page == nullptr) {
- LOGE("Render page pointers invalid");
- ANativeWindow_release(nativeWindow);
- return false;
- }
-
-
- auto leftClip = clipRectFloats[0 + pageIndex * 4];
- auto topClip = clipRectFloats[1 + pageIndex * 4];
- auto rightClip = clipRectFloats[2 + pageIndex * 4];
- auto bottomClip = clipRectFloats[3 + pageIndex * 4];
-
- auto drawSizeHor = (int) (rightClip - leftClip);
- auto drawSizeVer = (int) (bottomClip - topClip);
-
- auto startX = (int) leftClip;
- auto startY = (int) topClip;
-
-// if (drawSizeHor > width || drawSizeVer > height) {
-// LOGE("Render page clipRect is larger than the surface: %d, %d, clipRect, %d, %d", width, height, drawSizeHor, drawSizeVer);
-// ANativeWindow_unlockAndPost(nativeWindow);
-// ANativeWindow_release(nativeWindow);
-// return false;
-// }
- int baseHorSize = (width < drawSizeHor) ? width : drawSizeHor;
- int baseVerSize = (height < drawSizeVer) ? height : drawSizeVer;
- int baseX = (startX < 0) ? 0 : startX;
- int baseY = (startY < 0) ? 0 : startY;
- if (startX + drawSizeHor > width) {
- drawSizeHor = width - startX;
- }
- if (startY + drawSizeVer > height) {
- drawSizeVer = height - startY;
- }
- if (leftClip < 0) {
- leftClip = 0;
- }
- if (topClip < 0) {
- topClip = 0;
- }
- auto fWidth = (float) width;
- auto fHeight = (float) height;
- if (rightClip > fWidth) {
- rightClip = fWidth;
- }
- if (bottomClip > fHeight) {
- bottomClip = fHeight;
- }
-
-
- if (pageBackgroundColor != 0) {
- FPDFBitmap_FillRect(pdfBitmap, baseX, baseY, baseHorSize, baseVerSize,
- pageBackgroundColor); //White
- }
-
-
- auto scale = matrixFloats[0 + pageIndex * 3];
- auto xTrans = matrixFloats[1 + pageIndex * 3];
- auto yTrans = matrixFloats[2 + pageIndex * 3];
- auto matrix = FS_MATRIX();
- matrix.a = scale;
- matrix.b = 0;
- matrix.c = 0;
- matrix.d = scale;
- matrix.e = xTrans;
- matrix.f = yTrans;
- auto clip = FS_RECTF();
- clip.left = leftClip;
- clip.top = topClip;
- clip.right = rightClip;
- clip.bottom = bottomClip;
-
- FPDF_RenderPageBitmapWithMatrix(pdfBitmap, page, &matrix, &clip, flags);
- /* end process each page */
- }
-
- ANativeWindow_unlockAndPost(nativeWindow);
- ANativeWindow_release(nativeWindow);
-
-
- env->ReleaseFloatArrayElements(matrices, (jfloat *) matrixFloats, 0);
- env->ReleaseFloatArrayElements(clipRect, (jfloat *) clipRectFloats, 0);
- env->ReleaseLongArrayElements(pages, pagePtrs, 0);
-
- return true;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return false;
-}
-
-extern "C"
-JNIEXPORT void JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeRenderPagesWithMatrix(JNIEnv *env, jobject thiz,
- jlongArray pages, jlong buffer_ptr,
- jint draw_size_hor, jint draw_size_ver,
- jfloatArray matrices,
- jfloatArray clipRect,
- jboolean render_annot,
- jboolean text_mask,
- jint canvasColor,
- jint pageBackgroundColor) {
- try {
- auto bufferPtr = reinterpret_cast(buffer_ptr);
- auto buffer = *bufferPtr;
- jboolean isCopyPages;
- auto pagePtrs = env->GetLongArrayElements(pages, &isCopyPages);
- auto numPages = env->GetArrayLength(pages);
-
- jboolean isCopyClipRect;
- auto clipRectFloats = env->GetFloatArrayElements(clipRect, &isCopyClipRect);
-
- jboolean isCopyMatrices;
- auto matrixFloats = env->GetFloatArrayElements(matrices, &isCopyMatrices);
-
-
- auto canvasHorSize = draw_size_hor;
- auto canvasVerSize = draw_size_ver;
-
- FPDF_BITMAP pdfBitmap = FPDFBitmap_CreateEx(canvasHorSize, canvasVerSize,
- FPDFBitmap_BGRA,
- buffer.bits, (int)(buffer.stride) * 4);
-
- if(canvasColor != 0) {
- FPDFBitmap_FillRect( pdfBitmap, 0, 0, canvasHorSize, canvasVerSize,
- canvasColor); //Gray
- }
-
- int flags = FPDF_REVERSE_BYTE_ORDER;
-
- if (render_annot) {
- flags |= FPDF_ANNOT;
- }
-
- /* from here we process each page */
- for (int pageIndex = 0; pageIndex < numPages; ++pageIndex) {
-
- auto page = reinterpret_cast(pagePtrs[pageIndex]);
-
- if (page == nullptr) {
- LOGE("Render page pointers invalid");
- return;
- }
-
-
- auto leftClip = clipRectFloats[0 + pageIndex * 4];
- auto topClip = clipRectFloats[1 + pageIndex * 4];
- auto rightClip = clipRectFloats[2 + pageIndex * 4];
- auto bottomClip = clipRectFloats[3 + pageIndex * 4];
-
- auto drawSizeHor = (int) (rightClip - leftClip);
- auto drawSizeVer = (int) (bottomClip - topClip);
-
- auto startX = (int) leftClip;
- auto startY = (int) topClip;
- int baseHorSize = (canvasHorSize < drawSizeHor) ? canvasHorSize : drawSizeHor;
- int baseVerSize = (canvasVerSize < drawSizeVer) ? canvasVerSize : drawSizeVer;
- int baseX = (startX < 0) ? 0 : startX;
- int baseY = (startY < 0) ? 0 : startY;
-
-
- if (pageBackgroundColor != 0) {
- FPDFBitmap_FillRect(pdfBitmap, baseX, baseY, baseHorSize, baseVerSize,
- pageBackgroundColor); //White
- }
-
-
- auto scale = matrixFloats[0 + pageIndex * 3];
- auto xTrans = matrixFloats[1 + pageIndex * 3];
- auto yTrans = matrixFloats[2 + pageIndex * 3];
- auto matrix = FS_MATRIX();
- matrix.a = scale;
- matrix.b = 0;
- matrix.c = 0;
- matrix.d = scale;
- matrix.e = xTrans;
- matrix.f = yTrans;
- auto clip = FS_RECTF();
- clip.left = leftClip;
- clip.top = topClip;
- clip.right = rightClip;
- clip.bottom = bottomClip;
-
- FPDF_RenderPageBitmapWithMatrix(pdfBitmap, page, &matrix, &clip, flags);
- /* end process each page */
- }
-
-
- if (isCopyMatrices) {
- env->ReleaseFloatArrayElements(matrices, (jfloat *) matrixFloats, JNI_ABORT);
- }
-
- if (isCopyClipRect) {
- env->ReleaseFloatArrayElements(clipRect, (jfloat *) clipRectFloats, JNI_ABORT);
- }
- if (isCopyClipRect) {
- env->ReleaseLongArrayElements(pages, pagePtrs, JNI_ABORT);
- }
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
-}
-extern "C"
-JNIEXPORT void JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeRenderPageBitmap(JNIEnv *env, jclass,
- jlong doc_ptr,
- jlong page_ptr,
- jobject bitmap,
- jint start_x, jint start_y,
- jint draw_size_hor, jint draw_size_ver,
- jboolean render_annot,
- jboolean,
- jint canvasColor, jint pageBackgroundColor) {
- try {
- auto *doc = reinterpret_cast(doc_ptr);
- auto page = reinterpret_cast(page_ptr);
-
- if (page == nullptr || bitmap == nullptr) {
- LOGE("Render page pointers invalid");
- return;
- }
-
- AndroidBitmapInfo info;
- int ret;
- if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) {
- LOGE("Fetching bitmap info failed: %s", strerror(ret * -1));
- return;
- }
-
- auto canvasHorSize = info.width;
- auto canvasVerSize = info.height;
-
- if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888 &&
- info.format != ANDROID_BITMAP_FORMAT_RGB_565) {
- LOGE("Bitmap format must be RGBA_8888 or RGB_565");
- return;
- }
-
- void *addr;
- if ((ret = AndroidBitmap_lockPixels(env, bitmap, &addr)) != 0) {
- LOGE("Locking bitmap failed: %s", strerror(ret * -1));
- return;
- }
-
- void *tmp;
- int format;
- int sourceStride;
- if (info.format == ANDROID_BITMAP_FORMAT_RGB_565) {
- tmp = malloc(canvasVerSize * canvasHorSize * sizeof(rgb));
- sourceStride = (int) (canvasHorSize * sizeof(rgb));
- format = FPDFBitmap_BGR;
- } else {
- tmp = addr;
- sourceStride = (int) info.stride;
- format = FPDFBitmap_BGRA;
- }
-
- FPDF_BITMAP pdfBitmap = FPDFBitmap_CreateEx((int) canvasHorSize, (int) canvasVerSize,
- format, tmp, sourceStride);
-
- /*LOGD("Start X: %d", startX);
- LOGD("Start Y: %d", startY);
- LOGD("Canvas Hor: %d", canvasHorSize);
- LOGD("Canvas Ver: %d", canvasVerSize);
- LOGD("Draw Hor: %d", drawSizeHor);
- LOGD("Draw Ver: %d", drawSizeVer);*/
-
- if ((draw_size_hor < canvasHorSize || draw_size_ver < canvasVerSize) && canvasColor != 0) {
- FPDFBitmap_FillRect(pdfBitmap, 0, 0, (int) canvasHorSize, (int) canvasVerSize,
- canvasColor); //Gray
- }
-
- int baseHorSize = (canvasHorSize < draw_size_hor) ? (int) canvasHorSize
- : (int) draw_size_hor;
- int baseVerSize = (canvasVerSize < draw_size_ver) ? (int) canvasVerSize
- : (int) draw_size_ver;
- int baseX = (start_x < 0) ? 0 : (int) start_x;
- int baseY = (start_y < 0) ? 0 : (int) start_y;
- int flags = FPDF_REVERSE_BYTE_ORDER;
-
- FPDF_FORMFILLINFO form_callbacks = {0};
- form_callbacks.version = 2;
- FPDF_FORMHANDLE form;
-
- if (render_annot) {
- form = FPDFDOC_InitFormFillEnvironment(doc->pdfDocument, &form_callbacks);
- flags |= FPDF_ANNOT;
- }
-
-// if(text_mask) {
-// flags |= FPDF_RENDER_TEXT_MASK;
-// }
-
- if (pageBackgroundColor != 0) {
- FPDFBitmap_FillRect(pdfBitmap, baseX, baseY, baseHorSize, baseVerSize,
- pageBackgroundColor); //White
- }
-
- FPDF_RenderPageBitmap(pdfBitmap, page,
- start_x, start_y,
- (int) draw_size_hor, (int) draw_size_ver,
- 0, flags);
-
- if (render_annot) {
- FPDF_FFLDraw(form, pdfBitmap, page, start_x, start_y, (int) draw_size_hor, (int) draw_size_ver, 0, FPDF_ANNOT);
- FPDFDOC_ExitFormFillEnvironment(form);
- }
-
- if (info.format == ANDROID_BITMAP_FORMAT_RGB_565) {
- rgbBitmapTo565(tmp, sourceStride, addr, &info);
- free(tmp);
- }
-
- AndroidBitmap_unlockPixels(env, bitmap);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
-}
-
-extern "C"
-JNIEXPORT void JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeRenderPageBitmapWithMatrix(JNIEnv *env, jclass,
- jlong page_ptr,
- jobject bitmap,
- jfloatArray matrixValues,
- jfloatArray clipRect,
- jboolean render_annot,
- jboolean,
- jint canvasColor, jint pageBackgroundColor) {
- try {
- auto page = reinterpret_cast(page_ptr);
-
- if (page == nullptr || bitmap == nullptr) {
- LOGE("Render page pointers invalid");
- return;
- }
-
- AndroidBitmapInfo info;
- int ret;
- if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) {
- LOGE("Fetching bitmap info failed: %s", strerror(ret * -1));
- return;
- }
-
- auto canvasHorSize = info.width;
- auto canvasVerSize = info.height;
-
- if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888 &&
- info.format != ANDROID_BITMAP_FORMAT_RGB_565) {
- LOGE("Bitmap format must be RGBA_8888 or RGB_565");
- return;
- }
-
- void *addr;
- if ((ret = AndroidBitmap_lockPixels(env, bitmap, &addr)) != 0) {
- LOGE("Locking bitmap failed: %s", strerror(ret * -1));
- return;
- }
-
- void *tmp;
- int format;
- int sourceStride;
- if (info.format == ANDROID_BITMAP_FORMAT_RGB_565) {
- tmp = malloc(canvasVerSize * canvasHorSize * sizeof(rgb));
- sourceStride = (int) (canvasHorSize * sizeof(rgb));
- format = FPDFBitmap_BGR;
- } else {
- tmp = addr;
- sourceStride = (int) info.stride;
- format = FPDFBitmap_BGRA;
- }
-
- FPDF_BITMAP pdfBitmap = FPDFBitmap_CreateEx((int) canvasHorSize, (int) canvasVerSize,
- format, tmp, sourceStride);
-
- /*LOGD("Start X: %d", startX);
- LOGD("Start Y: %d", startY);
- LOGD("Canvas Hor: %d", canvasHorSize);
- LOGD("Canvas Ver: %d", canvasVerSize);
- LOGD("Draw Hor: %d", drawSizeHor);
- LOGD("Draw Ver: %d", drawSizeVer);*/
-
-// if (draw_size_hor < canvasHorSize || draw_size_ver < canvasVerSize) {
-// FPDFBitmap_FillRect(pdfBitmap, 0, 0, canvasHorSize, canvasVerSize,
-// 0x848484FF); //Gray
-// }
-//
-// int baseHorSize = (canvasHorSize < draw_size_hor) ? (int) canvasHorSize
-// : (int) draw_size_hor;
-// int baseVerSize = (canvasVerSize < draw_size_ver) ? (int) canvasVerSize
-// : (int) draw_size_ver;
-// int baseX = (start_x < 0) ? 0 : (int) start_x;
-// int baseY = (start_y < 0) ? 0 : (int) start_y;
- int flags = FPDF_REVERSE_BYTE_ORDER;
-
- if (render_annot) {
- flags |= FPDF_ANNOT;
- }
-
-// if(text_mask) {
-// flags |= FPDF_RENDER_TEXT_MASK;
-// }
-
- if (pageBackgroundColor != 0) {
- FPDFBitmap_FillRect(pdfBitmap, 0, 0, (int) canvasHorSize, (int) canvasVerSize,
- pageBackgroundColor); //White
- }
-
-// jclass clazz = env->FindClass("android/graphics/RectF");
-// jfieldID left = env->GetFieldID(clazz, "left", "F");
-// jfieldID top = env->GetFieldID(clazz, "top", "F");
-// jfieldID right = env->GetFieldID(clazz, "right", "F");
-// jfieldID bottom = env->GetFieldID(clazz, "bottom", "F");
- jboolean isCopyClipRect;
- auto clipRectFloats = env->GetFloatArrayElements(clipRect, &isCopyClipRect);
- auto leftClip = clipRectFloats[0];
- auto topClip = clipRectFloats[1];
- auto rightClip = clipRectFloats[2];
- auto bottomClip = clipRectFloats[3];
-
- jboolean isCopy;
- auto matrixFloats = env->GetFloatArrayElements(matrixValues, &isCopy);
-
- auto matrix = FS_MATRIX();
- matrix.a = matrixFloats[0];
- matrix.b = 0;
- matrix.c = 0;
- matrix.d = matrixFloats[1];
- matrix.e = matrixFloats[2];
- matrix.f = matrixFloats[3];
- auto clip = FS_RECTF();
- clip.left = leftClip;
- clip.top = topClip;
- clip.right = rightClip;
- clip.bottom = bottomClip;
- if (isCopy) {
- env->ReleaseFloatArrayElements(matrixValues, (jfloat *) matrixFloats, JNI_ABORT);
- }
-
- if (isCopyClipRect) {
- env->ReleaseFloatArrayElements(clipRect, (jfloat *) clipRectFloats, JNI_ABORT);
- }
-
- FPDF_RenderPageBitmapWithMatrix(pdfBitmap, page, &matrix, &clip, flags);
-
- if (info.format == ANDROID_BITMAP_FORMAT_RGB_565) {
- rgbBitmapTo565(tmp, sourceStride, addr, &info);
- free(tmp);
- }
-
- AndroidBitmap_unlockPixels(env, bitmap);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
-}
-extern "C"
-JNIEXPORT jintArray JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageSizeByIndex(JNIEnv *env, jclass,
- jlong doc_ptr, jint page_index,
- jint dpi) {
- try {
- auto *doc = reinterpret_cast(doc_ptr);
- if (doc == nullptr) {
- LOGE("Document is null");
-
- jniThrowException(env, "java/lang/IllegalStateException",
- "Document is null");
- return nullptr;
- }
-
- double width, height;
- int result = FPDF_GetPageSizeByIndex(doc->pdfDocument, page_index, &width, &height);
-
- if (result == 0) {
- width = 0;
- height = 0;
- }
-
- jint widthInt = (jint) (width * dpi / 72);
- jint heightInt = (jint) (height * dpi / 72);
-
- jintArray retVal = env->NewIntArray(2);
- if (retVal == nullptr) {
- return nullptr;
- }
-
- jint buffer[] = {widthInt, heightInt};
- env->SetIntArrayRegion(retVal, 0, 2, buffer);
-
- return retVal;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jlongArray JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageLinks(JNIEnv *env, jclass, jlong page_ptr) {
- try {
- auto page = reinterpret_cast(page_ptr);
- int pos = 0;
- std::vector links;
- FPDF_LINK link;
- while (FPDFLink_Enumerate(page, &pos, &link)) {
- links.push_back(reinterpret_cast(link));
- }
-
- jlongArray result = env->NewLongArray((int) links.size());
- env->SetLongArrayRegion(result, 0, (int) links.size(), &links[0]);
- return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jintArray JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativePageCoordsToDevice(JNIEnv *env, jclass,
- jlong page_ptr, jint start_x,
- jint start_y, jint size_x,
- jint size_y, jint rotate,
- jdouble page_x, jdouble page_y) {
- try {
- auto page = reinterpret_cast(page_ptr);
- int deviceX, deviceY;
-
- FPDF_PageToDevice(page, start_x, start_y, size_x, size_y, rotate, page_x, page_y, &deviceX,
- &deviceY);
- jintArray retVal = env->NewIntArray(2);
- if (retVal == nullptr) {
- return nullptr;
- }
-
- jint buffer[] = {deviceX, deviceY};
- env->SetIntArrayRegion(retVal, 0, 2, buffer);
- return retVal;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jfloatArray JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeDeviceCoordsToPage(JNIEnv *env, jclass,
- jlong page_ptr, jint start_x,
- jint start_y, jint size_x,
- jint size_y, jint rotate,
- jint device_x, jint device_y) {
- try {
- auto page = reinterpret_cast(page_ptr);
- double pageX, pageY;
-
-
- jfloatArray retVal = env->NewFloatArray(2);
- if (retVal == nullptr) {
- return nullptr;
- }
- float point[2];
- if (!FPDF_DeviceToPage(page, start_x, start_y, size_x, size_y, rotate, device_x, device_y,
- &pageX, &pageY)) {
- point[0] = -1.0f;
- point[1] = -1.0f;
- } else {
- point[0] = (float) pageX;
- point[1] = (float) pageY;
- }
-
- env->SetFloatArrayRegion(retVal, 0, 2, point);
- return retVal;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-static void closeTextPageInternal(jlong textPagePtr) { FPDFText_ClosePage(reinterpret_cast(textPagePtr)); }
-
-extern "C"
-JNIEXPORT void JNICALL
-Java_io_legere_pdfiumandroid_PdfTextPage_nativeCloseTextPage(JNIEnv *env, jclass,
- jlong page_ptr) {
- try {
- closeTextPageInternal(page_ptr);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextCountChars(JNIEnv *env, jclass,
- jlong text_page_ptr) {
- try {
- auto textPage = reinterpret_cast(text_page_ptr);
- return (jint) FPDFText_CountChars(textPage);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetText(JNIEnv *env, jclass,
- jlong text_page_ptr, jint start_index,
- jint count, jshortArray result) {
- try {
- auto textPage = reinterpret_cast(text_page_ptr);
- jboolean isCopy = 1;
- auto *arr = (unsigned short *) env->GetShortArrayElements(result, &isCopy);
- jint output = (jint) FPDFText_GetText(textPage, (int) start_index, (int) count, arr);
- if (isCopy) {
- env->SetShortArrayRegion(result, 0, output, (jshort *) arr);
- env->ReleaseShortArrayElements(result, (jshort *) arr, JNI_ABORT);
- }
- return output;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetTextByteArray(JNIEnv *env, jclass,
- jlong text_page_ptr,
- jint start_index, jint count,
- jbyteArray result) {
- try {
- auto textPage = reinterpret_cast(text_page_ptr);
- jboolean isCopy = 0;
- auto *arr = (jbyteArray) env->GetByteArrayElements(result, &isCopy);
- unsigned short buffer[count];
- jint output = (jint) FPDFText_GetText(textPage, (int) start_index, (int) count, buffer);
- memcpy(arr, buffer, count * sizeof(unsigned short));
- if (isCopy) {
- env->SetByteArrayRegion(result, 0, count * 2, (jbyte *) arr);
- env->ReleaseByteArrayElements(result, (jbyte *) arr, JNI_ABORT);
- }
- return output;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetUnicode(JNIEnv *env, jclass,
- jlong text_page_ptr, jint index) {
- try {
- auto textPage = reinterpret_cast(text_page_ptr);
- return (jint) FPDFText_GetUnicode(textPage, (int) index);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT jdoubleArray JNICALL
-Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetCharBox(JNIEnv *env, jclass,
- jlong text_page_ptr, jint index) {
- try {
- auto textPage = reinterpret_cast(text_page_ptr);
- jdoubleArray result = env->NewDoubleArray(4);
- if (result == nullptr) {
- return nullptr;
- }
- double fill[4];
- FPDFText_GetCharBox(textPage, (int) index, &fill[0], &fill[1], &fill[2], &fill[3]);
- env->SetDoubleArrayRegion(result, 0, 4, (jdouble *) fill);
- return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetCharIndexAtPos(JNIEnv *env, jclass,
- jlong text_page_ptr, jdouble x,
- jdouble y, jdouble x_tolerance,
- jdouble y_tolerance) {
- try {
- auto textPage = reinterpret_cast(text_page_ptr);
- return (jint) FPDFText_GetCharIndexAtPos(textPage, (double) x, (double) y,
- (double) x_tolerance, (double) y_tolerance);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextCountRects(JNIEnv *env, jclass,
- jlong text_page_ptr, jint start_index,
- jint count) {
- try {
- auto textPage = reinterpret_cast(text_page_ptr);
- return (jint) FPDFText_CountRects(textPage, (int) start_index, (int) count);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT jdoubleArray JNICALL
-Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetRect(JNIEnv *env, jclass,
- jlong text_page_ptr, jint rect_index) {
- try {
- auto textPage = reinterpret_cast(text_page_ptr);
- jdoubleArray result = env->NewDoubleArray(4);
- if (result == nullptr) {
- return nullptr;
- }
- double fill[4];
- FPDFText_GetRect(textPage, (int) rect_index, &fill[0], &fill[1], &fill[2], &fill[3]);
- env->SetDoubleArrayRegion(result, 0, 4, (jdouble *) fill);
- return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetBoundedText(JNIEnv *env, jclass,
- jlong text_page_ptr, jdouble left,
- jdouble top, jdouble right,
- jdouble bottom, jshortArray arr) {
- try {
- auto textPage = reinterpret_cast(text_page_ptr);
- jboolean isCopy = 0;
- unsigned short *buffer = nullptr;
- int bufLen = 0;
- if (arr != nullptr) {
- buffer = (unsigned short *) env->GetShortArrayElements(arr, &isCopy);
- bufLen = env->GetArrayLength(arr);
- }
- jint output = (jint) FPDFText_GetBoundedText(textPage, (double) left, (double) top,
- (double) right, (double) bottom, buffer,
- bufLen);
- if (isCopy) {
- env->SetShortArrayRegion(arr, 0, output, (jshort *) buffer);
- env->ReleaseShortArrayElements(arr, (jshort *) buffer, JNI_ABORT);
- }
- return output;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetDestPageIndex(JNIEnv *env, jclass,
- jlong doc_ptr, jlong link_ptr) {
- try {
- auto *doc = reinterpret_cast(doc_ptr);
- auto bookmark = reinterpret_cast(link_ptr);
-
- FPDF_DEST dest = FPDFBookmark_GetDest(doc->pdfDocument, bookmark);
- if (dest == nullptr) {
- return -1;
- }
- auto index = FPDFDest_GetDestPageIndex(doc->pdfDocument, dest);
- return (jint) index;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT jstring JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetLinkURI(JNIEnv *env, jclass, jlong doc_ptr,
- jlong link_ptr) {
- try {
- auto *doc = reinterpret_cast(doc_ptr);
- auto link = reinterpret_cast(link_ptr);
- FPDF_ACTION action = FPDFLink_GetAction(link);
- if (action == nullptr) {
- return nullptr;
- }
- size_t bufferLen = FPDFAction_GetURIPath(doc->pdfDocument, action, nullptr, 0);
- if (bufferLen <= 0) {
- return env->NewStringUTF("");
- }
- std::string uri;
- FPDFAction_GetURIPath(doc->pdfDocument, action, WriteInto(&uri, bufferLen), bufferLen);
- return env->NewStringUTF(uri.c_str());
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jfloatArray JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetLinkRect(JNIEnv *env, jclass, jlong,
- jlong link_ptr) {
- try {
- auto link = reinterpret_cast(link_ptr);
- FS_RECTF fsRectF;
- FPDF_BOOL result = FPDFLink_GetAnnotRect(link, &fsRectF);
-
- if (!result) {
- return nullptr;
- }
- jfloatArray retVal = env->NewFloatArray(4);
- if (retVal == nullptr) {
- return nullptr;
- }
-
- float rect[4];
- rect[0] = fsRectF.left;
- rect[1] = fsRectF.top;
- rect[2] = fsRectF.right;
- rect[3] = fsRectF.bottom;
-
- env->SetFloatArrayRegion(retVal, 0, 4, (jfloat *) rect);
- return retVal;
-
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-extern "C"
-JNIEXPORT jlong JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeGetBookmarkDestIndex(JNIEnv *env, jobject,
- jlong doc_ptr,
- jlong bookmark_ptr) {
- try {
- auto *doc = reinterpret_cast(doc_ptr);
- auto bookmark = reinterpret_cast(bookmark_ptr);
-
- FPDF_DEST dest = FPDFBookmark_GetDest(doc->pdfDocument, bookmark);
- if (dest == nullptr) {
- return -1;
- }
- return (jlong) FPDFDest_GetDestPageIndex(doc->pdfDocument, dest);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-extern "C"
-JNIEXPORT jintArray JNICALL
-Java_io_legere_pdfiumandroid_PdfDocument_nativeGetPageCharCounts(JNIEnv *env, jobject,
- jlong doc_ptr) {
- try {
- auto *doc = reinterpret_cast(doc_ptr);
- auto pageCount = FPDF_GetPageCount(doc->pdfDocument);
-
- std::vector charCounts;
-
- for (int i = 0; i< pageCount; i++) {
- auto page = FPDF_LoadPage(doc->pdfDocument, i);
- auto textPage = FPDFText_LoadPage(page);
- auto charCount = FPDFText_CountChars(textPage);
- charCounts.push_back(charCount);
- FPDFText_ClosePage(textPage);
- FPDF_ClosePage(page);
- }
-
- jintArray result = env->NewIntArray((int) charCounts.size());
- env->SetIntArrayRegion(result, 0, (int) charCounts.size(), &charCounts[0]);
- return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-extern "C"
-JNIEXPORT jlong JNICALL
-Java_io_legere_pdfiumandroid_PdfTextPage_nativeFindStart(JNIEnv *env, jclass,
- jlong text_page_ptr,
- jstring find_what,
- jint flags, jint start_index) {
- try {
- auto textPage = reinterpret_cast(text_page_ptr);
-
- const jchar* raw = env->GetStringChars(find_what, nullptr);
- if (raw == nullptr) {
- // Handle error, possibly throw an exception
- return 0;
- }
-
- jsize len = env->GetStringLength(find_what);
- std::u16string result(raw, raw + len);
-
- auto handle = FPDFText_FindStart(
- textPage,
- (FPDF_WIDESTRING) result.c_str(),
- flags,
- start_index
- );
-
- env->ReleaseStringChars(find_what, raw);
-
-
- return (jlong) handle;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return 0;
-}
-
-extern "C"
-JNIEXPORT jboolean JNICALL
-Java_io_legere_pdfiumandroid_FindResult_nativeFindNext(JNIEnv *env, jobject,
- jlong find_handle) {
- try {
- auto findHandle = reinterpret_cast(find_handle);
-
-
- auto result = FPDFText_FindNext(findHandle);
- return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return 0;
-}
-
-extern "C"
-JNIEXPORT jboolean JNICALL
-Java_io_legere_pdfiumandroid_FindResult_nativeFindPrev(JNIEnv *env, jobject,
- jlong find_handle) {
- try {
- auto findHandle = reinterpret_cast(find_handle);
-
-
- auto result = FPDFText_FindPrev(findHandle);
- return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return 0;
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_FindResult_nativeGetSchResultIndex(JNIEnv *env, jobject,
- jlong find_handle) {
- try {
- auto findHandle = reinterpret_cast(find_handle);
-
-
- auto result = FPDFText_GetSchResultIndex(findHandle);
- return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return 0;
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_FindResult_nativeGetSchCount(JNIEnv *env, jobject,
- jlong find_handle) {
- try {
- auto findHandle = reinterpret_cast(find_handle);
-
-
- auto result = FPDFText_GetSchCount(findHandle);
- return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return 0;
-}
-
-extern "C"
-JNIEXPORT void JNICALL
-Java_io_legere_pdfiumandroid_FindResult_nativeCloseFind(JNIEnv *env, jobject,
- jlong find_handle) {
- try {
- auto findHandle = reinterpret_cast(find_handle);
-
-
- FPDFText_FindClose(findHandle);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
-}
-extern "C"
-JNIEXPORT jlong JNICALL
-Java_io_legere_pdfiumandroid_PdfTextPage_nativeLoadWebLink(JNIEnv *env, jclass,
- jlong text_page_ptr) {
- try {
- auto textPage = reinterpret_cast(text_page_ptr);
-
- auto handle = FPDFLink_LoadWebLinks(textPage);
-
- return (jlong) handle;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return 0;
-}
-
-extern "C"
-JNIEXPORT void JNICALL
-Java_io_legere_pdfiumandroid_PdfPageLink_nativeClosePageLink(JNIEnv *env, jclass,
- jlong page_link_ptr) {
- try {
- auto pageLink = reinterpret_cast(page_link_ptr);
-
-
- FPDFLink_CloseWebLinks(pageLink);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
-}
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfPageLink_nativeCountWebLinks(JNIEnv *env, jclass,
- jlong page_link_ptr) {
- try {
- auto pageLink = reinterpret_cast(page_link_ptr);
-
-
- auto result = FPDFLink_CountWebLinks(pageLink);
- LOGE("CountWebLinks result %d", result);
- return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfPageLink_nativeGetURL(JNIEnv *env, jclass,
- jlong page_link_ptr, jint index, jint count, jbyteArray result) {
- try {
- auto pageLink = reinterpret_cast(page_link_ptr);
-
- jboolean isCopy = 0;
- auto *arr = (jbyteArray) env->GetByteArrayElements(result, &isCopy);
- unsigned short buffer[count];
-
- jint output = (jint) FPDFLink_GetURL(pageLink, index, buffer, count);
-
-
- memcpy(arr, buffer, count * sizeof(unsigned short));
- if (isCopy) {
- env->SetByteArrayRegion(result, 0, count * 2, (jbyte *) arr);
- env->ReleaseByteArrayElements(result, (jbyte *) arr, JNI_ABORT);
- }
- return output;
-
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return 0;
-}
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfPageLink_nativeCountRects(JNIEnv *env, jclass,
- jlong page_link_ptr, jint index) {
- try {
- auto pageLink = reinterpret_cast(page_link_ptr);
-
-
- auto result = FPDFLink_CountRects(pageLink, index);
- LOGE("CountRect %d", result);
-
- return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return 0;
-}
-extern "C"
-JNIEXPORT jfloatArray JNICALL
-Java_io_legere_pdfiumandroid_PdfPageLink_nativeGetRect(JNIEnv *env, jclass,
- jlong page_link_ptr, jint linkIndex, jint rectIndex) {
- try {
- auto pageLink = reinterpret_cast(page_link_ptr);
-
- double left;
- double top;
- double right;
- double bottom;
-
- if (FPDFLink_GetRect(pageLink, linkIndex, rectIndex, &left, &top, &right, &bottom )) {
- jfloatArray result = env->NewFloatArray(4);
- if (result == nullptr) {
- return nullptr;
- }
- jfloat array[4];
- array[0] = (float) left;
- array[1] = (float) top;
- array[2] = (float) right;
- array[3] = (float) bottom;
-
- env->SetFloatArrayRegion(result, 0, 4, array);
- return result;
- }
-
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-extern "C"
-JNIEXPORT jintArray JNICALL
-Java_io_legere_pdfiumandroid_PdfPageLink_nativeGetTextRange(JNIEnv *env, jclass,
- jlong page_link_ptr, jint index) {
- try {
- auto pageLink = reinterpret_cast(page_link_ptr);
-
- if (pageLink == nullptr) {
- LOGE("PageLink is null");
-
- jniThrowException(env, "java/lang/IllegalStateException",
- "Document is null");
- return nullptr;
- }
-
- int start, count;
- int result = FPDFLink_GetTextRange(pageLink, index, &start, &count);
-
- if (result == 0) {
- start = 0;
- count = 0;
- }
-
- jintArray retVal = env->NewIntArray(2);
- if (retVal == nullptr) {
- return nullptr;
- }
-
- jint buffer[] = {start, count};
- env->SetIntArrayRegion(retVal, 0, 2, buffer);
-
- return retVal;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return nullptr;
-}
-
-
-extern "C"
-JNIEXPORT jdoubleArray JNICALL
-Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetRects(JNIEnv *env, jclass clazz,
- jlong text_page_ptr,
- jintArray wordRanges) {
- auto textPage = reinterpret_cast(text_page_ptr);
-
- jsize numRanges = env->GetArrayLength(wordRanges) / 2;
-
- // Get the ranges array
- jint *ranges = env->GetIntArrayElements(wordRanges, nullptr);
-
- // Create a vector to store the data
- std::vector data;
-
- // Iterate through the ranges
- for (jsize i = 0; i < numRanges; ++i) {
- // Get the start and length
- jint start = ranges[i * 2];
- jint length = ranges[i * 2 + 1];
-
- // Get the number of rectangles in the range
- int rectCount = FPDFText_CountRects(textPage, start, length);
-
- // Get the rectangles
- for (int j = 0; j < rectCount; ++j) {
- double left, top, right, bottom;
- FPDFText_GetRect(textPage, j, &left, &top, &right, &bottom);
-
- // Add the rectangle to the data vector (left, top, right, bottom)
- data.push_back(left);
- data.push_back(top);
- data.push_back(right);
- data.push_back(bottom);
-
- // Add the range to the data vector (start, length)
- data.push_back(static_cast(start));
- data.push_back(static_cast(length));
- }
- }
-
- // Release the ranges array
- env->ReleaseIntArrayElements(wordRanges, ranges, JNI_ABORT);
-
- // Create a jdoubleArray and copy the data
- jdoubleArray result = env->NewDoubleArray(data.size());
- if (result == nullptr) {
- return nullptr; // Out of memory error
- }
- env->SetDoubleArrayRegion(result, 0, data.size(), data.data());
-
- return result;
-}
-
-extern "C"
-JNIEXPORT jint JNICALL
-Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageRotation(JNIEnv *env, jclass,
- jlong page_ptr) {
- try {
- auto page = reinterpret_cast(page_ptr);
- return (jint)FPDFPage_GetRotation(page);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch(std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch(std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch(std::exception &e) {
- raise_java_exception(env, e);
- } catch (...) {
- auto e = std::runtime_error("Unknown error");
- raise_java_exception(env, e);
- }
- return -1;
-}
-
-static const JNINativeMethod coreMethods[] = {
- {"nativeOpenDocument", "(ILjava/lang/String;)J", (void *) Java_io_legere_pdfiumandroid_PdfiumCore_nativeOpenDocument},
- {"nativeOpenMemDocument", "([BLjava/lang/String;)J", (void *) Java_io_legere_pdfiumandroid_PdfiumCore_nativeOpenMemDocument},
- {"nativeOpenCustomDocument", "(Lio/legere/pdfiumandroid/util/PdfiumNativeSourceBridge;Ljava/lang/String;J)J", (void *) Java_io_legere_pdfiumandroid_PdfiumCore_nativeOpenCustomDocument},
-};
-
-
-static const JNINativeMethod pageMethods[] = {
- {"nativeClosePage", "(J)V", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeClosePage},
- {"nativeClosePages", "([J)V", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeClosePages},
- {"nativeGetDestPageIndex", "(JJ)I", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetDestPageIndex},
- {"nativeGetLinkURI", "(JJ)Ljava/lang/String;", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetLinkURI},
- {"nativeGetLinkRect", "(JJ)[F", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetLinkRect},
- {"nativeLockSurface", "(Landroid/view/Surface;[I[J)Z", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeLockSurface},
- {"nativeUnlockSurface", "([J)V", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeUnlockSurface},
- {"nativeRenderPage", "(JJIIIIZII)Z", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeRenderPage},
- {"nativeRenderPageSurface", "(JLandroid/view/Surface;IIZII)Z", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeRenderPageSurface},
- {"nativeRenderPageWithMatrix", "(JJII[F[FZZII)Z", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeRenderPageWithMatrix},
- {"nativeRenderPageSurfaceWithMatrix", "(JLandroid/view/Surface;[F[FZZII)Z", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeRenderPageSurfaceWithMatrix},
- {"nativeRenderPageBitmap", "(JJLandroid/graphics/Bitmap;IIIIZZII)V", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeRenderPageBitmap},
- {"nativeRenderPageBitmapWithMatrix", "(JLandroid/graphics/Bitmap;[F[FZZII)V", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeRenderPageBitmapWithMatrix},
- {"nativeGetPageSizeByIndex", "(JII)[I", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageSizeByIndex},
- {"nativeGetPageLinks", "(J)[J", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageLinks},
- {"nativePageCoordsToDevice", "(JIIIIIDD)[I", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativePageCoordsToDevice},
- {"nativeDeviceCoordsToPage", "(JIIIIIII)[F", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeDeviceCoordsToPage},
- {"nativeGetPageWidthPixel", "(JI)I", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageWidthPixel},
- {"nativeGetPageHeightPixel", "(JI)I", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageHeightPixel},
- {"nativeGetPageWidthPoint", "(J)I", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageWidthPoint},
- {"nativeGetPageHeightPoint", "(J)I", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageHeightPoint},
- {"nativeGetPageRotation", "(J)I", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageRotation},
- {"nativeGetPageMediaBox", "(J)[F", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageMediaBox},
- {"nativeGetPageCropBox", "(J)[F", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageCropBox},
- {"nativeGetPageBleedBox", "(J)[F", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageBleedBox},
- {"nativeGetPageTrimBox", "(J)[F", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageTrimBox},
- {"nativeGetPageArtBox", "(J)[F", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageArtBox},
- {"nativeGetPageBoundingBox", "(J)[F", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageBoundingBox},
- {"nativeGetPageMatrix", "(J)[F", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageMatrix},
- {"nativeGetPageObjectsInformation", "(J)[F", (void *) Java_io_legere_pdfiumandroid_PdfPage_nativeGetPageObjectsInformation},
-};
-
-
-static const JNINativeMethod textPageMethods[] = {
-
- {"nativeCloseTextPage", "(J)V", (void *) Java_io_legere_pdfiumandroid_PdfTextPage_nativeCloseTextPage},
- {"nativeTextCountChars", "(J)I", (void *) Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextCountChars},
- {"nativeTextGetCharBox", "(JI)[D", (void *) Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetCharBox},
- {"nativeTextGetRect", "(JI)[D", (void *) Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetRect},
- {"nativeTextGetRects", "(J[I)[D", (void *) Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetRects},
- {"nativeTextGetBoundedText", "(JDDDD[S)I", (void *) Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetBoundedText},
- {"nativeFindStart", "(JLjava/lang/String;II)J", (void *) Java_io_legere_pdfiumandroid_PdfTextPage_nativeFindStart},
- {"nativeLoadWebLink", "(J)J", (void *) Java_io_legere_pdfiumandroid_PdfTextPage_nativeLoadWebLink},
- {"nativeTextGetCharIndexAtPos", "(JDDDD)I", (void *) Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetCharIndexAtPos},
- {"nativeTextGetText", "(JII[S)I", (void *) Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetText},
- {"nativeTextGetTextByteArray", "(JII[B)I", (void *) Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetTextByteArray},
- {"nativeTextGetUnicode", "(JI)I", (void *) Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextGetUnicode},
- {"nativeTextCountRects", "(JII)I", (void *) Java_io_legere_pdfiumandroid_PdfTextPage_nativeTextCountRects},
- {"nativeGetFontSize", "(JI)D", (void *) Java_io_legere_pdfiumandroid_PdfTextPage_nativeGetFontSize},
-};
-
-static const JNINativeMethod documentMethods[] = {
- {"nativeGetPageCount", "(J)I", (void *) Java_io_legere_pdfiumandroid_PdfDocument_nativeGetPageCount},
- {"nativeLoadPage", "(JI)J", (void *) Java_io_legere_pdfiumandroid_PdfDocument_nativeLoadPage},
- {"nativeDeletePage", "(JI)V", (void *) Java_io_legere_pdfiumandroid_PdfDocument_nativeDeletePage},
- {"nativeCloseDocument", "(J)V", (void *) Java_io_legere_pdfiumandroid_PdfDocument_nativeCloseDocument},
- {"nativeLoadPages", "(JII)[J", (void *) Java_io_legere_pdfiumandroid_PdfDocument_nativeLoadPages},
- {"nativeGetDocumentMetaText", "(JLjava/lang/String;)Ljava/lang/String;", (void *) Java_io_legere_pdfiumandroid_PdfDocument_nativeGetDocumentMetaText},
- {"nativeGetFirstChildBookmark", "(JJ)J", (void *) Java_io_legere_pdfiumandroid_PdfDocument_nativeGetFirstChildBookmark},
- {"nativeGetSiblingBookmark", "(JJ)J", (void *) Java_io_legere_pdfiumandroid_PdfDocument_nativeGetSiblingBookmark},
- {"nativeGetBookmarkDestIndex", "(JJ)J", (void *) Java_io_legere_pdfiumandroid_PdfDocument_nativeGetBookmarkDestIndex},
- {"nativeLoadTextPage", "(JJ)J", (void *) Java_io_legere_pdfiumandroid_PdfDocument_nativeLoadTextPage},
- {"nativeGetBookmarkTitle", "(J)Ljava/lang/String;", (void *) Java_io_legere_pdfiumandroid_PdfDocument_nativeGetBookmarkTitle},
- {"nativeSaveAsCopy", "(JLio/legere/pdfiumandroid/PdfWriteCallback;I)Z", (void *) Java_io_legere_pdfiumandroid_PdfDocument_nativeSaveAsCopy},
- {"nativeGetPageCharCounts", "(J)[I", (void *) Java_io_legere_pdfiumandroid_PdfDocument_nativeGetPageCharCounts},
- {"nativeRenderPagesWithMatrix", "([JJII[F[FZZII)V", (void *) Java_io_legere_pdfiumandroid_PdfDocument_nativeRenderPagesWithMatrix},
- {"nativeRenderPagesSurfaceWithMatrix", "([JLandroid/view/Surface;[F[FZZII)Z", (void *) Java_io_legere_pdfiumandroid_PdfDocument_nativeRenderPagesSurfaceWithMatrix},
-};
-
-static const JNINativeMethod findResultMethods[] = {
- {"nativeFindNext", "(J)Z", (void *) Java_io_legere_pdfiumandroid_FindResult_nativeFindNext},
- {"nativeFindPrev", "(J)Z", (void *) Java_io_legere_pdfiumandroid_FindResult_nativeFindPrev},
- {"nativeGetSchResultIndex", "(J)I", (void *) Java_io_legere_pdfiumandroid_FindResult_nativeGetSchResultIndex},
- {"nativeGetSchCount", "(J)I", (void *) Java_io_legere_pdfiumandroid_FindResult_nativeGetSchCount},
- {"nativeCloseFind", "(J)V", (void *) Java_io_legere_pdfiumandroid_FindResult_nativeCloseFind},
-
-};
-
-static const JNINativeMethod pageLinkMethods[] = {
- {"nativeClosePageLink", "(J)V", (void *) Java_io_legere_pdfiumandroid_PdfPageLink_nativeClosePageLink},
- {"nativeCountWebLinks", "(J)I", (void *) Java_io_legere_pdfiumandroid_PdfPageLink_nativeCountWebLinks},
- {"nativeGetURL", "(JII[B)I", (void *) Java_io_legere_pdfiumandroid_PdfPageLink_nativeGetURL},
- {"nativeCountRects", "(JI)I", (void *) Java_io_legere_pdfiumandroid_PdfPageLink_nativeCountRects},
- {"nativeGetRect", "(JII)[F", (void *) Java_io_legere_pdfiumandroid_PdfPageLink_nativeGetRect},
- {"nativeGetTextRange", "(JI)[I", (void *) Java_io_legere_pdfiumandroid_PdfPageLink_nativeGetTextRange},
-
-};
-
-extern "C"
-JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) {
- javaVm = vm;
-
- JNIEnv* env;
- if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) {
- return JNI_ERR;
- }
-
- jclass nativeSourceBridge = env->FindClass("io/legere/pdfiumandroid/util/PdfiumNativeSourceBridge");
- if (nativeSourceBridge == nullptr) return JNI_ERR;
-
- if ((dataBuffer = env->GetFieldID(nativeSourceBridge, "buffer", "[B")) == nullptr) {
- return JNI_ERR;
- }
-
- if ((readMethod = env->GetMethodID(nativeSourceBridge, "read", "(JJ)I")) == nullptr) {
- return JNI_ERR;
- }
-
- jclass clazz = env->FindClass("io/legere/pdfiumandroid/PdfiumCore"); // Replace with your class name
- if (clazz == nullptr) {
- return -1;
- }
-
- if (env->RegisterNatives(clazz, coreMethods, sizeof(coreMethods) / sizeof(coreMethods[0])) < 0) {
- return -1;
- }
-
- clazz = env->FindClass("io/legere/pdfiumandroid/PdfPage"); // Replace with your class name
- if (clazz == nullptr) {
- return -1;
- }
-
- if (env->RegisterNatives(clazz, pageMethods, sizeof(pageMethods) / sizeof(pageMethods[0])) < 0) {
- return -1;
- }
-
- clazz = env->FindClass("io/legere/pdfiumandroid/PdfTextPage"); // Replace with your class name
- if (clazz == nullptr) {
- return -1;
- }
-
- if (env->RegisterNatives(clazz, textPageMethods, sizeof(textPageMethods) / sizeof(textPageMethods[0])) < 0) {
- return -1;
- }
-
- clazz = env->FindClass("io/legere/pdfiumandroid/PdfDocument"); // Replace with your class name
- if (clazz == nullptr) {
- return -1;
- }
-
- if (env->RegisterNatives(clazz, documentMethods, sizeof(documentMethods) / sizeof(documentMethods[0])) < 0) {
- return -1;
- }
-
- clazz = env->FindClass("io/legere/pdfiumandroid/FindResult"); // Replace with your class name
- if (clazz == nullptr) {
- return -1;
- }
-
- if (env->RegisterNatives(clazz, findResultMethods, sizeof(findResultMethods) / sizeof(findResultMethods[0])) < 0) {
- return -1;
- }
-
- clazz = env->FindClass("io/legere/pdfiumandroid/PdfPageLink"); // Replace with your class name
- if (clazz == nullptr) {
- return -1;
- }
-
- if (env->RegisterNatives(clazz, pageLinkMethods, sizeof(pageLinkMethods) / sizeof(pageLinkMethods[0])) < 0) {
- return -1;
- }
-
- return JNI_VERSION_1_6;
-}
-
-void raise_java_exception(JNIEnv *pEnv, std::exception &exception) {
- jclass exClass;
- char const *className = "java/lang/NoClassDefFoundError";
-
- exClass = pEnv->FindClass( className );
- if (exClass == nullptr) {
- handleUnexpected(pEnv, className );
- } else {
- pEnv->ThrowNew( exClass, exception.what());
- }
-}
-
-void raise_java_invalid_arg_exception(JNIEnv *pEnv, std::invalid_argument &argument) {
- jclass exClass;
- char const *className = "java/lang/IllegalArgumentException";
-
- exClass = pEnv->FindClass( className );
- if (exClass == nullptr) {
- handleUnexpected(pEnv, className );
- } else {
- pEnv->ThrowNew( exClass, argument.what());
- }
-}
-
-void raise_java_runtime_exception(JNIEnv *pEnv, std::runtime_error &error) {
- jclass exClass;
- char const *className = "java/lang/RuntimeException";
-
- exClass = pEnv->FindClass( className );
- if (exClass == nullptr) {
- handleUnexpected(pEnv, className );
- } else {
- pEnv->ThrowNew( exClass, error.what());
- }
-}
-
-void raise_java_oom_exception(JNIEnv *pEnv, std::bad_alloc &alloc) {
- jclass exClass;
- char const *className = "java/lang/OutOfMemoryError";
-
- exClass = pEnv->FindClass( className );
- if (exClass == nullptr) {
- handleUnexpected(pEnv, className );
- } else {
- pEnv->ThrowNew( exClass, alloc.what());
- }
-}
-
-void handleUnexpected(JNIEnv *pEnv, char const *name) {
- LOGE("Unable to find class %s", name);
- pEnv->ExceptionClear();
-}
diff --git a/pdfiumandroid/src/main/cpp/util.h b/pdfiumandroid/src/main/cpp/util.h
deleted file mode 100644
index 1b83ddc..0000000
--- a/pdfiumandroid/src/main/cpp/util.h
+++ /dev/null
@@ -1,23 +0,0 @@
-//
-// Created by John Gray on 6/6/23.
-//
-
-#ifndef PDFIUMANDROIDKT_UTIL_H
-#define PDFIUMANDROIDKT_UTIL_H
-
-#include
-extern "C" {
-#include