diff --git a/build.gradle b/build.gradle index 49863608..395de793 100644 --- a/build.gradle +++ b/build.gradle @@ -1,17 +1,19 @@ buildscript { repositories { - jcenter() + mavenCentral() google() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.3' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.1' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' + classpath libs.gradle +// classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.1' +// classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' } } apply plugin: 'com.android.library' +apply plugin: 'maven-publish' + ext { bintrayRepo = 'maven' @@ -38,38 +40,77 @@ ext { } android { - compileSdkVersion 26 + namespace "com.shockwave.pdfium" + compileSdk 33 defaultConfig { - minSdkVersion 14 - targetSdkVersion 26 + minSdkVersion 21 + targetSdkVersion 33 versionCode 1 versionName "1.9.0" } buildTypes { release { - minifyEnabled false + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + debug { + testCoverageEnabled true + manifestPlaceholders = [crashlyticsEnabled: false] + } + qa { + initWith debug + minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets{ main { - jni.srcDirs = [] jniLibs.srcDir 'src/main/libs' } } } - -repositories { - google() - jcenter() -} +// +//repositories { +// google() +//// jcenter() +//} dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:support-v4:26.1.0' + implementation libs.androidx.legacy.support.v4 + implementation libs.androidx.collection +} + +subprojects { + tasks.withType(Javadoc).configureEach { enabled = false } +} + + +//apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' +//apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' + +publishing { + publications { + pdfium(MavenPublication) { + groupId 'com.agora_net' + artifactId 'pdfium' + version '1.1.725' // + getCommitCount() + artifact("$buildDir/outputs/aar/PdfiumAndroid-release.aar") + } + } + repositories { + maven { +// url "/var/www/maven/repository/" + url = "$buildDir/repo" + } + } } -apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' -apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' +tasks.withType(Javadoc).configureEach { + failOnError false + options.addStringOption('Xdoclint:none', '-quiet') + options.addStringOption('encoding', 'UTF-8') + options.addStringOption('charSet', 'UTF-8') +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..5465fec0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +android.enableJetifier=true +android.useAndroidX=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7d202716..eba178d4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Jun 06 19:49:00 CEST 2017 +#Sun May 10 14:49:34 EDT 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip diff --git a/src/main/java/com/shockwave/pdfium/PdfDocument.java b/src/main/java/com/shockwave/pdfium/PdfDocument.java index b5306a67..5d92a8e0 100644 --- a/src/main/java/com/shockwave/pdfium/PdfDocument.java +++ b/src/main/java/com/shockwave/pdfium/PdfDocument.java @@ -2,7 +2,7 @@ import android.graphics.RectF; import android.os.ParcelFileDescriptor; -import android.support.v4.util.ArrayMap; +import androidx.collection.ArrayMap; import java.util.ArrayList; import java.util.List; @@ -111,4 +111,6 @@ public RectF getBounds() { public boolean hasPage(int index) { return mNativePagesPtr.containsKey(index); } + + /*package*/ final Map mNativeTextPagesPtr = new ArrayMap<>(); } diff --git a/src/main/java/com/shockwave/pdfium/PdfWriteCallback.java b/src/main/java/com/shockwave/pdfium/PdfWriteCallback.java new file mode 100644 index 00000000..7e27416a --- /dev/null +++ b/src/main/java/com/shockwave/pdfium/PdfWriteCallback.java @@ -0,0 +1,5 @@ +package com.shockwave.pdfium; + +public interface PdfWriteCallback { + int WriteBlock(byte[] data); +} diff --git a/src/main/java/com/shockwave/pdfium/PdfiumCore.java b/src/main/java/com/shockwave/pdfium/PdfiumCore.java index 0b2421e6..bd03a8ed 100644 --- a/src/main/java/com/shockwave/pdfium/PdfiumCore.java +++ b/src/main/java/com/shockwave/pdfium/PdfiumCore.java @@ -3,6 +3,7 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.Point; +import android.graphics.PointF; import android.graphics.RectF; import android.os.ParcelFileDescriptor; import android.util.Log; @@ -13,6 +14,8 @@ import java.io.FileDescriptor; import java.io.IOException; import java.lang.reflect.Field; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.util.ArrayList; import java.util.List; @@ -23,10 +26,11 @@ public class PdfiumCore { static { try { - System.loadLibrary("c++_shared"); - System.loadLibrary("modpng"); - System.loadLibrary("modft2"); - System.loadLibrary("modpdfium"); + System.loadLibrary("c++.cr"); + System.loadLibrary("chrome_zlib.cr"); + System.loadLibrary("icui18n.cr"); + System.loadLibrary("icuuc.cr"); + System.loadLibrary("pdfium.cr"); System.loadLibrary("jniPdfium"); } catch (UnsatisfiedLinkError e) { Log.e(TAG, "Native libraries failed to load - " + e); @@ -57,6 +61,15 @@ public class PdfiumCore { private native int nativeGetPageHeightPoint(long pagePtr); + private native double nativeGetFontSize(long pagePtr, int charIndex); + + private native float[] nativeGetPageMediaBox(long pagePtr); + private native float[] nativeGetPageCropBox(long pagePtr); + private native float[] nativeGetPageBleedBox(long pagePtr); + private native float[] nativeGetPageTrimBox(long pagePtr); + private native float[] nativeGetPageArtBox(long pagePtr); + private native float[] nativeGetPageBoundingBox(long pagePtr); + //private native long nativeGetNativeWindow(Surface surface); //private native void nativeRenderPage(long pagePtr, long nativeWindowPtr); private native void nativeRenderPage(long pagePtr, Surface surface, int dpi, @@ -67,7 +80,7 @@ private native void nativeRenderPage(long pagePtr, Surface surface, int dpi, private native void nativeRenderPageBitmap(long pagePtr, Bitmap bitmap, int dpi, int startX, int startY, int drawSizeHor, int drawSizeVer, - boolean renderAnnot); + boolean renderAnnot, boolean textMask); private native String nativeGetDocumentMetaText(long docPtr, String tag); @@ -79,6 +92,26 @@ private native void nativeRenderPageBitmap(long pagePtr, Bitmap bitmap, int dpi, private native long nativeGetBookmarkDestIndex(long docPtr, long bookmarkPtr); + private native long nativeLoadTextPage(long docPtr, long pagePtr); + + private native void nativeCloseTextPage(long pagePtr); + + private native int nativeTextCountChars(long textPagePtr); + + private native int nativeTextGetText(long textPagePtr, int start_index, int count, short[] result); + + private native int nativeTextGetUnicode(long textPagePtr, int index); + + private native double[] nativeTextGetCharBox(long textPagePtr, int index); + + private native int nativeTextGetCharIndexAtPos(long textPagePtr, double x, double y, double xTolerance, double yTolerance); + + private native int nativeTextCountRects(long textPagePtr, int start_index, int count); + + private native double[] nativeTextGetRect(long textPagePtr, int rect_index); + + private native int nativeTextGetBoundedText(long textPagePtr, double left, double top, double right, double bottom, short[] arr); + private native Size nativeGetPageSizeByIndex(long docPtr, int pageIndex, int dpi); private native long[] nativeGetPageLinks(long pagePtr); @@ -92,6 +125,10 @@ private native void nativeRenderPageBitmap(long pagePtr, Bitmap bitmap, int dpi, private native Point nativePageCoordsToDevice(long pagePtr, int startX, int startY, int sizeX, int sizeY, int rotate, double pageX, double pageY); + private native PointF nativeDeviceCoordsToPage(long pagePtr, int startX, int startY, int sizeX, + int sizeY, int rotate, int deviceX, int deviceY); + + private native boolean nativeSaveAsCopy(long docPtr, PdfWriteCallback callback); /* synchronize native methods */ private static final Object lock = new Object(); @@ -119,7 +156,7 @@ public static int getNumFd(ParcelFileDescriptor fdObj) { /** Context needed to get screen density */ public PdfiumCore(Context ctx) { mCurrentDpi = ctx.getResources().getDisplayMetrics().densityDpi; - Log.d(TAG, "Starting PdfiumAndroid " + BuildConfig.VERSION_NAME); + Log.d(TAG, "Starting PdfiumAndroid " + BuildConfig.BUILD_TYPE); } /** Create new document from file */ @@ -161,15 +198,30 @@ public int getPageCount(PdfDocument doc) { /** Open page and store native pointer in {@link PdfDocument} */ public long openPage(PdfDocument doc, int pageIndex) { - long pagePtr; synchronized (lock) { - pagePtr = nativeLoadPage(doc.mNativeDocPtr, pageIndex); - doc.mNativePagesPtr.put(pageIndex, pagePtr); + if (doc.mNativePagesPtr == null) { + return -1; + } + Long pagePtr = doc.mNativePagesPtr.get(pageIndex); + if (pagePtr == null) { + pagePtr = nativeLoadPage(doc.mNativeDocPtr, pageIndex); + doc.mNativePagesPtr.put(pageIndex, pagePtr); + } return pagePtr; } } + public void closePage(PdfDocument doc, int pageIndex) { + synchronized (lock) { + final Long pagePtr = doc.mNativePagesPtr.get(pageIndex); + if (pagePtr != null) { + nativeClosePage(pagePtr); + doc.mNativePagesPtr.remove(pageIndex); + } + } + } + /** Open range of pages and store native pointers in {@link PdfDocument} */ public long[] openPage(PdfDocument doc, int fromIndex, int toIndex) { long[] pagesPtr; @@ -242,6 +294,152 @@ public int getPageHeightPoint(PdfDocument doc, int index) { } } + /** + * Get character font size in PostScript points (1/72th of an inch).
+ * This method requires page to be opened. + */ + public double getFontSize(PdfDocument doc, int pageIndex, int charIndex) { + synchronized (lock) { + Long pagePtr; + if ((pagePtr = doc.mNativePagesPtr.get(pageIndex)) != null) { + return nativeGetFontSize(pagePtr, charIndex); + } + return 0.0; + } + } + + /** + * Get page height in PostScript points (1/72th of an inch).
+ * This method requires page to be opened. + */ + public RectF getPageCropBox(PdfDocument doc, int index) { + synchronized (lock) { + Long pagePtr; + if ((pagePtr = doc.mNativePagesPtr.get(index)) != null) { + float[] o = nativeGetPageCropBox(pagePtr); + + RectF r = new RectF(); + r.left = o[0]; + r.top = o[1]; + r.right = o[2]; + r.bottom = o[3]; + + return r; + } + return new RectF(); + } + } + + /** + * Get page height in PostScript points (1/72th of an inch).
+ * This method requires page to be opened. + */ + public RectF getPageMediaBox(PdfDocument doc, int index) { + synchronized (lock) { + Long pagePtr; + if ((pagePtr = doc.mNativePagesPtr.get(index)) != null) { + float[] o = nativeGetPageMediaBox(pagePtr); + + RectF r = new RectF(); + r.left = o[0]; + r.top = o[1]; + r.right = o[2]; + r.bottom = o[3]; + + return r; + } + return new RectF(); + } + } + + /** + * Get page height in PostScript points (1/72th of an inch).
+ * This method requires page to be opened. + */ + public RectF getPageBleedBox(PdfDocument doc, int index) { + synchronized (lock) { + Long pagePtr; + if ((pagePtr = doc.mNativePagesPtr.get(index)) != null) { + float[] o = nativeGetPageBleedBox(pagePtr); + + RectF r = new RectF(); + r.left = o[0]; + r.top = o[1]; + r.right = o[2]; + r.bottom = o[3]; + + return r; + } + return new RectF(); + } + } + + /** + * Get page height in PostScript points (1/72th of an inch).
+ * This method requires page to be opened. + */ + public RectF getPageTrimBox(PdfDocument doc, int index) { + synchronized (lock) { + Long pagePtr; + if ((pagePtr = doc.mNativePagesPtr.get(index)) != null) { + float[] o = nativeGetPageTrimBox(pagePtr); + + RectF r = new RectF(); + r.left = o[0]; + r.top = o[1]; + r.right = o[2]; + r.bottom = o[3]; + + return r; + } + return new RectF(); + } + } + + /** + * Get page height in PostScript points (1/72th of an inch).
+ * This method requires page to be opened. + */ + public RectF getPageArtBox(PdfDocument doc, int index) { + synchronized (lock) { + Long pagePtr; + if ((pagePtr = doc.mNativePagesPtr.get(index)) != null) { + float[] o = nativeGetPageArtBox(pagePtr); + + RectF r = new RectF(); + r.left = o[0]; + r.top = o[1]; + r.right = o[2]; + r.bottom = o[3]; + + return r; + } + return new RectF(); + } + } + + /** + * Get page height in PostScript points (1/72th of an inch).
+ * This method requires page to be opened. + */ + public RectF getPageBoundingBox(PdfDocument doc, int index) { + synchronized (lock) { + Long pagePtr; + if ((pagePtr = doc.mNativePagesPtr.get(index)) != null) { + float[] o = nativeGetPageBoundingBox(pagePtr); + + RectF r = new RectF(); + r.left = o[0]; + r.top = o[1]; + r.right = o[2]; + r.bottom = o[3]; + + return r; + } + return new RectF(); + } + } + /** * Get size of page in pixels.
* This method does not require given page to be opened. @@ -294,8 +492,8 @@ public void renderPage(PdfDocument doc, Surface surface, int pageIndex, * */ public void renderPageBitmap(PdfDocument doc, Bitmap bitmap, int pageIndex, - int startX, int startY, int drawSizeX, int drawSizeY) { - renderPageBitmap(doc, bitmap, pageIndex, startX, startY, drawSizeX, drawSizeY, false); + int startX, int startY, int drawSizeX, int drawSizeY, boolean textMask) { + renderPageBitmap(doc, bitmap, pageIndex, startX, startY, drawSizeX, drawSizeY, false, textMask); } /** @@ -306,11 +504,11 @@ public void renderPageBitmap(PdfDocument doc, Bitmap bitmap, int pageIndex, */ public void renderPageBitmap(PdfDocument doc, Bitmap bitmap, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY, - boolean renderAnnot) { + boolean renderAnnot, boolean textMask) { synchronized (lock) { try { nativeRenderPageBitmap(doc.mNativePagesPtr.get(pageIndex), bitmap, mCurrentDpi, - startX, startY, drawSizeX, drawSizeY, renderAnnot); + startX, startY, drawSizeX, drawSizeY, renderAnnot, textMask); } catch (NullPointerException e) { Log.e(TAG, "mContext may be null"); e.printStackTrace(); @@ -324,10 +522,12 @@ public void renderPageBitmap(PdfDocument doc, Bitmap bitmap, int pageIndex, /** Release native resources and opened file */ public void closeDocument(PdfDocument doc) { synchronized (lock) { - for (Integer index : doc.mNativePagesPtr.keySet()) { - nativeClosePage(doc.mNativePagesPtr.get(index)); + if (doc.mNativePagesPtr != null) { + for (Integer index : doc.mNativePagesPtr.keySet()) { + nativeClosePage(doc.mNativePagesPtr.get(index)); + } + doc.mNativePagesPtr.clear(); } - doc.mNativePagesPtr.clear(); nativeCloseDocument(doc.mNativeDocPtr); @@ -365,13 +565,13 @@ public List getTableOfContents(PdfDocument doc) { List topLevel = new ArrayList<>(); Long first = nativeGetFirstChildBookmark(doc.mNativeDocPtr, null); if (first != null) { - recursiveGetBookmark(topLevel, doc, first); + recursiveGetBookmark(topLevel, doc, first, 1); } return topLevel; } } - private void recursiveGetBookmark(List tree, PdfDocument doc, long bookmarkPtr) { + private void recursiveGetBookmark(List tree, PdfDocument doc, long bookmarkPtr, long level) { PdfDocument.Bookmark bookmark = new PdfDocument.Bookmark(); bookmark.mNativePtr = bookmarkPtr; bookmark.title = nativeGetBookmarkTitle(bookmarkPtr); @@ -379,13 +579,13 @@ private void recursiveGetBookmark(List tree, PdfDocument d tree.add(bookmark); Long child = nativeGetFirstChildBookmark(doc.mNativeDocPtr, bookmarkPtr); - if (child != null) { - recursiveGetBookmark(bookmark.getChildren(), doc, child); + if (child != null && level < 16) { + recursiveGetBookmark(bookmark.getChildren(), doc, child, level++); } Long sibling = nativeGetSiblingBookmark(doc.mNativeDocPtr, bookmarkPtr); - if (sibling != null) { - recursiveGetBookmark(tree, doc, sibling); + if (sibling != null && level < 16) { + recursiveGetBookmark(tree, doc, sibling, level++); } } @@ -434,8 +634,29 @@ public Point mapPageCoordsToDevice(PdfDocument doc, int pageIndex, int startX, i } /** + * Map device screen coordinates to page coordinates + * + * @param doc pdf document + * @param pageIndex index of page + * @param startX left pixel position of the display area in device coordinates + * @param startY top pixel position of the display area in device coordinates + * @param sizeX horizontal size (in pixels) for displaying the page + * @param sizeY vertical size (in pixels) for displaying the page + * @param rotate page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), + * 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise) + * @param deviceX X value in page coordinates + * @param deviceY Y value in page coordinate * @return mapped coordinates + */ + public PointF mapDeviceCoordsToPage(PdfDocument doc, int pageIndex, int startX, int startY, int sizeX, + int sizeY, int rotate, int deviceX, int deviceY) { + long pagePtr = doc.mNativePagesPtr.get(pageIndex); + return nativeDeviceCoordsToPage(pagePtr, startX, startY, sizeX, sizeY, rotate, deviceX, deviceY); + } + + /** * @see PdfiumCore#mapPageCoordsToDevice(PdfDocument, int, int, int, int, int, int, double, double) + * @return mapped coordinates */ public RectF mapRectToDevice(PdfDocument doc, int pageIndex, int startX, int startY, int sizeX, int sizeY, int rotate, RectF coords) { @@ -446,4 +667,240 @@ public RectF mapRectToDevice(PdfDocument doc, int pageIndex, int startX, int sta coords.right, coords.bottom); return new RectF(leftTop.x, leftTop.y, rightBottom.x, rightBottom.y); } + + /** + * @see PdfiumCore#mapDeviceCoordsToPage(PdfDocument, int, int, int, int, int, int, int, int) + * @return mapped coordinates + */ + public RectF mapRectToPage(PdfDocument doc, int pageIndex, int startX, int startY, int sizeX, + int sizeY, int rotate, RectF coords) { + + PointF leftTop = mapDeviceCoordsToPage(doc, pageIndex, startX, startY, sizeX, sizeY, rotate, + (int)coords.left, (int)coords.top); + PointF rightBottom = mapDeviceCoordsToPage(doc, pageIndex, startX, startY, sizeX, sizeY, rotate, + (int)coords.right, (int)coords.bottom); + return new RectF(leftTop.x, leftTop.y, rightBottom.x, rightBottom.y); + } + + public long openTextPage(PdfDocument doc, int pageIndex) { + synchronized (lock) { + long page = openPage(doc, pageIndex); + Long textPagePtr = doc.mNativeTextPagesPtr.get(pageIndex); + if (textPagePtr == null) { + textPagePtr = nativeLoadTextPage(doc.mNativeDocPtr, page); + doc.mNativeTextPagesPtr.put(pageIndex, textPagePtr); + } + return textPagePtr; + } + + } + + public void closeTextPage(PdfDocument doc, int pageIndex) { + synchronized (lock) { + final Long nativeLoadTextPage = doc.mNativeTextPagesPtr.get(pageIndex); + if (nativeLoadTextPage != null) { + nativeCloseTextPage(nativeLoadTextPage); + doc.mNativeTextPagesPtr.remove(pageIndex); + } + } + } + + public long[] openTextPage(PdfDocument doc, int fromIndex, int toIndex) { + long[] textPagesPtr; + synchronized (lock) { + textPagesPtr = nativeLoadPages(doc.mNativeDocPtr, fromIndex, toIndex); + int pageIndex = fromIndex; + for (long page : textPagesPtr) { + if (pageIndex > toIndex) break; + doc.mNativeTextPagesPtr.put(pageIndex, page); + pageIndex++; + } + + return textPagesPtr; + } + } + + public int textPageCountChars(PdfDocument doc, int textPageIndex) { + synchronized (lock) { + try { + return nativeTextCountChars(doc.mNativeTextPagesPtr.get(textPageIndex)); + } catch (NullPointerException e) { + Log.e(TAG, "mContext may be null"); + e.printStackTrace(); + } catch (Exception e) { + Log.e(TAG, "Exception throw from native"); + e.printStackTrace(); + } + } + return -1; + } + + public String textPageGetText(PdfDocument doc, int textPageIndex, int startIndex, int length) { + synchronized (lock) { + try { + short[] buf = new short[length+1]; + + int r = nativeTextGetText(doc.mNativeTextPagesPtr.get(textPageIndex), startIndex, length, buf); + + byte[] bytes = new byte[(r-1)*2]; + ByteBuffer bb = ByteBuffer.wrap(bytes); + bb.order(ByteOrder.LITTLE_ENDIAN); + + for (int i = 0; i < r-1; i++) { + short s = buf[i]; + bb.putShort(s); + } + return new String(bytes, "UTF-16LE"); + } catch (NullPointerException e) { + Log.e(TAG, "mContext may be null"); + e.printStackTrace(); + } catch (Exception e) { + Log.e(TAG, "Exception throw from native"); + e.printStackTrace(); + } + return null; + } + } + + + + + + + + + + + public char textPageGetUnicode(PdfDocument doc, int textPageIndex, int index) { + synchronized (lock) { + try { + return (char)nativeTextGetUnicode(doc.mNativeTextPagesPtr.get(textPageIndex), index); + } catch (NullPointerException e) { + Log.e(TAG, "mContext may be null"); + e.printStackTrace(); + } catch (Exception e) { + Log.e(TAG, "Exception throw from native"); + e.printStackTrace(); + } + } + return 0; + } + + public RectF textPageGetCharBox(PdfDocument doc, int textPageIndex, int index) { + synchronized (lock) { + try { + double[] o = nativeTextGetCharBox(doc.mNativeTextPagesPtr.get(textPageIndex), index); + RectF r = new RectF(); + r.left = (float)o[0]; + r.right = (float)o[1]; + r.bottom = (float)o[2]; + r.top = (float)o[3]; + return r; + } catch (NullPointerException e) { + Log.e(TAG, "mContext may be null"); + e.printStackTrace(); + } catch (Exception e) { + Log.e(TAG, "Exception throw from native"); + e.printStackTrace(); + } + } + return null; + } + + public double textPageGetFontSize(PdfDocument doc, int textPageIndex, int index) { + synchronized (lock) { + try { + return nativeGetFontSize(doc.mNativeTextPagesPtr.get(textPageIndex), index); + } catch (NullPointerException e) { + Log.e(TAG, "mContext may be null"); + e.printStackTrace(); + } catch (Exception e) { + Log.e(TAG, "Exception throw from native"); + e.printStackTrace(); + } + } + return 0.0; + } + + public int textPageGetCharIndexAtPos(PdfDocument doc, int textPageIndex, double x, double y, double xTolerance, double yTolerance) { + synchronized (lock) { + try { + return nativeTextGetCharIndexAtPos(doc.mNativeTextPagesPtr.get(textPageIndex), x, y, xTolerance, yTolerance); + } catch (NullPointerException e) { + Log.e(TAG, "mContext may be null"); + e.printStackTrace(); + } catch (Exception e) { + Log.e(TAG, "Exception throw from native"); + e.printStackTrace(); + } + } + return -1; + } + + public int textPageCountRects(PdfDocument doc, int textPageIndex, int start_index, int count) { + synchronized (lock) { + try { + return nativeTextCountRects(doc.mNativeTextPagesPtr.get(textPageIndex), start_index, count); + } catch (NullPointerException e) { + Log.e(TAG, "mContext may be null"); + e.printStackTrace(); + } catch (Exception e) { + Log.e(TAG, "Exception throw from native"); + e.printStackTrace(); + } + } + return -1; + } + + public RectF textPageGetRect(PdfDocument doc, int textPageIndex, int rect_index) { + synchronized (lock) { + try { + double[] o = nativeTextGetRect(doc.mNativeTextPagesPtr.get(textPageIndex), rect_index); + RectF r = new RectF(); + r.left = (float)o[0]; + r.top = (float)o[1]; + r.right = (float)o[2]; + r.bottom = (float)o[3]; + return r; + } catch (NullPointerException e) { + Log.e(TAG, "mContext may be null"); + e.printStackTrace(); + } catch (Exception e) { + Log.e(TAG, "Exception throw from native"); + e.printStackTrace(); + } + } + return null; + } + + public String textPageGetBoundedText(PdfDocument doc, int textPageIndex, RectF rect, int length) { + synchronized (lock) { + try { + short[] buf = new short[length+1]; + + int r = nativeTextGetBoundedText(doc.mNativeTextPagesPtr.get(textPageIndex), rect.left, rect.top, rect.right, rect.bottom, buf); + + byte[] bytes = new byte[(r-1)*2]; + ByteBuffer bb = ByteBuffer.wrap(bytes); + bb.order(ByteOrder.LITTLE_ENDIAN); + + for (int i = 0; i < r-1; i++) { + short s = buf[i]; + bb.putShort(s); + } + return new String(bytes, "UTF-16LE"); + } catch (NullPointerException e) { + Log.e(TAG, "mContext may be null"); + e.printStackTrace(); + } catch (Exception e) { + Log.e(TAG, "Exception throw from native"); + e.printStackTrace(); + } + return null; + } + } + + public boolean saveAsCopy(PdfDocument doc, PdfWriteCallback callback) { + return nativeSaveAsCopy(doc.mNativeDocPtr, callback); + } } diff --git a/src/main/jni/Android.mk b/src/main/jni/Android.mk index 131211ee..5c05b006 100644 --- a/src/main/jni/Android.mk +++ b/src/main/jni/Android.mk @@ -6,7 +6,7 @@ LOCAL_MODULE := aospPdfium ARCH_PATH = $(TARGET_ARCH_ABI) -LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libmodpdfium.so +LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libpdfium.cr.so include $(PREBUILT_SHARED_LIBRARY) @@ -14,23 +14,31 @@ include $(PREBUILT_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := libmodc++_shared -LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libc++_shared.so +LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libc++.cr.so include $(PREBUILT_SHARED_LIBRARY) -#libmodft2 +#libchrome_zlib include $(CLEAR_VARS) -LOCAL_MODULE := libmodft2 +LOCAL_MODULE := libchrome_zlib -LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libmodft2.so +LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libchrome_zlib.cr.so include $(PREBUILT_SHARED_LIBRARY) -#libmodpng +#libicui18n include $(CLEAR_VARS) -LOCAL_MODULE := libmodpng +LOCAL_MODULE := libicui18n -LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libmodpng.so +LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libicui18n.cr.so + +include $(PREBUILT_SHARED_LIBRARY) + +#libicuuc +include $(CLEAR_VARS) +LOCAL_MODULE := libicuuc + +LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libicuuc.cr.so include $(PREBUILT_SHARED_LIBRARY) diff --git a/src/main/jni/Application.mk b/src/main/jni/Application.mk index df5c5088..d922f120 100644 --- a/src/main/jni/Application.mk +++ b/src/main/jni/Application.mk @@ -6,7 +6,5 @@ APP_PLATFORM = android-14 APP_ABI := armeabi-v7a \ arm64-v8a \ - mips \ - mips64 \ x86 \ - x86_64 \ No newline at end of file + x86_64 diff --git a/src/main/jni/include/fpdf_dataavail.h b/src/main/jni/include/fpdf_dataavail.h index 0f8ff7d6..ad70b7f4 100644 --- a/src/main/jni/include/fpdf_dataavail.h +++ b/src/main/jni/include/fpdf_dataavail.h @@ -7,8 +7,9 @@ #ifndef PUBLIC_FPDF_DATAAVAIL_H_ #define PUBLIC_FPDF_DATAAVAIL_H_ -#include // For size_t. +#include +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" #define PDF_LINEARIZATION_UNKNOWN -1 @@ -26,248 +27,179 @@ #ifdef __cplusplus extern "C" { -#endif +#endif // __cplusplus -/** - * Interface: FX_FILEAVAIL - * Interface for checking whether the section of the file is available. - */ +// Interface for checking whether sections of the file are available. typedef struct _FX_FILEAVAIL { - /** - * Version number of the interface. Currently must be 1. - */ + // Version number of the interface. Must be 1. int version; - /** - * Method: IsDataAvail - * Report whether the specified data section is available. A section is - * available only if all bytes in the section is available. - * Interface Version: - * 1 - * Implementation Required: - * Yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * offset - The offset of the data section in the file. - * size - The size of the data section - * Return Value: - * true means the specified data section is available. - * Comments: - * Called by Foxit SDK to check whether the data section is ready. - */ - FPDF_BOOL (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, size_t offset, size_t size); + // Reports if the specified data section is currently available. A section is + // available if all bytes in the section are available. + // + // Interface Version: 1 + // Implementation Required: Yes + // + // pThis - pointer to the interface structure. + // offset - the offset of the data section in the file. + // size - the size of the data section. + // + // Returns true if the specified data section at |offset| of |size| + // is available. + FPDF_BOOL (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, + size_t offset, + size_t size); } FX_FILEAVAIL; - typedef void* FPDF_AVAIL; -/** -* Function: FPDFAvail_Create -* Create a document availability provider. -* -* Parameters: -* file_avail - Pointer to file availability interface to check -* availability of file data. -* file - Pointer to a file access interface for reading data -* from file. -* Return value: -* A handle to the document availability provider. NULL for error. -* Comments: -* Application must call FPDFAvail_Destroy when done with the -* availability provider. -*/ -DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, - FPDF_FILEACCESS* file); - -/** -* Function: FPDFAvail_Destroy -* Destroy a document availibity provider. -* -* Parameters: -* avail - Handle to document availability provider returned by -* FPDFAvail_Create -* Return Value: -* None. -*/ -DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail); - -/** - * Interface: FX_DOWNLOADHINTS - * Download hints interface. Used to receive hints for further - * downloading. - */ +// Create a document availability provider. +// +// file_avail - pointer to file availability interface. +// file - pointer to a file access interface. +// +// Returns a handle to the document availability provider, or NULL on error. +// +// FPDFAvail_Destroy() must be called when done with the availability provider. +FPDF_EXPORT FPDF_AVAIL FPDF_CALLCONV FPDFAvail_Create(FX_FILEAVAIL* file_avail, + FPDF_FILEACCESS* file); + +// Destroy the |avail| document availability provider. +// +// avail - handle to document availability provider to be destroyed. +FPDF_EXPORT void FPDF_CALLCONV FPDFAvail_Destroy(FPDF_AVAIL avail); + +// Download hints interface. Used to receive hints for further downloading. typedef struct _FX_DOWNLOADHINTS { - /** - * Version number of the interface. Currently must be 1. - */ + // Version number of the interface. Must be 1. int version; - /** - * Method: AddSegment - * Add a section to be downloaded. - * Interface Version: - * 1 - * Implementation Required: - * Yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * offset - The offset of the hint reported to be downloaded. - * size - The size of the hint reported to be downloaded. - * Return Value: - * None. - * Comments: - * Called by Foxit SDK to report some downloading hints for download - * manager. - * The position and size of section may be not accurate, part of the - * section might be already available. - * The download manager must deal with that to maximize download - * efficiency. - */ + // Add a section to be downloaded. + // + // Interface Version: 1 + // Implementation Required: Yes + // + // pThis - pointer to the interface structure. + // offset - the offset of the hint reported to be downloaded. + // size - the size of the hint reported to be downloaded. + // + // The |offset| and |size| of the section may not be unique. Part of the + // section might be already available. The download manager must deal with + // overlapping sections. void (*AddSegment)(struct _FX_DOWNLOADHINTS* pThis, size_t offset, size_t size); } FX_DOWNLOADHINTS; -/** -* Function: FPDFAvail_IsDocAvail -* Check whether the document is ready for loading, if not, get -* download hints. -* -* Parameters: -* avail - Handle to document availability provider returned by -* FPDFAvail_Create -* hints - Pointer to a download hints interface, receiving -* generated hints -* Return value: -* PDF_DATA_ERROR: A common error is returned. It can't tell -* whehter data are availabe or not. -* PDF_DATA_NOTAVAIL: Data are not yet available. -* PDF_DATA_AVAIL: Data are available. -* Comments: -* Applications should call this function whenever new data arrived, -* and process all the generated download hints if any, until the -* function returns PDF_DATA_ERROR or PDF_DATA_AVAIL. Then -* applications can call FPDFAvail_GetDocument() to get a document -* handle. -*/ -DLLEXPORT int STDCALL -FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints); - -/** -* Function: FPDFAvail_GetDocument -* Get document from the availability provider. -* -* Parameters: -* avail - Handle to document availability provider returned by -* FPDFAvail_Create -* password - Optional password for decrypting the PDF file. -* Return value: -* Handle to the document. -* Comments: -* After FPDFAvail_IsDocAvail() returns TRUE, the application should -* call this function to -* get the document handle. To close the document, use -* FPDF_CloseDocument function. -*/ -DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail, - FPDF_BYTESTRING password); - -/** -* Function: FPDFAvail_GetFirstPageNum -* Get page number for the first available page in a linearized PDF -* -* Parameters: -* doc - A document handle returned by FPDFAvail_GetDocument -* Return Value: -* Zero-based index for the first available page. -* Comments: -* For most linearized PDFs, the first available page would be just the -* first page, however, -* some PDFs might make other page to be the first available page. -* For non-linearized PDF, this function will always return zero. -*/ -DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc); - -/** -* Function: FPDFAvail_IsPageAvail -* Check whether a page is ready for loading, if not, get download -* hints. -* -* Parameters: -* avail - Handle to document availability provider returned by -* FPDFAvail_Create -* page_index - Index number of the page. 0 for the first page. -* hints - Pointer to a download hints interface, receiving -* generated hints -* Return value: -* PDF_DATA_ERROR: A common error is returned. It can't tell -* whehter data are availabe or not. -* PDF_DATA_NOTAVAIL: Data are not yet available. -* PDF_DATA_AVAIL: Data are available. -* Comments: -* This function can be called only after FPDFAvail_GetDocument is -* called. Applications should call this function whenever new data -* arrived and process all the generated download hints if any, until -* this function returns PDF_DATA_ERROR or PDF_DATA_AVAIL. Then -* applications can perform page loading. -*/ -DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, - int page_index, - FX_DOWNLOADHINTS* hints); - -/** -* Function: FPDFAvail_ISFormAvail -* Check whether Form data is ready for init, if not, get download -* hints. -* -* Parameters: -* avail - Handle to document availability provider returned by -* FPDFAvail_Create -* hints - Pointer to a download hints interface, receiving -* generated hints -* Return value: -* PDF_FORM_ERROR - A common eror, in general incorrect parameters, -* like 'hints' is nullptr. -* PDF_FORM_NOTAVAIL - data not available -* PDF_FORM_AVAIL - data available -* PDF_FORM_NOTEXIST - no form data -* Comments: -* This function can be called only after FPDFAvail_GetDocument is -* called. -* The application should call this function whenever new data arrived, -* and process all the -* generated download hints if any, until the function returns non-zero -* value. Then the -* application can perform page loading. Recommend to call -* FPDFDOC_InitFormFillEnvironment -* after the function returns non-zero value. -*/ -DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail, - FX_DOWNLOADHINTS* hints); - -/** -* Function: FPDFAvail_IsLinearized -* To check whether a document is Linearized PDF file. -* -* Parameters: -* avail - Handle to document availability provider returned by -* FPDFAvail_Create -* Return value: -* PDF_LINEARIZED is a linearize file. -* PDF_NOT_LINEARIZED is not a linearize file. -* PDF_LINEARIZATION_UNKNOWN doesn't know whether the file is a -*linearize file. -* -* Comments: -* It return PDF_LINEARIZED or PDF_NOT_LINEARIZED as soon as -* we have first 1K data. If the file's size less than 1K, it returns -* PDF_LINEARIZATION_UNKNOWN because there is not enough information to -* tell whether a PDF file is a linearized file or not. -* -*/ -DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail); +// Checks if the document is ready for loading, if not, gets download hints. +// +// avail - handle to document availability provider. +// hints - pointer to a download hints interface. +// +// Returns one of: +// PDF_DATA_ERROR: A common error is returned. Data availability unknown. +// PDF_DATA_NOTAVAIL: Data not yet available. +// PDF_DATA_AVAIL: Data available. +// +// Applications should call this function whenever new data arrives, and process +// all the generated download hints, if any, until the function returns +// |PDF_DATA_ERROR| or |PDF_DATA_AVAIL|. +// if hints is nullptr, the function just check current document availability. +// +// Once all data is available, call FPDFAvail_GetDocument() to get a document +// handle. +FPDF_EXPORT int FPDF_CALLCONV FPDFAvail_IsDocAvail(FPDF_AVAIL avail, + FX_DOWNLOADHINTS* hints); + +// Get document from the availability provider. +// +// avail - handle to document availability provider. +// password - password for decrypting the PDF file. Optional. +// +// Returns a handle to the document. +// +// When FPDFAvail_IsDocAvail() returns TRUE, call FPDFAvail_GetDocument() to +// retrieve the document handle. +// See the comments for FPDF_LoadDocument() regarding the encoding for +// |password|. +FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV +FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password); + +// Get the page number for the first available page in a linearized PDF. +// +// doc - document handle. +// +// Returns the zero-based index for the first available page. +// +// For most linearized PDFs, the first available page will be the first page, +// however, some PDFs might make another page the first available page. +// For non-linearized PDFs, this function will always return zero. +FPDF_EXPORT int FPDF_CALLCONV FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc); + +// Check if |page_index| is ready for loading, if not, get the +// |FX_DOWNLOADHINTS|. +// +// avail - handle to document availability provider. +// page_index - index number of the page. Zero for the first page. +// hints - pointer to a download hints interface. Populated if +// |page_index| is not available. +// +// Returns one of: +// PDF_DATA_ERROR: A common error is returned. Data availability unknown. +// PDF_DATA_NOTAVAIL: Data not yet available. +// PDF_DATA_AVAIL: Data available. +// +// This function can be called only after FPDFAvail_GetDocument() is called. +// Applications should call this function whenever new data arrives and process +// all the generated download |hints|, if any, until this function returns +// |PDF_DATA_ERROR| or |PDF_DATA_AVAIL|. Applications can then perform page +// loading. +// if hints is nullptr, the function just check current availability of +// specified page. +FPDF_EXPORT int FPDF_CALLCONV FPDFAvail_IsPageAvail(FPDF_AVAIL avail, + int page_index, + FX_DOWNLOADHINTS* hints); + +// Check if form data is ready for initialization, if not, get the +// |FX_DOWNLOADHINTS|. +// +// avail - handle to document availability provider. +// hints - pointer to a download hints interface. Populated if form is not +// ready for initialization. +// +// Returns one of: +// PDF_FORM_ERROR: A common eror, in general incorrect parameters. +// PDF_FORM_NOTAVAIL: Data not available. +// PDF_FORM_AVAIL: Data available. +// PDF_FORM_NOTEXIST: No form data. +// +// This function can be called only after FPDFAvail_GetDocument() is called. +// The application should call this function whenever new data arrives and +// process all the generated download |hints|, if any, until the function +// |PDF_FORM_ERROR|, |PDF_FORM_AVAIL| or |PDF_FORM_NOTEXIST|. +// if hints is nullptr, the function just check current form availability. +// +// Applications can then perform page loading. It is recommend to call +// FPDFDOC_InitFormFillEnvironment() when |PDF_FORM_AVAIL| is returned. +FPDF_EXPORT int FPDF_CALLCONV FPDFAvail_IsFormAvail(FPDF_AVAIL avail, + FX_DOWNLOADHINTS* hints); + +// Check whether a document is a linearized PDF. +// +// avail - handle to document availability provider. +// +// Returns one of: +// PDF_LINEARIZED +// PDF_NOT_LINEARIZED +// PDF_LINEARIZATION_UNKNOWN +// +// FPDFAvail_IsLinearized() will return |PDF_LINEARIZED| or |PDF_NOT_LINEARIZED| +// when we have 1k of data. If the files size less than 1k, it returns +// |PDF_LINEARIZATION_UNKNOWN| as there is insufficient information to determine +// if the PDF is linearlized. +FPDF_EXPORT int FPDF_CALLCONV FPDFAvail_IsLinearized(FPDF_AVAIL avail); #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_DATAAVAIL_H_ diff --git a/src/main/jni/include/fpdf_doc.h b/src/main/jni/include/fpdf_doc.h index de05eb3a..565314eb 100644 --- a/src/main/jni/include/fpdf_doc.h +++ b/src/main/jni/include/fpdf_doc.h @@ -7,294 +7,35 @@ #ifndef PUBLIC_FPDF_DOC_H_ #define PUBLIC_FPDF_DOC_H_ +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" -// Exported Functions #ifdef __cplusplus extern "C" { -#endif - -// Function: FPDFBookmark_GetFirstChild -// Get the first child of a bookmark item, or the first top level -// bookmark item. -// Parameters: -// document - Handle to the document. Returned by -// FPDF_LoadDocument or FPDF_LoadMemDocument. -// bookmark - Handle to the current bookmark. Can be NULL if you -// want to get the first top level item. -// Return value: -// Handle to the first child or top level bookmark item. NULL if no -// child or top level bookmark found. -// -DLLEXPORT FPDF_BOOKMARK STDCALL -FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark); +#endif // __cplusplus -// Function: FPDFBookmark_GetNextSibling -// Get next bookmark item at the same level. -// Parameters: -// document - Handle to the document. Returned by -// FPDF_LoadDocument or FPDF_LoadMemDocument. -// bookmark - Handle to the current bookmark. Cannot be NULL. -// Return value: -// Handle to the next bookmark item at the same level. NULL if this is -// the last bookmark at this level. -// -DLLEXPORT FPDF_BOOKMARK STDCALL -FPDFBookmark_GetNextSibling(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark); +// 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 -// Function: FPDFBookmark_GetTitle -// Get title of a bookmark. -// Parameters: -// bookmark - Handle to the bookmark. -// buffer - Buffer for the title. Can be NULL. -// buflen - The length of the buffer in bytes. Can be 0. -// Return value: -// Number of bytes the title consumes, including trailing zeros. -// Comments: -// Regardless of the platform, the title is always in UTF-16LE -// encoding. That means the buffer -// can be treated as an array of WORD (on Intel and compatible CPUs), -// each WORD representing the Unicode of -// a character(some special Unicode may take 2 WORDs).The string is -// followed by two bytes of zero -// indicating the end of the string. -// -// The return value always indicates the number of bytes required for -// the buffer, even if no buffer is specified -// or the buffer size is less then required. In these cases, the buffer -// will not be modified. -// -DLLEXPORT unsigned long STDCALL FPDFBookmark_GetTitle(FPDF_BOOKMARK bookmark, - void* buffer, - unsigned long buflen); - -// Function: FPDFBookmark_Find -// Find a bookmark in the document, using the bookmark title. -// Parameters: -// document - Handle to the document. Returned by -// FPDF_LoadDocument or FPDF_LoadMemDocument. -// title - The UTF-16LE encoded Unicode string for the bookmark -// title to be searched. Can't be NULL. -// Return value: -// Handle to the found bookmark item. NULL if the title can't be found. -// Comments: -// It always returns the first found bookmark if more than one -// bookmarks have the same title. -// -DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document, - FPDF_WIDESTRING title); - -// Function: FPDFBookmark_GetDest -// Get the destination associated with a bookmark item. -// Parameters: -// document - Handle to the document. -// bookmark - Handle to the bookmark. -// Return value: -// Handle to the destination data. NULL if no destination is associated -// with this bookmark. -// -DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document, - FPDF_BOOKMARK bookmark); - -// Function: FPDFBookmark_GetAction -// Get the action associated with a bookmark item. -// Parameters: -// bookmark - Handle to the bookmark. -// Return value: -// Handle to the action data. NULL if no action is associated with this -// bookmark. In this case, the -// application should try FPDFBookmark_GetDest. -// -DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK bookmark); - -#define PDFACTION_UNSUPPORTED 0 // Unsupported action type. -#define PDFACTION_GOTO 1 // Go to a destination within current document. -#define PDFACTION_REMOTEGOTO 2 // Go to a destination within another document. -#define PDFACTION_URI 3 // Universal Resource Identifier, including web - // pages and other Internet based resources. -#define PDFACTION_LAUNCH 4 // Launch an application or open a file. - -// Function: FPDFAction_GetType -// Get type of an action. -// Parameters: -// action - Handle to the action. -// Return value: -// A type number as defined above. -// -DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION action); - -// Function: FPDFAction_GetDest -// Get destination of an action. -// Parameters: -// document - Handle to the document. -// action - Handle to the action. It must be a GOTO or -// REMOTEGOTO action. -// Return value: -// Handle to the destination data. -// Comments: -// In case of remote goto action, the application should first use -// FPDFAction_GetFilePath to -// get file path, then load that particular document, and use its -// document handle to call this -// function. -// -DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, - FPDF_ACTION action); - -// Function: FPDFAction_GetFilePath -// Get file path of a remote goto action. -// Parameters: -// action - Handle to the action. Must be a REMOTEGOTO or -// LAUNCH action. -// buffer - A buffer for output the path string. Can be NULL. -// buflen - The length of the buffer, number of bytes. Can be 0. -// Return value: -// Number of bytes the file path consumes, including trailing zero. -// -// Comments: -// The file path is UTF-8 encoded. The return value is the number of -// bytes required for the buffer, even when there is no buffer -// specified, or the buffer size is less then required. In this case, -// the buffer will not be modified. -// -DLLEXPORT unsigned long STDCALL -FPDFAction_GetFilePath(FPDF_ACTION action, void* buffer, unsigned long buflen); +// 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 -// Function: FPDFAction_GetURIPath -// Get URI path of a URI action. -// Parameters: -// document - Handle to the document. -// action - Handle to the action. Must be a URI action. -// buffer - A buffer for output the path string. Can be NULL. -// buflen - The length of the buffer, number of bytes. Can be 0. -// Return value: -// Number of bytes the URI path consumes, including trailing zeros. -// Comments: -// The URI path is always encoded in 7-bit ASCII. -// -// The return value is the number of bytes required for the buffer, -// even when there is no buffer specified, or the buffer size is less -// then required. In this case, the buffer will not be modified. -// -DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, - FPDF_ACTION action, - void* buffer, - unsigned long buflen); - -// Function: FPDFDest_GetPageIndex -// Get page index of a destination. -// Parameters: -// document - Handle to the document. -// dest - Handle to the destination. -// Return value: -// The page index. Starting from 0 for the first page. -// -DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, - FPDF_DEST dest); - -// Function: FPDFLink_GetLinkAtPoint -// Find a link at specified point on a document page. -// Parameters: -// page - Handle to the document page. -// x - The x coordinate of the point, specified in page -// coordinate system. -// y - The y coordinate of the point, specified in page -// coordinate system. -// Return value: -// Handle to the link. NULL if no link found at that point. -// Comments: -// The point coordinates are specified in page coordinate system. You can -// convert coordinates from screen system to page system using -// FPDF_DeviceToPage(). -// -DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, - double x, - double y); - -// Function: FPDFLink_GetLinkZOrderAtPoint -// Find the z-order of a link at specified point on a document page. -// Parameters: -// page - Handle to the document page. -// x - The x coordinate of the point, specified in page -// coordinate system. -// y - The y coordinate of the point, specified in page -// coordinate system. -// Return value: -// Z-order of the link, or -1 if no link found at that point. -// Higher numbers are closer to the front. -// Comments: -// The point coordinates are specified in page coordinate system. You can -// convert coordinates from screen system to page system using -// FPDF_DeviceToPage(). -// -DLLEXPORT int STDCALL -FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y); - -// Function: FPDFLink_GetDest -// Get destination info of a link. -// Parameters: -// document - Handle to the document. -// link - Handle to the link. Returned by -// FPDFLink_GetLinkAtPoint. -// Return value: -// Handle to the destination. NULL if there is no destination -// associated with the link, in this case -// the application should try FPDFLink_GetAction. -// -DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document, - FPDF_LINK link); - -// Function: FPDFLink_GetAction -// Get action info of a link. -// Parameters: -// link - Handle to the link. -// Return value: -// Handle to the action. NULL if there is no action associated with the -// link. -// -DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK link); - -// Function: FPDFLink_Enumerate -// This function would enumerate all the link annotations in a single -// PDF page. -// Parameters: -// page[in] - Handle to the page. -// startPos[in,out] - The start position to enumerate the link -// annotations, which should be specified to start from -// - 0 for the first call, and would receive the -// next position for enumerating to start from. -// linkAnnot[out] - Receive the link handle. -// Return value: -// TRUE if succceed, else False; -// -DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, - int* startPos, - FPDF_LINK* linkAnnot); - -// Function: FPDFLink_GetAnnotRect -// Get the annotation rectangle. (Specified by the ˇ°Rectˇ± entry of -// annotation dictionary). -// Parameters: -// linkAnnot[in] - Handle to the link annotation. -// rect[out] - The annotation rect. -// Return value: -// TRUE if succceed, else False; -// -DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot, - FS_RECTF* rect); - -// Function: FPDFLink_CountQuadPoints -// Get the count of quadrilateral points to the link annotation. -// Parameters: -// linkAnnot[in] - Handle to the link annotation. -// Return value: -// The count of quadrilateral points. -// -DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot); - -/* _FS_DEF_STRUCTURE_QUADPOINTSF_ */ -#ifndef _FS_DEF_STRUCTURE_QUADPOINTSF_ -#define _FS_DEF_STRUCTURE_QUADPOINTSF_ typedef struct _FS_QUADPOINTSF { FS_FLOAT x1; FS_FLOAT y1; @@ -305,61 +46,318 @@ typedef struct _FS_QUADPOINTSF { FS_FLOAT x4; FS_FLOAT y4; } FS_QUADPOINTSF; -#endif /* _FS_DEF_STRUCTURE_QUADPOINTSF_ */ - -// Function: FPDFLink_GetQuadPoints -// Get the quadrilateral points for the specified index in the link -// annotation. -// Parameters: -// linkAnnot[in] - Handle to the link annotation. -// quadIndex[in] - The specified quad points index. -// quadPoints[out] - Receive the quadrilateral points. -// Return value: -// True if succeed, else False. -// -DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, - int quadIndex, - FS_QUADPOINTSF* quadPoints); - -// Function: FPDF_GetMetaText -// Get a text from meta data of the document. Result is encoded in -// UTF-16LE. -// Parameters: -// doc - Handle to a document -// tag - The tag for the meta data. Currently, It can be -// "Title", "Author", -// "Subject", "Keywords", "Creator", "Producer", -// "CreationDate", or "ModDate". -// For detailed explanation of these tags and their -// respective values, -// please refer to PDF Reference 1.6, section 10.2.1, -// "Document Information Dictionary". -// buffer - A buffer for output the title. Can be NULL. -// buflen - The length of the buffer, number of bytes. Can be 0. -// Return value: -// Number of bytes the title consumes, including trailing zeros. -// Comments: -// No matter on what platform, the title is always output in UTF-16LE -// encoding, which means the buffer -// can be regarded as an array of WORD (on Intel and compatible CPUs), -// each WORD represent the Unicode of -// a character (some special Unicode may take 2 WORDs). The string is -// followed by two bytes of zero -// indicating end of the string. -// -// The return value always indicated number of bytes required for the -// buffer, even when there is -// no buffer specified, or the buffer size is less then required. In -// this case, the buffer will not -// be modified. -// -DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, - FPDF_BYTESTRING tag, - void* buffer, - unsigned long buflen); + +// Get the 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. +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. +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); + +// 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, 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|. When NULL is returned, 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| is always encoded in 7-bit ASCII. If |buflen| is less than the +// returned length, or |buffer| is NULL, |buffer| will not be modified. +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); + +// Get the view (fit type) specified by |dest|. +// Experimental API. Subject to change. +// +// 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. +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); + +// 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); + +// Get meta-data |tag| content from |document|. +// +// document - handle to the document. +// tag - the tag to retrieve. The tag can be one of: +// Title, Author, Subject, Keywords, Creator, Producer, +// CreationDate, or ModDate. +// For detailed explanations of these tags and their respective +// values, please refer to PDF Reference 1.6, section 10.2.1, +// 'Document Information Dictionary'. +// buffer - a buffer for the tag. May be NULL. +// buflen - the length of the buffer, in bytes. May be 0. +// +// Returns the number of bytes in the tag, including trailing zeros. +// +// The |buffer| is always encoded in UTF-16LE. The |buffer| is followed by two +// bytes of zeros indicating the end of the string. If |buflen| is less than +// the returned length, or |buffer| is NULL, |buffer| will not be modified. +// +// For linearized files, FPDFAvail_IsFormAvail must be called before this, and +// it must have returned PDF_FORM_AVAIL or PDF_FORM_NOTEXIST. Before that, there +// is no guarantee the metadata has been loaded. +FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetMetaText(FPDF_DOCUMENT document, + FPDF_BYTESTRING tag, + void* buffer, + unsigned long buflen); + +// Get the page label for |page_index| from |document|. +// +// document - handle to the document. +// page_index - the 0-based index of the page. +// buffer - a buffer for the page label. May be NULL. +// buflen - the length of the buffer, in bytes. May be 0. +// +// Returns the number of bytes in the page label, including trailing zeros. +// +// The |buffer| is always encoded in UTF-16LE. The |buffer| is followed by two +// bytes of zeros indicating the end of the string. If |buflen| is less than +// the returned length, or |buffer| is NULL, |buffer| will not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDF_GetPageLabel(FPDF_DOCUMENT document, + int page_index, + void* buffer, + unsigned long buflen); #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_DOC_H_ diff --git a/src/main/jni/include/fpdf_edit.h b/src/main/jni/include/fpdf_edit.h index 64eef263..8e0d2343 100644 --- a/src/main/jni/include/fpdf_edit.h +++ b/src/main/jni/include/fpdf_edit.h @@ -9,299 +9,1221 @@ #include +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" -// Define all types used in the SDK. Note they can be simply regarded as opaque -// pointers -// or long integer numbers. - -#define FPDF_ARGB(a, r, g, b) \ - ((((uint32_t)(((uint8_t)(b) | ((FX_WORD)((uint8_t)(g)) << 8)) | \ - (((FX_DWORD)(uint8_t)(r)) << 16)))) | \ - (((FX_DWORD)(uint8_t)(a)) << 24)) +#define FPDF_ARGB(a, r, g, b) \ + ((uint32_t)(((uint32_t)(b)&0xff) | (((uint32_t)(g)&0xff) << 8) | \ + (((uint32_t)(r)&0xff) << 16) | (((uint32_t)(a)&0xff) << 24))) #define FPDF_GetBValue(argb) ((uint8_t)(argb)) #define FPDF_GetGValue(argb) ((uint8_t)(((uint16_t)(argb)) >> 8)) #define FPDF_GetRValue(argb) ((uint8_t)((argb) >> 16)) #define FPDF_GetAValue(argb) ((uint8_t)((argb) >> 24)) -#ifdef __cplusplus -extern "C" { -#endif - -////////////////////////////////////////////////////////////////////// -// -// Document functions -// -////////////////////////////////////////////////////////////////////// - -// Function: FPDF_CreateNewDocument -// Create a new PDF document. -// Parameters: -// None. -// Return value: -// A handle to a document. If failed, NULL is returned. -DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument(); - -////////////////////////////////////////////////////////////////////// -// -// Page functions -// -////////////////////////////////////////////////////////////////////// - -// Function: FPDFPage_New -// Construct an empty page. -// Parameters: -// document - Handle to document. Returned by FPDF_LoadDocument -// and FPDF_CreateNewDocument. -// page_index - The index of a page. -// width - The page width. -// height - The page height. -// Return value: -// The handle to the page. -// Comments: -// Loaded page can be deleted by FPDFPage_Delete. -DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, - int page_index, - double width, - double height); - -// Function: FPDFPage_Delete -// Delete a PDF page. -// Parameters: -// document - Handle to document. Returned by FPDF_LoadDocument -// and FPDF_CreateNewDocument. -// page_index - The index of a page. -// Return value: -// None. -DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index); - -// Function: FPDFPage_GetRotation -// Get the page rotation. One of following values will be returned: -// 0(0), 1(90), 2(180), 3(270). -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New or -// FPDF_LoadPage. -// Return value: -// The PDF page rotation. -// Comment: -// The PDF page rotation is rotated clockwise. -DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page); - -// Function: FPDFPage_SetRotation -// Set page rotation. One of following values will be set: 0(0), 1(90), -// 2(180), 3(270). -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New or -// FPDF_LoadPage. -// rotate - The value of the PDF page rotation. -// Return value: -// None. -// Comment: -// The PDF page rotation is rotated clockwise. -// -DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate); - -// Function: FPDFPage_InsertObject -// Insert an object to the page. The page object is automatically -// freed. -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New or -// FPDF_LoadPage. -// page_obj - Handle to a page object. Returned by -// FPDFPageObj_NewTextObj,FPDFPageObj_NewTextObjEx and -// FPDFPageObj_NewPathObj. -// Return value: -// None. -DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, - FPDF_PAGEOBJECT page_obj); - -// Function: FPDFPage_CountObject -// Get number of page objects inside the page. -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New or -// FPDF_LoadPage. -// Return value: -// The number of the page object. -DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page); - -// Function: FPDFPage_GetObject -// Get page object by index. -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New or -// FPDF_LoadPage. -// index - The index of a page object. -// Return value: -// The handle of the page object. Null for failed. -DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index); - -// Function: FPDFPage_HasTransparency -// Check that whether the content of specified PDF page contains -// transparency. -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New or -// FPDF_LoadPage. -// Return value: -// TRUE means that the PDF page does contains transparency. -// Otherwise, returns FALSE. -DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page); - -// Function: FPDFPage_GenerateContent -// Generate PDF Page content. -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New or -// FPDF_LoadPage. -// Return value: -// True if successful, false otherwise. -// Comment: -// Before you save the page to a file, or reload the page, you must -// call the FPDFPage_GenerateContent function. -// Or the changed information will be lost. -DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page); - -////////////////////////////////////////////////////////////////////// -// -// Page Object functions -// -////////////////////////////////////////////////////////////////////// - -// Function: FPDFPageObj_HasTransparency -// Check that whether the specified PDF page object contains -// transparency. -// Parameters: -// pageObject - Handle to a page object. -// Return value: -// TRUE means that the PDF page object does contains transparency. -// Otherwise, returns FALSE. -DLLEXPORT FPDF_BOOL STDCALL -FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject); - -// Function: FPDFPageObj_Transform -// Transform (scale, rotate, shear, move) page object. -// Parameters: -// page_object - Handle to a page object. Returned by -// FPDFPageObj_NewImageObj. -// a - The coefficient "a" of the matrix. -// b - The coefficient "b" of the matrix. -// c - The coefficient "c" of the matrix. -// d - The coefficient "d" of the matrix. -// e - The coefficient "e" of the matrix. -// f - The coefficient "f" of the matrix. -// Return value: -// None. -DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, - double a, - double b, - double c, - double d, - double e, - double f); - -// Function: FPDFPage_TransformAnnots -// Transform (scale, rotate, shear, move) all annots in a page. -// Parameters: -// page - Handle to a page. -// a - The coefficient "a" of the matrix. -// b - The coefficient "b" of the matrix. -// c - The coefficient "c" of the matrix. -// d - The coefficient "d" of the matrix. -// e - The coefficient "e" of the matrix. -// f - The coefficient "f" of the matrix. -// Return value: -// None. -DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, - double a, - double b, - double c, - double d, - double e, - double f); +// Refer to PDF Reference version 1.7 table 4.12 for all color space families. +#define FPDF_COLORSPACE_UNKNOWN 0 +#define FPDF_COLORSPACE_DEVICEGRAY 1 +#define FPDF_COLORSPACE_DEVICERGB 2 +#define FPDF_COLORSPACE_DEVICECMYK 3 +#define FPDF_COLORSPACE_CALGRAY 4 +#define FPDF_COLORSPACE_CALRGB 5 +#define FPDF_COLORSPACE_LAB 6 +#define FPDF_COLORSPACE_ICCBASED 7 +#define FPDF_COLORSPACE_SEPARATION 8 +#define FPDF_COLORSPACE_DEVICEN 9 +#define FPDF_COLORSPACE_INDEXED 10 +#define FPDF_COLORSPACE_PATTERN 11 // The page object constants. +#define FPDF_PAGEOBJ_UNKNOWN 0 #define FPDF_PAGEOBJ_TEXT 1 #define FPDF_PAGEOBJ_PATH 2 #define FPDF_PAGEOBJ_IMAGE 3 #define FPDF_PAGEOBJ_SHADING 4 #define FPDF_PAGEOBJ_FORM 5 -////////////////////////////////////////////////////////////////////// -// -// Image functions -// -////////////////////////////////////////////////////////////////////// - -// Function: FPDFPageObj_NewImgeObj -// Create a new Image Object. -// Parameters: -// document - Handle to document. Returned by -// FPDF_LoadDocument or FPDF_CreateNewDocument function. -// Return Value: -// Handle of image object. -DLLEXPORT FPDF_PAGEOBJECT STDCALL -FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document); - -// Function: FPDFImageObj_LoadJpegFile -// Load Image from a JPEG image file and then set it to an image -// object. -// Parameters: -// pages - Pointers to the start of all loaded pages, could -// be NULL. -// nCount - Number of pages, could be 0. -// image_object - Handle of image object returned by -// FPDFPageObj_NewImgeObj. -// fileAccess - The custom file access handler, which specifies -// the JPEG image file. -// Return Value: -// TRUE if successful, FALSE otherwise. -// Note: -// The image object might already has an associated image, which is -// shared and cached by the loaded pages, In this case, we need to -// clear the cache of image for all the loaded pages. -// Pass pages and count to this API to clear the image cache. -DLLEXPORT FPDF_BOOL STDCALL +// The path segment constants. +#define FPDF_SEGMENT_UNKNOWN -1 +#define FPDF_SEGMENT_LINETO 0 +#define FPDF_SEGMENT_BEZIERTO 1 +#define FPDF_SEGMENT_MOVETO 2 + +#define FPDF_FILLMODE_NONE 0 +#define FPDF_FILLMODE_ALTERNATE 1 +#define FPDF_FILLMODE_WINDING 2 + +#define FPDF_FONT_TYPE1 1 +#define FPDF_FONT_TRUETYPE 2 + +#define FPDF_LINECAP_BUTT 0 +#define FPDF_LINECAP_ROUND 1 +#define FPDF_LINECAP_PROJECTING_SQUARE 2 + +#define FPDF_LINEJOIN_MITER 0 +#define FPDF_LINEJOIN_ROUND 1 +#define FPDF_LINEJOIN_BEVEL 2 + +#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 + +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); + +// 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_obj| into |page|. +// +// page - handle to a page +// page_obj - handle to a page object. The |page_obj| will be automatically +// freed. +FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertObject(FPDF_PAGE page, + FPDF_PAGEOBJECT page_obj); + +// Experimental API. +// Remove |page_obj| from |page|. +// +// page - handle to a page +// page_obj - handle to a page object to be removed. +// +// Returns TRUE on success. +// +// Ownership is transferred to the caller. Call FPDFPageObj_Destroy() to free +// it. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPage_RemoveObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj); + +// 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_obj| by releasing its resources. |page_obj| 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_obj - handle to a page object. +FPDF_EXPORT void FPDF_CALLCONV FPDFPageObj_Destroy(FPDF_PAGEOBJECT page_obj); + +// 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); + +// 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 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 nCount, + int count, FPDF_PAGEOBJECT image_object, - FPDF_FILEACCESS* fileAccess); - -// Function: FPDFImageObj_SetMatrix -// Set the matrix of an image object. -// Parameters: -// image_object - Handle of image object returned by -// FPDFPageObj_NewImgeObj. -// a - The coefficient "a" of the matrix. -// b - The coefficient "b" of the matrix. -// c - The coefficient "c" of the matrix. -// d - The coefficient "d" of the matrix. -// e - The coefficient "e" of the matrix. -// f - The coefficient "f" of the matrix. -// Return value: -// TRUE if successful, FALSE otherwise. -DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object, - double a, - double b, - double c, - double d, - double e, - double f); - -// Function: FPDFImageObj_SetBitmap -// Set the bitmap to an image object. -// Parameters: -// pages - Pointer's to the start of all loaded pages. -// nCount - Number of pages. -// image_object - Handle of image object returned by -// FPDFPageObj_NewImgeObj. -// bitmap - The handle of the bitmap which you want to set -// it to the image object. -// Return value: -// TRUE if successful, FALSE otherwise. -DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages, - int nCount, - FPDF_PAGEOBJECT image_object, - FPDF_BITMAP bitmap); + FPDF_FILEACCESS* file_access); + +// Load an image from a JPEG image file and then set it into |image_object|. +// +// pages - pointer to the start of all loaded pages, may be NULL. +// count - number of |pages|, may be 0. +// image_object - handle to an image object. +// file_access - file access handler which specifies the JPEG image file. +// +// Returns TRUE on success. +// +// The image object might already have an associated image, which is shared and +// cached by the loaded pages. In that case, we need to clear the cached image +// for all the loaded pages. Pass |pages| and page count (|count|) to this API +// to clear the image cache. If the image is not previously shared, or NULL is a +// valid |pages| value. This function loads the JPEG image inline, so the image +// content is copied to the file. This allows |file_access| and its associated +// data to be deleted after this function returns. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFImageObj_LoadJpegFileInline(FPDF_PAGE* pages, + int count, + FPDF_PAGEOBJECT image_object, + FPDF_FILEACCESS* file_access); + +// Experimental API. +// Get the transform matrix of an 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 used to scale, rotate, shear and translate the image. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFImageObj_GetMatrix(FPDF_PAGEOBJECT image_object, + double* a, + double* b, + double* c, + double* d, + double* e, + double* f); + +// 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 rasterisation of |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); + +// 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); + +// 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 +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFPageObj_GetBounds(FPDF_PAGEOBJECT page_object, + float* left, + float* bottom, + float* right, + float* top); + +// 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); + +// Experimental API. +// 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 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); + +// Experimental API. +// 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); + +// Experimental API. +// 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); + +// Experimental API. +// 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); + +// Experimental API. +// 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); + +// Experimental API. +// 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); + +// Experimental API. +// Get the transform matrix of a path. +// +// path - handle to a path. +// 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 path. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetMatrix(FPDF_PAGEOBJECT path, + FS_MATRIX* matrix); + +// Experimental API. +// Set the transform matrix of a path. +// +// path - handle to a path. +// 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 path. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetMatrix(FPDF_PAGEOBJECT path, + const FS_MATRIX* matrix); + +// 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 textobject. 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); + +// Returns a font object loaded from a stream of data. The font is loaded +// into the document. +// +// document - handle to the document. +// data - the stream of data, which will be copied by the font object. +// size - size of the stream, in bytes. +// font_type - FPDF_FONT_TYPE1 or FPDF_FONT_TRUETYPE depending on the font +// type. +// cid - a boolean specifying if the font is a CID font or not. +// +// The loaded font can be closed using FPDFFont_Close. +// +// Returns NULL on failure +FPDF_EXPORT FPDF_FONT FPDF_CALLCONV FPDFText_LoadFont(FPDF_DOCUMENT document, + const uint8_t* data, + uint32_t size, + int font_type, + FPDF_BOOL cid); + +// Experimental API. +// Loads one of the standard 14 fonts per PDF spec 1.7 page 416. The preferred +// way of using font style is using a dash to separate the name from the style, +// for example 'Helvetica-BoldItalic'. +// +// document - handle to the document. +// font - string containing the font name, without spaces. +// +// The loaded font can be closed using FPDFFont_Close. +// +// Returns NULL on failure. +FPDF_EXPORT FPDF_FONT FPDF_CALLCONV +FPDFText_LoadStandardFont(FPDF_DOCUMENT document, FPDF_BYTESTRING font); + +// Experimental API. +// Get the transform matrix of a text object. +// +// text - handle to a text. +// matrix - pointer to struct with the matrix value. +// +// The matrix is composed as: +// |a c e| +// |b d f| +// and used to scale, rotate, shear and translate the text. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFTextObj_GetMatrix(FPDF_PAGEOBJECT text, + FS_MATRIX* matrix); + +// Experimental API. +// Get the font size of a text object. +// +// text - handle to a text. +// +// Returns the font size of the text object, measured in points (about 1/72 +// inch) on success; 0 on failure. +FPDF_EXPORT float FPDF_CALLCONV FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text); + +// 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); + +// Experimental API. +// 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); + +// Experimental API. +// Get the font name of a text object. +// +// text - the handle to the text 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 font 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 unsigned long FPDF_CALLCONV +FPDFTextObj_GetFontName(FPDF_PAGEOBJECT text, + void* buffer, + unsigned long length); + +// Experimental API. +// 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, + void* buffer, + unsigned long length); + +// Experimental API. +// 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); + +// Experimental API. +// 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); + +// Experimental API. +// Get the transform matrix of a form object. +// +// form_object - handle to a form. +// 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 form object. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFFormObj_GetMatrix(FPDF_PAGEOBJECT form_object, FS_MATRIX* matrix); #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_EDIT_H_ diff --git a/src/main/jni/include/fpdf_ext.h b/src/main/jni/include/fpdf_ext.h index c80dcbbf..b1784dd6 100644 --- a/src/main/jni/include/fpdf_ext.h +++ b/src/main/jni/include/fpdf_ext.h @@ -7,102 +7,113 @@ #ifndef PUBLIC_FPDF_EXT_H_ #define PUBLIC_FPDF_EXT_H_ +#include + +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" #ifdef __cplusplus extern "C" { -#endif +#endif // __cplusplus -// flags for type of unsupport object. +// Unsupported XFA form. #define FPDF_UNSP_DOC_XFAFORM 1 +// Unsupported portable collection. #define FPDF_UNSP_DOC_PORTABLECOLLECTION 2 +// Unsupported attachment. #define FPDF_UNSP_DOC_ATTACHMENT 3 +// Unsupported security. #define FPDF_UNSP_DOC_SECURITY 4 +// Unsupported shared review. #define FPDF_UNSP_DOC_SHAREDREVIEW 5 +// Unsupported shared form, acrobat. #define FPDF_UNSP_DOC_SHAREDFORM_ACROBAT 6 +// Unsupported shared form, filesystem. #define FPDF_UNSP_DOC_SHAREDFORM_FILESYSTEM 7 +// Unsupported shared form, email. #define FPDF_UNSP_DOC_SHAREDFORM_EMAIL 8 +// Unsupported 3D annotation. #define FPDF_UNSP_ANNOT_3DANNOT 11 +// Unsupported movie annotation. #define FPDF_UNSP_ANNOT_MOVIE 12 +// Unsupported sound annotation. #define FPDF_UNSP_ANNOT_SOUND 13 +// Unsupported screen media annotation. #define FPDF_UNSP_ANNOT_SCREEN_MEDIA 14 +// Unsupported screen rich media annotation. #define FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA 15 +// Unsupported attachment annotation. #define FPDF_UNSP_ANNOT_ATTACHMENT 16 +// Unsupported signature annotation. #define FPDF_UNSP_ANNOT_SIG 17 +// Interface for unsupported feature notifications. typedef struct _UNSUPPORT_INFO { - /** - * Version number of the interface. Currently must be 1. - **/ + // Version number of the interface. Must be 1. int version; - /** - * Method: FSDK_UnSupport_Handler - * UnSupport Object process handling function. - * Interface Version: - * 1 - * Implementation Required: - * Yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * nType - The type of unsupportObject - * Return value: - * None. - * */ - + // Unsupported object notification function. + // Interface Version: 1 + // Implementation Required: Yes + // + // pThis - pointer to the interface structure. + // nType - the type of unsupported object. One of the |FPDF_UNSP_*| entries. void (*FSDK_UnSupport_Handler)(struct _UNSUPPORT_INFO* pThis, int nType); } UNSUPPORT_INFO; -/** - * Function: FSDK_SetUnSpObjProcessHandler - * Setup A UnSupport Object process handler for foxit sdk. - * Parameters: - * unsp_info - Pointer to a UNSUPPORT_INFO structure. - * Return Value: - * TRUE means successful. FALSE means fails. - **/ - -DLLEXPORT FPDF_BOOL STDCALL +// Setup an unsupported object handler. +// +// unsp_info - Pointer to an UNSUPPORT_INFO structure. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_info); -// flags for page mode. - -// Unknown value +// Set replacement function for calls to time(). +// +// This API is intended to be used only for testing, thus may cause PDFium to +// behave poorly in production environments. +// +// func - Function pointer to alternate implementation of time(), or +// NULL to restore to actual time() call itself. +FPDF_EXPORT void FPDF_CALLCONV FSDK_SetTimeFunction(time_t (*func)()); + +// Set replacement function for calls to localtime(). +// +// This API is intended to be used only for testing, thus may cause PDFium to +// behave poorly in production environments. +// +// func - Function pointer to alternate implementation of localtime(), or +// NULL to restore to actual localtime() call itself. +FPDF_EXPORT void FPDF_CALLCONV +FSDK_SetLocaltimeFunction(struct tm* (*func)(const time_t*)); + +// Unknown page mode. #define PAGEMODE_UNKNOWN -1 - -// Neither document outline nor thumbnail images visible +// Document outline, and thumbnails hidden. #define PAGEMODE_USENONE 0 - -// Document outline visible +// Document outline visible. #define PAGEMODE_USEOUTLINES 1 - -// Thumbnial images visible +// Thumbnail images visible. #define PAGEMODE_USETHUMBS 2 - -// Full-screen mode, with no menu bar, window controls, or any other window -// visible +// Full-screen mode, no menu bar, window controls, or other decorations visible. #define PAGEMODE_FULLSCREEN 3 - -// Optional content group panel visible +// Optional content group panel visible. #define PAGEMODE_USEOC 4 - -// Attachments panel visible +// Attachments panel visible. #define PAGEMODE_USEATTACHMENTS 5 -/** - * Function: FPDFDoc_GetPageMode - * Get the document's PageMode(How the document should be displayed - *when opened) - * Parameters: - * doc - Handle to document. Returned by FPDF_LoadDocument - *function. - * Return Value: - * The flags for page mode. - **/ -DLLEXPORT int FPDFDoc_GetPageMode(FPDF_DOCUMENT document); +// Get the document's PageMode. +// +// doc - Handle to document. +// +// Returns one of the |PAGEMODE_*| flags defined above. +// +// The page mode defines how the document should be initially displayed. +FPDF_EXPORT int FPDF_CALLCONV FPDFDoc_GetPageMode(FPDF_DOCUMENT document); #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_EXT_H_ diff --git a/src/main/jni/include/fpdf_flatten.h b/src/main/jni/include/fpdf_flatten.h index af77c293..614540e1 100644 --- a/src/main/jni/include/fpdf_flatten.h +++ b/src/main/jni/include/fpdf_flatten.h @@ -7,39 +7,38 @@ #ifndef PUBLIC_FPDF_FLATTEN_H_ #define PUBLIC_FPDF_FLATTEN_H_ +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" -// Result codes. -#define FLATTEN_FAIL 0 // Flatten operation failed. -#define FLATTEN_SUCCESS 1 // Flatten operation succeed. -#define FLATTEN_NOTHINGTODO 2 // There is nothing to be flattened. +// Flatten operation failed. +#define FLATTEN_FAIL 0 +// Flatten operation succeed. +#define FLATTEN_SUCCESS 1 +// Nothing to be flattened. +#define FLATTEN_NOTHINGTODO 2 -// Flags. +// Flatten for normal display. #define FLAT_NORMALDISPLAY 0 +// Flatten for print. #define FLAT_PRINT 1 #ifdef __cplusplus extern "C" { -#endif - -// Function: FPDFPage_Flatten -// Make annotations and form fields become part of the page contents -// itself. -// Parameters: -// page - Handle to the page, as returned by FPDF_LoadPage(). -// nFlag - Intended use of the flattened result: 0 for normal display, -// 1 for printing. -// Return value: -// Either FLATTEN_FAIL, FLATTEN_SUCCESS, or FLATTEN_NOTHINGTODO (see -// above). -// Comments: -// Currently, all failures return FLATTEN_FAIL, with no indication for -// the reason -// for the failure. -DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag); +#endif // __cplusplus + +// Flatten annotations and form fields into the page contents. +// +// page - handle to the page. +// nFlag - One of the |FLAT_*| values denoting the page usage. +// +// Returns one of the |FLATTEN_*| values. +// +// Currently, all failures return |FLATTEN_FAIL| with no indication of the +// cause. +FPDF_EXPORT int FPDF_CALLCONV FPDFPage_Flatten(FPDF_PAGE page, int nFlag); #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_FLATTEN_H_ diff --git a/src/main/jni/include/fpdf_formfill.h b/src/main/jni/include/fpdf_formfill.h index b3bbb928..9b6c4d44 100644 --- a/src/main/jni/include/fpdf_formfill.h +++ b/src/main/jni/include/fpdf_formfill.h @@ -7,15 +7,42 @@ #ifndef PUBLIC_FPDF_FORMFILL_H_ #define PUBLIC_FPDF_FORMFILL_H_ +// clang-format off +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" -typedef void* FPDF_FORMHANDLE; - -#ifdef PDF_ENABLE_XFA -#define DOCTYPE_PDF 0 // Normal pdf Document -#define DOCTYPE_DYNAMIC_XFA 1 // Dynamic xfa Document Type -#define DOCTYPE_STATIC_XFA 2 // Static xfa Document Type -#endif // PDF_ENABLE_XFA +// These values are return values for a public API, so should not be changed +// other than the count when adding new values. +#define FORMTYPE_NONE 0 // Document contains no forms +#define FORMTYPE_ACRO_FORM 1 // Forms are specified using AcroForm spec +#define FORMTYPE_XFA_FULL 2 // Forms are specified using entire XFA spec +#define FORMTYPE_XFA_FOREGROUND 3 // Forms are specified using the XFAF subset + // of XFA spec +#define FORMTYPE_COUNT 4 // The number of form types + +#define JSPLATFORM_ALERT_BUTTON_OK 0 // OK button +#define JSPLATFORM_ALERT_BUTTON_OKCANCEL 1 // OK & Cancel buttons +#define JSPLATFORM_ALERT_BUTTON_YESNO 2 // Yes & No buttons +#define JSPLATFORM_ALERT_BUTTON_YESNOCANCEL 3 // Yes, No & Cancel buttons +#define JSPLATFORM_ALERT_BUTTON_DEFAULT JSPLATFORM_ALERT_BUTTON_OK + +#define JSPLATFORM_ALERT_ICON_ERROR 0 // Error +#define JSPLATFORM_ALERT_ICON_WARNING 1 // Warning +#define JSPLATFORM_ALERT_ICON_QUESTION 2 // Question +#define JSPLATFORM_ALERT_ICON_STATUS 3 // Status +#define JSPLATFORM_ALERT_ICON_ASTERISK 4 // Asterisk +#define JSPLATFORM_ALERT_ICON_DEFAULT JSPLATFORM_ALERT_ICON_ERROR + +#define JSPLATFORM_ALERT_RETURN_OK 1 // OK +#define JSPLATFORM_ALERT_RETURN_CANCEL 2 // Cancel +#define JSPLATFORM_ALERT_RETURN_NO 3 // No +#define JSPLATFORM_ALERT_RETURN_YES 4 // Yes + +#define JSPLATFORM_BEEP_ERROR 0 // Error +#define JSPLATFORM_BEEP_WARNING 1 // Warning +#define JSPLATFORM_BEEP_QUESTION 2 // Question +#define JSPLATFORM_BEEP_STATUS 3 // Status +#define JSPLATFORM_BEEP_DEFAULT 4 // Default // Exported Functions #ifdef __cplusplus @@ -23,103 +50,89 @@ extern "C" { #endif typedef struct _IPDF_JsPlatform { - /** - * Version number of the interface. Currently must be 2. - **/ + /* + * Version number of the interface. Currently must be 2. + */ int version; /* Version 1. */ - /** - * Method: app_alert - * pop up a dialog to show warning or hint. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * Msg - A string containing the message to be displayed. - * Title - The title of the dialog. - * Type - The stype of button group. - * 0-OK(default); - * 1-OK,Cancel; - * 2-Yes,NO; - * 3-Yes, NO, Cancel. - * nIcon - The Icon type. - * 0-Error(default); - * 1-Warning; - * 2-Question; - * 3-Status. - * 4-Asterisk - * Return Value: - * The return value could be the folowing type: - * 1-OK; - * 2-Cancel; - * 3-NO; - * 4-Yes; - */ + /* + * Method: app_alert + * Pop up a dialog to show warning or hint. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * Msg - A string containing the message to be displayed. + * Title - The title of the dialog. + * Type - The type of button group, one of the + * JSPLATFORM_ALERT_BUTTON_* values above. + * nIcon - The type of the icon, one of the + * JSPLATFORM_ALERT_ICON_* above. + * Return Value: + * Option selected by user in dialogue, one of the + * JSPLATFORM_ALERT_RETURN_* values above. + */ int (*app_alert)(struct _IPDF_JsPlatform* pThis, FPDF_WIDESTRING Msg, FPDF_WIDESTRING Title, int Type, int Icon); - /** - * Method: app_beep - * Causes the system to play a sound. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * nType - The sound type. - * 0 - Error - * 1 - Warning - * 2 - Question - * 3 - Status - * 4 - Default (default value) - * Return Value: - * None - */ + /* + * Method: app_beep + * Causes the system to play a sound. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * nType - The sound type, see JSPLATFORM_BEEP_TYPE_* + * above. + * Return Value: + * None + */ void (*app_beep)(struct _IPDF_JsPlatform* pThis, int nType); - /** - * Method: app_response - * Displays a dialog box containing a question and an entry field for - * the user to reply to the question. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * Question - The question to be posed to the user. - * Title - The title of the dialog box. - * Default - A default value for the answer to the question. If - * not specified, no default value is presented. - * cLabel - A short string to appear in front of and on the - * same line as the edit text field. - * bPassword - If true, indicates that the user's response should - * show as asterisks (*) or bullets (?) to mask the response, which might be - * sensitive information. The default is false. - * response - A string buffer allocated by SDK, to receive the - * user's response. - * length - The length of the buffer, number of bytes. - * Currently, It's always be 2048. - * Return Value: - * Number of bytes the complete user input would actually require, not - * including trailing zeros, regardless of the value of the length - * parameter or the presence of the response buffer. - * Comments: - * No matter on what platform, the response buffer should be always - * written using UTF-16LE encoding. If a response buffer is - * present and the size of the user input exceeds the capacity of the - * buffer as specified by the length parameter, only the - * first "length" bytes of the user input are to be written to the - * buffer. - */ + /* + * Method: app_response + * Displays a dialog box containing a question and an entry field for + * the user to reply to the question. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * Question - The question to be posed to the user. + * Title - The title of the dialog box. + * Default - A default value for the answer to the question. If + * not specified, no default value is presented. + * cLabel - A short string to appear in front of and on the + * same line as the edit text field. + * bPassword - If true, indicates that the user's response should + * be shown as asterisks (*) or bullets (?) to mask + * the response, which might be sensitive information. + * response - A string buffer allocated by PDFium, to receive the + * user's response. + * length - The length of the buffer in bytes. Currently, it is + * always 2048. + * Return Value: + * Number of bytes the complete user input would actually require, not + * including trailing zeros, regardless of the value of the length + * parameter or the presence of the response buffer. + * Comments: + * No matter on what platform, the response buffer should be always + * written using UTF-16LE encoding. If a response buffer is + * present and the size of the user input exceeds the capacity of the + * buffer as specified by the length parameter, only the + * first "length" bytes of the user input are to be written to the + * buffer. + */ int (*app_response)(struct _IPDF_JsPlatform* pThis, FPDF_WIDESTRING Question, FPDF_WIDESTRING Title, @@ -130,65 +143,64 @@ typedef struct _IPDF_JsPlatform { int length); /* - * Method: Doc_getFilePath - * Get the file path of the current document. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * filePath - The string buffer to receive the file path. Can be - * NULL. - * length - The length of the buffer, number of bytes. Can be - * 0. - * Return Value: - * Number of bytes the filePath consumes, including trailing zeros. - * Comments: - * The filePath should be always input in local encoding. - * - * The return value always indicated number of bytes required for the - * buffer, even when there is - * no buffer specified, or the buffer size is less then required. In this - * case, the buffer will not - * be modified. - */ + * Method: Doc_getFilePath + * Get the file path of the current document. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * filePath - The string buffer to receive the file path. Can + * be NULL. + * length - The length of the buffer, number of bytes. Can + * be 0. + * Return Value: + * Number of bytes the filePath consumes, including trailing zeros. + * Comments: + * The filePath should always be provided in the local encoding. + * The return value always indicated number of bytes required for + * the buffer, even when there is no buffer specified, or the buffer + * size is less than required. In this case, the buffer will not + * be modified. + */ int (*Doc_getFilePath)(struct _IPDF_JsPlatform* pThis, void* filePath, int length); /* - * Method: Doc_mail - * Mails the data buffer as an attachment to all recipients, with or - * without user interaction. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * mailData - Pointer to the data buffer to be sent.Can be NULL. - * length - The size,in bytes, of the buffer pointed by - * mailData parameter.Can be 0. - * bUI - If true, the rest of the parameters are used in a - * compose-new-message window that is displayed to the user. If false, the cTo - * parameter is required and all others are optional. - * To - A semicolon-delimited list of recipients for the - * message. - * Subject - The subject of the message. The length limit is 64 - * KB. - * CC - A semicolon-delimited list of CC recipients for - * the message. - * BCC - A semicolon-delimited list of BCC recipients for - * the message. - * Msg - The content of the message. The length limit is 64 - * KB. - * Return Value: - * None. - * Comments: - * If the parameter mailData is NULL or length is 0, the current - * document will be mailed as an attachment to all recipients. - */ + * Method: Doc_mail + * Mails the data buffer as an attachment to all recipients, with or + * without user interaction. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * mailData - Pointer to the data buffer to be sent. Can be NULL. + * length - The size,in bytes, of the buffer pointed by + * mailData parameter. Can be 0. + * bUI - If true, the rest of the parameters are used in a + * compose-new-message window that is displayed to the + * user. If false, the cTo parameter is required and + * all others are optional. + * To - A semicolon-delimited list of recipients for the + * message. + * Subject - The subject of the message. The length limit is + * 64 KB. + * CC - A semicolon-delimited list of CC recipients for + * the message. + * BCC - A semicolon-delimited list of BCC recipients for + * the message. + * Msg - The content of the message. The length limit is + * 64 KB. + * Return Value: + * None. + * Comments: + * If the parameter mailData is NULL or length is 0, the current + * document will be mailed as an attachment to all recipients. + */ void (*Doc_mail)(struct _IPDF_JsPlatform* pThis, void* mailData, int length, @@ -200,29 +212,32 @@ typedef struct _IPDF_JsPlatform { FPDF_WIDESTRING Msg); /* - * Method: Doc_print - * Prints all or a specific number of pages of the document. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * bUI - If true, will cause a UI to be presented to the - * user to obtain printing information and confirm the action. - * nStart - A 0-based index that defines the start of an - * inclusive range of pages. - * nEnd - A 0-based index that defines the end of an - * inclusive page range. - * bSilent - If true, suppresses the cancel dialog box while - * the document is printing. The default is false. - * bShrinkToFit - If true, the page is shrunk (if necessary) to - * fit within the imageable area of the printed page. - * bPrintAsImage - If true, print pages as an image. - * bReverse - If true, print from nEnd to nStart. - * bAnnotations - If true (the default), annotations are - * printed. - */ + * Method: Doc_print + * Prints all or a specific number of pages of the document. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * bUI - If true, will cause a UI to be presented to the + * user to obtain printing information and confirm + * the action. + * nStart - A 0-based index that defines the start of an + * inclusive range of pages. + * nEnd - A 0-based index that defines the end of an + * inclusive page range. + * bSilent - If true, suppresses the cancel dialog box while + * the document is printing. The default is false. + * bShrinkToFit - If true, the page is shrunk (if necessary) to + * fit within the imageable area of the printed page. + * bPrintAsImage - If true, print pages as an image. + * bReverse - If true, print from nEnd to nStart. + * bAnnotations - If true (the default), annotations are + * printed. + * Return Value: + * None. + */ void (*Doc_print)(struct _IPDF_JsPlatform* pThis, FPDF_BOOL bUI, int nStart, @@ -234,68 +249,66 @@ typedef struct _IPDF_JsPlatform { FPDF_BOOL bAnnotations); /* - * Method: Doc_submitForm - * Send the form data to a specified URL. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * formData - Pointer to the data buffer to be sent. - * length - The size,in bytes, of the buffer pointed by - * formData parameter. - * URL - The URL to send to. - * Return Value: - * None. - * - */ + * Method: Doc_submitForm + * Send the form data to a specified URL. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * formData - Pointer to the data buffer to be sent. + * length - The size,in bytes, of the buffer pointed by + * formData parameter. + * URL - The URL to send to. + * Return Value: + * None. + */ void (*Doc_submitForm)(struct _IPDF_JsPlatform* pThis, void* formData, int length, FPDF_WIDESTRING URL); /* - * Method: Doc_gotoPage - * Jump to a specified page. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * nPageNum - The specified page number, zero for the first - * page. - * Return Value: - * None. - * - */ + * Method: Doc_gotoPage + * Jump to a specified page. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * nPageNum - The specified page number, zero for the first page. + * Return Value: + * None. + * + */ void (*Doc_gotoPage)(struct _IPDF_JsPlatform* pThis, int nPageNum); + /* - * Method: Field_browse - * Show a file selection dialog, and return the selected file path. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * filePath - Pointer to the data buffer to receive the file - * path.Can be NULL. - * length - The length of the buffer, number of bytes. Can be - * 0. - * Return Value: - * Number of bytes the filePath consumes, including trailing zeros. - * Comments: - * The filePath shoule be always input in local encoding. - */ + * Method: Field_browse + * Show a file selection dialog, and return the selected file path. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * filePath - Pointer to the data buffer to receive the file + * path. Can be NULL. + * length - The length of the buffer, in bytes. Can be 0. + * Return Value: + * Number of bytes the filePath consumes, including trailing zeros. + * Comments: + * The filePath shoule always be provided in local encoding. + */ int (*Field_browse)(struct _IPDF_JsPlatform* pThis, void* filePath, int length); - /** - * pointer to FPDF_FORMFILLINFO interface. - **/ + /* + * Pointer to FPDF_FORMFILLINFO interface. + */ void* m_pFormfillinfo; /* Version 2. */ @@ -305,7 +318,6 @@ typedef struct _IPDF_JsPlatform { /* Version 3. */ /* Version 3 moves m_Isolate and m_v8EmbedderSlot to FPDF_LIBRARY_CONFIG. */ - } IPDF_JSPLATFORM; // Flags for Cursor type @@ -316,19 +328,19 @@ typedef struct _IPDF_JsPlatform { #define FXCT_HBEAM 4 #define FXCT_HAND 5 -/** - * Declares of a pointer type to the callback function for the FFI_SetTimer - *method. +/* + * 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] */ @@ -341,92 +353,84 @@ typedef struct _FPDF_SYSTEMTIME { } FPDF_SYSTEMTIME; #ifdef PDF_ENABLE_XFA -// XFA -/** - * @name Pageview event flags - */ -/*@{*/ -/** @brief After a new pageview is added. */ -#define FXFA_PAGEVIEWEVENT_POSTADDED 1 -/** @brief After a pageview is removed. */ -#define FXFA_PAGEVIEWEVENT_POSTREMOVED 3 -/*@}*/ - -// menu -/** - * @name Macro Definitions for Right Context Menu Features Of XFA Fields - */ -/*@{*/ -#define FXFA_MEMU_COPY 1 -#define FXFA_MEMU_CUT 2 -#define FXFA_MEMU_SELECTALL 4 -#define FXFA_MEMU_UNDO 8 -#define FXFA_MEMU_REDO 16 -#define FXFA_MEMU_PASTE 32 -/*@}*/ - -// file type -/** - * @name Macro Definitions for File Type. - */ -/*@{*/ + +// Pageview event flags +#define FXFA_PAGEVIEWEVENT_POSTADDED 1 // After a new pageview is added. +#define FXFA_PAGEVIEWEVENT_POSTREMOVED 3 // After a pageview is removed. + +// Definitions for Right Context Menu Features Of XFA Fields +#define FXFA_MENU_COPY 1 +#define FXFA_MENU_CUT 2 +#define FXFA_MENU_SELECTALL 4 +#define FXFA_MENU_UNDO 8 +#define FXFA_MENU_REDO 16 +#define FXFA_MENU_PASTE 32 + +// Definitions for File Type. #define FXFA_SAVEAS_XML 1 #define FXFA_SAVEAS_XDP 2 -/*@}*/ + #endif // PDF_ENABLE_XFA typedef struct _FPDF_FORMFILLINFO { - /** - * Version number of the interface. Currently must be 1 (when PDFium is built - * without the XFA module) or must be 2 (when built with the XFA module). - **/ + /* + * Version number of the interface. + * Version 1 contains stable interfaces. Version 2 has additional + * experimental interfaces. + * When PDFium is built without the XFA module, version can be 1 or 2. + * With version 1, only stable interfaces are called. With version 2, + * additional experimental interfaces are also called. + * When PDFium is built with the XFA module, version must be 2. + * All the XFA related interfaces are experimental. If PDFium is built with + * the XFA module and version 1 then none of the XFA related interfaces + * would be called. When PDFium is built with XFA module then the version + * must be 2. + */ int version; /* Version 1. */ - /** - *Method: Release - * Give implementation a chance to release any data after the - * interface is no longer used - *Interface Version: - * 1 - *Implementation Required: - * No - *Comments: - * Called by Foxit SDK during the final cleanup process. - *Parameters: - * pThis - Pointer to the interface structure itself - *Return Value: - * None + /* + * 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. + * Invalidate the client area within the specified rectangle. * Interface Version: - * 1 + * 1 * Implementation Required: - * yes + * yes * Parameters: - * pThis - Pointer to the interface structure itself. - * page - Handle to the page. Returned by FPDF_LoadPage - *function. - * left - Left position of the client area in PDF page - *coordinate. - * top - Top position of the client area in PDF page - *coordinate. - * right - Right position of the client area in PDF page - *coordinate. - * bottom - Bottom position of the client area in PDF page - *coordinate. + * 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() function for - *repainting a specified page area. - */ + * None. + * Comments: + * All positions are measured in PDF "user space". + * Implementation should call FPDF_RenderPageBitmap() for repainting + * the specified page area. + */ void (*FFI_Invalidate)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, double left, @@ -434,38 +438,34 @@ typedef struct _FPDF_FORMFILLINFO { double right, double bottom); - /** + /* * Method: FFI_OutputSelectedRect - * When user is taking the mouse to select texts on a form field, - * this callback function will keep - * returning the selected areas to the implementation. - * + * When the user selects text in form fields with the mouse, this + * callback function will be invoked with the selected areas. * Interface Version: - * 1 + * 1 * Implementation Required: - * No + * No * Parameters: - * pThis - Pointer to the interface structure itself. - * page - Handle to the page. Returned by FPDF_LoadPage - * function. - * left - Left position of the client area in PDF page - * coordinate. - * top - Top position of the client area in PDF page - * coordinate. - * right - Right position of the client area in PDF page - * coordinate. - * bottom - Bottom position of the client area in PDF page - * coordinate. + * 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 effect. Implementation should - * first records the returned rectangles, then draw them one by one - * at the painting period, last,remove all - * the recorded rectangles when finish painting. - */ + * None. + * Comments: + * This callback function is useful for implementing special text + * selection effects. An implementation should first record the + * returned rectangles, then draw them one by one during the next + * painting period. Lastly, it should remove all the recorded + * rectangles when finished painting. + */ void (*FFI_OutputSelectedRect)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, double left, @@ -473,260 +473,289 @@ typedef struct _FPDF_FORMFILLINFO { double right, double bottom); - /** - * Method: FFI_SetCursor - * Set the Cursor shape. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * nCursorType - Cursor type. see Flags for Cursor type for the - * details. - * Return value: - * None. - * */ + /* + * Method: FFI_SetCursor + * Set the Cursor shape. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * nCursorType - Cursor type, see Flags for Cursor type for details. + * Return value: + * None. + */ void (*FFI_SetCursor)(struct _FPDF_FORMFILLINFO* pThis, int nCursorType); - /** - * Method: FFI_SetTimer - * This method installs a system timer. A time-out value is - * specified, - * and every time a time-out occurs, the system passes a message to - * the TimerProc callback function. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * uElapse - Specifies the time-out value, in milliseconds. - * lpTimerFunc - A pointer to the callback function-TimerCallback. - * Return value: - * The timer identifier of the new timer if the function is successful. - * An application passes this value to the FFI_KillTimer method to kill - * the timer. Nonzero if it is successful; otherwise, it is zero. - * */ + /* + * Method: FFI_SetTimer + * This method installs a system timer. An interval value is specified, + * and every time that interval elapses, the system must call into the + * callback function with the timer ID as returned by this function. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * uElapse - Specifies the time-out value, in milliseconds. + * lpTimerFunc - A pointer to the callback function-TimerCallback. + * Return value: + * The timer identifier of the new timer if the function is successful. + * An application passes this value to the FFI_KillTimer method to kill + * the timer. Nonzero if it is successful; otherwise, it is zero. + */ int (*FFI_SetTimer)(struct _FPDF_FORMFILLINFO* pThis, int uElapse, TimerCallback lpTimerFunc); - /** - * Method: FFI_KillTimer - * This method kills the timer event identified by nIDEvent, set by - * an earlier call to FFI_SetTimer. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * nTimerID - The timer ID return by FFI_SetTimer function. - * Return value: - * None. - * */ + /* + * Method: FFI_KillTimer + * This method uninstalls a system timer, as set by an earlier call to + * FFI_SetTimer. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * nTimerID - The timer ID returned by FFI_SetTimer function. + * Return value: + * None. + */ void (*FFI_KillTimer)(struct _FPDF_FORMFILLINFO* pThis, int nTimerID); - /** - * Method: FFI_GetLocalTime - * This method receives the current local time on the system. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * Return value: - * None. - * */ + /* + * Method: FFI_GetLocalTime + * This method receives the current local time on the system. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * Return value: + * The local time. See FPDF_SYSTEMTIME above for details. + * Note: Unused. + */ FPDF_SYSTEMTIME (*FFI_GetLocalTime)(struct _FPDF_FORMFILLINFO* pThis); - /** - * Method: FFI_OnChange - * This method will be invoked to notify implementation when the - * value of any FormField on the document had been changed. - * Interface Version: - * 1 - * Implementation Required: - * no - * Parameters: - * pThis - Pointer to the interface structure itself. - * Return value: - * None. - * */ + /* + * Method: FFI_OnChange + * This method will be invoked to notify the implementation when the + * value of any FormField on the document had been changed. + * Interface Version: + * 1 + * Implementation Required: + * no + * Parameters: + * pThis - Pointer to the interface structure itself. + * Return value: + * None. + */ void (*FFI_OnChange)(struct _FPDF_FORMFILLINFO* pThis); - /** - * Method: FFI_GetPage - * This method receives the page pointer associated with a specified - * page index. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * document - Handle to document. Returned by FPDF_LoadDocument - * function. - * nPageIndex - Index number of the page. 0 for the first page. - * Return value: - * Handle to the page. Returned by FPDF_LoadPage function. - * Comments: - * In some cases, the document-level JavaScript action may refer to a - * page which hadn't been loaded yet. - * To successfully run the javascript action, implementation need to load - * the page for SDK. - * */ - FPDF_PAGE (*FFI_GetPage)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document, int nPageIndex); - - /** - * Method: FFI_GetCurrentPage - * This method receives the current page pointer. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * document - Handle to document. Returned by FPDF_LoadDocument - * function. - * Return value: - * Handle to the page. Returned by FPDF_LoadPage function. - * */ - FPDF_PAGE (*FFI_GetCurrentPage)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document); + /* + * Method: FFI_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_GetRotation - * This method receives currently rotation of the page view. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * page - Handle to page. Returned by FPDF_LoadPage function. - * Return value: - * The page rotation. Should be 0(0 degree),1(90 degree),2(180 - * degree),3(270 degree), in a clockwise direction. - * */ + /* + * Method: FFI_GetCurrentPage + * This method receives the handle to the current page. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * document - Handle to document. Returned by FPDF_LoadDocument(). + * Return value: + * Handle to the page. Returned by FPDF_LoadPage(). + * Comments: + * The implementation is expected to keep track of the current page, + * e.g. the current page can be the one that is most visible on screen. + */ + FPDF_PAGE (*FFI_GetCurrentPage)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_DOCUMENT document); + + /* + * Method: FFI_GetRotation + * This method receives currently rotation of the page view. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * page - Handle to page, as returned by FPDF_LoadPage(). + * Return value: + * A number to indicate the page rotation in 90 degree increments + * in a clockwise direction: + * 0 - 0 degrees + * 1 - 90 degrees + * 2 - 180 degrees + * 3 - 270 degrees + * Note: Unused. + */ int (*FFI_GetRotation)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page); - /** - * Method: FFI_ExecuteNamedAction - * This method will execute an named action. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * namedAction - A byte string which indicates the named action, - * terminated by 0. - * Return value: - * None. - * Comments: - * See the named actions description of <> - * for more details. - * */ + /* + * Method: FFI_ExecuteNamedAction + * This method will execute a named action. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * namedAction - A byte string which indicates the named action, + * terminated by 0. + * Return value: + * None. + * Comments: + * See the named actions description of <> + * for more details. + */ void (*FFI_ExecuteNamedAction)(struct _FPDF_FORMFILLINFO* pThis, FPDF_BYTESTRING namedAction); - /** - * @brief This method will be called when a text field is getting or losing a - * focus. - * - * @param[in] pThis Pointer to the interface structure itself. - * @param[in] value The string value of the form field, in UTF-16LE - * format. - * @param[in] valueLen The length of the string value, number of characters - * (not bytes). - * @param[in] is_focus True if the form field is getting a focus, False for - * losing a focus. - * - * @return None. - * - * @note Currently,only support text field and combobox field. - * */ + /* + * Method: FFI_SetTextFieldFocus + * Called when a text field is getting or losing focus. + * Interface Version: + * 1 + * Implementation Required: + * no + * Parameters: + * pThis - Pointer to the interface structure itself. + * value - The string value of the form field, in UTF-16LE + * format. + * valueLen - The length of the string value. This is the + * number of characters, not bytes. + * is_focus - True if the form field is getting focus, false + * if the form field is losing focus. + * Return value: + * None. + * Comments: + * Only supports text fields and combobox fields. + */ void (*FFI_SetTextFieldFocus)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING value, FPDF_DWORD valueLen, FPDF_BOOL is_focus); - /** - * Method: FFI_DoURIAction - * This action resolves to a uniform resource identifier. - * Interface Version: - * 1 - * Implementation Required: - * No - * Parameters: - * pThis - Pointer to the interface structure itself. - * bsURI - A byte string which indicates the uniform resource - * identifier, terminated by 0. - * Return value: - * None. - * Comments: - * See the URI actions description of <> for - * more details. - * */ + /* + * Method: FFI_DoURIAction + * Ask the implementation to navigate to a uniform resource identifier. + * Interface Version: + * 1 + * Implementation Required: + * No + * Parameters: + * pThis - Pointer to the interface structure itself. + * bsURI - A byte string which indicates the uniform + * resource identifier, terminated by 0. + * Return value: + * None. + * Comments: + * See the URI actions description of <> + * for more details. + */ void (*FFI_DoURIAction)(struct _FPDF_FORMFILLINFO* pThis, FPDF_BYTESTRING bsURI); - /** - * Method: FFI_DoGoToAction - * This action changes the view to a specified destination. - * Interface Version: - * 1 - * Implementation Required: - * No - * Parameters: - * pThis - Pointer to the interface structure itself. - * nPageIndex - The index of the PDF page. - * zoomMode - The zoom mode for viewing page.See Macros - *"PDFZOOM_XXX" defined in "fpdfdoc.h". - * fPosArray - The float array which carries the position info. - * sizeofArray - The size of float array. - * Return value: - * None. - * Comments: - * See the Destinations description of <> in - *8.2.1 for more details. - **/ + /* + * Method: FFI_DoGoToAction + * This action changes the view to a specified destination. + * Interface Version: + * 1 + * Implementation Required: + * No + * Parameters: + * pThis - Pointer to the interface structure itself. + * nPageIndex - The index of the PDF page. + * zoomMode - The zoom mode for viewing page. See below. + * fPosArray - The float array which carries the position info. + * sizeofArray - The size of float array. + * PDFZoom values: + * - XYZ = 1 + * - FITPAGE = 2 + * - FITHORZ = 3 + * - FITVERT = 4 + * - FITRECT = 5 + * - FITBBOX = 6 + * - FITBHORZ = 7 + * - FITBVERT = 8 + * Return value: + * None. + * Comments: + * See the Destinations description of <> + * in 8.2.1 for more details. + */ void (*FFI_DoGoToAction)(struct _FPDF_FORMFILLINFO* pThis, int nPageIndex, int zoomMode, float* fPosArray, int sizeofArray); - /** - * pointer to IPDF_JSPLATFORM interface - **/ + /* + * Pointer to IPDF_JSPLATFORM interface. + * Unused if PDFium is built without V8 support. Otherwise, if NULL, then + * JavaScript will be prevented from executing while rendering the document. + */ IPDF_JSPLATFORM* m_pJsPlatform; -#ifdef PDF_ENABLE_XFA - /* Version 2. */ - /** - * Method: FFI_DisplayCaret - * This method will show the caret at specified position. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * page - Handle to page. Returned by FPDF_LoadPage - *function. - * left - Left position of the client area in PDF page - *coordinate. - * top - Top position of the client area in PDF page - *coordinate. - * right - Right position of the client area in PDF page - *coordinate. - * bottom - Bottom position of the client area in PDF page - *coordinate. - * Return value: - * None. - **/ + /* Version 2 - Experimental. */ + /* + * Whether the XFA module is disabled when built with the XFA module. + * Interface Version: + * Ignored if |version| < 2. + */ + FPDF_BOOL xfa_disabled; + + /* + * Method: FFI_DisplayCaret + * This method will show the caret at specified position. + * Interface Version: + * Ignored if |version| < 2. + * Implementation Required: + * Required for XFA, otherwise set to NULL. + * Parameters: + * pThis - Pointer to the interface structure itself. + * page - Handle to page. Returned by FPDF_LoadPage(). + * left - Left position of the client area in PDF page + * coordinates. + * top - Top position of the client area in PDF page + * coordinates. + * right - Right position of the client area in PDF page + * coordinates. + * bottom - Bottom position of the client area in PDF page + * coordinates. + * Return value: + * None. + */ void (*FFI_DisplayCaret)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, FPDF_BOOL bVisible, @@ -735,157 +764,185 @@ typedef struct _FPDF_FORMFILLINFO { double right, double bottom); - /** - * Method: FFI_GetCurrentPageIndex - * This method will get the current page index. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * document - Handle to document. Returned by FPDF_LoadDocument - *function. - * Return value: - * The index of current page. - **/ + /* + * Method: FFI_GetCurrentPageIndex + * This method will get the current page index. + * Interface Version: + * Ignored if |version| < 2. + * Implementation Required: + * Required for XFA, otherwise set to NULL. + * Parameters: + * pThis - Pointer to the interface structure itself. + * document - Handle to document from FPDF_LoadDocument(). + * Return value: + * The index of current page. + */ int (*FFI_GetCurrentPageIndex)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document); - /** - * Method: FFI_SetCurrentPage - * This method will set the current page. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * document - Handle to document. Returned by FPDF_LoadDocument - *function. - * iCurPage - The index of the PDF page. - * Return value: - * None. - **/ + /* + * Method: FFI_SetCurrentPage + * This method will set the current page. + * Interface Version: + * Ignored if |version| < 2. + * Implementation Required: + * Required for XFA, otherwise set to NULL. + * Parameters: + * pThis - Pointer to the interface structure itself. + * document - Handle to document from FPDF_LoadDocument(). + * iCurPage - The index of the PDF page. + * Return value: + * None. + */ void (*FFI_SetCurrentPage)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document, int iCurPage); - /** + /* * Method: FFI_GotoURL - * This method will link to the specified URL. + * This method will navigate to the specified URL. * Interface Version: - * 1 + * Ignored if |version| < 2. * Implementation Required: - * no + * Required for XFA, otherwise set to NULL. * Parameters: - * pThis - Pointer to the interface structure itself. - * document - Handle to document. Returned by FPDF_LoadDocument - *function. - * wsURL - The string value of the URL, in UTF-16LE format. + * pThis - Pointer to the interface structure itself. + * document - Handle to document from FPDF_LoadDocument(). + * wsURL - The string value of the URL, in UTF-16LE format. * Return value: * None. - **/ + */ void (*FFI_GotoURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document, FPDF_WIDESTRING wsURL); - /** - * Method: FFI_GetPageViewRect - * This method will get the current page view rectangle. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * page - Handle to page. Returned by FPDF_LoadPage - *function. - * left - The pointer to receive left position of the page - *view area in PDF page coordinate. - * top - The pointer to receive top position of the page - *view area in PDF page coordinate. - * right - The pointer to receive right position of the - *client area in PDF page coordinate. - * bottom - The pointer to receive bottom position of the - *client area in PDF page coordinate. - * Return value: - * None. - **/ + /* + * Method: FFI_GetPageViewRect + * This method will get the current page view rectangle. + * Interface Version: + * Ignored if |version| < 2. + * Implementation Required: + * Required for XFA, otherwise set to NULL. + * Parameters: + * pThis - Pointer to the interface structure itself. + * page - Handle to page. Returned by FPDF_LoadPage(). + * left - The pointer to receive left position of the page + * view area in PDF page coordinates. + * top - The pointer to receive top position of the page + * view area in PDF page coordinates. + * right - The pointer to receive right position of the + * page view area in PDF page coordinates. + * bottom - The pointer to receive bottom position of the + * page view area in PDF page coordinates. + * Return value: + * None. + */ void (*FFI_GetPageViewRect)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, double* left, double* top, double* right, double* bottom); - /** - * Method: FFI_PopupMenu - * This method will track the right context menu for XFA fields. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * page - Handle to page. Returned by FPDF_LoadPage - *function. - * hWidget - Handle to XFA fields. - * menuFlag - The menu flags. Please refer to macro definition - *of FXFA_MEMU_XXX and this can be one or a combination of these macros. - * x - X position of the client area in PDF page - *coordinate. - * y - Y position of the client area in PDF page - *coordinate. - * Return value: - * TRUE indicates success; otherwise false. - **/ - FPDF_BOOL (*FFI_PopupMenu)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, FPDF_WIDGET hWidget, int menuFlag, float x, float y); - - /** - * Method: FFI_OpenFile - * This method will open the specified file with the specified mode. - * Interface Version - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * fileFlag - The file flag.Please refer to macro definition of - *FXFA_SAVEAS_XXX and this can be one of these macros. - * wsURL - The string value of the file URL, in UTF-16LE - *format. - * mode - The mode for open file. - * Return value: - * The handle to FPDF_FILEHANDLER. - **/ + + /* + * Method: FFI_PageEvent + * This method fires when pages have been added to or deleted from + * the XFA document. + * Interface Version: + * Ignored if |version| < 2. + * Implementation Required: + * Required for XFA, otherwise set to NULL. + * Parameters: + * pThis - Pointer to the interface structure itself. + * page_count - The number of pages to be added or deleted. + * event_type - See FXFA_PAGEVIEWEVENT_* above. + * Return value: + * None. + * Comments: + * The pages to be added or deleted always start from the last page + * of document. This means that if parameter page_count is 2 and + * event type is FXFA_PAGEVIEWEVENT_POSTADDED, 2 new pages have been + * appended to the tail of document; If page_count is 2 and + * event type is FXFA_PAGEVIEWEVENT_POSTREMOVED, the last 2 pages + * have been deleted. + */ + void (*FFI_PageEvent)(struct _FPDF_FORMFILLINFO* pThis, + int page_count, + FPDF_DWORD event_type); + + /* + * Method: FFI_PopupMenu + * This method will track the right context menu for XFA fields. + * Interface Version: + * Ignored if |version| < 2. + * Implementation Required: + * Required for XFA, otherwise set to NULL. + * Parameters: + * pThis - Pointer to the interface structure itself. + * page - Handle to page. Returned by FPDF_LoadPage(). + * hWidget - Always null, exists for compatibility. + * menuFlag - The menu flags. Please refer to macro definition + * of FXFA_MENU_XXX and this can be one or a + * combination of these macros. + * x - X position of the client area in PDF page + * coordinates. + * y - Y position of the client area in PDF page + * coordinates. + * Return value: + * TRUE indicates success; otherwise false. + */ + FPDF_BOOL (*FFI_PopupMenu)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_PAGE page, + FPDF_WIDGET hWidget, + int menuFlag, + float x, + float y); + + /* + * Method: FFI_OpenFile + * This method will open the specified file with the specified mode. + * Interface Version: + * Ignored if |version| < 2. + * Implementation Required: + * Required for XFA, otherwise set to NULL. + * Parameters: + * pThis - Pointer to the interface structure itself. + * fileFlag - The file flag. Please refer to macro definition + * of FXFA_SAVEAS_XXX and use one of these macros. + * wsURL - The string value of the file URL, in UTF-16LE + * format. + * mode - The mode for open file, e.g. "rb" or "wb". + * Return value: + * The handle to FPDF_FILEHANDLER. + */ FPDF_FILEHANDLER* (*FFI_OpenFile)(struct _FPDF_FORMFILLINFO* pThis, int fileFlag, FPDF_WIDESTRING wsURL, const char* mode); - /** - * Method: FFI_EmailTo - * This method will email the specified file stream to the specified - *contacter. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * pFileHandler - Handle to the FPDF_FILEHANDLER. - * pTo - A semicolon-delimited list of recipients for the - *message,in UTF-16LE format. - * pSubject - The subject of the message,in UTF-16LE format. - * pCC - A semicolon-delimited list of CC recipients for - *the message,in UTF-16LE format. - * pBcc - A semicolon-delimited list of BCC recipients for - *the message,in UTF-16LE format. - * pMsg - Pointer to the data buffer to be sent.Can be - *NULL,in UTF-16LE format. - * Return value: - * None. - **/ + /* + * Method: FFI_EmailTo + * This method will email the specified file stream to the specified + * contact. + * Interface Version: + * Ignored if |version| < 2. + * Implementation Required: + * Required for XFA, otherwise set to NULL. + * Parameters: + * pThis - Pointer to the interface structure itself. + * pFileHandler - Handle to the FPDF_FILEHANDLER. + * pTo - A semicolon-delimited list of recipients for the + * message,in UTF-16LE format. + * pSubject - The subject of the message,in UTF-16LE format. + * pCC - A semicolon-delimited list of CC recipients for + * the message,in UTF-16LE format. + * pBcc - A semicolon-delimited list of BCC recipients for + * the message,in UTF-16LE format. + * pMsg - Pointer to the data buffer to be sent.Can be + * NULL,in UTF-16LE format. + * Return value: + * None. + */ void (*FFI_EmailTo)(struct _FPDF_FORMFILLINFO* pThis, FPDF_FILEHANDLER* fileHandler, FPDF_WIDESTRING pTo, @@ -894,427 +951,677 @@ typedef struct _FPDF_FORMFILLINFO { FPDF_WIDESTRING pBcc, FPDF_WIDESTRING pMsg); - /** - * Method: FFI_UploadTo - * This method will get upload the specified file stream to the - *specified URL. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * pFileHandler - Handle to the FPDF_FILEHANDLER. - * fileFlag - The file flag.Please refer to macro definition of - *FXFA_SAVEAS_XXX and this can be one of these macros. - * uploadTo - Pointer to the URL path, in UTF-16LE format. - * Return value: - * None. - **/ + /* + * Method: FFI_UploadTo + * This method will upload the specified file stream to the + * specified URL. + * Interface Version: + * Ignored if |version| < 2. + * Implementation Required: + * Required for XFA, otherwise set to NULL. + * Parameters: + * pThis - Pointer to the interface structure itself. + * pFileHandler - Handle to the FPDF_FILEHANDLER. + * fileFlag - The file flag. Please refer to macro definition + * of FXFA_SAVEAS_XXX and use one of these macros. + * uploadTo - Pointer to the URL path, in UTF-16LE format. + * Return value: + * None. + */ void (*FFI_UploadTo)(struct _FPDF_FORMFILLINFO* pThis, FPDF_FILEHANDLER* fileHandler, int fileFlag, FPDF_WIDESTRING uploadTo); - /** - * Method: FFI_GetPlatform - * This method will get the current platform. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * platform - Pointer to the data buffer to receive the - *platform.Can be NULL,in UTF-16LE format. - * length - The length of the buffer, number of bytes. Can be - *0. - * Return value: - * The length of the buffer, number of bytes. - **/ + /* + * Method: FFI_GetPlatform + * This method will get the current platform. + * Interface Version: + * Ignored if |version| < 2. + * Implementation Required: + * Required for XFA, otherwise set to NULL. + * Parameters: + * pThis - Pointer to the interface structure itself. + * platform - Pointer to the data buffer to receive the + * platform,in UTF-16LE format. Can be NULL. + * length - The length of the buffer in bytes. Can be + * 0 to query the required size. + * Return value: + * The length of the buffer, number of bytes. + */ int (*FFI_GetPlatform)(struct _FPDF_FORMFILLINFO* pThis, void* platform, int length); - /** - * Method: FFI_GetLanguage - * This method will get the current language. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * language - Pointer to the data buffer to receive the current - *language.Can be NULL. - * length - The length of the buffer, number of bytes. Can be - *0. - * Return value: - * The length of the buffer, number of bytes. - **/ + /* + * Method: FFI_GetLanguage + * This method will get the current language. + * Interface Version: + * Ignored if |version| < 2. + * Implementation Required: + * Required for XFA, otherwise set to NULL. + * Parameters: + * pThis - Pointer to the interface structure itself. + * language - Pointer to the data buffer to receive the + * current language. Can be NULL. + * length - The length of the buffer in bytes. Can be + * 0 to query the required size. + * Return value: + * The length of the buffer, number of bytes. + */ int (*FFI_GetLanguage)(struct _FPDF_FORMFILLINFO* pThis, void* language, int length); - /** + /* * Method: FFI_DownloadFromURL - * This method will download the specified file from the URL. + * This method will download the specified file from the URL. * Interface Version: - * 1 + * Ignored if |version| < 2. * Implementation Required: - * yes + * 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. + * format. * Return value: * The handle to FPDF_FILEHANDLER. - **/ - FPDF_LPFILEHANDLER (*FFI_DownloadFromURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING URL); - /** - * Method: FFI_PostRequestURL - * This method will post the request to the server URL. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * wsURL - The string value of the server URL, in UTF-16LE - *format. - * wsData - The post data,in UTF-16LE format. - * wsContentType - The content type of the request data,in UTF-16LE - *format. - * wsEncode - The encode type,in UTF-16LE format. - * wsHeader - The request header,in UTF-16LE format. - * response - Pointer to the FPDF_BSTR to receive the response - *data from server,,in UTF-16LE format. - * Return value: - * TRUE indicates success, otherwise FALSE. - **/ - FPDF_BOOL (*FFI_PostRequestURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING wsURL, FPDF_WIDESTRING wsData, FPDF_WIDESTRING wsContentType, FPDF_WIDESTRING wsEncode, FPDF_WIDESTRING wsHeader, FPDF_BSTR* respone); + */ + 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: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * wsURL - The string value of the server URL, in UTF-16LE - *format. - * wsData - The put data, in UTF-16LE format. - * wsEncode - The encode type, in UTR-16LE format. - * Return value: - * TRUE indicates success, otherwise FALSE. - **/ - FPDF_BOOL (*FFI_PutRequestURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING wsURL, FPDF_WIDESTRING wsData, FPDF_WIDESTRING wsEncode); -#endif // PDF_ENABLE_XFA + /* + * Method: FFI_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); } FPDF_FORMFILLINFO; -/** +/* * Function: FPDFDOC_InitFormFillEnvironment - * Init form fill environment. - * Comments: - * This function should be called before any form fill operation. + * Initialize form fill environment. * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * pFormFillInfo - Pointer to a FPDF_FORMFILLINFO structure. + * document - Handle to document from FPDF_LoadDocument(). + * pFormFillInfo - Pointer to a FPDF_FORMFILLINFO structure. * Return Value: - * Return handler to the form fill module. NULL means fails. - **/ -DLLEXPORT FPDF_FORMHANDLE STDCALL + * Handle to the form fill module, or NULL on failure. + * Comments: + * This function should be called before any form fill operation. + */ +FPDF_EXPORT FPDF_FORMHANDLE FPDF_CALLCONV FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document, FPDF_FORMFILLINFO* formInfo); -/** +/* * Function: FPDFDOC_ExitFormFillEnvironment - * Exit form fill environment. + * Take ownership of |hHandle| and exit form fill environment. * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. + * hHandle - Handle to the form fill module, as returned by + * FPDFDOC_InitFormFillEnvironment(). * Return Value: - * NULL. - **/ -DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle); + * 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 method - *FPDFDOC_InitFormFillEnvironment had been invoked. + * 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. Returned by - *FPDFDOC_InitFormFillEnvironment. + * hHandle - Handle to the form fill module, as returned by + * FPDFDOC_InitFormFillEnvironment(). * Return Value: - * NONE. - **/ -DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, - FPDF_FORMHANDLE hHandle); + * 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 - * close the PDF page. + * 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. Returned by FPDF_LoadPage - *function. - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. + * 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. - **/ -DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, - FPDF_FORMHANDLE hHandle); - -/** -* Function: FORM_DoDocumentJSAction -* This method is required for performing Document-level JavaScript -*action. It should be invoked after the PDF document -* had been loaded. -* Parameters: -* hHandle - Handle to the form fill module. Returned by -*FPDFDOC_InitFormFillEnvironment. -* Return Value: -* NONE -* Comments: -* If there is Document-level JavaScript action embedded in the -*document, this method will execute the javascript action; -* otherwise, the method will do nothing. -**/ -DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle); - -/** -* Function: FORM_DoDocumentOpenAction -* This method is required for performing open-action when the document -*is opened. -* Parameters: -* hHandle - Handle to the form fill module. Returned by -*FPDFDOC_InitFormFillEnvironment. -* Return Value: -* NONE -* Comments: -* This method will do nothing if there is no open-actions embedded in -*the document. -**/ -DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle); - -// additional actions type of document. -#define FPDFDOC_AACTION_WC \ - 0x10 // WC, before closing document, JavaScript action. -#define FPDFDOC_AACTION_WS \ - 0x11 // WS, before saving document, JavaScript action. -#define FPDFDOC_AACTION_DS 0x12 // DS, after saving document, JavaScript - // action. -#define FPDFDOC_AACTION_WP \ - 0x13 // WP, before printing document, JavaScript action. -#define FPDFDOC_AACTION_DP \ - 0x14 // DP, after printing document, JavaScript action. - -/** -* Function: FORM_DoDocumentAAction -* This method is required for performing the document's -*additional-action. -* Parameters: -* hHandle - Handle to the form fill module. Returned by -*FPDFDOC_InitFormFillEnvironment. -* aaType - The type of the additional-actions which defined -*above. -* Return Value: -* NONE -* Comments: -* This method will do nothing if there is no document -*additional-action corresponding to the specified aaType. -**/ - -DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, - int aaType); - -// Additional-action types of page object -#define FPDFPAGE_AACTION_OPEN \ - 0 // /O -- An action to be performed when the page is opened -#define FPDFPAGE_AACTION_CLOSE \ - 1 // /C -- An action to be performed when the page is closed - -/** -* Function: FORM_DoPageAAction -* This method is required for performing the page object's -*additional-action when opened or closed. -* Parameters: -* page - Handle to the page. Returned by FPDF_LoadPage -*function. -* hHandle - Handle to the form fill module. Returned by -*FPDFDOC_InitFormFillEnvironment. -* aaType - The type of the page object's additional-actions -*which defined above. -* Return Value: -* NONE -* Comments: -* This method will do nothing if no additional-action corresponding to -*the specified aaType exists. -**/ -DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, - FPDF_FORMHANDLE hHandle, - int aaType); - -/** + * 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 - * You can call this member function when the mouse cursor moves. + * Call this member function when the mouse cursor moves. * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * page - Handle to the page. Returned by FPDF_LoadPage - *function. - * modifier - Indicates whether various virtual keys are down. - * page_x - Specifies the x-coordinate of the cursor in PDF user - *space. - * page_y - Specifies the y-coordinate of the cursor in PDF user - *space. + * 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. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int modifier, - double page_x, - double page_y); - -/** + * 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); + +/* + * 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 - * You can call this member function when the user presses the left - *mouse button. + * Call this member function when the user presses the left + * mouse button. * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * page - Handle to the page. Returned by FPDF_LoadPage - *function. - * modifier - Indicates whether various virtual keys are down. - * page_x - Specifies the x-coordinate of the cursor in PDF user - *space. - * page_y - Specifies the y-coordinate of the cursor in PDF user - *space. + * 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. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int modifier, - double page_x, - double page_y); - -/** + * 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 - * You can call this member function when the user releases the left - *mouse button. + * Call this member function when the user releases the left + * mouse button. * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * page - Handle to the page. Returned by FPDF_LoadPage - *function. - * modifier - Indicates whether various virtual keys are down. - * page_x - Specifies the x-coordinate of the cursor in device. - * page_y - Specifies the y-coordinate of the cursor in device. + * 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. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int modifier, - double page_x, - double page_y); - -#ifdef PDF_ENABLE_XFA -DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int modifier, - double page_x, - double page_y); -DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int modifier, - double page_x, - double page_y); -#endif // PDF_ENABLE_XFA - -/** + * 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 - * You can call this member function when a nonsystem key is pressed. + * Call this member function when a nonsystem key is pressed. * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * page - Handle to the page. Returned by FPDF_LoadPage - *function. - * nKeyCode - Indicates whether various virtual keys are down. - * modifier - Contains the scan code, key-transition code, - *previous key state, and context code. + * hHandle - Handle to the form fill module, aseturned by + * FPDFDOC_InitFormFillEnvironment(). + * page - Handle to the page, as returned by FPDF_LoadPage(). + * nKeyCode - Indicates whether various virtual keys are down. + * modifier - Contains the scan code, key-transition code, + * previous key state, and context code. * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int nKeyCode, - int modifier); - -/** + * 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 - * You can call this member function when a nonsystem key is released. + * Call this member function when a nonsystem key is released. * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * page - Handle to the page. Returned by FPDF_LoadPage - *function. - * nKeyCode - The virtual-key code of the given key. - * modifier - Contains the scan code, key-transition code, - *previous key state, and context code. + * 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. + * modifier - Contains the scan code, key-transition code, + * previous key state, and context code. * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int nKeyCode, - int modifier); - -/** + * True indicates success; otherwise false. + */ +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int nKeyCode, + int modifier); + +/* * Function: FORM_OnChar - * You can call this member function when a keystroke translates to a - *nonsystem character. + * 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 of the key. + * modifier - Contains the scan code, key-transition code, + * previous key state, and context code. + * 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); + +/* + * 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. + * 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); + +/* + * 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. Returned by - *FPDFDOC_InitFormFillEnvironment. - * page - Handle to the page. Returned by FPDF_LoadPage - *function. - * nChar - The character code value of the key. - * modifier - Contains the scan code, key-transition code, - *previous key state, and context code. + * 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 indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - int nChar, - int modifier); - -/** + * True if the redo operation succeeded. + */ +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_Redo(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page); + +/* * Function: FORM_ForceToKillFocus. - * You can call this member function to force to kill the focus of the - *form field which got focus. - * It would kill the focus on the form field, save the value of form - *field if it's changed by user. + * 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. Returned by - *FPDFDOC_InitFormFillEnvironment. + * hHandle - Handle to the form fill module, as returned by + * FPDFDOC_InitFormFillEnvironment(). * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle); + * True indicates success; otherwise false. + */ +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle); -// Field Types +/* + * 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(). + * page - Handle to a page. + * 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_PAGE page, + FPDF_ANNOTATION annot); + +// Form Field Types +// The names of the defines are stable, but the specific values associated with +// them are not, so do not hardcode their values. #define FPDF_FORMFIELD_UNKNOWN 0 // Unknown. #define FPDF_FORMFIELD_PUSHBUTTON 1 // push button type. #define FPDF_FORMFIELD_CHECKBOX 2 // check box type. @@ -1322,11 +1629,37 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle); #define FPDF_FORMFIELD_COMBOBOX 4 // combo box type. #define FPDF_FORMFIELD_LISTBOX 5 // list box type. #define FPDF_FORMFIELD_TEXTFIELD 6 // text field type. +#define FPDF_FORMFIELD_SIGNATURE 7 // text field type. +#ifdef PDF_ENABLE_XFA +#define FPDF_FORMFIELD_XFA 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 FPDF_FORMFIELD_XFA 7 // text field type. +#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: @@ -1338,22 +1671,14 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle); * Return Value: * Return the type of the form field; -1 indicates no field. * See field types above. - **/ -DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - double page_x, - double page_y); - -/** - * Function: FPDPage_HasFormFieldAtPoint - * DEPRECATED. Please use FPDFPage_HasFormFieldAtPoint. - **/ -DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - double page_x, - double page_y); - -/** + */ +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: @@ -1365,328 +1690,206 @@ DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, * Return Value: * Return the z-order of the form field; -1 indicates no field. * Higher numbers are closer to the front. - **/ -DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page, - double page_x, - double page_y); + */ +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 specified or all the form fields in the - *document. + * Set the highlight color of the specified (or all) form fields + * in the document. * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * doc - Handle to the document. Returned by - *FPDF_LoadDocument function. - * fieldType - A 32-bit integer indicating the type of a form - *field(defined above). - * color - The highlight color of the form field.Constructed by - *0xxxrrggbb. + * 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. + * None. * Comments: - * When the parameter fieldType is set to zero, the highlight color - *will be applied to all the form fields in the - * document. - * Please refresh the client window to show the highlight immediately - *if necessary. - **/ -DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, - int fieldType, - unsigned long color); - -/** + * 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. + * Set the transparency of the form field highlight color in the + * document. * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. - * doc - Handle to the document. Returned by - *FPDF_LoadDocument function. - * alpha - The transparency of the form field highlight color. - *between 0-255. + * 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. - **/ -DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, - unsigned char alpha); + * 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. + * Remove the form field highlight color in the document. * Parameters: - * hHandle - Handle to the form fill module. Returned by - *FPDFDOC_InitFormFillEnvironment. + * hHandle - Handle to the form fill module, as returned by + * FPDFDOC_InitFormFillEnvironment(). * Return Value: - * NONE. + * None. * Comments: - * Please refresh the client window to remove the highlight immediately - *if necessary. - **/ -DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle); + * 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 FormFeilds on a page to a device independent bitmap. +* Render FormFields and popup window on a page to a device independent +* bitmap. * Parameters: -* hHandle - Handle to the form fill module. Returned by -*FPDFDOC_InitFormFillEnvironment. -* bitmap - Handle to the device independent bitmap (as the -*output buffer). -* Bitmap handle can be created by FPDFBitmap_Create -*function. -* page - Handle to the page. Returned by FPDF_LoadPage -*function. -* start_x - Left pixel position of the display area in the -*device coordinate. -* start_y - Top pixel position of the display area in the device -*coordinate. -* size_x - Horizontal size (in pixels) for displaying the page. -* size_y - Vertical size (in pixels) for displaying the page. -* rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees -*clockwise), -* 2 (rotated 180 degrees), 3 (rotated 90 degrees -*counter-clockwise). -* flags - 0 for normal display, or combination of flags -*defined above. +* 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. +* None. * Comments: -* This method is designed to only render annotations and FormFields on -*the page. -* Without FPDF_ANNOT specified for flags, Rendering functions such as -*FPDF_RenderPageBitmap or FPDF_RenderPageBitmap_Start will only render page -*contents(without annotations) to a bitmap. -* In order to implement the FormFill functions,Implementation should -*call this method after rendering functions finish rendering the page contents. -**/ -DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, - FPDF_BITMAP bitmap, - FPDF_PAGE page, - int start_x, - int start_y, - int size_x, - int size_y, - int rotate, - int flags); +* 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); + +#ifdef _SKIA_SUPPORT_ +FPDF_EXPORT void FPDF_CALLCONV FPDF_FFLRecord(FPDF_FORMHANDLE hHandle, + FPDF_RECORDER recorder, + FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int flags); +#endif -#ifdef PDF_ENABLE_XFA -/** - * Function: FPDF_HasXFAField - * This method is designed to check whether a pdf document - *has XFA fields. +/* + * Experimental API + * Function: FPDF_GetFormType + * Returns the type of form contained in the PDF document. * Parameters: - * document - Handle to document. - *Returned by FPDF_LoadDocument function. - * docType - Document type defined as - *DOCTYPE_xxx. + * document - Handle to document. * Return Value: - * TRUE indicates that the input document has XFA fields, - *otherwise FALSE. - **/ -DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, - int* docType); + * 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); -/** - * Function: FPDF_LoadXFA - * If the document consists of XFA fields, there should call this - *method to load XFA fields. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * Return Value: - * TRUE indicates success,otherwise FALSE. - **/ -DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document); - -/** - * Function: FPDF_Widget_Undo - * This method will implement the undo feature for the specified xfa - *field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget); -/** - * Function: FPDF_Widget_Redo - * This method will implement the redo feature for the specified xfa - *field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget); -/** - * Function: FPDF_Widget_SelectAll - * This method will implement the select all feature for the specified - *xfa field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget); -/** - * Function: FPDF_Widget_Copy - * This method will implement the copy feature for the specified xfa - *field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * wsText - Pointer to data buffer to receive the copied - *data, in UTF-16LE format. - * size - The data buffer size. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget, - FPDF_WIDESTRING wsText, - FPDF_DWORD* size); -/** - * Function: FPDF_Widget_Cut - * This method will implement the cut feature for the specified xfa - *field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * wsText - Pointer to data buffer to receive the cut - *data,in UTF-16LE format. - * size - The data buffer size,not the byte number. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget, - FPDF_WIDESTRING wsText, - FPDF_DWORD* size); -/** - * Function: FPDF_Widget_Paste - * This method will implement the paste feature for the specified xfa - *field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * wsText - The paste text buffer, in UTF-16LE format. - * size - The data buffer size,not the byte number. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL FPDF_Widget_Paste(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget, - FPDF_WIDESTRING wsText, - FPDF_DWORD size); -/** - * Function: FPDF_Widget_ReplaceSpellCheckWord - * This method will implement the spell check feature for the specified - *xfa field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * x - The x value of the specified point. - * y - The y value of the specified point. - * bsText - The text buffer needed to be speck check, in - *UTF-16LE format. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL -FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget, - float x, - float y, - FPDF_BYTESTRING bsText); -/** - * Function: FPDF_Widget_GetSpellCheckWords - * This method will implement the spell check feature for the specified - *xfa field. - * Parameters: - * document - Handle to document. Returned by - *FPDF_LoadDocument function. - * hWidget - Handle to the xfa field. - * x - The x value of the specified point. - * y - The y value of the specified point. - * stringHandle - Pointer to FPDF_STRINGHANDLE to receive the - *speck check text buffer, in UTF-16LE format. - * Return Value: - * None. - **/ -DLLEXPORT void STDCALL -FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, - FPDF_WIDGET hWidget, - float x, - float y, - FPDF_STRINGHANDLE* stringHandle); -/** - * Function: FPDF_StringHandleCounts - * This method will get the count of the text buffer. +/* + * Experimental API + * Function: FORM_SetIndexSelected + * Selects/deselects the value at the given |index| of the focused + * annotation. * Parameters: - * stringHandle - Pointer to FPDF_STRINGHANDLE. + * 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: - * None. - **/ -DLLEXPORT int STDCALL FPDF_StringHandleCounts(FPDF_STRINGHANDLE stringHandle); -/** - * Function: FPDF_StringHandleGetStringByIndex - * This method will get the specified index of the text buffer. - * Parameters: - * stringHandle - Pointer to FPDF_STRINGHANDLE. - * index - The specified index of text buffer. - * bsText - Pointer to data buffer to receive the text - *buffer, in UTF-16LE format. - * size - The byte size of data buffer. - * Return Value: - * TRUE indicates success, otherwise FALSE. - **/ -DLLEXPORT FPDF_BOOL STDCALL -FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE stringHandle, - int index, - FPDF_BYTESTRING bsText, - FPDF_DWORD* size); -/** - * Function: FPDF_StringHandleRelease - * This method will release the FPDF_STRINGHANDLE. + * 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: - * stringHandle - Pointer to FPDF_STRINGHANDLE. + * 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: - * None. - **/ -DLLEXPORT void STDCALL FPDF_StringHandleRelease(FPDF_STRINGHANDLE stringHandle); -/** - * Function: FPDF_StringHandleAddString - * This method will add the specified text buffer. + * 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: - * stringHandle - Pointer to FPDF_STRINGHANDLE. - * bsText - Pointer to data buffer of the text buffer, in - *UTF-16LE format. - * size - The byte size of data buffer. + * document - Handle to document from FPDF_LoadDocument(). * Return Value: - * TRUE indicates success, otherwise FALSE. - **/ -DLLEXPORT FPDF_BOOL STDCALL -FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringHandle, - FPDF_BYTESTRING bsText, - FPDF_DWORD size); -#endif // PDF_ENABLE_XFA + * 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 } diff --git a/src/main/jni/include/fpdf_fwlevent.h b/src/main/jni/include/fpdf_fwlevent.h index 22c01e42..c8593e94 100644 --- a/src/main/jni/include/fpdf_fwlevent.h +++ b/src/main/jni/include/fpdf_fwlevent.h @@ -7,23 +7,14 @@ #ifndef PUBLIC_FPDF_FWLEVENT_H_ #define PUBLIC_FPDF_FWLEVENT_H_ +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" #ifdef __cplusplus extern "C" { -#endif +#endif // __cplusplus -typedef int FPDF_INT32; -typedef unsigned int FPDF_UINT32; -typedef float FPDF_FLOAT; -// event type -typedef enum { - FWL_EVENTTYPE_Mouse = 0, - FWL_EVENTTYPE_MouseWheel, - FWL_EVENTTYPE_Key, -} FWL_EVENTTYPE; - -// key flag +// Key flags. typedef enum { FWL_EVENTFLAG_ShiftKey = 1 << 0, FWL_EVENTFLAG_ControlKey = 1 << 1, @@ -36,44 +27,11 @@ typedef enum { FWL_EVENTFLAG_RightButtonDown = 1 << 8, } FWL_EVENTFLAG; -// Mouse message command -typedef enum { - FWL_EVENTMOUSECMD_LButtonDown = 1, - FWL_EVENTMOUSECMD_LButtonUp, - FWL_EVENTMOUSECMD_LButtonDblClk, - FWL_EVENTMOUSECMD_RButtonDown, - FWL_EVENTMOUSECMD_RButtonUp, - FWL_EVENTMOUSECMD_RButtonDblClk, - FWL_EVENTMOUSECMD_MButtonDown, - FWL_EVENTMOUSECMD_MButtonUp, - FWL_EVENTMOUSECMD_MButtonDblClk, - FWL_EVENTMOUSECMD_MouseMove, - FWL_EVENTMOUSECMD_MouseEnter, - FWL_EVENTMOUSECMD_MouseHover, - FWL_EVENTMOUSECMD_MouseLeave, -} FWL_EVENT_MOUSECMD; - -// mouse event -struct FWL_EVENT_MOUSE { - FPDF_UINT32 command; - FPDF_DWORD flag; - FPDF_FLOAT x; - FPDF_FLOAT y; -}; - -// mouse wheel -struct FWL_EVENT_MOUSEWHEEL { - FPDF_DWORD flag; - FPDF_FLOAT x; - FPDF_FLOAT y; - FPDF_FLOAT deltaX; - FPDF_FLOAT deltaY; -}; - -// virtual keycode +// Virtual keycodes. typedef enum { FWL_VKEY_Back = 0x08, FWL_VKEY_Tab = 0x09, + FWL_VKEY_NewLine = 0x0A, FWL_VKEY_Clear = 0x0C, FWL_VKEY_Return = 0x0D, FWL_VKEY_Shift = 0x10, @@ -242,40 +200,8 @@ typedef enum { FWL_VKEY_Unknown = 0, } FWL_VKEYCODE; -// key event command -typedef enum { - FWL_EVENTKEYCMD_KeyDown = 1, - FWL_EVENTKEYCMD_KeyUp, - FWL_EVENTKEYCMD_Char, -} FWL_EVENTKEYCMD; - -// key event -struct FWL_EVENT_KEY { - FPDF_UINT32 command; - FPDF_DWORD flag; - union { - // Virtual key code. - FPDF_UINT32 vkcode; - // Character code. - FPDF_DWORD charcode; - } code; -}; - -// event type -struct FWL_EVENT { - // structure size. - FPDF_UINT32 size; - // FWL_EVENTTYPE. - FPDF_UINT32 type; - union { - struct FWL_EVENT_MOUSE mouse; - struct FWL_EVENT_MOUSEWHEEL wheel; - struct FWL_EVENT_KEY key; - } s; -}; - #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_FWLEVENT_H_ diff --git a/src/main/jni/include/fpdf_ppo.h b/src/main/jni/include/fpdf_ppo.h index e7d77678..e9f3f666 100644 --- a/src/main/jni/include/fpdf_ppo.h +++ b/src/main/jni/include/fpdf_ppo.h @@ -7,41 +7,62 @@ #ifndef PUBLIC_FPDF_PPO_H_ #define PUBLIC_FPDF_PPO_H_ +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" #ifdef __cplusplus extern "C" { #endif -// Function: FPDF_ImportPages -// Import some pages to a PDF document. -// Parameters: -// dest_doc - The destination document which add the pages. -// src_doc - A document to be imported. -// pagerange - A page range string, Such as "1,3,5-7". -// If this parameter is NULL, it would import all pages -// in src_doc. -// index - The page index wanted to insert from. -// Return value: -// TRUE for succeed, FALSE for Failed. -DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc, - FPDF_DOCUMENT src_doc, - FPDF_BYTESTRING pagerange, - int index); - -// Function: FPDF_CopyViewerPreferences -// Copy the viewer preferences from one PDF document to another.#endif -// Parameters: -// dest_doc - Handle to document to write the viewer preferences -// to. -// src_doc - Handle to document with the viewer preferences. +// 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". If |pagerange| is NULL, +// all pages from |src_doc| are imported. +// index - The page index to insert at. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_ImportPages(FPDF_DOCUMENT dest_doc, + FPDF_DOCUMENT src_doc, + FPDF_BYTESTRING pagerange, + int index); + +// Experimental API. +// Create a new document from |src_doc|. The pages of |src_doc| will be +// combined to provide |num_pages_on_x_axis x num_pages_on_y_axis| pages per +// |output_doc| page. +// +// src_doc - The document to be imported. +// output_width - The output page width in PDF "user space" units. +// output_height - The output page height in PDF "user space" units. +// num_pages_on_x_axis - The number of pages on X Axis. +// num_pages_on_y_axis - The number of pages on Y Axis. +// // Return value: -// TRUE for success, FALSE for failure. -DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, - FPDF_DOCUMENT src_doc); +// A handle to the created document, or NULL on failure. +// +// Comments: +// number of pages per page = num_pages_on_x_axis * num_pages_on_y_axis +// +FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV +FPDF_ImportNPagesToOne(FPDF_DOCUMENT src_doc, + float output_width, + float output_height, + size_t num_pages_on_x_axis, + size_t num_pages_on_y_axis); + +// Copy the viewer preferences from |src_doc| into |dest_doc|. +// +// dest_doc - Document to write the viewer preferences into. +// src_doc - Document to read the viewer preferences from. +// +// Returns TRUE on success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, FPDF_DOCUMENT src_doc); #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_PPO_H_ diff --git a/src/main/jni/include/fpdf_progressive.h b/src/main/jni/include/fpdf_progressive.h index f352ff9d..99803b87 100644 --- a/src/main/jni/include/fpdf_progressive.h +++ b/src/main/jni/include/fpdf_progressive.h @@ -7,11 +7,13 @@ #ifndef PUBLIC_FPDF_PROGRESSIVE_H_ #define PUBLIC_FPDF_PROGRESSIVE_H_ +// clang-format off +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" // Flags for progressive process status. -#define FPDF_RENDER_READER 0 -#define FPDF_RENDER_TOBECOUNTINUED 1 +#define FPDF_RENDER_READY 0 +#define FPDF_RENDER_TOBECONTINUED 1 #define FPDF_RENDER_DONE 2 #define FPDF_RENDER_FAILED 3 @@ -21,24 +23,23 @@ extern "C" { // IFPDF_RENDERINFO interface. typedef struct _IFSDK_PAUSE { - /** - * Version number of the interface. Currently must be 1. - **/ + /* + * Version number of the interface. Currently must be 1. + */ int version; /* - * Method: NeedToPauseNow - * Check if we need to pause a progressive process now. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * Return Value: - * Non-zero for pause now, 0 for continue. - * - */ + * Method: NeedToPauseNow + * Check if we need to pause a progressive process now. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * Return Value: + * Non-zero for pause now, 0 for continue. + */ FPDF_BOOL (*NeedToPauseNow)(struct _IFSDK_PAUSE* pThis); // A user defined data pointer, used by user's application. Can be NULL. @@ -50,64 +51,62 @@ typedef struct _IFSDK_PAUSE { // progressively. // Parameters: // bitmap - Handle to the device independent bitmap (as the -// output buffer). -// Bitmap handle can be created by FPDFBitmap_Create -// function. -// page - Handle to the page. Returned by FPDF_LoadPage -// function. +// output buffer). Bitmap handle can be created by +// FPDFBitmap_Create(). +// page - Handle to the page, as returned by FPDF_LoadPage(). // start_x - Left pixel position of the display area in the -// bitmap coordinate. +// bitmap coordinates. // start_y - Top pixel position of the display area in the bitmap -// coordinate. +// coordinates. // size_x - Horizontal size (in pixels) for displaying the page. // size_y - Vertical size (in pixels) for displaying the page. // rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees -// clockwise), -// 2 (rotated 180 degrees), 3 (rotated 90 degrees -// counter-clockwise). +// clockwise), 2 (rotated 180 degrees), 3 (rotated 90 +// degrees counter-clockwise). // flags - 0 for normal display, or combination of flags -// defined above. +// defined in fpdfview.h. With FPDF_ANNOT flag, it +// renders all annotations that does not require +// user-interaction, which are all annotations except +// widget and popup annotations. // pause - The IFSDK_PAUSE interface.A callback mechanism -// allowing the page rendering process +// allowing the page rendering process // Return value: // Rendering Status. See flags for progressive process status for the // details. // -DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, - FPDF_PAGE page, - int start_x, - int start_y, - int size_x, - int size_y, - int rotate, - int flags, - IFSDK_PAUSE* pause); +FPDF_EXPORT int FPDF_CALLCONV FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, + FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int flags, + IFSDK_PAUSE* pause); // Function: FPDF_RenderPage_Continue // Continue rendering a PDF page. // Parameters: -// page - Handle to the page. Returned by FPDF_LoadPage -// function. -// pause - The IFSDK_PAUSE interface.A callback mechanism -// allowing the page rendering process -// to be paused before it's finished. This can be NULL -// if you don't want to pause. +// page - Handle to the page, as returned by FPDF_LoadPage(). +// pause - The IFSDK_PAUSE interface (a callback mechanism +// allowing the page rendering process to be paused +// before it's finished). This can be NULL if you +// don't want to pause. // Return value: // The rendering status. See flags for progressive process status for // the details. -DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page, - IFSDK_PAUSE* pause); +FPDF_EXPORT int FPDF_CALLCONV FPDF_RenderPage_Continue(FPDF_PAGE page, + IFSDK_PAUSE* pause); // Function: FPDF_RenderPage_Close // Release the resource allocate during page rendering. Need to be // called after finishing rendering or // cancel the rendering. // Parameters: -// page - Handle to the page. Returned by FPDF_LoadPage -// function. +// page - Handle to the page, as returned by FPDF_LoadPage(). // Return value: -// NULL -DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page); +// None. +FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPage_Close(FPDF_PAGE page); #ifdef __cplusplus } diff --git a/src/main/jni/include/fpdf_save.h b/src/main/jni/include/fpdf_save.h index 4eea054e..527d9428 100644 --- a/src/main/jni/include/fpdf_save.h +++ b/src/main/jni/include/fpdf_save.h @@ -7,6 +7,8 @@ #ifndef PUBLIC_FPDF_SAVE_H_ #define PUBLIC_FPDF_SAVE_H_ +// clang-format off +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" #ifdef __cplusplus @@ -20,7 +22,6 @@ typedef struct FPDF_FILEWRITE_ { // int version; - // // Method: WriteBlock // Output a block of data in your custom way. // Interface Version: @@ -35,50 +36,47 @@ typedef struct FPDF_FILEWRITE_ { // size - The size of the buffer. // Return value: // Should be non-zero if successful, zero for error. - // int (*WriteBlock)(struct FPDF_FILEWRITE_* pThis, const void* pData, unsigned long size); - } FPDF_FILEWRITE; -/** @brief Incremental. */ + // Flags for FPDF_SaveAsCopy() #define FPDF_INCREMENTAL 1 -/** @brief No Incremental. */ #define FPDF_NO_INCREMENTAL 2 -/** @brief Remove security. */ #define FPDF_REMOVE_SECURITY 3 // Function: FPDF_SaveAsCopy // Saves the copy of specified document in custom way. // Parameters: -// document - Handle to document. Returned by -// FPDF_LoadDocument and FPDF_CreateNewDocument. +// document - Handle to document, as returned by +// FPDF_LoadDocument() or FPDF_CreateNewDocument(). // pFileWrite - A pointer to a custom file write structure. // flags - The creating flags. // Return value: // TRUE for succeed, FALSE for failed. // -DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy(FPDF_DOCUMENT document, - FPDF_FILEWRITE* pFileWrite, - FPDF_DWORD flags); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_SaveAsCopy(FPDF_DOCUMENT document, + FPDF_FILEWRITE* pFileWrite, + FPDF_DWORD flags); // Function: FPDF_SaveWithVersion -// Same as function ::FPDF_SaveAsCopy, except the file version of the -// saved document could be specified by user. +// Same as FPDF_SaveAsCopy(), except the file version of the +// saved document can be specified by the caller. // Parameters: // document - Handle to document. // pFileWrite - A pointer to a custom file write structure. // flags - The creating flags. // fileVersion - The PDF file version. File version: 14 for 1.4, -// 15 for 1.5, ... +// 15 for 1.5, ... // Return value: // TRUE if succeed, FALSE if failed. // -DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, - FPDF_FILEWRITE* pFileWrite, - FPDF_DWORD flags, - int fileVersion); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDF_SaveWithVersion(FPDF_DOCUMENT document, + FPDF_FILEWRITE* pFileWrite, + FPDF_DWORD flags, + int fileVersion); #ifdef __cplusplus } diff --git a/src/main/jni/include/fpdf_searchex.h b/src/main/jni/include/fpdf_searchex.h index a6b6e1bd..4b67786f 100644 --- a/src/main/jni/include/fpdf_searchex.h +++ b/src/main/jni/include/fpdf_searchex.h @@ -7,26 +7,33 @@ #ifndef PUBLIC_FPDF_SEARCHEX_H_ #define PUBLIC_FPDF_SEARCHEX_H_ +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" #ifdef __cplusplus extern "C" { -#endif - -// Function: FPDFText_GetCharIndexFromTextIndex -// Get the actually char index in text_page's internal char list. -// Parameters: -// text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. -// nTextIndex - The index of the text in the string get from -// FPDFText_GetText. -// Return value: -// The index of the character in internal charlist. -1 for error. -DLLEXPORT int STDCALL +#endif // __cplusplus + +// Get the character index in |text_page| internal character list. +// +// text_page - a text page information structure. +// nTextIndex - index of the text returned from FPDFText_GetText(). +// +// Returns the index of the character in internal character list. -1 for error. +FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetCharIndexFromTextIndex(FPDF_TEXTPAGE text_page, int nTextIndex); +// Get the text index in |text_page| internal character list. +// +// text_page - a text page information structure. +// nCharIndex - index of the character in internal character list. +// +// Returns the index of the text returned from FPDFText_GetText(). -1 for error. +FPDF_EXPORT int FPDF_CALLCONV +FPDFText_GetTextIndexFromCharIndex(FPDF_TEXTPAGE text_page, int nCharIndex); + #ifdef __cplusplus -} -#endif +} // extern "C" +#endif // __cplusplus #endif // PUBLIC_FPDF_SEARCHEX_H_ diff --git a/src/main/jni/include/fpdf_sysfontinfo.h b/src/main/jni/include/fpdf_sysfontinfo.h index c2da74b7..936de962 100644 --- a/src/main/jni/include/fpdf_sysfontinfo.h +++ b/src/main/jni/include/fpdf_sysfontinfo.h @@ -7,6 +7,8 @@ #ifndef PUBLIC_FPDF_SYSFONTINFO_H_ #define PUBLIC_FPDF_SYSFONTINFO_H_ +// clang-format off +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" /* Character sets for the font */ @@ -17,9 +19,12 @@ #define FXFONT_HANGEUL_CHARSET 129 #define FXFONT_GB2312_CHARSET 134 #define FXFONT_CHINESEBIG5_CHARSET 136 +#define FXFONT_ARABIC_CHARSET 178 +#define FXFONT_CYRILLIC_CHARSET 204 +#define FXFONT_EASTERNEUROPEAN_CHARSET 238 /* Font pitch and family flags */ -#define FXFONT_FF_FIXEDPITCH 1 +#define FXFONT_FF_FIXEDPITCH (1 << 0) #define FXFONT_FF_ROMAN (1 << 4) #define FXFONT_FF_SCRIPT (4 << 4) @@ -32,87 +37,84 @@ 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 is no longer used. * Interface Version: * 1 * Implementation Required: * No - * Comments: - * Called by Foxit SDK during the final cleanup process. * Parameters: * pThis - Pointer to the interface structure itself * Return Value: * None + * Comments: + * Called by PDFium during the final cleanup process. */ void (*Release)(struct _FPDF_SYSFONTINFO* pThis); - /** + /* * Method: EnumFonts * Enumerate all fonts installed on the system * Interface Version: * 1 * Implementation Required: * No - * Comments: - * Implementation should call FPDF_AddIntalledFont() function for - * each font found. - * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK. * Parameters: * pThis - Pointer to the interface structure itself * pMapper - An opaque pointer to internal font mapper, used - * when calling FPDF_AddInstalledFont + * when calling FPDF_AddInstalledFont(). * Return Value: * None + * Comments: + * Implementations should call FPDF_AddIntalledFont() 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 + * parameters. * Interface Version: * 1 * Implementation Required: - * Yes only if GetFont method is not implemented. - * Comments: - * If the system supports native font mapper (like Windows), - *implementation can implement this method to get a font handle. - * Otherwise, Foxit SDK will do the mapping and then call GetFont - *method. - * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK. + * 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. + * 700 is bold. * bItalic - Italic option of the requested font, TRUE or - *FALSE. + * FALSE. * charset - Character set identifier for the requested font. - *See above defined constants. + * See above defined constants. * pitch_family - A combination of flags. See above defined - *constants. + * constants. * face - Typeface name. Currently use system local encoding - *only. - * bExact - Pointer to a boolean value receiving the indicator - *whether mapper found the exact match. - * If mapper is not sure whether it's exact match, - *ignore this paramter. + * only. + * bExact - Obsolete: this parameter is now ignored. * Return Value: * An opaque pointer for font handle, or NULL if system mapping is - *not supported. - **/ + * not supported. + * Comments: + * If the system supports native font mapper (like Windows), + * implementation can implement this method to get a font handle. + * Otherwise, PDFium will do the mapping and then call GetFont + * method. Only TrueType/OpenType and Type1 fonts are accepted + * by PDFium. + */ void* (*MapFont)(struct _FPDF_SYSFONTINFO* pThis, int weight, FPDF_BOOL bItalic, @@ -121,56 +123,53 @@ typedef struct _FPDF_SYSFONTINFO { const char* face, FPDF_BOOL* bExact); - /** + /* * Method: GetFont * Get a handle to a particular font by its internal ID * Interface Version: * 1 * Implementation Required: - * Yes only if MapFont method is not implemented. - * Comments: - * If the system mapping not supported, Foxit SDK will do the font - *mapping and use this method to get a font handle. - * Parameters: - * pThis - Pointer to the interface structure itself - * face - Typeface name. Currently use system local encoding - *only. + * Required if MapFont method is not implemented. * Return Value: * An opaque pointer for font handle. - **/ + * Parameters: + * pThis - Pointer to the interface structure itself + * face - Typeface name in system local encoding. + * Comments: + * If the system mapping not supported, PDFium will do the font + * mapping and use this method to get a font handle. + */ void* (*GetFont)(struct _FPDF_SYSFONTINFO* pThis, const char* face); - /** + /* * Method: GetFontData * Get font data from a font * Interface Version: * 1 * Implementation Required: * Yes - * Comments: - * Can read either full font file, or a particular TrueType/OpenType - *table * Parameters: * pThis - Pointer to the interface structure itself * hFont - Font handle returned by MapFont or GetFont method * table - TrueType/OpenType table identifier (refer to - *TrueType specification). - * 0 for the whole font file. + * 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 + * 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. - **/ + * 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: @@ -181,19 +180,18 @@ typedef struct _FPDF_SYSFONTINFO { * 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 + * 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. - **/ + * 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: @@ -205,10 +203,10 @@ typedef struct _FPDF_SYSFONTINFO { * 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: @@ -220,20 +218,20 @@ typedef struct _FPDF_SYSFONTINFO { * 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 @@ -242,58 +240,71 @@ typedef struct FPDF_CharsetFontMap_ { * None. * Return Value: * Pointer to the Charset Font Map. - **/ -DLLEXPORT const FPDF_CharsetFontMap* STDCALL FPDF_GetDefaultTTFMap(); + */ +FPDF_EXPORT const FPDF_CharsetFontMap* FPDF_CALLCONV FPDF_GetDefaultTTFMap(); -/** +/* * Function: FPDF_AddInstalledFont - * Add a system font to the list in Foxit SDK. + * Add a system font to the list in PDFium. * Comments: * This function is only called during the system font list building - *process. + * process. * Parameters: * mapper - Opaque pointer to Foxit font mapper * face - The font face name * charset - Font character set. See above defined constants. * Return Value: * None. - **/ -DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper, - const char* face, - int charset); + */ +FPDF_EXPORT void FPDF_CALLCONV FPDF_AddInstalledFont(void* mapper, + const char* face, + int charset); -/** +/* * Function: FPDF_SetSystemFontInfo - * Set the system font info interface into Foxit SDK - * Comments: - * Platform support implementation should implement required methods of - *FFDF_SYSFONTINFO interface, - * then call this function during SDK initialization process. + * Set the system font info interface into PDFium * Parameters: * pFontInfo - Pointer to a FPDF_SYSFONTINFO structure * Return Value: * None - **/ -DLLEXPORT void STDCALL FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfo); + * Comments: + * Platform support implementation should implement required methods of + * FFDF_SYSFONTINFO interface, then call this function during PDFium + * initialization process. + */ +FPDF_EXPORT void FPDF_CALLCONV +FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfo); -/** +/* * Function: FPDF_GetDefaultSystemFontInfo * Get default system font info interface for current platform - * Comments: - * For some platforms Foxit SDK implement a default version of system - *font info interface. - * The default implementation can be used in FPDF_SetSystemFontInfo - *function. * Parameters: * None * Return Value: * Pointer to a FPDF_SYSFONTINFO structure describing the default - *interface. - * Or NULL if the platform doesn't have a default interface. - * Application should call FPDF_FreeMemory to free the returned - *pointer. - **/ -DLLEXPORT FPDF_SYSFONTINFO* STDCALL FPDF_GetDefaultSystemFontInfo(); + * 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_SetSystemFontInfo() once it is no longer needed. + */ +FPDF_EXPORT void FPDF_CALLCONV +FPDF_FreeDefaultSystemFontInfo(FPDF_SYSFONTINFO* pFontInfo); #ifdef __cplusplus } diff --git a/src/main/jni/include/fpdf_text.h b/src/main/jni/include/fpdf_text.h index 32cc1318..65554e4c 100644 --- a/src/main/jni/include/fpdf_text.h +++ b/src/main/jni/include/fpdf_text.h @@ -7,6 +7,8 @@ #ifndef PUBLIC_FPDF_TEXT_H_ #define PUBLIC_FPDF_TEXT_H_ +// clang-format off +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" // Exported Functions @@ -18,7 +20,7 @@ extern "C" { // Prepare information about all characters in a page. // Parameters: // page - Handle to the page. Returned by FPDF_LoadPage function -// (in FPDFVIEW module). +// (in FPDFVIEW module). // Return value: // A handle to the text page information structure. // NULL if something goes wrong. @@ -26,24 +28,24 @@ extern "C" { // Application must call FPDFText_ClosePage to release the text page // information. // -DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page); +FPDF_EXPORT FPDF_TEXTPAGE FPDF_CALLCONV FPDFText_LoadPage(FPDF_PAGE page); // Function: FPDFText_ClosePage // Release all resources allocated for a text page information // structure. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // Return Value: // None. // -DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page); +FPDF_EXPORT void FPDF_CALLCONV FPDFText_ClosePage(FPDF_TEXTPAGE text_page); // Function: FPDFText_CountChars // Get number of characters in a page. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // Return value: // Number of characters in the page. Return -1 for error. // Generated characters, like additional space characters, new line @@ -55,13 +57,13 @@ DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page); // first character in the page // has an index value of zero. // -DLLEXPORT int STDCALL FPDFText_CountChars(FPDF_TEXTPAGE text_page); +FPDF_EXPORT int FPDF_CALLCONV FPDFText_CountChars(FPDF_TEXTPAGE text_page); // Function: FPDFText_GetUnicode // Get Unicode of a character in a page. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // index - Zero-based index of the character. // Return value: // The Unicode of the particular character. @@ -69,187 +71,377 @@ DLLEXPORT int STDCALL FPDFText_CountChars(FPDF_TEXTPAGE text_page); // convert to Unicode, // the return value will be zero. // -DLLEXPORT unsigned int STDCALL FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, - int index); +FPDF_EXPORT unsigned int FPDF_CALLCONV +FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, int index); // Function: FPDFText_GetFontSize // Get the font size of a particular character. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // index - Zero-based index of the character. // Return value: // The font size of the particular character, measured in points (about -// 1/72 inch). -// This is the typographic size of the font (so called "em size"). +// 1/72 inch). This is the typographic size of the font (so called +// "em size"). // -DLLEXPORT double STDCALL FPDFText_GetFontSize(FPDF_TEXTPAGE text_page, - int index); +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_GetTextRenderMode +// Get text rendering mode of 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 render mode value. A valid value is of type +// FPDF_TEXT_RENDERMODE. If |text_page| is invalid, if |index| is out +// of bounds, or if the text object is undefined, then return +// FPDF_TEXTRENDERMODE_UNKNOWN. +// +FPDF_EXPORT FPDF_TEXT_RENDERMODE FPDF_CALLCONV +FPDFText_GetTextRenderMode(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. +// Returned by FPDFText_LoadPage function. // index - Zero-based index of the character. // left - Pointer to a double number receiving left position -// of the character box. +// of the character box. // right - Pointer to a double number receiving right position -// of the character box. +// of the character box. // bottom - Pointer to a double number receiving bottom position -// of the character box. +// of the character box. // top - Pointer to a double number receiving top position of -// the character box. +// the character box. // Return Value: -// None. +// On success, return TRUE and fill in |left|, |right|, |bottom|, and +// |top|. If |text_page| is invalid, or if |index| is out of bounds, +// then return FALSE, and the out parameters remain unmodified. // Comments: // All positions are measured in PDF "user space". // -DLLEXPORT void STDCALL FPDFText_GetCharBox(FPDF_TEXTPAGE text_page, - int index, - double* left, - double* right, - double* bottom, - double* top); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetCharBox(FPDF_TEXTPAGE text_page, + int index, + double* left, + double* right, + double* bottom, + double* top); + +// Experimental API. +// Function: FPDFText_GetLooseCharBox +// Get a "loose" bounding box of a particular character, i.e., covering +// the entire glyph bounds, without taking the actual glyph shape into +// account. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// index - Zero-based index of the character. +// rect - Pointer to a FS_RECTF receiving the character box. +// Return Value: +// On success, return TRUE and fill in |rect|. If |text_page| is +// invalid, or if |index| is out of bounds, then return FALSE, and the +// |rect| out parameter remains unmodified. +// Comments: +// All positions are measured in PDF "user space". +// +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFText_GetLooseCharBox(FPDF_TEXTPAGE text_page, int index, FS_RECTF* rect); + +// Experimental API. +// Function: FPDFText_GetMatrix +// Get the effective transformation matrix for a particular character. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage(). +// index - Zero-based index of the character. +// matrix - Pointer to a FS_MATRIX receiving the transformation +// matrix. +// Return Value: +// On success, return TRUE and fill in |matrix|. If |text_page| is +// invalid, or if |index| is out of bounds, or if |matrix| is NULL, +// then return FALSE, and |matrix| remains unmodified. +// +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetMatrix(FPDF_TEXTPAGE text_page, + int index, + FS_MATRIX* matrix); + +// Function: FPDFText_GetCharOrigin +// Get origin of a particular character. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// index - Zero-based index of the character. +// x - Pointer to a double number receiving x coordinate of +// the character origin. +// y - Pointer to a double number receiving y coordinate of +// the character origin. +// Return Value: +// Whether the call succeeded. If false, x and y are unchanged. +// Comments: +// All positions are measured in PDF "user space". +// +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFText_GetCharOrigin(FPDF_TEXTPAGE text_page, + int index, + double* x, + double* y); // Function: FPDFText_GetCharIndexAtPos // Get the index of a character at or nearby a certain position on the // page. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // x - X position in PDF "user space". // y - Y position in PDF "user space". // xTolerance - An x-axis tolerance value for character hit -// detection, in point unit. +// detection, in point units. // yTolerance - A y-axis tolerance value for character hit -// detection, in point unit. +// detection, in point units. // Return Value: // The zero-based index of the character at, or nearby the point (x,y). // If there is no character at or nearby the point, return value will -// be -1. -// If an error occurs, -3 will be returned. +// be -1. If an error occurs, -3 will be returned. // -DLLEXPORT int STDCALL FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page, - double x, - double y, - double xTolerance, - double yTolerance); +FPDF_EXPORT int FPDF_CALLCONV +FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page, + double x, + double y, + double xTolerance, + double yTolerance); // Function: FPDFText_GetText // Extract unicode text string from the page. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // start_index - Index for the start characters. // count - Number of characters to be extracted. // result - A buffer (allocated by application) receiving the -// extracted unicodes. -// The size of the buffer must be able to hold the -// number of characters plus a terminator. +// extracted unicodes. The size of the buffer must be +// able to hold the number of characters plus a +// terminator. // Return Value: // Number of characters written into the result buffer, including the // trailing terminator. // Comments: // This function ignores characters without unicode information. // -DLLEXPORT int STDCALL FPDFText_GetText(FPDF_TEXTPAGE text_page, - int start_index, - int count, - unsigned short* result); +FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetText(FPDF_TEXTPAGE text_page, + int start_index, + int count, + unsigned short* result); // Function: FPDFText_CountRects // Count number of rectangular areas occupied by a segment of texts. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // start_index - Index for the start characters. // count - Number of characters. // Return value: // Number of rectangles. Zero for error. // Comments: // This function, along with FPDFText_GetRect can be used by -// applications to detect the position -// on the page for a text segment, so proper areas can be highlighted -// or something. -// FPDFTEXT will automatically merge small character boxes into bigger -// one if those characters +// applications to detect the position on the page for a text segment, +// so proper areas can be highlighted. FPDFTEXT will automatically +// merge small character boxes into bigger one if those characters // are on the same line and use same font settings. // -DLLEXPORT int STDCALL FPDFText_CountRects(FPDF_TEXTPAGE text_page, - int start_index, - int count); +FPDF_EXPORT int FPDF_CALLCONV FPDFText_CountRects(FPDF_TEXTPAGE text_page, + int start_index, + int count); // Function: FPDFText_GetRect // Get a rectangular area from the result generated by // FPDFText_CountRects. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // rect_index - Zero-based index for the rectangle. // left - Pointer to a double value receiving the rectangle -// left boundary. +// left boundary. // top - Pointer to a double value receiving the rectangle -// top boundary. +// top boundary. // right - Pointer to a double value receiving the rectangle -// right boundary. +// right boundary. // bottom - Pointer to a double value receiving the rectangle -// bottom boundary. +// bottom boundary. // Return Value: -// None. +// On success, return TRUE and fill in |left|, |top|, |right|, and +// |bottom|. If |text_page| is invalid then return FALSE, and the out +// parameters remain unmodified. If |text_page| is valid but +// |rect_index| is out of bounds, then return FALSE and set the out +// parameters to 0. // -DLLEXPORT void STDCALL FPDFText_GetRect(FPDF_TEXTPAGE text_page, - int rect_index, - double* left, - double* top, - double* right, - double* bottom); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetRect(FPDF_TEXTPAGE text_page, + int rect_index, + double* left, + double* top, + double* right, + double* bottom); // Function: FPDFText_GetBoundedText // Extract unicode text within a rectangular boundary on the page. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // left - Left boundary. // top - Top boundary. // right - Right boundary. // bottom - Bottom boundary. // buffer - A unicode buffer. // buflen - Number of characters (not bytes) for the buffer, -// excluding an additional terminator. +// excluding an additional terminator. // Return Value: // If buffer is NULL or buflen is zero, return number of characters -// (not bytes) of text present within -// the rectangle, excluding a terminating NUL. Generally you should -// pass a buffer at least one larger -// than this if you want a terminating NUL, which will be provided if -// space is available. -// Otherwise, return number of characters copied into the buffer, -// including the terminating NUL +// (not bytes) of text present within the rectangle, excluding a +// terminating NUL. Generally you should pass a buffer at least one +// larger than this if you want a terminating NUL, which will be +// provided if space is available. Otherwise, return number of +// characters copied into the buffer, including the terminating NUL // when space for it is available. // Comment: // If the buffer is too small, as much text as will fit is copied into // it. // -DLLEXPORT int STDCALL FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page, - double left, - double top, - double right, - double bottom, - unsigned short* buffer, - int buflen); +FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page, + double left, + double top, + double right, + double bottom, + unsigned short* buffer, + int buflen); // Flags used by FPDFText_FindStart function. -#define FPDF_MATCHCASE \ - 0x00000001 // If not set, it will not match case by default. -#define FPDF_MATCHWHOLEWORD \ - 0x00000002 // If not set, it will not match the whole word by default. +// +// If not set, it will not match case by default. +#define FPDF_MATCHCASE 0x00000001 +// If not set, it will not match the whole word by default. +#define FPDF_MATCHWHOLEWORD 0x00000002 +// If not set, it will skip past the current match to look for the next match. +#define FPDF_CONSECUTIVE 0x00000004 // Function: FPDFText_FindStart // Start a search. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // findwhat - A unicode match pattern. // flags - Option flags. // start_index - Start from this character. -1 for end of the page. @@ -257,85 +449,83 @@ DLLEXPORT int STDCALL FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page, // A handle for the search context. FPDFText_FindClose must be called // to release this handle. // -DLLEXPORT FPDF_SCHHANDLE STDCALL FPDFText_FindStart(FPDF_TEXTPAGE text_page, - FPDF_WIDESTRING findwhat, - unsigned long flags, - int start_index); +FPDF_EXPORT FPDF_SCHHANDLE FPDF_CALLCONV +FPDFText_FindStart(FPDF_TEXTPAGE text_page, + FPDF_WIDESTRING findwhat, + unsigned long flags, + int start_index); // Function: FPDFText_FindNext // Search in the direction from page start to end. // Parameters: // handle - A search context handle returned by -// FPDFText_FindStart. +// FPDFText_FindStart. // Return Value: // Whether a match is found. // -DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindNext(FPDF_SCHHANDLE handle); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_FindNext(FPDF_SCHHANDLE handle); // Function: FPDFText_FindPrev // Search in the direction from page end to start. // Parameters: // handle - A search context handle returned by -// FPDFText_FindStart. +// FPDFText_FindStart. // Return Value: // Whether a match is found. // -DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindPrev(FPDF_SCHHANDLE handle); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_FindPrev(FPDF_SCHHANDLE handle); // Function: FPDFText_GetSchResultIndex // Get the starting character index of the search result. // Parameters: // handle - A search context handle returned by -// FPDFText_FindStart. +// FPDFText_FindStart. // Return Value: // Index for the starting character. // -DLLEXPORT int STDCALL FPDFText_GetSchResultIndex(FPDF_SCHHANDLE handle); +FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetSchResultIndex(FPDF_SCHHANDLE handle); // Function: FPDFText_GetSchCount // Get the number of matched characters in the search result. // Parameters: // handle - A search context handle returned by -// FPDFText_FindStart. +// FPDFText_FindStart. // Return Value: // Number of matched characters. // -DLLEXPORT int STDCALL FPDFText_GetSchCount(FPDF_SCHHANDLE handle); +FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetSchCount(FPDF_SCHHANDLE handle); // Function: FPDFText_FindClose // Release a search context. // Parameters: // handle - A search context handle returned by -// FPDFText_FindStart. +// FPDFText_FindStart. // Return Value: // None. // -DLLEXPORT void STDCALL FPDFText_FindClose(FPDF_SCHHANDLE handle); +FPDF_EXPORT void FPDF_CALLCONV FPDFText_FindClose(FPDF_SCHHANDLE handle); // Function: FPDFLink_LoadWebLinks // Prepare information about weblinks in a page. // Parameters: // text_page - Handle to a text page information structure. -// Returned by FPDFText_LoadPage function. +// Returned by FPDFText_LoadPage function. // Return Value: -// A handle to the page's links information structure. +// A handle to the page's links information structure, or // NULL if something goes wrong. // Comments: // Weblinks are those links implicitly embedded in PDF pages. PDF also -// has a type of -// annotation called "link", FPDFTEXT doesn't deal with that kind of -// link. -// FPDFTEXT weblink feature is useful for automatically detecting links -// in the page -// contents. For example, things like "http://www.foxitsoftware.com" -// will be detected, -// so applications can allow user to click on those characters to -// activate the link, -// even the PDF doesn't come with link annotations. +// has a type of annotation called "link" (FPDFTEXT doesn't deal with +// that kind of link). FPDFTEXT weblink feature is useful for +// automatically detecting links in the page contents. For example, +// things like "https://www.example.com" will be detected, so +// applications can allow user to click on those characters to activate +// the link, even the PDF doesn't come with link annotations. // // FPDFLink_CloseWebLinks must be called to release resources. // -DLLEXPORT FPDF_PAGELINK STDCALL FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page); +FPDF_EXPORT FPDF_PAGELINK FPDF_CALLCONV +FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page); // Function: FPDFLink_CountWebLinks // Count number of detected web links. @@ -344,25 +534,31 @@ DLLEXPORT FPDF_PAGELINK STDCALL FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page); // Return Value: // Number of detected web links. // -DLLEXPORT int STDCALL FPDFLink_CountWebLinks(FPDF_PAGELINK link_page); +FPDF_EXPORT int FPDF_CALLCONV FPDFLink_CountWebLinks(FPDF_PAGELINK link_page); // Function: FPDFLink_GetURL // Fetch the URL information for a detected web link. // Parameters: // link_page - Handle returned by FPDFLink_LoadWebLinks. // link_index - Zero-based index for the link. -// buffer - A unicode buffer. -// buflen - Number of characters (not bytes) for the buffer, -// including an additional terminator. +// buffer - A unicode buffer for the result. +// buflen - Number of 16-bit code units (not bytes) for the +// buffer, including an additional terminator. // Return Value: -// If buffer is NULL or buflen is zero, return number of characters -// (not bytes and an additional terminator is also counted) needed, -// otherwise, return number of characters copied into the buffer. +// If |buffer| is NULL or |buflen| is zero, return the number of 16-bit +// code units (not bytes) needed to buffer the result (an additional +// terminator is included in this count). +// Otherwise, copy the result into |buffer|, truncating at |buflen| if +// the result is too large to fit, and return the number of 16-bit code +// units actually copied into the buffer (the additional terminator is +// also included in this count). +// If |link_index| does not correspond to a valid link, then the result +// is an empty string. // -DLLEXPORT int STDCALL FPDFLink_GetURL(FPDF_PAGELINK link_page, - int link_index, - unsigned short* buffer, - int buflen); +FPDF_EXPORT int FPDF_CALLCONV FPDFLink_GetURL(FPDF_PAGELINK link_page, + int link_index, + unsigned short* buffer, + int buflen); // Function: FPDFLink_CountRects // Count number of rectangular areas for the link. @@ -370,10 +566,11 @@ DLLEXPORT int STDCALL FPDFLink_GetURL(FPDF_PAGELINK link_page, // link_page - Handle returned by FPDFLink_LoadWebLinks. // link_index - Zero-based index for the link. // Return Value: -// Number of rectangular areas for the link. +// Number of rectangular areas for the link. If |link_index| does +// not correspond to a valid link, then 0 is returned. // -DLLEXPORT int STDCALL FPDFLink_CountRects(FPDF_PAGELINK link_page, - int link_index); +FPDF_EXPORT int FPDF_CALLCONV FPDFLink_CountRects(FPDF_PAGELINK link_page, + int link_index); // Function: FPDFLink_GetRect // Fetch the boundaries of a rectangle for a link. @@ -382,23 +579,46 @@ DLLEXPORT int STDCALL FPDFLink_CountRects(FPDF_PAGELINK link_page, // link_index - Zero-based index for the link. // rect_index - Zero-based index for a rectangle. // left - Pointer to a double value receiving the rectangle -// left boundary. +// left boundary. // top - Pointer to a double value receiving the rectangle -// top boundary. +// top boundary. // right - Pointer to a double value receiving the rectangle -// right boundary. +// right boundary. // bottom - Pointer to a double value receiving the rectangle -// bottom boundary. +// bottom boundary. // Return Value: -// None. +// On success, return TRUE and fill in |left|, |top|, |right|, and +// |bottom|. If |link_page| is invalid or if |link_index| does not +// correspond to a valid link, then return FALSE, and the out +// parameters remain unmodified. +// +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFLink_GetRect(FPDF_PAGELINK link_page, + int link_index, + int rect_index, + double* left, + double* top, + double* right, + double* bottom); + +// Experimental API. +// Function: FPDFLink_GetTextRange +// Fetch the start char index and char count for a link. +// Parameters: +// link_page - Handle returned by FPDFLink_LoadWebLinks. +// link_index - Zero-based index for the link. +// start_char_index - pointer to int receiving the start char index +// char_count - pointer to int receiving the char count +// Return Value: +// On success, return TRUE and fill in |start_char_index| and +// |char_count|. if |link_page| is invalid or if |link_index| does +// not correspond to a valid link, then return FALSE and the out +// parameters remain unmodified. // -DLLEXPORT void STDCALL FPDFLink_GetRect(FPDF_PAGELINK link_page, - int link_index, - int rect_index, - double* left, - double* top, - double* right, - double* bottom); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDFLink_GetTextRange(FPDF_PAGELINK link_page, + int link_index, + int* start_char_index, + int* char_count); // Function: FPDFLink_CloseWebLinks // Release resources used by weblink feature. @@ -407,7 +627,7 @@ DLLEXPORT void STDCALL FPDFLink_GetRect(FPDF_PAGELINK link_page, // Return Value: // None. // -DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page); +FPDF_EXPORT void FPDF_CALLCONV FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page); #ifdef __cplusplus } diff --git a/src/main/jni/include/fpdf_transformpage.h b/src/main/jni/include/fpdf_transformpage.h index 569df2a7..03c26483 100644 --- a/src/main/jni/include/fpdf_transformpage.h +++ b/src/main/jni/include/fpdf_transformpage.h @@ -7,108 +7,211 @@ #ifndef PUBLIC_FPDF_TRANSFORMPAGE_H_ #define PUBLIC_FPDF_TRANSFORMPAGE_H_ +// NOLINTNEXTLINE(build/include) #include "fpdfview.h" #ifdef __cplusplus extern "C" { #endif -typedef void* FPDF_PAGEARCSAVER; -typedef void* FPDF_PAGEARCLOADER; +/** + * Set "MediaBox" entry to the page dictionary. + * + * 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); /** -* Set "MediaBox" entry to the page dictionary. -* @param[in] page - Handle to a page. -* @param[in] left - The left of the rectangle. -* @param[in] bottom - The bottom of the rectangle. -* @param[in] right - The right of the rectangle. -* @param[in] top - The top of the rectangle. -* @retval None. -*/ -DLLEXPORT void STDCALL FPDFPage_SetMediaBox(FPDF_PAGE page, - float left, - float bottom, - float right, - float top); + * 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); /** -* Set "CropBox" entry to the page dictionary. -* @param[in] page - Handle to a page. -* @param[in] left - The left of the rectangle. -* @param[in] bottom - The bottom of the rectangle. -* @param[in] right - The right of the rectangle. -* @param[in] top - The top of the rectangle. -* @retval None. -*/ -DLLEXPORT void STDCALL FPDFPage_SetCropBox(FPDF_PAGE page, - float left, - float bottom, - float right, - float top); - -/** Get "MediaBox" entry from the page dictionary. -* @param[in] page - Handle to a page. -* @param[in] left - Pointer to a double value receiving the left of the -* rectangle. -* @param[in] bottom - Pointer to a double value receiving the bottom of the -* rectangle. -* @param[in] right - Pointer to a double value receiving the right of the -* rectangle. -* @param[in] top - Pointer to a double value receiving the top of the -* rectangle. -* @retval True if success,else fail. -*/ -DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetMediaBox(FPDF_PAGE page, - float* left, - float* bottom, - float* right, - float* top); - -/** Get "CropBox" entry from the page dictionary. -* @param[in] page - Handle to a page. -* @param[in] left - Pointer to a double value receiving the left of the -* rectangle. -* @param[in] bottom - Pointer to a double value receiving the bottom of the -* rectangle. -* @param[in] right - Pointer to a double value receiving the right of the -* rectangle. -* @param[in] top - Pointer to a double value receiving the top of the -* rectangle. -* @retval True if success,else fail. -*/ -DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetCropBox(FPDF_PAGE page, - float* left, - float* bottom, - float* right, - float* top); + * 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); /** -* Transform the whole page with a specified matrix, then clip the page content -* region. -* -* @param[in] page - A page handle. -* @param[in] matrix - The transform matrix. -* @param[in] clipRect - A rectangle page area to be clipped. -* @Note. This function will transform the whole page, and would take effect to -* all the objects in the page. -*/ -DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, - FS_MATRIX* matrix, - FS_RECTF* clipRect); + * 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. -* @param[in] page_object - Handle to a page object. Returned by -* FPDFPageObj_NewImageObj. -* @param[in] a - The coefficient "a" of the matrix. -* @param[in] b - The coefficient "b" of the matrix. -* @param[in] c - The coefficient "c" of the matrix. -* @param[in] d - The coefficient "d" of the matrix. -* @param[in] e - The coefficient "e" of the matrix. -* @param[in] f - The coefficient "f" of the matrix. -* @retval None. -*/ -DLLEXPORT void STDCALL + * Transform (scale, rotate, shear, move) the clip path of page object. + * page_object - Handle to a page object. Returned by + * FPDFPageObj_NewImageObj(). + * + * a - The coefficient "a" of the matrix. + * b - The coefficient "b" of the matrix. + * c - The coefficient "c" of the matrix. + * d - The coefficient "d" of the matrix. + * e - The coefficient "e" of the matrix. + * f - The coefficient "f" of the matrix. + */ +FPDF_EXPORT void FPDF_CALLCONV FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object, double a, double b, @@ -117,41 +220,86 @@ FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object, 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. -* -* @param[in] left - The left of the clip box. -* @param[in] bottom - The bottom of the clip box. -* @param[in] right - The right of the clip box. -* @param[in] top - The top of the clip box. -* @retval a handle to the clip path. -*/ -DLLEXPORT FPDF_CLIPPATH STDCALL FPDF_CreateClipPath(float left, - float bottom, - float right, - float top); + * 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. -* -* @param[in] clipPath - A handle to the clip path. -* Destroy the clip path. -* @retval None. -*/ -DLLEXPORT void STDCALL FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath); + * 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. -* -* @param[in] page - A page handle. -* @param[in] clipPath - A handle to the clip path. -* @Note. A clip path will be inserted before the page content stream or content -* array. In this way, the page content will be clipped -* by this clip path. -*/ -DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page, - FPDF_CLIPPATH clipPath); + * Clip the page content, the page content that outside the clipping region + * become invisible. + * + * A clip path will be inserted before the page content stream or content array. + * In this way, the page content will be clipped by this clip path. + * + * page - A page handle. + * clipPath - A handle to the clip path. (Does not take ownership.) + */ +FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertClipPath(FPDF_PAGE page, + FPDF_CLIPPATH clipPath); #ifdef __cplusplus } diff --git a/src/main/jni/include/fpdfview.h b/src/main/jni/include/fpdfview.h index 87312925..1768ebd3 100644 --- a/src/main/jni/include/fpdfview.h +++ b/src/main/jni/include/fpdfview.h @@ -5,58 +5,83 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com // NOTE: External docs refer to this file as "fpdfview.h", so do not rename -// despite lack of consitency with other public files. +// despite lack of consistency with other public files. #ifndef PUBLIC_FPDFVIEW_H_ #define PUBLIC_FPDFVIEW_H_ +// clang-format off + +#include + #if defined(_WIN32) && !defined(__WINDOWS__) #include #endif #ifdef PDF_ENABLE_XFA -// TODO: remove the #define when XFA is officially in pdfium +// PDF_USE_XFA is set in confirmation that this version of PDFium can support +// XFA forms as requested by the PDF_ENABLE_XFA setting. #define PDF_USE_XFA #endif // PDF_ENABLE_XFA -// PDF types -typedef void* FPDF_ACTION; -typedef void* FPDF_BITMAP; -typedef void* FPDF_BOOKMARK; -typedef void* FPDF_CLIPPATH; -typedef void* FPDF_DEST; -typedef void* FPDF_DOCSCHHANDLE; -typedef void* FPDF_DOCUMENT; -typedef void* FPDF_FONT; -typedef void* FPDF_HMODULE; -typedef void* FPDF_LINK; -typedef void* FPDF_MODULEMGR; -typedef void* FPDF_PAGE; -typedef void* FPDF_PAGELINK; -typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc) -typedef void* FPDF_PAGERANGE; -typedef void* FPDF_PATH; -typedef void* FPDF_SCHHANDLE; -typedef void* FPDF_TEXTPAGE; - -#ifdef PDF_ENABLE_XFA -typedef void* FPDF_STRINGHANDLE; -typedef void* FPDF_WIDGET; -#endif // PDF_ENABLE_XFA +// PDF object types +#define FPDF_OBJECT_UNKNOWN 0 +#define FPDF_OBJECT_BOOLEAN 1 +#define FPDF_OBJECT_NUMBER 2 +#define FPDF_OBJECT_STRING 3 +#define FPDF_OBJECT_NAME 4 +#define FPDF_OBJECT_ARRAY 5 +#define FPDF_OBJECT_DICTIONARY 6 +#define FPDF_OBJECT_STREAM 7 +#define FPDF_OBJECT_NULLOBJ 8 +#define FPDF_OBJECT_REFERENCE 9 + +// PDF text rendering modes +typedef enum { + FPDF_TEXTRENDERMODE_UNKNOWN = -1, + FPDF_TEXTRENDERMODE_FILL = 0, + FPDF_TEXTRENDERMODE_STROKE = 1, + FPDF_TEXTRENDERMODE_FILL_STROKE = 2, + FPDF_TEXTRENDERMODE_INVISIBLE = 3, + FPDF_TEXTRENDERMODE_FILL_CLIP = 4, + FPDF_TEXTRENDERMODE_STROKE_CLIP = 5, + FPDF_TEXTRENDERMODE_FILL_STROKE_CLIP = 6, + FPDF_TEXTRENDERMODE_CLIP = 7, + FPDF_TEXTRENDERMODE_LAST = FPDF_TEXTRENDERMODE_CLIP, +} FPDF_TEXT_RENDERMODE; + +// PDF types - use incomplete types (never completed) just for 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_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 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 struct fpdf_pagerange_t__* FPDF_PAGERANGE; +typedef const struct fpdf_pathsegment_t* FPDF_PATHSEGMENT; +typedef void* FPDF_RECORDER; // Passed into skia. +typedef struct fpdf_schhandle_t__* FPDF_SCHHANDLE; +typedef struct fpdf_structelement_t__* FPDF_STRUCTELEMENT; +typedef struct fpdf_structtree_t__* FPDF_STRUCTTREE; +typedef struct fpdf_textpage_t__* FPDF_TEXTPAGE; +typedef struct fpdf_widget_t__* FPDF_WIDGET; // Basic data types typedef int FPDF_BOOL; -typedef int FPDF_ERROR; +typedef int FPDF_RESULT; typedef unsigned long FPDF_DWORD; typedef float FS_FLOAT; -#ifdef PDF_ENABLE_XFA -typedef void* FPDF_LPVOID; -typedef void const* FPDF_LPCVOID; -typedef char const* FPDF_LPCSTR; -typedef int FPDF_RESULT; -#endif - // Duplex types typedef enum _FPDF_DUPLEXTYPE_ { DuplexUndefined = 0, @@ -67,7 +92,6 @@ typedef enum _FPDF_DUPLEXTYPE_ { // String types typedef unsigned short FPDF_WCHAR; -typedef unsigned char const* FPDF_LPCBYTE; // FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE // encoded), and platform dependent string @@ -77,16 +101,13 @@ typedef const char* FPDF_BYTESTRING; // bytes (except surrogation), with the low byte first. typedef const unsigned short* FPDF_WIDESTRING; -#ifdef PDF_ENABLE_XFA -// Structure for a byte string. -// Note, a byte string commonly means a UTF-16LE formated string. -typedef struct _FPDF_BSTR { - // String buffer. - char* str; - // Length of the string, in bytes. - int len; +// Structure for persisting a string beyond the duration of a callback. +// Note: although represented as a char*, string may be interpreted as +// a UTF-16LE formated string. Used only by XFA callbacks. +typedef struct FPDF_BSTR_ { + char* str; // String buffer, manipulate only with FPDF_BStr_* methods. + int len; // Length of the string, in bytes. } FPDF_BSTR; -#endif // PDF_ENABLE_XFA // For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a // Windows unicode string, however, special care needs to be taken if you @@ -95,13 +116,16 @@ typedef struct _FPDF_BSTR { // For Linux/Unix programmers: most compiler/library environments use 4 bytes // for a Unicode character, and you have to convert between FPDF_WIDESTRING and // system wide string by yourself. -#ifdef _WIN32_WCE -typedef const unsigned short* FPDF_STRING; -#else typedef const char* FPDF_STRING; -#endif -// Matrix for transformation. +// Matrix for transformation, in the form [a b c d e f], equivalent to: +// | a b 0 | +// | c d 0 | +// | e f 1 | +// +// Translation is performed with [1 0 0 1 tx ty]. +// Scaling is performed with [sx 0 0 sy 0 0]. +// See PDF Reference 1.7, 4.2.2 Common Transformations for more. typedef struct _FS_MATRIX_ { float a; float b; @@ -126,13 +150,55 @@ typedef struct _FS_RECTF_ { // Const Pointer to FS_RECTF structure. typedef const FS_RECTF* FS_LPCRECTF; -#if defined(_WIN32) && defined(FPDFSDK_EXPORTS) -// On Windows system, functions are exported in a DLL -#define DLLEXPORT __declspec(dllexport) -#define STDCALL __stdcall +// Rectangle size. Coordinate system agnostic. +typedef struct FS_SIZEF_ { + float width; + float height; +} * FS_LPSIZEF, FS_SIZEF; + +// Const Pointer to FS_SIZEF structure. +typedef const FS_SIZEF* FS_LPCSIZEF; + +// 2D Point. Coordinate system agnostic. +typedef struct FS_POINTF_ { + float x; + float y; +} * FS_LPPOINTF, FS_POINTF; + +// Const Pointer to FS_POINTF structure. +typedef const FS_POINTF* FS_LPCPOINTF; + +// Annotation enums. +typedef int FPDF_ANNOTATION_SUBTYPE; +typedef int FPDF_ANNOT_APPEARANCEMODE; + +// Dictionary value types. +typedef int FPDF_OBJECT_TYPE; + +#if defined(COMPONENT_BUILD) +// FPDF_EXPORT should be consistent with |export| in the pdfium_fuzzer +// template in testing/fuzzers/BUILD.gn. +#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) +#else +#define FPDF_EXPORT +#endif // defined(COMPONENT_BUILD) + +#if defined(WIN32) && defined(FPDFSDK_EXPORTS) +#define FPDF_CALLCONV __stdcall #else -#define DLLEXPORT -#define STDCALL +#define FPDF_CALLCONV #endif // Exported Functions @@ -148,12 +214,14 @@ extern "C" { // None. // Comments: // Convenience function to call FPDF_InitLibraryWithConfig() for -// backwards comatibility purposes. -DLLEXPORT void STDCALL FPDF_InitLibrary(); +// backwards compatibility purposes. This will be deprecated in the +// future. +FPDF_EXPORT void FPDF_CALLCONV FPDF_InitLibrary(); // 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 @@ -168,9 +236,9 @@ typedef struct FPDF_LIBRARY_CONFIG_ { void* m_pIsolate; // The embedder data slot to use in the v8::Isolate to store PDFium's - // per-isolate data. The value needs to be between 0 and - // v8::Internals::kNumIsolateDataLots (exclusive). Note that 0 is fine - // for most embedders. + // per-isolate data. The value needs to be in the range + // [0, |v8::Internals::kNumIsolateDataLots|). Note that 0 is fine for most + // embedders. unsigned int m_v8EmbedderSlot; } FPDF_LIBRARY_CONFIG; @@ -183,8 +251,8 @@ typedef struct FPDF_LIBRARY_CONFIG_ { // Comments: // You have to call this function before you can call any PDF // processing functions. -DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig( - const FPDF_LIBRARY_CONFIG* config); +FPDF_EXPORT void FPDF_CALLCONV +FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* config); // Function: FPDF_DestroyLibary // Release all resources allocated by the FPDFSDK library. @@ -197,7 +265,7 @@ DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig( // the library. // After this function is called, you should not call any PDF // processing functions. -DLLEXPORT void STDCALL FPDF_DestroyLibrary(); +FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyLibrary(); // Policy for accessing the local machine time. #define FPDF_POLICY_MACHINETIME_ACCESS 0 @@ -210,8 +278,57 @@ DLLEXPORT void STDCALL FPDF_DestroyLibrary(); // enable - True to enable, false to disable the policy. // Return value: // None. -DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, - FPDF_BOOL enable); +FPDF_EXPORT void FPDF_CALLCONV FPDF_SetSandBoxPolicy(FPDF_DWORD policy, + FPDF_BOOL enable); + +#if defined(_WIN32) +#if defined(PDFIUM_PRINT_TEXT_WITH_GDI) +// Pointer to a helper function to make |font| with |text| of |text_length| +// accessible when printing text with GDI. This is useful in sandboxed +// environments where PDFium's access to GDI may be restricted. +typedef void (*PDFiumEnsureTypefaceCharactersAccessible)(const LOGFONT* font, + const wchar_t* text, + size_t text_length); + +// Function: FPDF_SetTypefaceAccessibleFunc +// Set the function pointer that makes GDI fonts available in sandboxed +// environments. Experimental API. +// Parameters: +// func - A function pointer. See description above. +// Return value: +// None. +FPDF_EXPORT void FPDF_CALLCONV +FPDF_SetTypefaceAccessibleFunc(PDFiumEnsureTypefaceCharactersAccessible func); + +// Function: FPDF_SetPrintTextWithGDI +// Set whether to use GDI to draw fonts when printing on Windows. +// Experimental API. +// Parameters: +// use_gdi - Set to true to enable printing text with GDI. +// Return value: +// None. +FPDF_EXPORT void FPDF_CALLCONV FPDF_SetPrintTextWithGDI(FPDF_BOOL use_gdi); +#endif // PDFIUM_PRINT_TEXT_WITH_GDI + +// Function: FPDF_SetPrintMode +// Set printing mode when printing on Windows. +// Experimental API. +// 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. +// Return value: +// True if successful, false if unsuccessful (typically invalid input). +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_SetPrintMode(int mode); +#endif // defined(_WIN32) // Function: FPDF_LoadDocument // Open and load a PDF document. @@ -219,14 +336,21 @@ DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, // file_path - Path to the PDF file (including extension). // password - A string used as the password for the PDF file. // If no password is needed, empty or NULL can be used. +// See comments below regarding the encoding. // Return value: // A handle to the loaded document, or NULL on failure. // Comments: // Loaded document can be closed by FPDF_CloseDocument(). // If this function fails, you can use FPDF_GetLastError() to retrieve // the reason why it failed. -DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, - FPDF_BYTESTRING password); +// +// The encoding for |password| can be either UTF-8 or Latin-1. PDFs, +// depending on the security handler revision, will only accept one or +// the other encoding. If |password|'s encoding and the PDF's expected +// encoding do not match, FPDF_LoadDocument() will automatically +// convert |password| to the other encoding. +FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV +FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BYTESTRING password); // Function: FPDF_LoadMemDocument // Open and load a PDF document from memory. @@ -242,13 +366,15 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, // The loaded document can be closed by FPDF_CloseDocument. // If this function fails, you can use FPDF_GetLastError() to retrieve // the reason why it failed. +// +// See the comments for FPDF_LoadDocument() regarding the encoding for +// |password|. // Notes: // If PDFium is built with the XFA module, the application should call // FPDF_LoadXFA() function after the PDF document loaded to support XFA // fields defined in the fpdfformfill.h file. -DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, - int size, - FPDF_BYTESTRING password); +FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV +FPDF_LoadMemDocument(const void* data_buf, int size, FPDF_BYTESTRING password); // Structure for custom file access. typedef struct { @@ -257,6 +383,7 @@ typedef struct { // A function pointer for getting a block of data from a specific position. // Position is specified by byte offset from the beginning of the file. + // The pointer to the buffer is never NULL and the size is never 0. // The position and size will never go out of range of the file length. // It may be possible for FPDFSDK to call this function multiple times for // the same position. @@ -271,87 +398,102 @@ typedef struct { void* m_Param; } FPDF_FILEACCESS; -#ifdef PDF_ENABLE_XFA -/** - * @brief Structure for file reading or writing (I/O). +/* + * Structure for file reading or writing (I/O). * - * @note This is a handler and should be implemented by callers. + * Note: This is a handler and should be implemented by callers, + * and is only used from XFA. */ -typedef struct _FPDF_FILEHANDLER { - /** - * @brief User-defined data. - * @note Callers can use this field to track controls. +typedef struct FPDF_FILEHANDLER_ { + /* + * User-defined data. + * Note: Callers can use this field to track controls. */ - FPDF_LPVOID clientData; - /** - * @brief Callback function to release the current file stream object. - * - * @param[in] clientData Pointer to user-defined data. + void* clientData; + + /* + * Callback function to release the current file stream object. * - * @return None. + * Parameters: + * clientData - Pointer to user-defined data. + * Returns: + * None. */ - void (*Release)(FPDF_LPVOID clientData); - /** - * @brief Callback function to retrieve the current file stream size. - * - * @param[in] clientData Pointer to user-defined data. + void (*Release)(void* clientData); + + /* + * Callback function to retrieve the current file stream size. * - * @return Size of file stream. + * Parameters: + * clientData - Pointer to user-defined data. + * Returns: + * Size of file stream. */ - FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData); - /** - * @brief Callback function to read data from the current file stream. - * - * @param[in] clientData Pointer to user-defined data. - * @param[in] offset Offset position starts from the beginning of file - * stream. This parameter indicates reading position. - * @param[in] buffer Memory buffer to store data which are read from - * file stream. This parameter should not be NULL. - * @param[in] size Size of data which should be read from file - * stream, in bytes. The buffer indicated by the parameter buffer - * should be enough to store specified data. + FPDF_DWORD (*GetSize)(void* clientData); + + /* + * Callback function to read data from the current file stream. * - * @return 0 for success, other value for failure. + * 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)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPVOID buffer, FPDF_DWORD size); - /** - * @brief Callback function to write data into the current file stream. - * - * @param[in] clientData Pointer to user-defined data. - * @param[in] offset Offset position starts from the beginning of file - * stream. This parameter indicates writing position. - * @param[in] buffer Memory buffer contains data which is written into - * file stream. This parameter should not be NULL. - * @param[in] size Size of data which should be written into file - * stream, in bytes. + FPDF_RESULT (*ReadBlock)(void* clientData, + FPDF_DWORD offset, + void* buffer, + FPDF_DWORD size); + + /* + * Callback function to write data into the current file stream. * - * @return 0 for success, other value for failure. + * 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)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPCVOID buffer, FPDF_DWORD size); - /** - * @brief Callback function to flush all internal accessing buffers. - * - * @param[in] clientData Pointer to user-defined data. + FPDF_RESULT (*WriteBlock)(void* clientData, + FPDF_DWORD offset, + const void* buffer, + FPDF_DWORD size); + /* + * Callback function to flush all internal accessing buffers. * - * @return 0 for success, other value for failure. + * Parameters: + * clientData - Pointer to user-defined data. + * Returns: + * 0 for success, other value for failure. */ - FPDF_RESULT (*Flush)(FPDF_LPVOID clientData); - /** - * @brief Callback function to change file size. - * - * @details This function is called under writing mode usually. Implementer - * can determine whether to realize it based on application requests. - * - * @param[in] clientData Pointer to user-defined data. - * @param[in] size New size of file stream, in bytes. + FPDF_RESULT (*Flush)(void* clientData); + + /* + * Callback function to change file size. * - * @return 0 for success, other value for failure. + * 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)(FPDF_LPVOID clientData, FPDF_DWORD size); + FPDF_RESULT (*Truncate)(void* clientData, FPDF_DWORD size); +} FPDF_FILEHANDLER; -} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER; - -#endif // Function: FPDF_LoadCustomDocument // Load PDF document from a custom access descriptor. // Parameters: @@ -360,15 +502,19 @@ typedef struct _FPDF_FILEHANDLER { // Return value: // A handle to the loaded document, or NULL on failure. // Comments: -// The application must keep the file resources valid until the PDF -// document is closed. +// The application must keep the file resources |pFileAccess| points to +// valid until the returned FPDF_DOCUMENT is closed. |pFileAccess| +// itself does not need to outlive the FPDF_DOCUMENT. +// +// The loaded document can be closed with FPDF_CloseDocument(). // -// The loaded document can be closed with FPDF_CloseDocument. +// See the comments for FPDF_LoadDocument() regarding the encoding for +// |password|. // Notes: // If PDFium is built with the XFA module, the application should call // FPDF_LoadXFA() function after the PDF document loaded to support XFA // fields defined in the fpdfformfill.h file. -DLLEXPORT FPDF_DOCUMENT STDCALL +FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password); // Function: FPDF_GetFileVersion @@ -382,8 +528,8 @@ FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password); // Comments: // If the document was created by FPDF_CreateNewDocument, // then this function will always fail. -DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, - int* fileVersion); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetFileVersion(FPDF_DOCUMENT doc, + int* fileVersion); #define FPDF_ERR_SUCCESS 0 // No error. #define FPDF_ERR_UNKNOWN 1 // Unknown error. @@ -406,7 +552,22 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, // Comments: // If the previous SDK call succeeded, the return value of this // function is not defined. -DLLEXPORT unsigned long STDCALL FPDF_GetLastError(); +FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetLastError(); + +// Function: FPDF_DocumentHasValidCrossReferenceTable +// Whether the document's cross reference table is valid or not. +// Experimental API. +// 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); // Function: FPDF_GetDocPermission // Get file permission flags of the document. @@ -416,7 +577,8 @@ DLLEXPORT unsigned long STDCALL FPDF_GetLastError(); // A 32-bit integer indicating permission flags. Please refer to the // PDF Reference for detailed descriptions. If the document is not // protected, 0xffffffff will be returned. -DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document); +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDF_GetDocPermissions(FPDF_DOCUMENT document); // Function: FPDF_GetSecurityHandlerRevision // Get the revision for the security handler. @@ -426,7 +588,8 @@ DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document); // The security handler revision number. Please refer to the PDF // Reference for a detailed description. If the document is not // protected, -1 will be returned. -DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document); +FPDF_EXPORT int FPDF_CALLCONV +FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document); // Function: FPDF_GetPageCount // Get total number of pages in the document. @@ -434,7 +597,7 @@ DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document); // document - Handle to document. Returned by FPDF_LoadDocument. // Return value: // Total number of pages in the document. -DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document); +FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageCount(FPDF_DOCUMENT document); // Function: FPDF_LoadPage // Load a page inside the document. @@ -446,8 +609,18 @@ DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document); // Comments: // The loaded page can be rendered to devices using FPDF_RenderPage. // The loaded page can be closed using FPDF_ClosePage. -DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, - int page_index); +FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDF_LoadPage(FPDF_DOCUMENT document, + int page_index); + +// Experimental API +// Function: FPDF_GetPageWidthF +// Get page width. +// Parameters: +// page - Handle to the page. Returned by FPDF_LoadPage(). +// Return value: +// Page width (excluding non-displayable area) measured in points. +// One point is 1/72 inch (around 0.3528 mm). +FPDF_EXPORT float FPDF_CALLCONV FPDF_GetPageWidthF(FPDF_PAGE page); // Function: FPDF_GetPageWidth // Get page width. @@ -456,7 +629,20 @@ DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, // Return value: // Page width (excluding non-displayable area) measured in points. // One point is 1/72 inch (around 0.3528 mm). -DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page); +// Note: +// Prefer FPDF_GetPageWidthF() above. This will be deprecated in the +// future. +FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageWidth(FPDF_PAGE page); + +// Experimental API +// Function: FPDF_GetPageHeightF +// Get page height. +// Parameters: +// page - Handle to the page. Returned by FPDF_LoadPage(). +// Return value: +// Page height (excluding non-displayable area) measured in points. +// One point is 1/72 inch (around 0.3528 mm) +FPDF_EXPORT float FPDF_CALLCONV FPDF_GetPageHeightF(FPDF_PAGE page); // Function: FPDF_GetPageHeight // Get page height. @@ -465,7 +651,38 @@ DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page); // Return value: // Page height (excluding non-displayable area) measured in points. // One point is 1/72 inch (around 0.3528 mm) -DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page); +// Note: +// Prefer FPDF_GetPageHeightF() above. This will be deprecated in the +// future. +FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageHeight(FPDF_PAGE page); + +// Experimental API. +// Function: FPDF_GetPageBoundingBox +// Get the bounding box of the page. This is the intersection between +// its media box and its crop box. +// Parameters: +// page - Handle to the page. Returned by FPDF_LoadPage. +// rect - Pointer to a rect to receive the page bounding box. +// On an error, |rect| won't be filled. +// Return value: +// True for success. +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetPageBoundingBox(FPDF_PAGE page, + FS_RECTF* rect); + +// Experimental API. +// Function: FPDF_GetPageSizeByIndexF +// Get the size of the page at the given index. +// Parameters: +// document - Handle to document. Returned by FPDF_LoadDocument(). +// page_index - Page index, zero for the first page. +// size - Pointer to a FS_SIZEF to receive the page size. +// (in points). +// Return value: +// Non-zero for success. 0 for error (document or page not found). +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV +FPDF_GetPageSizeByIndexF(FPDF_DOCUMENT document, + int page_index, + FS_SIZEF* size); // Function: FPDF_GetPageSizeByIndex // Get the size of the page at the given index. @@ -478,10 +695,13 @@ DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page); // (in points). // Return value: // Non-zero for success. 0 for error (document or page not found). -DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, - int page_index, - double* width, - double* height); +// Note: +// Prefer FPDF_GetPageSizeByIndexF() above. This will be deprecated in +// the future. +FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, + int page_index, + double* width, + double* height); // Page rendering flags. They can be combined with bit-wise OR. // @@ -493,9 +713,9 @@ DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, #define FPDF_NO_NATIVETEXT 0x04 // Grayscale output. #define FPDF_GRAYSCALE 0x08 -// Set if you want to get some debug info. +// Obsolete, has no effect, retained for compatibility. #define FPDF_DEBUG_INFO 0x80 -// Set if you don't want to catch exceptions. +// Obsolete, has no effect, retained for compatibility. #define FPDF_NO_CATCH 0x100 // Limit image cache size. #define FPDF_RENDER_LIMITEDIMAGECACHE 0x200 @@ -509,6 +729,8 @@ DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, #define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000 // Set to disable anti-aliasing on paths. #define FPDF_RENDER_NO_SMOOTHPATH 0x4000 +// Set to only render grayscale text (no images, etc). +#define FPDF_RENDER_TEXT_MASK 0x8000 // 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 @@ -535,14 +757,14 @@ DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, // defined above. // Return value: // None. -DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, - FPDF_PAGE page, - int start_x, - int start_y, - int size_x, - int size_y, - int rotate, - int flags); +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 @@ -550,7 +772,8 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, // Parameters: // bitmap - Handle to the device independent bitmap (as the // output buffer). The bitmap handle can be created -// by FPDFBitmap_Create. +// by FPDFBitmap_Create or retrieved from an image +// object by FPDFImageObj_GetBitmap. // page - Handle to the page. Returned by FPDF_LoadPage // start_x - Left pixel position of the display area in // bitmap coordinates. @@ -563,18 +786,52 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, // 1 (rotated 90 degrees clockwise) // 2 (rotated 180 degrees) // 3 (rotated 90 degrees counter-clockwise) -// flags - 0 for normal display, or combination of flags -// defined above. +// flags - 0 for normal display, or combination of the Page +// Rendering flags defined above. With the FPDF_ANNOT +// flag, it renders all annotations that do not require +// user-interaction, which are all annotations except +// widget and popup annotations. // Return value: // None. -DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, - FPDF_PAGE page, - int start_x, - int start_y, - int size_x, - int size_y, - int rotate, - int flags); +FPDF_EXPORT void FPDF_CALLCONV FPDF_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); + +#ifdef _SKIA_SUPPORT_ +FPDF_EXPORT FPDF_RECORDER FPDF_CALLCONV FPDF_RenderPageSkp(FPDF_PAGE page, + int size_x, + int size_y); +#endif // Function: FPDF_ClosePage // Close a loaded PDF page. @@ -582,7 +839,7 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, // page - Handle to the loaded page. // Return value: // None. -DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page); +FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page); // Function: FPDF_CloseDocument // Close a loaded PDF document. @@ -590,7 +847,7 @@ DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page); // document - Handle to the loaded document. // Return value: // None. -DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document); +FPDF_EXPORT void FPDF_CALLCONV FPDF_CloseDocument(FPDF_DOCUMENT document); // Function: FPDF_DeviceToPage // Convert the screen coordinates of a point to page coordinates. @@ -614,7 +871,8 @@ DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document); // page_y - A pointer to a double receiving the converted Y // value in page coordinates. // Return value: -// None. +// Returns true if the conversion succeeds, and |page_x| and |page_y| +// successfully receives the converted coordinates. // Comments: // The page coordinate system has its origin at the left-bottom corner // of the page, with the X-axis on the bottom going to the right, and @@ -632,16 +890,16 @@ DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document); // You must make sure the start_x, start_y, size_x, size_y // and rotate parameters have exactly same values as you used in // the FPDF_RenderPage() function call. -DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, - int start_x, - int start_y, - int size_x, - int size_y, - int rotate, - int device_x, - int device_y, - double* page_x, - double* page_y); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_DeviceToPage(FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int device_x, + int device_y, + double* page_x, + double* page_y); // Function: FPDF_PageToDevice // Convert the page coordinates of a point to screen coordinates. @@ -665,19 +923,20 @@ DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, // device_y - A pointer to an integer receiving the result Y // value in device coordinates. // Return value: -// None. +// Returns true if the conversion succeeds, and |device_x| and +// |device_y| successfully receives the converted coordinates. // Comments: // See comments for FPDF_DeviceToPage(). -DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, - int start_x, - int start_y, - int size_x, - int size_y, - int rotate, - double page_x, - double page_y, - int* device_x, - int* device_y); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_PageToDevice(FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + double page_x, + double page_y, + int* device_x, + int* device_y); // Function: FPDFBitmap_Create // Create a device independent bitmap (FXDIB). @@ -707,12 +966,15 @@ DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, // // This function allocates enough memory for holding all pixels in the // bitmap, but it doesn't initialize the buffer. Applications can use -// FPDFBitmap_FillRect to fill the bitmap using any color. -DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, - int height, - int alpha); +// FPDFBitmap_FillRect() to fill the bitmap using any color. If the OS +// allows it, this function can allocate up to 4 GB of memory. +FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_Create(int width, + int height, + int alpha); // More DIB formats +// Unknown or unsupported format. +#define FPDFBitmap_Unknown 0 // Gray scale bitmap, one byte per pixel. #define FPDFBitmap_Gray 1 // 3 bytes per pixel, byte order: blue, green, red. @@ -747,11 +1009,23 @@ DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, // If an external buffer is used, then the application should destroy // the buffer by itself. FPDFBitmap_Destroy function will not destroy // the buffer. -DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, - int height, - int format, - void* first_scan, - int stride); +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. @@ -777,17 +1051,18 @@ DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, // background will be replaced by the source color and the alpha. // // If the alpha channel is not used, the alpha parameter is ignored. -DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, - int left, - int top, - int width, - int height, - FPDF_DWORD color); +FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_FillRect(FPDF_BITMAP bitmap, + int left, + int top, + int width, + int height, + FPDF_DWORD color); // Function: FPDFBitmap_GetBuffer // Get data buffer of a bitmap. // Parameters: -// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create +// or FPDFImageObj_GetBitmap. // Return value: // The pointer to the first byte of the bitmap buffer. // Comments: @@ -799,44 +1074,48 @@ DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, // // The data is in BGRA format. Where the A maybe unused if alpha was // not specified. -DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap); +FPDF_EXPORT void* FPDF_CALLCONV FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap); // Function: FPDFBitmap_GetWidth // Get width of a bitmap. // Parameters: -// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create +// or FPDFImageObj_GetBitmap. // Return value: // The width of the bitmap in pixels. -DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap); +FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetWidth(FPDF_BITMAP bitmap); // Function: FPDFBitmap_GetHeight // Get height of a bitmap. // Parameters: -// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create +// or FPDFImageObj_GetBitmap. // Return value: // The height of the bitmap in pixels. -DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap); +FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetHeight(FPDF_BITMAP bitmap); // Function: FPDFBitmap_GetStride // Get number of bytes for each line in the bitmap buffer. // Parameters: -// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create +// or FPDFImageObj_GetBitmap. // Return value: // The number of bytes for each line in the bitmap buffer. // Comments: // The stride may be more than width * number of bytes per pixel. -DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap); +FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetStride(FPDF_BITMAP bitmap); // Function: FPDFBitmap_Destroy // Destroy a bitmap and release all related buffers. // Parameters: -// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create +// or FPDFImageObj_GetBitmap. // Return value: // None. // Comments: // This function will not destroy any external buffers provided when // the bitmap was created. -DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap); +FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_Destroy(FPDF_BITMAP bitmap); // Function: FPDF_VIEWERREF_GetPrintScaling // Whether the PDF document prefers to be scaled or not. @@ -844,7 +1123,7 @@ DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap); // document - Handle to the loaded document. // Return value: // None. -DLLEXPORT FPDF_BOOL STDCALL +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document); // Function: FPDF_VIEWERREF_GetNumCopies @@ -853,7 +1132,8 @@ FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document); // document - Handle to the loaded document. // Return value: // The number of copies to be printed. -DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document); +FPDF_EXPORT int FPDF_CALLCONV +FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document); // Function: FPDF_VIEWERREF_GetPrintPageRange // Page numbers to initialize print dialog box when file is printed. @@ -861,9 +1141,31 @@ DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document); // document - Handle to the loaded document. // Return value: // The print page range to be used for printing. -DLLEXPORT FPDF_PAGERANGE STDCALL +FPDF_EXPORT FPDF_PAGERANGE FPDF_CALLCONV FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document); +// Function: FPDF_VIEWERREF_GetPrintPageRangeCount +// Returns the number of elements in a FPDF_PAGERANGE. +// Experimental API. +// 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); + +// Function: FPDF_VIEWERREF_GetPrintPageRangeElement +// Returns an element from a FPDF_PAGERANGE. +// Experimental API. +// Parameters: +// pagerange - Handle to the page range. +// index - Index of the element. +// Return value: +// The value of the element in the page range at a given index. +// Returns -1 on error. +FPDF_EXPORT int FPDF_CALLCONV +FPDF_VIEWERREF_GetPrintPageRangeElement(FPDF_PAGERANGE pagerange, size_t index); + // Function: FPDF_VIEWERREF_GetDuplex // Returns the paper handling option to be used when printing from // the print dialog. @@ -871,16 +1173,38 @@ FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document); // document - Handle to the loaded document. // Return value: // The paper handling option to be used when printing. -DLLEXPORT FPDF_DUPLEXTYPE STDCALL +FPDF_EXPORT FPDF_DUPLEXTYPE FPDF_CALLCONV FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document); +// Function: FPDF_VIEWERREF_GetName +// Gets the contents for a viewer ref, with a given key. The value must +// be of type "name". +// Parameters: +// document - Handle to the loaded document. +// key - Name of the key in the viewer pref dictionary, +// encoded in UTF-8. +// buffer - A string to write the contents of the key to. +// 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 or |buffer| is NULL. If |length| is +// less than the returned length, or |buffer| is NULL, |buffer| will +// not be modified. +FPDF_EXPORT unsigned long FPDF_CALLCONV +FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document, + FPDF_BYTESTRING key, + char* buffer, + unsigned long length); + // Function: FPDF_CountNamedDests // Get the count of named destinations in the PDF document. // Parameters: // document - Handle to a document // Return value: // The count of named destinations. -DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document); +FPDF_EXPORT FPDF_DWORD FPDF_CALLCONV +FPDF_CountNamedDests(FPDF_DOCUMENT document); // Function: FPDF_GetNamedDestByName // Get a the destination handle for the given name. @@ -889,8 +1213,8 @@ DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document); // name - The name of a destination. // Return value: // The handle to the destination. -DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document, - FPDF_BYTESTRING name); +FPDF_EXPORT FPDF_DEST FPDF_CALLCONV +FPDF_GetNamedDestByName(FPDF_DOCUMENT document, FPDF_BYTESTRING name); // Function: FPDF_GetNamedDest // Get the named destination by index. @@ -913,25 +1237,38 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document, // // If buflen is not sufficiently large, it will be set to -1 upon // return. -DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, - int index, - void* buffer, - long* buflen); +FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDF_GetNamedDest(FPDF_DOCUMENT document, + int index, + void* buffer, + long* buflen); + +#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(); +#endif // PDF_ENABLE_V8 #ifdef PDF_ENABLE_XFA // Function: FPDF_BStr_Init -// Helper function to initialize a byte string. -DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str); +// Helper function to initialize a FPDF_BSTR. +FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Init(FPDF_BSTR* bstr); // Function: FPDF_BStr_Set -// Helper function to set string data. -DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str, - FPDF_LPCSTR bstr, - int length); +// Helper function to copy string data into the FPDF_BSTR. +FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Set(FPDF_BSTR* bstr, + const char* cstr, + int length); // Function: FPDF_BStr_Clear -// Helper function to clear a byte string. -DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str); +// Helper function to clear a FPDF_BSTR. +FPDF_EXPORT FPDF_RESULT FPDF_CALLCONV FPDF_BStr_Clear(FPDF_BSTR* bstr); #endif // PDF_ENABLE_XFA #ifdef __cplusplus diff --git a/src/main/jni/lib/arm64-v8a/libc++_shared.so b/src/main/jni/lib/arm64-v8a/libc++_shared.so deleted file mode 100755 index 562430e3..00000000 Binary files a/src/main/jni/lib/arm64-v8a/libc++_shared.so and /dev/null differ diff --git a/src/main/jni/lib/arm64-v8a/libmodft2.so b/src/main/jni/lib/arm64-v8a/libmodft2.so deleted file mode 100755 index b28c461a..00000000 Binary files a/src/main/jni/lib/arm64-v8a/libmodft2.so and /dev/null differ diff --git a/src/main/jni/lib/arm64-v8a/libmodpdfium.so b/src/main/jni/lib/arm64-v8a/libmodpdfium.so deleted file mode 100755 index 898326b5..00000000 Binary files a/src/main/jni/lib/arm64-v8a/libmodpdfium.so and /dev/null differ diff --git a/src/main/jni/lib/arm64-v8a/libmodpng.so b/src/main/jni/lib/arm64-v8a/libmodpng.so deleted file mode 100755 index 65410615..00000000 Binary files a/src/main/jni/lib/arm64-v8a/libmodpng.so and /dev/null differ diff --git a/src/main/jni/lib/armeabi-v7a/libc++_shared.so b/src/main/jni/lib/armeabi-v7a/libc++_shared.so deleted file mode 100755 index 65413400..00000000 Binary files a/src/main/jni/lib/armeabi-v7a/libc++_shared.so and /dev/null differ diff --git a/src/main/jni/lib/armeabi-v7a/libmodft2.so b/src/main/jni/lib/armeabi-v7a/libmodft2.so deleted file mode 100755 index 80ec5265..00000000 Binary files a/src/main/jni/lib/armeabi-v7a/libmodft2.so and /dev/null differ diff --git a/src/main/jni/lib/armeabi-v7a/libmodpdfium.so b/src/main/jni/lib/armeabi-v7a/libmodpdfium.so deleted file mode 100755 index bc89f3dd..00000000 Binary files a/src/main/jni/lib/armeabi-v7a/libmodpdfium.so and /dev/null differ diff --git a/src/main/jni/lib/armeabi-v7a/libmodpng.so b/src/main/jni/lib/armeabi-v7a/libmodpng.so deleted file mode 100755 index 42249c5b..00000000 Binary files a/src/main/jni/lib/armeabi-v7a/libmodpng.so and /dev/null differ diff --git a/src/main/jni/lib/mips/libc++_shared.so b/src/main/jni/lib/mips/libc++_shared.so deleted file mode 100755 index 533554ca..00000000 Binary files a/src/main/jni/lib/mips/libc++_shared.so and /dev/null differ diff --git a/src/main/jni/lib/mips/libmodft2.so b/src/main/jni/lib/mips/libmodft2.so deleted file mode 100755 index 2aeb607d..00000000 Binary files a/src/main/jni/lib/mips/libmodft2.so and /dev/null differ diff --git a/src/main/jni/lib/mips/libmodpdfium.so b/src/main/jni/lib/mips/libmodpdfium.so deleted file mode 100755 index 94a7100a..00000000 Binary files a/src/main/jni/lib/mips/libmodpdfium.so and /dev/null differ diff --git a/src/main/jni/lib/mips/libmodpng.so b/src/main/jni/lib/mips/libmodpng.so deleted file mode 100755 index bcb4bb73..00000000 Binary files a/src/main/jni/lib/mips/libmodpng.so and /dev/null differ diff --git a/src/main/jni/lib/mips64/libc++_shared.so b/src/main/jni/lib/mips64/libc++_shared.so deleted file mode 100755 index 3844c40a..00000000 Binary files a/src/main/jni/lib/mips64/libc++_shared.so and /dev/null differ diff --git a/src/main/jni/lib/mips64/libmodft2.so b/src/main/jni/lib/mips64/libmodft2.so deleted file mode 100755 index 1e179a4d..00000000 Binary files a/src/main/jni/lib/mips64/libmodft2.so and /dev/null differ diff --git a/src/main/jni/lib/mips64/libmodpdfium.so b/src/main/jni/lib/mips64/libmodpdfium.so deleted file mode 100755 index fd261ca6..00000000 Binary files a/src/main/jni/lib/mips64/libmodpdfium.so and /dev/null differ diff --git a/src/main/jni/lib/mips64/libmodpng.so b/src/main/jni/lib/mips64/libmodpng.so deleted file mode 100755 index aa45e700..00000000 Binary files a/src/main/jni/lib/mips64/libmodpng.so and /dev/null differ diff --git a/src/main/jni/lib/x86/libc++_shared.so b/src/main/jni/lib/x86/libc++_shared.so deleted file mode 100755 index 232d49d4..00000000 Binary files a/src/main/jni/lib/x86/libc++_shared.so and /dev/null differ diff --git a/src/main/jni/lib/x86/libmodft2.so b/src/main/jni/lib/x86/libmodft2.so deleted file mode 100755 index e6712e3d..00000000 Binary files a/src/main/jni/lib/x86/libmodft2.so and /dev/null differ diff --git a/src/main/jni/lib/x86/libmodpdfium.so b/src/main/jni/lib/x86/libmodpdfium.so deleted file mode 100755 index 5b937530..00000000 Binary files a/src/main/jni/lib/x86/libmodpdfium.so and /dev/null differ diff --git a/src/main/jni/lib/x86/libmodpng.so b/src/main/jni/lib/x86/libmodpng.so deleted file mode 100755 index 5cbaf78d..00000000 Binary files a/src/main/jni/lib/x86/libmodpng.so and /dev/null differ diff --git a/src/main/jni/lib/x86_64/libc++_shared.so b/src/main/jni/lib/x86_64/libc++_shared.so deleted file mode 100755 index 4fe5affd..00000000 Binary files a/src/main/jni/lib/x86_64/libc++_shared.so and /dev/null differ diff --git a/src/main/jni/lib/x86_64/libmodft2.so b/src/main/jni/lib/x86_64/libmodft2.so deleted file mode 100755 index 57bec3ca..00000000 Binary files a/src/main/jni/lib/x86_64/libmodft2.so and /dev/null differ diff --git a/src/main/jni/lib/x86_64/libmodpdfium.so b/src/main/jni/lib/x86_64/libmodpdfium.so deleted file mode 100755 index 4edc2c27..00000000 Binary files a/src/main/jni/lib/x86_64/libmodpdfium.so and /dev/null differ diff --git a/src/main/jni/lib/x86_64/libmodpng.so b/src/main/jni/lib/x86_64/libmodpng.so deleted file mode 100755 index 3833468f..00000000 Binary files a/src/main/jni/lib/x86_64/libmodpng.so and /dev/null differ diff --git a/src/main/jni/src/mainJNILib.cpp b/src/main/jni/src/mainJNILib.cpp index a888e69f..dd67fde0 100644 --- a/src/main/jni/src/mainJNILib.cpp +++ b/src/main/jni/src/mainJNILib.cpp @@ -16,6 +16,9 @@ using namespace android; #include #include +#include +#include +#include #include #include @@ -340,10 +343,131 @@ JNI_FUNC(void, PdfiumCore, nativeClosePages)(JNI_ARGS, jlongArray pagesPtr){ for(i = 0; i < length; i++){ closePageInternal(pages[i]); } } +JNI_FUNC(jfloatArray, PdfiumCore, nativeGetPageCropBox)(JNI_ARGS, jlong pagePtr) { + FPDF_PAGE page = reinterpret_cast(pagePtr); + jfloatArray result = env->NewFloatArray(4); + if (result == NULL) { + return NULL; + } + + 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; +} + +JNI_FUNC(jfloatArray, PdfiumCore, nativeGetPageMediaBox)(JNI_ARGS, jlong pagePtr) { + FPDF_PAGE page = reinterpret_cast(pagePtr); + jfloatArray result = env->NewFloatArray(4); + if (result == NULL) { + return NULL; + } + + 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; +} + +JNI_FUNC(jfloatArray, PdfiumCore, nativeGetPageBleedBox)(JNI_ARGS, jlong pagePtr) { + FPDF_PAGE page = reinterpret_cast(pagePtr); + jfloatArray result = env->NewFloatArray(4); + if (result == NULL) { + return NULL; + } + + 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; +} + +JNI_FUNC(jfloatArray, PdfiumCore, nativeGetPageTrimBox)(JNI_ARGS, jlong pagePtr) { + FPDF_PAGE page = reinterpret_cast(pagePtr); + jfloatArray result = env->NewFloatArray(4); + if (result == NULL) { + return NULL; + } + + 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; +} + +JNI_FUNC(jfloatArray, PdfiumCore, nativeGetPageArtBox)(JNI_ARGS, jlong pagePtr) { + FPDF_PAGE page = reinterpret_cast(pagePtr); + jfloatArray result = env->NewFloatArray(4); + if (result == NULL) { + return NULL; + } + + 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; +} + +JNI_FUNC(jfloatArray, PdfiumCore, nativeGetPageBoundingBox)(JNI_ARGS, jlong pagePtr) { + FPDF_PAGE page = reinterpret_cast(pagePtr); + jfloatArray result = env->NewFloatArray(4); + if (result == NULL) { + return NULL; + } + + 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; +} + JNI_FUNC(jint, PdfiumCore, nativeGetPageWidthPixel)(JNI_ARGS, jlong pagePtr, jint dpi){ FPDF_PAGE page = reinterpret_cast(pagePtr); return (jint)(FPDF_GetPageWidth(page) * dpi / 72); } + JNI_FUNC(jint, PdfiumCore, nativeGetPageHeightPixel)(JNI_ARGS, jlong pagePtr, jint dpi){ FPDF_PAGE page = reinterpret_cast(pagePtr); return (jint)(FPDF_GetPageHeight(page) * dpi / 72); @@ -357,6 +481,10 @@ JNI_FUNC(jint, PdfiumCore, nativeGetPageHeightPoint)(JNI_ARGS, jlong pagePtr){ FPDF_PAGE page = reinterpret_cast(pagePtr); return (jint)FPDF_GetPageHeight(page); } +JNI_FUNC(jdouble, PdfiumCore, nativeGetFontSize)(JNI_ARGS, jlong textPagePtr, jint index){ + FPDF_TEXTPAGE textPage = reinterpret_cast(textPagePtr); + return (jdouble)FPDFText_GetFontSize(textPage, index); +} JNI_FUNC(jobject, PdfiumCore, nativeGetPageSizeByIndex)(JNI_ARGS, jlong docPtr, jint pageIndex, jint dpi){ DocumentFile *doc = reinterpret_cast(docPtr); if(doc == NULL) { @@ -469,7 +597,7 @@ JNI_FUNC(void, PdfiumCore, nativeRenderPage)(JNI_ARGS, jlong pagePtr, jobject ob JNI_FUNC(void, PdfiumCore, nativeRenderPageBitmap)(JNI_ARGS, jlong pagePtr, jobject bitmap, jint dpi, jint startX, jint startY, jint drawSizeHor, jint drawSizeVer, - jboolean renderAnnot){ + jboolean renderAnnot, jboolean textMask){ FPDF_PAGE page = reinterpret_cast(pagePtr); @@ -537,6 +665,10 @@ JNI_FUNC(void, PdfiumCore, nativeRenderPageBitmap)(JNI_ARGS, jlong pagePtr, jobj flags |= FPDF_ANNOT; } + if(textMask) { + flags |= FPDF_RENDER_TEXT_MASK; + } + FPDFBitmap_FillRect( pdfBitmap, baseX, baseY, baseHorSize, baseVerSize, 0xFFFFFFFF); //White @@ -618,7 +750,7 @@ JNI_FUNC(jlong, PdfiumCore, nativeGetBookmarkDestIndex)(JNI_ARGS, jlong docPtr, if (dest == NULL) { return -1; } - return (jlong) FPDFDest_GetPageIndex(doc->pdfDocument, dest); + return (jlong) FPDFDest_GetDestPageIndex(doc->pdfDocument, dest); } JNI_FUNC(jlongArray, PdfiumCore, nativeGetPageLinks)(JNI_ARGS, jlong pagePtr) { @@ -642,7 +774,7 @@ JNI_FUNC(jobject, PdfiumCore, nativeGetDestPageIndex)(JNI_ARGS, jlong docPtr, jl if (dest == NULL) { return NULL; } - unsigned long index = FPDFDest_GetPageIndex(doc->pdfDocument, dest); + unsigned long index = FPDFDest_GetDestPageIndex(doc->pdfDocument, dest); return NewInteger(env, (jint) index); } @@ -688,4 +820,226 @@ JNI_FUNC(jobject, PdfiumCore, nativePageCoordsToDevice)(JNI_ARGS, jlong pagePtr, return env->NewObject(clazz, constructorID, deviceX, deviceY); } +JNI_FUNC(jobject, PdfiumCore, nativeDeviceCoordsToPage)(JNI_ARGS, jlong pagePtr, jint startX, jint startY, jint sizeX, + jint sizeY, jint rotate, jint deviceX, jint deviceY) { + FPDF_PAGE page = reinterpret_cast(pagePtr); + double pageX, pageY; + + FPDF_DeviceToPage(page, startX, startY, sizeX, sizeY, rotate, deviceX, deviceY, &pageX, &pageY); + + jclass clazz = env->FindClass("android/graphics/PointF"); + jmethodID constructorID = env->GetMethodID(clazz, "", "(FF)V"); + return env->NewObject(clazz, constructorID, pageX, pageY); +} + + +////////////////////////////////////////// +//Begin FPDF_TEXTPAGE section + +static jlong loadTextPageInternal(JNIEnv *env, DocumentFile *doc, jlong pagePtr){ + try{ + if(doc == NULL) throw "Get page document null"; + + FPDF_PAGE page = reinterpret_cast(pagePtr); + if(page != NULL){ + FPDF_TEXTPAGE textPage = FPDFText_LoadPage(page); + if (textPage == NULL) { + throw "Loaded text page is null"; + } + return reinterpret_cast(textPage); + }else{ + throw "Load page null"; + } + }catch(const char *msg){ + LOGE("%s", msg); + + jniThrowException(env, "java/lang/IllegalStateException", + "cannot load text page"); + + return -1; + } +} + +static void closeTextPageInternal(jlong textPagePtr) { FPDFText_ClosePage(reinterpret_cast(textPagePtr)); } + +JNI_FUNC(jlong, PdfiumCore, nativeLoadTextPage)(JNI_ARGS, jlong docPtr, jlong pagePtr){ + DocumentFile *doc = reinterpret_cast(docPtr); + return loadTextPageInternal(env, doc, pagePtr); +} +JNI_FUNC(jlongArray, PdfiumCore, nativeLoadTextPages)(JNI_ARGS, jlong docPtr, jint fromIndex, jint toIndex){ + DocumentFile *doc = reinterpret_cast(docPtr); + + if(toIndex < fromIndex) return NULL; + jlong pages[ toIndex - fromIndex + 1 ]; + + int i; + for(i = 0; i <= (toIndex - fromIndex); i++){ + pages[i] = loadTextPageInternal(env, doc, (int)(i + fromIndex)); + } + + jlongArray javaPages = env -> NewLongArray( (jsize)(toIndex - fromIndex + 1) ); + env -> SetLongArrayRegion(javaPages, 0, (jsize)(toIndex - fromIndex + 1), (const jlong*)pages); + + return javaPages; +} + +JNI_FUNC(void, PdfiumCore, nativeCloseTextPage)(JNI_ARGS, jlong textPagePtr){ closeTextPageInternal(textPagePtr); } +JNI_FUNC(void, PdfiumCore, nativeCloseTextPages)(JNI_ARGS, jlongArray textPagesPtr){ + int length = (int)(env -> GetArrayLength(textPagesPtr)); + jlong *textPages = env -> GetLongArrayElements(textPagesPtr, NULL); + + int i; + for(i = 0; i < length; i++){ closeTextPageInternal(textPages[i]); } +} + +//DLLEXPORT int STDCALL FPDFText_CountChars(FPDF_TEXTPAGE text_page); +JNI_FUNC(jint, PdfiumCore, nativeTextCountChars)(JNI_ARGS, jlong textPagePtr){ + FPDF_TEXTPAGE textPage = reinterpret_cast(textPagePtr); + return (jint)FPDFText_CountChars(textPage); +} + +//DLLEXPORT unsigned int STDCALL FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, int index); +JNI_FUNC(jint, PdfiumCore, nativeTextGetUnicode)(JNI_ARGS, jlong textPagePtr, jint index){ + FPDF_TEXTPAGE textPage = reinterpret_cast(textPagePtr); + return (jint)FPDFText_GetUnicode(textPage, (int)index); +} + +/*DLLEXPORT void STDCALL FPDFText_GetCharBox(FPDF_TEXTPAGE text_page, + int index, + double* left, + double* right, + double* bottom, + double* top);*/ +JNI_FUNC(jdoubleArray, PdfiumCore, nativeTextGetCharBox)(JNI_ARGS, jlong textPagePtr, jint index){ + FPDF_TEXTPAGE textPage = reinterpret_cast(textPagePtr); + jdoubleArray result = env->NewDoubleArray(4); + if (result == NULL) { + return NULL; + } + 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; +} + +/*DLLEXPORT int STDCALL FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page, + double x, + double y, + double xTolerance, + double yTolerance);*/ +JNI_FUNC(jint, PdfiumCore, nativeTextGetCharIndexAtPos)(JNI_ARGS, jlong textPagePtr, jdouble x, jdouble y, jdouble xTolerance, jdouble yTolerance){ + FPDF_TEXTPAGE textPage = reinterpret_cast(textPagePtr); + return (jint)FPDFText_GetCharIndexAtPos(textPage, (double)x, (double)y, (double)xTolerance, (double)yTolerance); +} + +/*DLLEXPORT int STDCALL FPDFText_GetText(FPDF_TEXTPAGE text_page, + int start_index, + int count, + unsigned short* result);*/ +JNI_FUNC(jint, PdfiumCore, nativeTextGetText)(JNI_ARGS, jlong textPagePtr, jint start_index, jint count, jshortArray result){ + FPDF_TEXTPAGE textPage = reinterpret_cast(textPagePtr); + jboolean isCopy = 0; + unsigned short *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; +} + +/*DLLEXPORT int STDCALL FPDFText_CountRects(FPDF_TEXTPAGE text_page, + int start_index, + int count);*/ +JNI_FUNC(jint, PdfiumCore, nativeTextCountRects)(JNI_ARGS, jlong textPagePtr, jint start_index, jint count){ + FPDF_TEXTPAGE textPage = reinterpret_cast(textPagePtr); + return (jint)FPDFText_CountRects(textPage, (int)start_index, (int) count); +} + +/*DLLEXPORT void STDCALL FPDFText_GetRect(FPDF_TEXTPAGE text_page, + int rect_index, + double* left, + double* top, + double* right, + double* bottom);*/ +JNI_FUNC(jdoubleArray, PdfiumCore, nativeTextGetRect)(JNI_ARGS, jlong textPagePtr, jint rect_index){ + FPDF_TEXTPAGE textPage = reinterpret_cast(textPagePtr); + jdoubleArray result = env->NewDoubleArray(4); + if (result == NULL) { + return NULL; + } + 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; +} + +/*DLLEXPORT int STDCALL FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page, + double left, + double top, + double right, + double bottom, + unsigned short* buffer, + int buflen); +*/ + +JNI_FUNC(jint, PdfiumCore, nativeTextGetBoundedText)(JNI_ARGS, jlong textPagePtr, jdouble left, jdouble top, jdouble right, jdouble bottom, jshortArray arr){ + FPDF_TEXTPAGE textPage = reinterpret_cast(textPagePtr); + jboolean isCopy = 0; + unsigned short *buffer = NULL; + int bufLen = 0; + if (arr != NULL) { + 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; +} + +class FileWrite : public FPDF_FILEWRITE { + public: + jobject callbackObject; + jmethodID callbackMethodID; + _JNIEnv *env; + + static int WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, const void* data, unsigned long size) { + FileWrite* pThis = static_cast(pFileWrite); + _JNIEnv *env = pThis->env; + //Convert the native array to Java array. + jbyteArray a = env->NewByteArray(size); + if (a != NULL) { + env->SetByteArrayRegion(a, 0, size, (const jbyte *)data); + return env->CallIntMethod(pThis->callbackObject, pThis->callbackMethodID, a); + } + return -1; + } +}; + +/*DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy(FPDF_DOCUMENT document, + FPDF_FILEWRITE* pFileWrite, + FPDF_DWORD flags); +*/ + +JNI_FUNC(jboolean, PdfiumCore, nativeSaveAsCopy)(JNI_ARGS, jlong documentPtr, jobject callback) { + jclass callbackClass = env->FindClass("com/shockwave/pdfium/PdfWriteCallback"); + if (callback != NULL && env->IsInstanceOf(callback, callbackClass)) { + //Setup the callback to Java. + FileWrite fw; + fw.version = 1; + fw.FPDF_FILEWRITE::WriteBlock = FileWrite::WriteBlockCallback; + fw.callbackObject = callback; + fw.callbackMethodID = env->GetMethodID(callbackClass, "WriteBlock", "([B)I"); + fw.env = env; + + DocumentFile *doc = reinterpret_cast(documentPtr); + jboolean output = (jboolean)FPDF_SaveAsCopy(doc->pdfDocument, &fw, 0); + return output; + } + return false; +} + }//extern C