Update pdfium for windows

This commit is contained in:
Luis Ángel San Martín 2024-10-12 10:15:43 +02:00
parent b7b9e9561c
commit 442307cc65
32 changed files with 5351 additions and 2630 deletions

View File

@ -1,6 +1,8 @@
TODO: this file needs to be updated
YACReader for Windows uses a shared library version of pdfium.
pdfium branch used for building: chromium/3729
pdfium branch used for building: chromium/6668
Build parameters used (gn args):

View File

@ -1,56 +0,0 @@
From 0706085c41f645d68e29732f21da733e191abc34 Mon Sep 17 00:00:00 2001
From: Felix Kauselmann <licorn@gmail.com>
Date: Sat, 27 Apr 2019 16:57:01 +0200
Subject: [PATCH] Build a shared library
---
BUILD.gn | 3 ++-
public/fpdfview.h | 9 +++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/BUILD.gn b/BUILD.gn
index 6885fc27d..06335fcd3 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -22,6 +22,7 @@ config("pdfium_common_config") {
defines = [
"PNG_PREFIX",
"PNG_USE_READ_MACROS",
+ "FPDFSDK_EXPORTS",
]
if (!use_system_libopenjpeg2) {
@@ -132,7 +133,7 @@ jumbo_source_set("pdfium_public_headers") {
public_configs = [ ":pdfium_public_config" ]
}
-jumbo_static_library("pdfium") {
+shared_library("pdfium") {
sources = [
"fpdfsdk/fpdf_annot.cpp",
"fpdfsdk/fpdf_attachment.cpp",
diff --git a/public/fpdfview.h b/public/fpdfview.h
index 8892da536..8453ee66e 100644
--- a/public/fpdfview.h
+++ b/public/fpdfview.h
@@ -154,10 +154,15 @@ typedef int FPDF_ANNOT_APPEARANCEMODE;
// Dictionary value types.
typedef int FPDF_OBJECT_TYPE;
-#if defined(_WIN32) && defined(FPDFSDK_EXPORTS)
+#if defined(_WIN32)
+#if defined(FPDFSDK_EXPORTS)
// On Windows system, functions are exported in a DLL
#define FPDF_EXPORT __declspec(dllexport)
-#define FPDF_CALLCONV __stdcall
+#define FPDF_CALLCONV __cdecl
+#else
+#define FPDF_EXPORT __declspec(dllimport)
+#define FPDF_CALLCONV __cdecl
+#endif
#else
#define FPDF_EXPORT
#define FPDF_CALLCONV
--
2.20.1.windows.1

2
dependencies/pdfium/win/public/DEPS vendored Normal file
View File

@ -0,0 +1,2 @@
# public/ needs to be standalone; don't inherit any include rules.
noparent = True

View File

@ -4,6 +4,8 @@ The header files in this directory are the only ones that should ever be
included by an embedder of PDFium. If there arises a need for functionality
beyond what is present here, then a new API must be added here to provide it.
Documentation for the API is within the headers. Start by reading fpdfview.h.
These header files must be entirely contained in this directory; they must
never include other header files from outside of it.

View File

@ -0,0 +1,86 @@
// Copyright 2017 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PUBLIC_CPP_FPDF_DELETERS_H_
#define PUBLIC_CPP_FPDF_DELETERS_H_
#include "public/fpdf_annot.h"
#include "public/fpdf_dataavail.h"
#include "public/fpdf_edit.h"
#include "public/fpdf_formfill.h"
#include "public/fpdf_javascript.h"
#include "public/fpdf_structtree.h"
#include "public/fpdf_text.h"
#include "public/fpdf_transformpage.h"
#include "public/fpdfview.h"
// Custom deleters for using FPDF_* types with std::unique_ptr<>.
struct FPDFAnnotationDeleter {
inline void operator()(FPDF_ANNOTATION annot) { FPDFPage_CloseAnnot(annot); }
};
struct FPDFAvailDeleter {
inline void operator()(FPDF_AVAIL avail) { FPDFAvail_Destroy(avail); }
};
struct FPDFBitmapDeleter {
inline void operator()(FPDF_BITMAP bitmap) { FPDFBitmap_Destroy(bitmap); }
};
struct FPDFClipPathDeleter {
inline void operator()(FPDF_CLIPPATH clip_path) {
FPDF_DestroyClipPath(clip_path);
}
};
struct FPDFDocumentDeleter {
inline void operator()(FPDF_DOCUMENT doc) { FPDF_CloseDocument(doc); }
};
struct FPDFFontDeleter {
inline void operator()(FPDF_FONT font) { FPDFFont_Close(font); }
};
struct FPDFFormHandleDeleter {
inline void operator()(FPDF_FORMHANDLE form) {
FPDFDOC_ExitFormFillEnvironment(form);
}
};
struct FPDFJavaScriptActionDeleter {
inline void operator()(FPDF_JAVASCRIPT_ACTION javascript) {
FPDFDoc_CloseJavaScriptAction(javascript);
}
};
struct FPDFPageDeleter {
inline void operator()(FPDF_PAGE page) { FPDF_ClosePage(page); }
};
struct FPDFPageLinkDeleter {
inline void operator()(FPDF_PAGELINK pagelink) {
FPDFLink_CloseWebLinks(pagelink);
}
};
struct FPDFPageObjectDeleter {
inline void operator()(FPDF_PAGEOBJECT object) {
FPDFPageObj_Destroy(object);
}
};
struct FPDFStructTreeDeleter {
inline void operator()(FPDF_STRUCTTREE tree) { FPDF_StructTree_Close(tree); }
};
struct FPDFTextFindDeleter {
inline void operator()(FPDF_SCHHANDLE handle) { FPDFText_FindClose(handle); }
};
struct FPDFTextPageDeleter {
inline void operator()(FPDF_TEXTPAGE text) { FPDFText_ClosePage(text); }
};
#endif // PUBLIC_CPP_FPDF_DELETERS_H_

View File

@ -0,0 +1,67 @@
// Copyright 2018 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PUBLIC_CPP_FPDF_SCOPERS_H_
#define PUBLIC_CPP_FPDF_SCOPERS_H_
#include <memory>
#include <type_traits>
#include "public/cpp/fpdf_deleters.h"
// Versions of FPDF types that clean up the object at scope exit.
using ScopedFPDFAnnotation =
std::unique_ptr<std::remove_pointer<FPDF_ANNOTATION>::type,
FPDFAnnotationDeleter>;
using ScopedFPDFAvail =
std::unique_ptr<std::remove_pointer<FPDF_AVAIL>::type, FPDFAvailDeleter>;
using ScopedFPDFBitmap =
std::unique_ptr<std::remove_pointer<FPDF_BITMAP>::type, FPDFBitmapDeleter>;
using ScopedFPDFClipPath =
std::unique_ptr<std::remove_pointer<FPDF_CLIPPATH>::type,
FPDFClipPathDeleter>;
using ScopedFPDFDocument =
std::unique_ptr<std::remove_pointer<FPDF_DOCUMENT>::type,
FPDFDocumentDeleter>;
using ScopedFPDFFont =
std::unique_ptr<std::remove_pointer<FPDF_FONT>::type, FPDFFontDeleter>;
using ScopedFPDFFormHandle =
std::unique_ptr<std::remove_pointer<FPDF_FORMHANDLE>::type,
FPDFFormHandleDeleter>;
using ScopedFPDFJavaScriptAction =
std::unique_ptr<std::remove_pointer<FPDF_JAVASCRIPT_ACTION>::type,
FPDFJavaScriptActionDeleter>;
using ScopedFPDFPage =
std::unique_ptr<std::remove_pointer<FPDF_PAGE>::type, FPDFPageDeleter>;
using ScopedFPDFPageLink =
std::unique_ptr<std::remove_pointer<FPDF_PAGELINK>::type,
FPDFPageLinkDeleter>;
using ScopedFPDFPageObject =
std::unique_ptr<std::remove_pointer<FPDF_PAGEOBJECT>::type,
FPDFPageObjectDeleter>;
using ScopedFPDFStructTree =
std::unique_ptr<std::remove_pointer<FPDF_STRUCTTREE>::type,
FPDFStructTreeDeleter>;
using ScopedFPDFTextFind =
std::unique_ptr<std::remove_pointer<FPDF_SCHHANDLE>::type,
FPDFTextFindDeleter>;
using ScopedFPDFTextPage =
std::unique_ptr<std::remove_pointer<FPDF_TEXTPAGE>::type,
FPDFTextPageDeleter>;
#endif // PUBLIC_CPP_FPDF_SCOPERS_H_

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,179 @@
// Copyright 2017 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PUBLIC_FPDF_ATTACHMENT_H_
#define PUBLIC_FPDF_ATTACHMENT_H_
// NOLINTNEXTLINE(build/include)
#include "fpdfview.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// Experimental API.
// Get the number of embedded files in |document|.
//
// document - handle to a document.
//
// Returns the number of embedded files in |document|.
FPDF_EXPORT int FPDF_CALLCONV
FPDFDoc_GetAttachmentCount(FPDF_DOCUMENT document);
// Experimental API.
// Add an embedded file with |name| in |document|. If |name| is empty, or if
// |name| is the name of a existing embedded file in |document|, or if
// |document|'s embedded file name tree is too deep (i.e. |document| has too
// many embedded files already), then a new attachment will not be added.
//
// document - handle to a document.
// name - name of the new attachment.
//
// Returns a handle to the new attachment object, or NULL on failure.
FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV
FPDFDoc_AddAttachment(FPDF_DOCUMENT document, FPDF_WIDESTRING name);
// Experimental API.
// Get the embedded attachment at |index| in |document|. Note that the returned
// attachment handle is only valid while |document| is open.
//
// document - handle to a document.
// index - the index of the requested embedded file.
//
// Returns the handle to the attachment object, or NULL on failure.
FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV
FPDFDoc_GetAttachment(FPDF_DOCUMENT document, int index);
// Experimental API.
// Delete the embedded attachment at |index| in |document|. Note that this does
// not remove the attachment data from the PDF file; it simply removes the
// file's entry in the embedded files name tree so that it does not appear in
// the attachment list. This behavior may change in the future.
//
// document - handle to a document.
// index - the index of the embedded file to be deleted.
//
// Returns true if successful.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFDoc_DeleteAttachment(FPDF_DOCUMENT document, int index);
// Experimental API.
// Get the name of the |attachment| file. |buffer| is only modified if |buflen|
// is longer than the length of the file name. On errors, |buffer| is unmodified
// and the returned length is 0.
//
// attachment - handle to an attachment.
// buffer - buffer for holding the file name, encoded in UTF-16LE.
// buflen - length of the buffer in bytes.
//
// Returns the length of the file name in bytes.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDFAttachment_GetName(FPDF_ATTACHMENT attachment,
FPDF_WCHAR* buffer,
unsigned long buflen);
// Experimental API.
// Check if the params dictionary of |attachment| has |key| as a key.
//
// attachment - handle to an attachment.
// key - the key to look for, encoded in UTF-8.
//
// Returns true if |key| exists.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFAttachment_HasKey(FPDF_ATTACHMENT attachment, FPDF_BYTESTRING key);
// Experimental API.
// Get the type of the value corresponding to |key| in the params dictionary of
// the embedded |attachment|.
//
// attachment - handle to an attachment.
// key - the key to look for, encoded in UTF-8.
//
// Returns the type of the dictionary value.
FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV
FPDFAttachment_GetValueType(FPDF_ATTACHMENT attachment, FPDF_BYTESTRING key);
// Experimental API.
// Set the string value corresponding to |key| in the params dictionary of the
// embedded file |attachment|, overwriting the existing value if any. The value
// type should be FPDF_OBJECT_STRING after this function call succeeds.
//
// attachment - handle to an attachment.
// key - the key to the dictionary entry, encoded in UTF-8.
// value - the string value to be set, encoded in UTF-16LE.
//
// Returns true if successful.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFAttachment_SetStringValue(FPDF_ATTACHMENT attachment,
FPDF_BYTESTRING key,
FPDF_WIDESTRING value);
// Experimental API.
// Get the string value corresponding to |key| in the params dictionary of the
// embedded file |attachment|. |buffer| is only modified if |buflen| is longer
// than the length of the string value. Note that if |key| does not exist in the
// dictionary or if |key|'s corresponding value in the dictionary is not a
// string (i.e. the value is not of type FPDF_OBJECT_STRING or
// FPDF_OBJECT_NAME), then an empty string would be copied to |buffer| and the
// return value would be 2. On other errors, nothing would be added to |buffer|
// and the return value would be 0.
//
// attachment - handle to an attachment.
// key - the key to the requested string value, encoded in UTF-8.
// buffer - buffer for holding the string value encoded in UTF-16LE.
// buflen - length of the buffer in bytes.
//
// Returns the length of the dictionary value string in bytes.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDFAttachment_GetStringValue(FPDF_ATTACHMENT attachment,
FPDF_BYTESTRING key,
FPDF_WCHAR* buffer,
unsigned long buflen);
// Experimental API.
// Set the file data of |attachment|, overwriting the existing file data if any.
// The creation date and checksum will be updated, while all other dictionary
// entries will be deleted. Note that only contents with |len| smaller than
// INT_MAX is supported.
//
// attachment - handle to an attachment.
// contents - buffer holding the file data to write to |attachment|.
// len - length of file data in bytes.
//
// Returns true if successful.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFAttachment_SetFile(FPDF_ATTACHMENT attachment,
FPDF_DOCUMENT document,
const void* contents,
unsigned long len);
// Experimental API.
// Get the file data of |attachment|.
// When the attachment file data is readable, true is returned, and |out_buflen|
// is updated to indicate the file data size. |buffer| is only modified if
// |buflen| is non-null and long enough to contain the entire file data. Callers
// must check both the return value and the input |buflen| is no less than the
// returned |out_buflen| before using the data.
//
// Otherwise, when the attachment file data is unreadable or when |out_buflen|
// is null, false is returned and |buffer| and |out_buflen| remain unmodified.
//
// attachment - handle to an attachment.
// buffer - buffer for holding the file data from |attachment|.
// buflen - length of the buffer in bytes.
// out_buflen - pointer to the variable that will receive the minimum buffer
// size to contain the file data of |attachment|.
//
// Returns true on success, false otherwise.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFAttachment_GetFile(FPDF_ATTACHMENT attachment,
void* buffer,
unsigned long buflen,
unsigned long* out_buflen);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // PUBLIC_FPDF_ATTACHMENT_H_

View File

@ -0,0 +1,42 @@
// Copyright 2017 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PUBLIC_FPDF_CATALOG_H_
#define PUBLIC_FPDF_CATALOG_H_
// NOLINTNEXTLINE(build/include)
#include "fpdfview.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// Experimental API.
//
// Determine if |document| represents a tagged PDF.
//
// For the definition of tagged PDF, See (see 10.7 "Tagged PDF" in PDF
// Reference 1.7).
//
// document - handle to a document.
//
// Returns |true| iff |document| is a tagged PDF.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFCatalog_IsTagged(FPDF_DOCUMENT document);
// Experimental API.
// Sets the language of |document| to |language|.
//
// document - handle to a document.
// language - the language to set to.
//
// Returns TRUE on success.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFCatalog_SetLanguage(FPDF_DOCUMENT document, FPDF_BYTESTRING language);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // PUBLIC_FPDF_CATALOG_H_

View File

@ -1,4 +1,4 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -50,7 +50,6 @@ typedef struct _FX_FILEAVAIL {
size_t offset,
size_t size);
} FX_FILEAVAIL;
typedef void* FPDF_AVAIL;
// Create a document availability provider.
//

View File

@ -1,4 +1,4 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -24,6 +24,8 @@ extern "C" {
#define PDFACTION_URI 3
// Launch an application or open a file.
#define PDFACTION_LAUNCH 4
// Go to a destination in an embedded file.
#define PDFACTION_EMBEDDEDGOTO 5
// View destination fit types. See pdfmark reference v9, page 48.
#define PDFDEST_VIEW_UNKNOWN_MODE 0
@ -36,16 +38,12 @@ extern "C" {
#define PDFDEST_VIEW_FITBH 7
#define PDFDEST_VIEW_FITBV 8
typedef struct _FS_QUADPOINTSF {
FS_FLOAT x1;
FS_FLOAT y1;
FS_FLOAT x2;
FS_FLOAT y2;
FS_FLOAT x3;
FS_FLOAT y3;
FS_FLOAT x4;
FS_FLOAT y4;
} FS_QUADPOINTSF;
// The file identifier entry type. See section 14.4 "File Identifiers" of the
// ISO 32000-1:2008 spec.
typedef enum {
FILEIDTYPE_PERMANENT = 0,
FILEIDTYPE_CHANGING = 1
} FPDF_FILEIDTYPE;
// Get the first child of |bookmark|, or the first top-level bookmark item.
//
@ -55,6 +53,8 @@ typedef struct _FS_QUADPOINTSF {
//
// Returns a handle to the first child of |bookmark| or the first top-level
// bookmark item. NULL if no child or top-level bookmark found.
// Note that another name for the bookmarks is the document outline, as
// described in ISO 32000-1:2008, section 12.3.3.
FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV
FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark);
@ -65,6 +65,9 @@ FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark);
//
// Returns a handle to the next sibling of |bookmark|, or NULL if this is the
// last bookmark at this level.
//
// Note that the caller is responsible for handling circular bookmark
// references, as may arise from malformed documents.
FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV
FPDFBookmark_GetNextSibling(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark);
@ -86,6 +89,18 @@ FPDFBookmark_GetTitle(FPDF_BOOKMARK bookmark,
void* buffer,
unsigned long buflen);
// Experimental API.
// Get the number of chlidren of |bookmark|.
//
// bookmark - handle to the bookmark.
//
// Returns a signed integer that represents the number of sub-items the given
// bookmark has. If the value is positive, child items shall be shown by default
// (open state). If the value is negative, child items shall be hidden by
// default (closed state). Please refer to PDF 32000-1:2008, Table 153.
// Returns 0 if the bookmark has no children or is invalid.
FPDF_EXPORT int FPDF_CALLCONV FPDFBookmark_GetCount(FPDF_BOOKMARK bookmark);
// Find the bookmark with |title| in |document|.
//
// document - handle to the document.
@ -103,7 +118,7 @@ FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title);
// document - handle to the document.
// bookmark - handle to the bookmark.
//
// Returns the handle to the destination data, NULL if no destination is
// Returns the handle to the destination data, or NULL if no destination is
// associated with |bookmark|.
FPDF_EXPORT FPDF_DEST FPDF_CALLCONV
FPDFBookmark_GetDest(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark);
@ -113,8 +128,11 @@ FPDFBookmark_GetDest(FPDF_DOCUMENT document, FPDF_BOOKMARK 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.
// with |bookmark|.
// If this function returns a valid handle, it is valid as long as |bookmark| is
// valid.
// If this function returns NULL, FPDFBookmark_GetDest() should be called to get
// the |bookmark| destination data.
FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV
FPDFBookmark_GetAction(FPDF_BOOKMARK bookmark);
@ -173,8 +191,18 @@ FPDFAction_GetFilePath(FPDF_ACTION action, void* buffer, unsigned long buflen);
// 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.
// The |buffer| may contain badly encoded data. The caller should validate the
// output. e.g. Check to see if it is UTF-8.
//
// If |buflen| is less than the returned length, or |buffer| is NULL, |buffer|
// will not be modified.
//
// Historically, the documentation for this API claimed |buffer| is always
// encoded in 7-bit ASCII, but did not actually enforce it.
// https://pdfium.googlesource.com/pdfium.git/+/d609e84cee2e14a18333247485af91df48a40592
// added that enforcement, but that did not work well for real world PDFs that
// used UTF-8. As of this writing, this API reverted back to its original
// behavior prior to commit d609e84cee.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDFAction_GetURIPath(FPDF_DOCUMENT document,
FPDF_ACTION action,
@ -190,8 +218,8 @@ FPDFAction_GetURIPath(FPDF_DOCUMENT document,
FPDF_EXPORT int FPDF_CALLCONV FPDFDest_GetDestPageIndex(FPDF_DOCUMENT document,
FPDF_DEST dest);
// Experimental API.
// 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.
@ -218,9 +246,9 @@ FPDFDest_GetView(FPDF_DEST dest, unsigned long* pNumParams, FS_FLOAT* pParams);
// hasYVal or hasZoomVal flags are true.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFDest_GetLocationInPage(FPDF_DEST dest,
FPDF_BOOL* hasXCoord,
FPDF_BOOL* hasYCoord,
FPDF_BOOL* hasZoom,
FPDF_BOOL* hasXVal,
FPDF_BOOL* hasYVal,
FPDF_BOOL* hasZoomVal,
FS_FLOAT* x,
FS_FLOAT* y,
FS_FLOAT* zoom);
@ -270,6 +298,8 @@ FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDFLink_GetDest(FPDF_DOCUMENT document,
// link - handle to the link.
//
// Returns a handle to the action associated to |link|, or NULL if no action.
// If this function returns a valid handle, it is valid as long as |link| is
// valid.
FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV FPDFLink_GetAction(FPDF_LINK link);
// Enumerates all the link annotations in |page|.
@ -284,6 +314,17 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFLink_Enumerate(FPDF_PAGE page,
int* start_pos,
FPDF_LINK* link_annot);
// Experimental API.
// Gets FPDF_ANNOTATION object for |link_annot|.
//
// page - handle to the page in which FPDF_LINK object is present.
// link_annot - handle to link annotation.
//
// Returns FPDF_ANNOTATION from the FPDF_LINK and NULL on failure,
// if the input link annot or page is NULL.
FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV
FPDFLink_GetAnnot(FPDF_PAGE page, FPDF_LINK link_annot);
// Get the rectangle for |link_annot|.
//
// link_annot - handle to the link annotation.
@ -312,6 +353,40 @@ FPDFLink_GetQuadPoints(FPDF_LINK link_annot,
int quad_index,
FS_QUADPOINTSF* quad_points);
// Experimental API
// Gets an additional-action from |page|.
//
// page - handle to the page, as returned by FPDF_LoadPage().
// aa_type - the type of the page object's addtional-action, defined
// in public/fpdf_formfill.h
//
// Returns the handle to the action data, or NULL if there is no
// additional-action of type |aa_type|.
// If this function returns a valid handle, it is valid as long as |page| is
// valid.
FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV FPDF_GetPageAAction(FPDF_PAGE page,
int aa_type);
// Experimental API.
// Get the file identifer defined in the trailer of |document|.
//
// document - handle to the document.
// id_type - the file identifier type to retrieve.
// buffer - a buffer for the file identifier. May be NULL.
// buflen - the length of the buffer, in bytes. May be 0.
//
// Returns the number of bytes in the file identifier, including the NUL
// terminator.
//
// The |buffer| is always a byte string. The |buffer| is followed by a NUL
// terminator. If |buflen| is less than the returned length, or |buffer| is
// NULL, |buffer| will not be modified.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDF_GetFileIdentifier(FPDF_DOCUMENT document,
FPDF_FILEIDTYPE id_type,
void* buffer,
unsigned long buflen);
// Get meta-data |tag| content from |document|.
//
// document - handle to the document.

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

View File

@ -1,4 +1,4 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -14,17 +14,6 @@
extern "C" {
#endif // __cplusplus
typedef int FPDF_INT32;
typedef unsigned int FPDF_UINT32;
typedef float FPDF_FLOAT;
// Event types.
typedef enum {
FWL_EVENTTYPE_Mouse = 0,
FWL_EVENTTYPE_MouseWheel,
FWL_EVENTTYPE_Key,
} FWL_EVENTTYPE;
// Key flags.
typedef enum {
FWL_EVENTFLAG_ShiftKey = 1 << 0,
@ -38,40 +27,6 @@ typedef enum {
FWL_EVENTFLAG_RightButtonDown = 1 << 8,
} FWL_EVENTFLAG;
// Mouse messages.
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 events.
struct FWL_EVENT_MOUSE {
FPDF_UINT32 command;
FPDF_DWORD flag;
FPDF_FLOAT x;
FPDF_FLOAT y;
};
// Mouse wheel events.
struct FWL_EVENT_MOUSEWHEEL {
FPDF_DWORD flag;
FPDF_FLOAT x;
FPDF_FLOAT y;
FPDF_FLOAT deltaX;
FPDF_FLOAT deltaY;
};
// Virtual keycodes.
typedef enum {
FWL_VKEY_Back = 0x08,
@ -245,38 +200,6 @@ typedef enum {
FWL_VKEY_Unknown = 0,
} FWL_VKEYCODE;
// Key event commands.
typedef enum {
FWL_EVENTKEYCMD_KeyDown = 1,
FWL_EVENTKEYCMD_KeyUp,
FWL_EVENTKEYCMD_Char,
} FWL_EVENTKEYCMD;
// Key events.
struct FWL_EVENT_KEY {
FPDF_UINT32 command;
FPDF_DWORD flag;
union {
// Virtual key code.
FPDF_UINT32 vkcode;
// Character code.
FPDF_DWORD charcode;
} code;
};
// Event types.
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
} // extern "C"
#endif // __cplusplus

View File

@ -0,0 +1,77 @@
// Copyright 2019 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PUBLIC_FPDF_JAVASCRIPT_H_
#define PUBLIC_FPDF_JAVASCRIPT_H_
// NOLINTNEXTLINE(build/include)
#include "fpdfview.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// Experimental API.
// Get the number of JavaScript actions in |document|.
//
// document - handle to a document.
//
// Returns the number of JavaScript actions in |document| or -1 on error.
FPDF_EXPORT int FPDF_CALLCONV
FPDFDoc_GetJavaScriptActionCount(FPDF_DOCUMENT document);
// Experimental API.
// Get the JavaScript action at |index| in |document|.
//
// document - handle to a document.
// index - the index of the requested JavaScript action.
//
// Returns the handle to the JavaScript action, or NULL on failure.
// Caller owns the returned handle and must close it with
// FPDFDoc_CloseJavaScriptAction().
FPDF_EXPORT FPDF_JAVASCRIPT_ACTION FPDF_CALLCONV
FPDFDoc_GetJavaScriptAction(FPDF_DOCUMENT document, int index);
// Experimental API.
// Close a loaded FPDF_JAVASCRIPT_ACTION object.
// javascript - Handle to a JavaScript action.
FPDF_EXPORT void FPDF_CALLCONV
FPDFDoc_CloseJavaScriptAction(FPDF_JAVASCRIPT_ACTION javascript);
// Experimental API.
// Get the name from the |javascript| handle. |buffer| is only modified if
// |buflen| is longer than the length of the name. On errors, |buffer| is
// unmodified and the returned length is 0.
//
// javascript - handle to an JavaScript action.
// buffer - buffer for holding the name, encoded in UTF-16LE.
// buflen - length of the buffer in bytes.
//
// Returns the length of the JavaScript action name in bytes.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDFJavaScriptAction_GetName(FPDF_JAVASCRIPT_ACTION javascript,
FPDF_WCHAR* buffer,
unsigned long buflen);
// Experimental API.
// Get the script from the |javascript| handle. |buffer| is only modified if
// |buflen| is longer than the length of the script. On errors, |buffer| is
// unmodified and the returned length is 0.
//
// javascript - handle to an JavaScript action.
// buffer - buffer for holding the name, encoded in UTF-16LE.
// buflen - length of the buffer in bytes.
//
// Returns the length of the JavaScript action name in bytes.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDFJavaScriptAction_GetScript(FPDF_JAVASCRIPT_ACTION javascript,
FPDF_WCHAR* buffer,
unsigned long buflen);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // PUBLIC_FPDF_JAVASCRIPT_H_

View File

@ -1,4 +1,4 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -14,15 +14,38 @@
extern "C" {
#endif
// Experimental API.
// Import pages to a FPDF_DOCUMENT.
//
// dest_doc - The destination document for the pages.
// src_doc - The document to be imported.
// page_indices - An array of page indices to be imported. The first page is
// zero. If |page_indices| is NULL, all pages from |src_doc|
// are imported.
// length - The length of the |page_indices| array.
// index - The page index at which to insert the first imported page
// into |dest_doc|. The first page is zero.
//
// Returns TRUE on success. Returns FALSE if any pages in |page_indices| is
// invalid.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDF_ImportPagesByIndex(FPDF_DOCUMENT dest_doc,
FPDF_DOCUMENT src_doc,
const int* page_indices,
unsigned long length,
int index);
// Import pages to a FPDF_DOCUMENT.
//
// dest_doc - The destination document for the pages.
// src_doc - The document to be imported.
// pagerange - A page range string, Such as "1,3,5-7". If |pagerange| is NULL,
// all pages from |src_doc| are imported.
// index - The page index to insert at.
// pagerange - A page range string, Such as "1,3,5-7". The first page is one.
// If |pagerange| is NULL, all pages from |src_doc| are imported.
// index - The page index at which to insert the first imported page into
// |dest_doc|. The first page is zero.
//
// Returns TRUE on success.
// Returns TRUE on success. Returns FALSE if any pages in |pagerange| is
// invalid or if |pagerange| cannot be read.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_ImportPages(FPDF_DOCUMENT dest_doc,
FPDF_DOCUMENT src_doc,
FPDF_BYTESTRING pagerange,
@ -49,8 +72,32 @@ FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV
FPDF_ImportNPagesToOne(FPDF_DOCUMENT src_doc,
float output_width,
float output_height,
unsigned int num_pages_on_x_axis,
unsigned int num_pages_on_y_axis);
size_t num_pages_on_x_axis,
size_t num_pages_on_y_axis);
// Experimental API.
// Create a template to generate form xobjects from |src_doc|'s page at
// |src_page_index|, for use in |dest_doc|.
//
// Returns a handle on success, or NULL on failure. Caller owns the newly
// created object.
FPDF_EXPORT FPDF_XOBJECT FPDF_CALLCONV
FPDF_NewXObjectFromPage(FPDF_DOCUMENT dest_doc,
FPDF_DOCUMENT src_doc,
int src_page_index);
// Experimental API.
// Close an FPDF_XOBJECT handle created by FPDF_NewXObjectFromPage().
// FPDF_PAGEOBJECTs created from the FPDF_XOBJECT handle are not affected.
FPDF_EXPORT void FPDF_CALLCONV FPDF_CloseXObject(FPDF_XOBJECT xobject);
// Experimental API.
// Create a new form object from an FPDF_XOBJECT object.
//
// Returns a new form object on success, or NULL on failure. Caller owns the
// newly created object.
FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
FPDF_NewFormObjectFromXObject(FPDF_XOBJECT xobject);
// Copy the viewer preferences from |src_doc| into |dest_doc|.
//

View File

@ -1,4 +1,4 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -7,6 +7,7 @@
#ifndef PUBLIC_FPDF_PROGRESSIVE_H_
#define PUBLIC_FPDF_PROGRESSIVE_H_
// clang-format off
// NOLINTNEXTLINE(build/include)
#include "fpdfview.h"
@ -22,61 +23,97 @@ extern "C" {
// IFPDF_RENDERINFO interface.
typedef struct _IFSDK_PAUSE {
/**
* Version number of the interface. Currently must be 1.
**/
// Version number of the interface. Currently must be 1.
int version;
/*
* Method: NeedToPauseNow
* Check if we need to pause a progressive process now.
* Interface Version:
* 1
* Implementation Required:
* yes
* Parameters:
* pThis - Pointer to the interface structure itself
* Return Value:
* Non-zero for pause now, 0 for continue.
*
*/
// Method: NeedToPauseNow
// Check if we need to pause a progressive process now.
// Interface Version:
// 1
// Implementation Required:
// yes
// Parameters:
// pThis - Pointer to the interface structure itself
// Return Value:
// Non-zero for pause now, 0 for continue.
FPDF_BOOL (*NeedToPauseNow)(struct _IFSDK_PAUSE* pThis);
// A user defined data pointer, used by user's application. Can be NULL.
void* user;
} IFSDK_PAUSE;
// Experimental API.
// Function: FPDF_RenderPageBitmapWithColorScheme_Start
// Start to render page contents to a device independent bitmap
// progressively with a specified color scheme for the content.
// Parameters:
// bitmap - Handle to the device independent bitmap (as the
// output buffer). Bitmap handle can be created by
// FPDFBitmap_Create function.
// page - Handle to the page as returned by FPDF_LoadPage
// function.
// start_x - Left pixel position of the display area in the
// bitmap coordinate.
// start_y - Top pixel position of the display area in the
// bitmap coordinate.
// size_x - Horizontal size (in pixels) for displaying the
// page.
// size_y - Vertical size (in pixels) for displaying the page.
// rotate - Page orientation: 0 (normal), 1 (rotated 90
// degrees clockwise), 2 (rotated 180 degrees),
// 3 (rotated 90 degrees counter-clockwise).
// flags - 0 for normal display, or combination of flags
// defined in fpdfview.h. With FPDF_ANNOT flag, it
// renders all annotations that does not require
// user-interaction, which are all annotations except
// widget and popup annotations.
// color_scheme - Color scheme to be used in rendering the |page|.
// If null, this function will work similar to
// FPDF_RenderPageBitmap_Start().
// pause - The IFSDK_PAUSE interface. A callback mechanism
// allowing the page rendering process.
// Return value:
// Rendering Status. See flags for progressive process status for the
// details.
FPDF_EXPORT int FPDF_CALLCONV
FPDF_RenderPageBitmapWithColorScheme_Start(FPDF_BITMAP bitmap,
FPDF_PAGE page,
int start_x,
int start_y,
int size_x,
int size_y,
int rotate,
int flags,
const FPDF_COLORSCHEME* color_scheme,
IFSDK_PAUSE* pause);
// Function: FPDF_RenderPageBitmap_Start
// Start to render page contents to a device independent bitmap
// progressively.
// Parameters:
// bitmap - Handle to the device independent bitmap (as the
// output buffer).
// Bitmap handle can be created by FPDFBitmap_Create
// function.
// page - Handle to the page. Returned by FPDF_LoadPage
// function.
// output buffer). Bitmap handle can be created by
// FPDFBitmap_Create().
// page - Handle to the page, as returned by FPDF_LoadPage().
// start_x - Left pixel position of the display area in the
// bitmap coordinate.
// bitmap coordinates.
// start_y - Top pixel position of the display area in the bitmap
// coordinate.
// coordinates.
// size_x - Horizontal size (in pixels) for displaying the page.
// size_y - Vertical size (in pixels) for displaying the page.
// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees
// clockwise),
// 2 (rotated 180 degrees), 3 (rotated 90 degrees
// counter-clockwise).
// clockwise), 2 (rotated 180 degrees), 3 (rotated 90
// degrees counter-clockwise).
// flags - 0 for normal display, or combination of flags
// defined 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.
//
FPDF_EXPORT int FPDF_CALLCONV FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap,
FPDF_PAGE page,
int start_x,
@ -90,12 +127,11 @@ FPDF_EXPORT int FPDF_CALLCONV FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap,
// 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.
@ -107,10 +143,9 @@ FPDF_EXPORT int FPDF_CALLCONV FPDF_RenderPage_Continue(FPDF_PAGE page,
// 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
// None.
FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPage_Close(FPDF_PAGE page);
#ifdef __cplusplus

View File

@ -1,4 +1,4 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -7,6 +7,7 @@
#ifndef PUBLIC_FPDF_SAVE_H_
#define PUBLIC_FPDF_SAVE_H_
// clang-format off
// NOLINTNEXTLINE(build/include)
#include "fpdfview.h"
@ -21,7 +22,6 @@ typedef struct FPDF_FILEWRITE_ {
//
int version;
//
// Method: WriteBlock
// Output a block of data in your custom way.
// Interface Version:
@ -36,24 +36,21 @@ 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:
@ -64,14 +61,14 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_SaveAsCopy(FPDF_DOCUMENT document,
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.
//

View File

@ -1,4 +1,4 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

View File

@ -0,0 +1,155 @@
// Copyright 2020 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PUBLIC_FPDF_SIGNATURE_H_
#define PUBLIC_FPDF_SIGNATURE_H_
// NOLINTNEXTLINE(build/include)
#include "fpdfview.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// Experimental API.
// Function: FPDF_GetSignatureCount
// Get total number of signatures in the document.
// Parameters:
// document - Handle to document. Returned by FPDF_LoadDocument().
// Return value:
// Total number of signatures in the document on success, -1 on error.
FPDF_EXPORT int FPDF_CALLCONV FPDF_GetSignatureCount(FPDF_DOCUMENT document);
// Experimental API.
// Function: FPDF_GetSignatureObject
// Get the Nth signature of the document.
// Parameters:
// document - Handle to document. Returned by FPDF_LoadDocument().
// index - Index into the array of signatures of the document.
// Return value:
// Returns the handle to the signature, or NULL on failure. The caller
// does not take ownership of the returned FPDF_SIGNATURE. Instead, it
// remains valid until FPDF_CloseDocument() is called for the document.
FPDF_EXPORT FPDF_SIGNATURE FPDF_CALLCONV
FPDF_GetSignatureObject(FPDF_DOCUMENT document, int index);
// Experimental API.
// Function: FPDFSignatureObj_GetContents
// Get the contents of a signature object.
// Parameters:
// signature - Handle to the signature object. Returned by
// FPDF_GetSignatureObject().
// buffer - The address of a buffer that receives the contents.
// length - The size, in bytes, of |buffer|.
// Return value:
// Returns the number of bytes in the contents on success, 0 on error.
//
// For public-key signatures, |buffer| is either a DER-encoded PKCS#1 binary or
// a DER-encoded PKCS#7 binary. If |length| is less than the returned length, or
// |buffer| is NULL, |buffer| will not be modified.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDFSignatureObj_GetContents(FPDF_SIGNATURE signature,
void* buffer,
unsigned long length);
// Experimental API.
// Function: FPDFSignatureObj_GetByteRange
// Get the byte range of a signature object.
// Parameters:
// signature - Handle to the signature object. Returned by
// FPDF_GetSignatureObject().
// buffer - The address of a buffer that receives the
// byte range.
// length - The size, in ints, of |buffer|.
// Return value:
// Returns the number of ints in the byte range on
// success, 0 on error.
//
// |buffer| is an array of pairs of integers (starting byte offset,
// length in bytes) that describes the exact byte range for the digest
// calculation. If |length| is less than the returned length, or
// |buffer| is NULL, |buffer| will not be modified.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDFSignatureObj_GetByteRange(FPDF_SIGNATURE signature,
int* buffer,
unsigned long length);
// Experimental API.
// Function: FPDFSignatureObj_GetSubFilter
// Get the encoding of the value of a signature object.
// Parameters:
// signature - Handle to the signature object. Returned by
// FPDF_GetSignatureObject().
// buffer - The address of a buffer that receives the encoding.
// length - The size, in bytes, of |buffer|.
// Return value:
// Returns the number of bytes in the encoding name (including the
// trailing NUL character) on success, 0 on error.
//
// The |buffer| is always encoded in 7-bit ASCII. If |length| is less than the
// returned length, or |buffer| is NULL, |buffer| will not be modified.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDFSignatureObj_GetSubFilter(FPDF_SIGNATURE signature,
char* buffer,
unsigned long length);
// Experimental API.
// Function: FPDFSignatureObj_GetReason
// Get the reason (comment) of the signature object.
// Parameters:
// signature - Handle to the signature object. Returned by
// FPDF_GetSignatureObject().
// buffer - The address of a buffer that receives the reason.
// length - The size, in bytes, of |buffer|.
// Return value:
// Returns the number of bytes in the reason on success, 0 on error.
//
// Regardless of the platform, the |buffer| is always in UTF-16LE encoding. The
// string is terminated by a UTF16 NUL character. If |length| is less than the
// returned length, or |buffer| is NULL, |buffer| will not be modified.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDFSignatureObj_GetReason(FPDF_SIGNATURE signature,
void* buffer,
unsigned long length);
// Experimental API.
// Function: FPDFSignatureObj_GetTime
// Get the time of signing of a signature object.
// Parameters:
// signature - Handle to the signature object. Returned by
// FPDF_GetSignatureObject().
// buffer - The address of a buffer that receives the time.
// length - The size, in bytes, of |buffer|.
// Return value:
// Returns the number of bytes in the encoding name (including the
// trailing NUL character) on success, 0 on error.
//
// The |buffer| is always encoded in 7-bit ASCII. If |length| is less than the
// returned length, or |buffer| is NULL, |buffer| will not be modified.
//
// The format of time is expected to be D:YYYYMMDDHHMMSS+XX'YY', i.e. it's
// percision is seconds, with timezone information. This value should be used
// only when the time of signing is not available in the (PKCS#7 binary)
// signature.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDFSignatureObj_GetTime(FPDF_SIGNATURE signature,
char* buffer,
unsigned long length);
// Experimental API.
// Function: FPDFSignatureObj_GetDocMDPPermission
// Get the DocMDP permission of a signature object.
// Parameters:
// signature - Handle to the signature object. Returned by
// FPDF_GetSignatureObject().
// Return value:
// Returns the permission (1, 2 or 3) on success, 0 on error.
FPDF_EXPORT unsigned int FPDF_CALLCONV
FPDFSignatureObj_GetDocMDPPermission(FPDF_SIGNATURE signature);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // PUBLIC_FPDF_SIGNATURE_H_

View File

@ -1,4 +1,4 @@
// Copyright 2016 PDFium Authors. All rights reserved.
// Copyright 2016 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -7,6 +7,7 @@
#ifndef PUBLIC_FPDF_STRUCTTREE_H_
#define PUBLIC_FPDF_STRUCTTREE_H_
// clang-format off
// NOLINTNEXTLINE(build/include)
#include "fpdfview.h"
@ -17,28 +18,29 @@ extern "C" {
// Function: FPDF_StructTree_GetForPage
// Get the structure tree for a page.
// Parameters:
// page - Handle to the page. Returned by FPDF_LoadPage
// function.
// page - Handle to the page, as returned by FPDF_LoadPage().
// Return value:
// A handle to the structure tree or NULL on error.
// A handle to the structure tree or NULL on error. The caller owns the
// returned handle and must use FPDF_StructTree_Close() to release it.
// The handle should be released before |page| gets released.
FPDF_EXPORT FPDF_STRUCTTREE FPDF_CALLCONV
FPDF_StructTree_GetForPage(FPDF_PAGE page);
// Function: FPDF_StructTree_Close
// Release the resource allocate by FPDF_StructTree_GetForPage.
// Release a resource allocated by FPDF_StructTree_GetForPage().
// Parameters:
// struct_tree - Handle to the struct tree. Returned by
// FPDF_StructTree_LoadPage function.
// struct_tree - Handle to the structure tree, as returned by
// FPDF_StructTree_LoadPage().
// Return value:
// NULL
// None.
FPDF_EXPORT void FPDF_CALLCONV
FPDF_StructTree_Close(FPDF_STRUCTTREE struct_tree);
// Function: FPDF_StructTree_CountChildren
// Count the number of children for the structure tree.
// Parameters:
// struct_tree - Handle to the struct tree. Returned by
// FPDF_StructTree_LoadPage function.
// struct_tree - Handle to the structure tree, as returned by
// FPDF_StructTree_LoadPage().
// Return value:
// The number of children, or -1 on error.
FPDF_EXPORT int FPDF_CALLCONV
@ -47,11 +49,16 @@ FPDF_StructTree_CountChildren(FPDF_STRUCTTREE struct_tree);
// Function: FPDF_StructTree_GetChildAtIndex
// Get a child in the structure tree.
// Parameters:
// struct_tree - Handle to the struct tree. Returned by
// FPDF_StructTree_LoadPage function.
// struct_tree - Handle to the structure tree, as returned by
// FPDF_StructTree_LoadPage().
// index - The index for the child, 0-based.
// Return value:
// The child at the n-th index or NULL on error.
// The child at the n-th index or NULL on error. The caller does not
// own the handle. The handle remains valid as long as |struct_tree|
// remains valid.
// Comments:
// The |index| must be less than the FPDF_StructTree_CountChildren()
// return value.
FPDF_EXPORT FPDF_STRUCTELEMENT FPDF_CALLCONV
FPDF_StructTree_GetChildAtIndex(FPDF_STRUCTTREE struct_tree, int index);
@ -62,7 +69,7 @@ FPDF_StructTree_GetChildAtIndex(FPDF_STRUCTTREE struct_tree, int index);
// buffer - A buffer for output the alt text. May be NULL.
// buflen - The length of the buffer, in bytes. May be 0.
// Return value:
// The number of bytes in the title, including the terminating NUL
// The number of bytes in the alt text, including the terminating NUL
// character. The number of bytes is returned regardless of the
// |buffer| and |buflen| parameters.
// Comments:
@ -75,6 +82,91 @@ FPDF_StructElement_GetAltText(FPDF_STRUCTELEMENT struct_element,
void* buffer,
unsigned long buflen);
// Experimental API.
// Function: FPDF_StructElement_GetActualText
// Get the actual text for a given element.
// Parameters:
// struct_element - Handle to the struct element.
// buffer - A buffer for output the actual text. May be NULL.
// buflen - The length of the buffer, in bytes. May be 0.
// Return value:
// The number of bytes in the actual text, including the terminating
// NUL character. The number of bytes is returned regardless of the
// |buffer| and |buflen| parameters.
// Comments:
// Regardless of the platform, the |buffer| is always in UTF-16LE
// encoding. The string is terminated by a UTF16 NUL character. If
// |buflen| is less than the required length, or |buffer| is NULL,
// |buffer| will not be modified.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDF_StructElement_GetActualText(FPDF_STRUCTELEMENT struct_element,
void* buffer,
unsigned long buflen);
// Function: FPDF_StructElement_GetID
// Get the ID for a given element.
// Parameters:
// struct_element - Handle to the struct element.
// buffer - A buffer for output the ID string. May be NULL.
// buflen - The length of the buffer, in bytes. May be 0.
// Return value:
// The number of bytes in the ID string, including the terminating NUL
// character. The number of bytes is returned regardless of the
// |buffer| and |buflen| parameters.
// Comments:
// Regardless of the platform, the |buffer| is always in UTF-16LE
// encoding. The string is terminated by a UTF16 NUL character. If
// |buflen| is less than the required length, or |buffer| is NULL,
// |buffer| will not be modified.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDF_StructElement_GetID(FPDF_STRUCTELEMENT struct_element,
void* buffer,
unsigned long buflen);
// Experimental API.
// Function: FPDF_StructElement_GetLang
// Get the case-insensitive IETF BCP 47 language code for an element.
// Parameters:
// struct_element - Handle to the struct element.
// buffer - A buffer for output the lang string. May be NULL.
// buflen - The length of the buffer, in bytes. May be 0.
// Return value:
// The number of bytes in the ID string, including the terminating NUL
// character. The number of bytes is returned regardless of the
// |buffer| and |buflen| parameters.
// Comments:
// Regardless of the platform, the |buffer| is always in UTF-16LE
// encoding. The string is terminated by a UTF16 NUL character. If
// |buflen| is less than the required length, or |buffer| is NULL,
// |buffer| will not be modified.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDF_StructElement_GetLang(FPDF_STRUCTELEMENT struct_element,
void* buffer,
unsigned long buflen);
// Experimental API.
// Function: FPDF_StructElement_GetStringAttribute
// Get a struct element attribute of type "name" or "string".
// Parameters:
// struct_element - Handle to the struct element.
// attr_name - The name of the attribute to retrieve.
// buffer - A buffer for output. May be NULL.
// buflen - The length of the buffer, in bytes. May be 0.
// Return value:
// The number of bytes in the attribute value, including the
// terminating NUL character. The number of bytes is returned
// regardless of the |buffer| and |buflen| parameters.
// Comments:
// Regardless of the platform, the |buffer| is always in UTF-16LE
// encoding. The string is terminated by a UTF16 NUL character. If
// |buflen| is less than the required length, or |buffer| is NULL,
// |buffer| will not be modified.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDF_StructElement_GetStringAttribute(FPDF_STRUCTELEMENT struct_element,
FPDF_BYTESTRING attr_name,
void* buffer,
unsigned long buflen);
// Function: FPDF_StructElement_GetMarkedContentID
// Get the marked content ID for a given element.
// Parameters:
@ -82,6 +174,10 @@ FPDF_StructElement_GetAltText(FPDF_STRUCTELEMENT struct_element,
// Return value:
// The marked content ID of the element. If no ID exists, returns
// -1.
// Comments:
// FPDF_StructElement_GetMarkedContentIdAtIndex() may be able to
// extract more marked content IDs out of |struct_element|. This API
// may be deprecated in the future.
FPDF_EXPORT int FPDF_CALLCONV
FPDF_StructElement_GetMarkedContentID(FPDF_STRUCTELEMENT struct_element);
@ -89,8 +185,8 @@ FPDF_StructElement_GetMarkedContentID(FPDF_STRUCTELEMENT struct_element);
// Get the type (/S) for a given element.
// Parameters:
// struct_element - Handle to the struct element.
// buffer - A buffer for output. May be NULL.
// buflen - The length of the buffer, in bytes. May be 0.
// buffer - A buffer for output. May be NULL.
// buflen - The length of the buffer, in bytes. May be 0.
// Return value:
// The number of bytes in the type, including the terminating NUL
// character. The number of bytes is returned regardless of the
@ -105,6 +201,27 @@ FPDF_StructElement_GetType(FPDF_STRUCTELEMENT struct_element,
void* buffer,
unsigned long buflen);
// Experimental API.
// Function: FPDF_StructElement_GetObjType
// Get the object type (/Type) for a given element.
// Parameters:
// struct_element - Handle to the struct element.
// buffer - A buffer for output. May be NULL.
// buflen - The length of the buffer, in bytes. May be 0.
// Return value:
// The number of bytes in the object type, including the terminating
// NUL character. The number of bytes is returned regardless of the
// |buffer| and |buflen| parameters.
// Comments:
// Regardless of the platform, the |buffer| is always in UTF-16LE
// encoding. The string is terminated by a UTF16 NUL character. If
// |buflen| is less than the required length, or |buffer| is NULL,
// |buffer| will not be modified.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDF_StructElement_GetObjType(FPDF_STRUCTELEMENT struct_element,
void* buffer,
unsigned long buflen);
// Function: FPDF_StructElement_GetTitle
// Get the title (/T) for a given element.
// Parameters:
@ -137,17 +254,269 @@ FPDF_StructElement_CountChildren(FPDF_STRUCTELEMENT struct_element);
// Function: FPDF_StructElement_GetChildAtIndex
// Get a child in the structure element.
// Parameters:
// struct_tree - Handle to the struct element.
// index - The index for the child, 0-based.
// struct_element - Handle to the struct element.
// index - The index for the child, 0-based.
// Return value:
// The child at the n-th index or NULL on error.
// Comments:
// If the child exists but is not an element, then this function will
// return NULL. This will also return NULL for out of bounds indices.
// The |index| must be less than the FPDF_StructElement_CountChildren()
// return value.
FPDF_EXPORT FPDF_STRUCTELEMENT FPDF_CALLCONV
FPDF_StructElement_GetChildAtIndex(FPDF_STRUCTELEMENT struct_element,
int index);
// Experimental API.
// Function: FPDF_StructElement_GetChildMarkedContentID
// Get the child's content id
// Parameters:
// struct_element - Handle to the struct element.
// index - The index for the child, 0-based.
// Return value:
// The marked content ID of the child. If no ID exists, returns -1.
// Comments:
// If the child exists but is not a stream or object, then this
// function will return -1. This will also return -1 for out of bounds
// indices. Compared to FPDF_StructElement_GetMarkedContentIdAtIndex,
// it is scoped to the current page.
// The |index| must be less than the FPDF_StructElement_CountChildren()
// return value.
FPDF_EXPORT int FPDF_CALLCONV
FPDF_StructElement_GetChildMarkedContentID(FPDF_STRUCTELEMENT struct_element,
int index);
// Experimental API.
// Function: FPDF_StructElement_GetParent
// Get the parent of the structure element.
// Parameters:
// struct_element - Handle to the struct element.
// Return value:
// The parent structure element or NULL on error.
// Comments:
// If structure element is StructTreeRoot, then this function will
// return NULL.
FPDF_EXPORT FPDF_STRUCTELEMENT FPDF_CALLCONV
FPDF_StructElement_GetParent(FPDF_STRUCTELEMENT struct_element);
// Function: FPDF_StructElement_GetAttributeCount
// Count the number of attributes for the structure element.
// Parameters:
// struct_element - Handle to the struct element.
// Return value:
// The number of attributes, or -1 on error.
FPDF_EXPORT int FPDF_CALLCONV
FPDF_StructElement_GetAttributeCount(FPDF_STRUCTELEMENT struct_element);
// Experimental API.
// Function: FPDF_StructElement_GetAttributeAtIndex
// Get an attribute object in the structure element.
// Parameters:
// struct_element - Handle to the struct element.
// index - The index for the attribute object, 0-based.
// Return value:
// The attribute object at the n-th index or NULL on error.
// Comments:
// If the attribute object exists but is not a dict, then this
// function will return NULL. This will also return NULL for out of
// bounds indices. The caller does not own the handle. The handle
// remains valid as long as |struct_element| remains valid.
// The |index| must be less than the
// FPDF_StructElement_GetAttributeCount() return value.
FPDF_EXPORT FPDF_STRUCTELEMENT_ATTR FPDF_CALLCONV
FPDF_StructElement_GetAttributeAtIndex(FPDF_STRUCTELEMENT struct_element, int index);
// Experimental API.
// Function: FPDF_StructElement_Attr_GetCount
// Count the number of attributes in a structure element attribute map.
// Parameters:
// struct_attribute - Handle to the struct element attribute.
// Return value:
// The number of attributes, or -1 on error.
FPDF_EXPORT int FPDF_CALLCONV
FPDF_StructElement_Attr_GetCount(FPDF_STRUCTELEMENT_ATTR struct_attribute);
// Experimental API.
// Function: FPDF_StructElement_Attr_GetName
// Get the name of an attribute in a structure element attribute map.
// Parameters:
// struct_attribute - Handle to the struct element attribute.
// index - The index of attribute in the map.
// buffer - A buffer for output. May be NULL. This is only
// modified if |buflen| is longer than the length
// of the key. Optional, pass null to just
// retrieve the size of the buffer needed.
// buflen - The length of the buffer.
// out_buflen - A pointer to variable that will receive the
// minimum buffer size to contain the key. Not
// filled if FALSE is returned.
// Return value:
// TRUE if the operation was successful, FALSE otherwise.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDF_StructElement_Attr_GetName(FPDF_STRUCTELEMENT_ATTR struct_attribute,
int index,
void* buffer,
unsigned long buflen,
unsigned long* out_buflen);
// Experimental API.
// Function: FPDF_StructElement_Attr_GetValue
// Get a handle to a value for an attribute in a structure element
// attribute map.
// Parameters:
// struct_attribute - Handle to the struct element attribute.
// name - The attribute name.
// Return value:
// Returns a handle to the value associated with the input, if any.
// Returns NULL on failure. The caller does not own the handle.
// The handle remains valid as long as |struct_attribute| remains
// valid.
FPDF_EXPORT FPDF_STRUCTELEMENT_ATTR_VALUE FPDF_CALLCONV
FPDF_StructElement_Attr_GetValue(FPDF_STRUCTELEMENT_ATTR struct_attribute,
FPDF_BYTESTRING name);
// Experimental API.
// Function: FPDF_StructElement_Attr_GetType
// Get the type of an attribute in a structure element attribute map.
// Parameters:
// value - Handle to the value.
// Return value:
// Returns the type of the value, or FPDF_OBJECT_UNKNOWN in case of
// failure. Note that this will never return FPDF_OBJECT_REFERENCE, as
// references are always dereferenced.
FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV
FPDF_StructElement_Attr_GetType(FPDF_STRUCTELEMENT_ATTR_VALUE value);
// Experimental API.
// Function: FPDF_StructElement_Attr_GetBooleanValue
// Get the value of a boolean attribute in an attribute map as
// FPDF_BOOL. FPDF_StructElement_Attr_GetType() should have returned
// FPDF_OBJECT_BOOLEAN for this property.
// Parameters:
// value - Handle to the value.
// out_value - A pointer to variable that will receive the value. Not
// filled if false is returned.
// Return value:
// Returns TRUE if the attribute maps to a boolean value, FALSE
// otherwise.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDF_StructElement_Attr_GetBooleanValue(FPDF_STRUCTELEMENT_ATTR_VALUE value,
FPDF_BOOL* out_value);
// Experimental API.
// Function: FPDF_StructElement_Attr_GetNumberValue
// Get the value of a number attribute in an attribute map as float.
// FPDF_StructElement_Attr_GetType() should have returned
// FPDF_OBJECT_NUMBER for this property.
// Parameters:
// value - Handle to the value.
// out_value - A pointer to variable that will receive the value. Not
// filled if false is returned.
// Return value:
// Returns TRUE if the attribute maps to a number value, FALSE
// otherwise.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDF_StructElement_Attr_GetNumberValue(FPDF_STRUCTELEMENT_ATTR_VALUE value,
float* out_value);
// Experimental API.
// Function: FPDF_StructElement_Attr_GetStringValue
// Get the value of a string attribute in an attribute map as string.
// FPDF_StructElement_Attr_GetType() should have returned
// FPDF_OBJECT_STRING or FPDF_OBJECT_NAME for this property.
// Parameters:
// value - Handle to the value.
// buffer - A buffer for holding the returned key in UTF-16LE.
// This is only modified if |buflen| is longer than the
// length of the key. Optional, pass null to just
// retrieve the size of the buffer needed.
// buflen - The length of the buffer.
// out_buflen - A pointer to variable that will receive the minimum
// buffer size to contain the key. Not filled if FALSE is
// returned.
// Return value:
// Returns TRUE if the attribute maps to a string value, FALSE
// otherwise.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDF_StructElement_Attr_GetStringValue(FPDF_STRUCTELEMENT_ATTR_VALUE value,
void* buffer,
unsigned long buflen,
unsigned long* out_buflen);
// Experimental API.
// Function: FPDF_StructElement_Attr_GetBlobValue
// Get the value of a blob attribute in an attribute map as string.
// Parameters:
// value - Handle to the value.
// buffer - A buffer for holding the returned value. This is only
// modified if |buflen| is at least as long as the length
// of the value. Optional, pass null to just retrieve the
// size of the buffer needed.
// buflen - The length of the buffer.
// out_buflen - A pointer to variable that will receive the minimum
// buffer size to contain the key. Not filled if FALSE is
// returned.
// Return value:
// Returns TRUE if the attribute maps to a string value, FALSE
// otherwise.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDF_StructElement_Attr_GetBlobValue(FPDF_STRUCTELEMENT_ATTR_VALUE value,
void* buffer,
unsigned long buflen,
unsigned long* out_buflen);
// Experimental API.
// Function: FPDF_StructElement_Attr_CountChildren
// Count the number of children values in an attribute.
// Parameters:
// value - Handle to the value.
// Return value:
// The number of children, or -1 on error.
FPDF_EXPORT int FPDF_CALLCONV
FPDF_StructElement_Attr_CountChildren(FPDF_STRUCTELEMENT_ATTR_VALUE value);
// Experimental API.
// Function: FPDF_StructElement_Attr_GetChildAtIndex
// Get a child from an attribute.
// Parameters:
// value - Handle to the value.
// index - The index for the child, 0-based.
// Return value:
// The child at the n-th index or NULL on error.
// Comments:
// The |index| must be less than the
// FPDF_StructElement_Attr_CountChildren() return value.
FPDF_EXPORT FPDF_STRUCTELEMENT_ATTR_VALUE FPDF_CALLCONV
FPDF_StructElement_Attr_GetChildAtIndex(FPDF_STRUCTELEMENT_ATTR_VALUE value,
int index);
// Experimental API.
// Function: FPDF_StructElement_GetMarkedContentIdCount
// Get the count of marked content ids for a given element.
// Parameters:
// struct_element - Handle to the struct element.
// Return value:
// The count of marked content ids or -1 if none exists.
FPDF_EXPORT int FPDF_CALLCONV
FPDF_StructElement_GetMarkedContentIdCount(FPDF_STRUCTELEMENT struct_element);
// Experimental API.
// Function: FPDF_StructElement_GetMarkedContentIdAtIndex
// Get the marked content id at a given index for a given element.
// Parameters:
// struct_element - Handle to the struct element.
// index - The index of the marked content id, 0-based.
// Return value:
// The marked content ID of the element. If no ID exists, returns
// -1.
// Comments:
// The |index| must be less than the
// FPDF_StructElement_GetMarkedContentIdCount() return value.
// This will likely supersede FPDF_StructElement_GetMarkedContentID().
FPDF_EXPORT int FPDF_CALLCONV
FPDF_StructElement_GetMarkedContentIdAtIndex(FPDF_STRUCTELEMENT struct_element,
int index);
#ifdef __cplusplus
} // extern "C"
#endif

View File

@ -1,4 +1,4 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -7,10 +7,13 @@
#ifndef PUBLIC_FPDF_SYSFONTINFO_H_
#define PUBLIC_FPDF_SYSFONTINFO_H_
#include <stddef.h>
// clang-format off
// NOLINTNEXTLINE(build/include)
#include "fpdfview.h"
/* Character sets for the font */
// Character sets for the font
#define FXFONT_ANSI_CHARSET 0
#define FXFONT_DEFAULT_CHARSET 1
#define FXFONT_SYMBOL_CHARSET 2
@ -18,13 +21,20 @@
#define FXFONT_HANGEUL_CHARSET 129
#define FXFONT_GB2312_CHARSET 134
#define FXFONT_CHINESEBIG5_CHARSET 136
#define FXFONT_GREEK_CHARSET 161
#define FXFONT_VIETNAMESE_CHARSET 163
#define FXFONT_HEBREW_CHARSET 177
#define FXFONT_ARABIC_CHARSET 178
#define FXFONT_CYRILLIC_CHARSET 204
#define FXFONT_THAI_CHARSET 222
#define FXFONT_EASTERNEUROPEAN_CHARSET 238
/* Font pitch and family flags */
// Font pitch and family flags
#define FXFONT_FF_FIXEDPITCH (1 << 0)
#define FXFONT_FF_ROMAN (1 << 4)
#define FXFONT_FF_SCRIPT (4 << 4)
/* Typical weight values */
// Typical weight values
#define FXFONT_FW_NORMAL 400
#define FXFONT_FW_BOLD 700
@ -33,84 +43,74 @@
extern "C" {
#endif
/**
* Interface: FPDF_SYSFONTINFO
* Interface for getting system font information and font mapping
*/
// Interface: FPDF_SYSFONTINFO
// Interface for getting system font information and font mapping
typedef struct _FPDF_SYSFONTINFO {
/**
* Version number of the interface. Currently must be 1.
**/
// Version number of the interface. Currently must be 1.
int version;
/**
* Method: Release
* Give implementation a chance to release any data after the
* interface is no longer used
* Interface Version:
* 1
* Implementation Required:
* No
* Comments:
* Called by Foxit SDK during the final cleanup process.
* Parameters:
* pThis - Pointer to the interface structure itself
* Return Value:
* None
*/
// Method: Release
// Give implementation a chance to release any data after the
// interface is no longer used.
// Interface Version:
// 1
// Implementation Required:
// No
// Parameters:
// pThis - Pointer to the interface structure itself
// Return Value:
// None
// Comments:
// Called by PDFium during the final cleanup process.
void (*Release)(struct _FPDF_SYSFONTINFO* pThis);
/**
* Method: EnumFonts
* Enumerate all fonts installed on the system
* Interface Version:
* 1
* Implementation Required:
* No
* Comments:
* Implementation should call FPDF_AddIntalledFont() function for
* each font found.
* Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK.
* Parameters:
* pThis - Pointer to the interface structure itself
* pMapper - An opaque pointer to internal font mapper, used
* when calling FPDF_AddInstalledFont
* Return Value:
* None
*/
// Method: EnumFonts
// Enumerate all fonts installed on the system
// Interface Version:
// 1
// Implementation Required:
// No
// Parameters:
// pThis - Pointer to the interface structure itself
// pMapper - An opaque pointer to internal font mapper, used
// when calling FPDF_AddInstalledFont().
// Return Value:
// None
// Comments:
// Implementations should call FPDF_AddInstalledFont() function for
// each font found. Only TrueType/OpenType and Type1 fonts are
// accepted by PDFium.
void (*EnumFonts)(struct _FPDF_SYSFONTINFO* pThis, void* pMapper);
/**
* Method: MapFont
* Use the system font mapper to get a font handle from requested
*parameters
* Interface Version:
* 1
* Implementation Required:
* Yes only if GetFont method is not implemented.
* Comments:
* If the system supports native font mapper (like Windows),
*implementation can implement this method to get a font handle.
* Otherwise, Foxit SDK will do the mapping and then call GetFont
*method.
* Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK.
* Parameters:
* pThis - Pointer to the interface structure itself
* weight - Weight of the requested font. 400 is normal and
*700 is bold.
* bItalic - Italic option of the requested font, TRUE or
*FALSE.
* charset - Character set identifier for the requested font.
*See above defined constants.
* pitch_family - A combination of flags. See above defined
*constants.
* face - Typeface name. Currently use system local encoding
*only.
* bExact - Obsolete: this parameter is now ignored.
* Return Value:
* An opaque pointer for font handle, or NULL if system mapping is
*not supported.
**/
// Method: MapFont
// Use the system font mapper to get a font handle from requested
// parameters.
// Interface Version:
// 1
// Implementation Required:
// Required if GetFont method is not implemented.
// Parameters:
// pThis - Pointer to the interface structure itself
// weight - Weight of the requested font. 400 is normal and
// 700 is bold.
// bItalic - Italic option of the requested font, TRUE or
// FALSE.
// charset - Character set identifier for the requested font.
// See above defined constants.
// pitch_family - A combination of flags. See above defined
// constants.
// face - Typeface name. Currently use system local encoding
// only.
// bExact - Obsolete: this parameter is now ignored.
// Return Value:
// An opaque pointer for font handle, or NULL if system mapping is
// not supported.
// Comments:
// If the system supports native font mapper (like Windows),
// implementation can implement this method to get a font handle.
// Otherwise, PDFium will do the mapping and then call GetFont
// method. Only TrueType/OpenType and Type1 fonts are accepted
// by PDFium.
void* (*MapFont)(struct _FPDF_SYSFONTINFO* pThis,
int weight,
FPDF_BOOL bItalic,
@ -119,192 +119,194 @@ typedef struct _FPDF_SYSFONTINFO {
const char* face,
FPDF_BOOL* bExact);
/**
* Method: GetFont
* Get a handle to a particular font by its internal ID
* Interface Version:
* 1
* Implementation Required:
* Yes only if MapFont method is not implemented.
* Comments:
* If the system mapping not supported, Foxit SDK will do the font
*mapping and use this method to get a font handle.
* Parameters:
* pThis - Pointer to the interface structure itself
* face - Typeface name. Currently use system local encoding
*only.
* Return Value:
* An opaque pointer for font handle.
**/
// Method: GetFont
// Get a handle to a particular font by its internal ID
// Interface Version:
// 1
// Implementation Required:
// Required if MapFont method is not implemented.
// Return Value:
// An opaque pointer for font handle.
// Parameters:
// pThis - Pointer to the interface structure itself
// face - Typeface name in system local encoding.
// Comments:
// If the system mapping not supported, PDFium will do the font
// mapping and use this method to get a font handle.
void* (*GetFont)(struct _FPDF_SYSFONTINFO* pThis, const char* face);
/**
* Method: GetFontData
* Get font data from a font
* Interface Version:
* 1
* Implementation Required:
* Yes
* Comments:
* Can read either full font file, or a particular TrueType/OpenType
*table
* Parameters:
* pThis - Pointer to the interface structure itself
* hFont - Font handle returned by MapFont or GetFont method
* table - TrueType/OpenType table identifier (refer to
*TrueType specification).
* 0 for the whole font file.
* buffer - The buffer receiving the font data. Can be NULL if
*not provided
* buf_size - Buffer size, can be zero if not provided
* Return Value:
* Number of bytes needed, if buffer not provided or not large
*enough,
* or number of bytes written into buffer otherwise.
**/
// Method: GetFontData
// Get font data from a font
// Interface Version:
// 1
// Implementation Required:
// Yes
// Parameters:
// pThis - Pointer to the interface structure itself
// hFont - Font handle returned by MapFont or GetFont method
// table - TrueType/OpenType table identifier (refer to
// TrueType specification), or 0 for the whole file.
// buffer - The buffer receiving the font data. Can be NULL if
// not provided.
// buf_size - Buffer size, can be zero if not provided.
// Return Value:
// Number of bytes needed, if buffer not provided or not large
// enough, or number of bytes written into buffer otherwise.
// Comments:
// Can read either the full font file, or a particular
// TrueType/OpenType table.
unsigned long (*GetFontData)(struct _FPDF_SYSFONTINFO* pThis,
void* hFont,
unsigned int table,
unsigned char* buffer,
unsigned long buf_size);
/**
* Method: GetFaceName
* Get face name from a font handle
* Interface Version:
* 1
* Implementation Required:
* No
* Parameters:
* pThis - Pointer to the interface structure itself
* hFont - Font handle returned by MapFont or GetFont method
* buffer - The buffer receiving the face name. Can be NULL if
*not provided
* buf_size - Buffer size, can be zero if not provided
* Return Value:
* Number of bytes needed, if buffer not provided or not large
*enough,
* or number of bytes written into buffer otherwise.
**/
// Method: GetFaceName
// Get face name from a font handle
// Interface Version:
// 1
// Implementation Required:
// No
// Parameters:
// pThis - Pointer to the interface structure itself
// hFont - Font handle returned by MapFont or GetFont method
// buffer - The buffer receiving the face name. Can be NULL if
// not provided
// buf_size - Buffer size, can be zero if not provided
// Return Value:
// Number of bytes needed, if buffer not provided or not large
// enough, or number of bytes written into buffer otherwise.
unsigned long (*GetFaceName)(struct _FPDF_SYSFONTINFO* pThis,
void* hFont,
char* buffer,
unsigned long buf_size);
/**
* Method: GetFontCharset
* Get character set information for a font handle
* Interface Version:
* 1
* Implementation Required:
* No
* Parameters:
* pThis - Pointer to the interface structure itself
* hFont - Font handle returned by MapFont or GetFont method
* Return Value:
* Character set identifier. See defined constants above.
**/
// Method: GetFontCharset
// Get character set information for a font handle
// Interface Version:
// 1
// Implementation Required:
// No
// Parameters:
// pThis - Pointer to the interface structure itself
// hFont - Font handle returned by MapFont or GetFont method
// Return Value:
// Character set identifier. See defined constants above.
int (*GetFontCharset)(struct _FPDF_SYSFONTINFO* pThis, void* hFont);
/**
* Method: DeleteFont
* Delete a font handle
* Interface Version:
* 1
* Implementation Required:
* Yes
* Parameters:
* pThis - Pointer to the interface structure itself
* hFont - Font handle returned by MapFont or GetFont method
* Return Value:
* None
**/
// Method: DeleteFont
// Delete a font handle
// Interface Version:
// 1
// Implementation Required:
// Yes
// Parameters:
// pThis - Pointer to the interface structure itself
// hFont - Font handle returned by MapFont or GetFont method
// Return Value:
// None
void (*DeleteFont)(struct _FPDF_SYSFONTINFO* pThis, void* hFont);
} FPDF_SYSFONTINFO;
/**
* Struct: FPDF_CharsetFontMap
* Provides the name of a font to use for a given charset value.
**/
// Struct: FPDF_CharsetFontMap
// Provides the name of a font to use for a given charset value.
typedef struct FPDF_CharsetFontMap_ {
int charset; // Character Set Enum value, see FXFONT_*_CHARSET above.
const char* fontname; // Name of default font to use with that charset.
} FPDF_CharsetFontMap;
/**
* Function: FPDF_GetDefaultTTFMap
* Returns a pointer to the default character set to TT Font name map. The
* map is an array of FPDF_CharsetFontMap structs, with its end indicated
* by a { -1, NULL } entry.
* Parameters:
* None.
* Return Value:
* Pointer to the Charset Font Map.
**/
// Function: FPDF_GetDefaultTTFMap
// Returns a pointer to the default character set to TT Font name map. The
// map is an array of FPDF_CharsetFontMap structs, with its end indicated
// by a { -1, NULL } entry.
// Parameters:
// None.
// Return Value:
// Pointer to the Charset Font Map.
// Note:
// Once FPDF_GetDefaultTTFMapCount() and FPDF_GetDefaultTTFMapEntry() are no
// longer experimental, this API will be marked as deprecated.
// See https://crbug.com/348468114
FPDF_EXPORT const FPDF_CharsetFontMap* FPDF_CALLCONV FPDF_GetDefaultTTFMap();
/**
* Function: FPDF_AddInstalledFont
* Add a system font to the list in Foxit SDK.
* Comments:
* This function is only called during the system font list building
*process.
* Parameters:
* mapper - Opaque pointer to Foxit font mapper
* face - The font face name
* charset - Font character set. See above defined constants.
* Return Value:
* None.
**/
// Experimental API.
//
// Function: FPDF_GetDefaultTTFMapCount
// Returns the number of entries in the default character set to TT Font name
// map.
// Parameters:
// None.
// Return Value:
// The number of entries in the map.
FPDF_EXPORT size_t FPDF_CALLCONV FPDF_GetDefaultTTFMapCount();
// Experimental API.
//
// Function: FPDF_GetDefaultTTFMapEntry
// Returns an entry in the default character set to TT Font name map.
// Parameters:
// index - The index to the entry in the map to retrieve.
// Return Value:
// A pointer to the entry, if it is in the map, or NULL if the index is out
// of bounds.
FPDF_EXPORT const FPDF_CharsetFontMap* FPDF_CALLCONV
FPDF_GetDefaultTTFMapEntry(size_t index);
// Function: FPDF_AddInstalledFont
// Add a system font to the list in PDFium.
// Comments:
// This function is only called during the system font list building
// process.
// Parameters:
// mapper - Opaque pointer to Foxit font mapper
// face - The font face name
// charset - Font character set. See above defined constants.
// Return Value:
// None.
FPDF_EXPORT void FPDF_CALLCONV FPDF_AddInstalledFont(void* mapper,
const char* face,
int charset);
/**
* Function: FPDF_SetSystemFontInfo
* Set the system font info interface into Foxit SDK
* Comments:
* Platform support implementation should implement required methods of
*FFDF_SYSFONTINFO interface,
* then call this function during SDK initialization process.
* Parameters:
* pFontInfo - Pointer to a FPDF_SYSFONTINFO structure
* Return Value:
* None
**/
// Function: FPDF_SetSystemFontInfo
// Set the system font info interface into PDFium
// Parameters:
// pFontInfo - Pointer to a FPDF_SYSFONTINFO structure
// Return Value:
// None
// Comments:
// Platform support implementation should implement required methods of
// FFDF_SYSFONTINFO interface, then call this function during PDFium
// initialization process.
//
// Call this with NULL to tell PDFium to stop using a previously set
// |FPDF_SYSFONTINFO|.
FPDF_EXPORT void FPDF_CALLCONV
FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfo);
/**
* Function: FPDF_GetDefaultSystemFontInfo
* Get default system font info interface for current platform
* 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_FreeDefaultSystemFontInfo to free the
*returned pointer.
**/
// Function: FPDF_GetDefaultSystemFontInfo
// Get default system font info interface for current platform
// Parameters:
// None
// Return Value:
// Pointer to a FPDF_SYSFONTINFO structure describing the default
// interface, or NULL if the platform doesn't have a default interface.
// Application should call FPDF_FreeDefaultSystemFontInfo to free the
// returned pointer.
// Comments:
// For some platforms, PDFium implements a default version of system
// font info interface. The default implementation can be passed to
// FPDF_SetSystemFontInfo().
FPDF_EXPORT FPDF_SYSFONTINFO* FPDF_CALLCONV FPDF_GetDefaultSystemFontInfo();
/**
* Function: FPDF_FreeDefaultSystemFontInfo
* Free a default system font info interface
* Comments:
* This function should be called on the output from
*FPDF_SetSystemFontInfo once it is no longer needed by the client.
* Parameters:
* pFontInfo - Pointer to a FPDF_SYSFONTINFO structure
* Return Value:
* None
**/
// Function: FPDF_FreeDefaultSystemFontInfo
// Free a default system font info interface
// Parameters:
// pFontInfo - Pointer to a FPDF_SYSFONTINFO structure
// Return Value:
// None
// Comments:
// This function should be called on the output from
// FPDF_GetDefaultSystemFontInfo() once it is no longer needed.
FPDF_EXPORT void FPDF_CALLCONV
FPDF_FreeDefaultSystemFontInfo(FPDF_SYSFONTINFO* pFontInfo);

View File

@ -1,4 +1,4 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -7,6 +7,7 @@
#ifndef PUBLIC_FPDF_TEXT_H_
#define PUBLIC_FPDF_TEXT_H_
// clang-format off
// NOLINTNEXTLINE(build/include)
#include "fpdfview.h"
@ -19,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.
@ -34,7 +35,7 @@ FPDF_EXPORT FPDF_TEXTPAGE FPDF_CALLCONV FPDFText_LoadPage(FPDF_PAGE page);
// structure.
// Parameters:
// text_page - Handle to a text page information structure.
// Returned by FPDFText_LoadPage function.
// Returned by FPDFText_LoadPage function.
// Return Value:
// None.
//
@ -44,7 +45,7 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFText_ClosePage(FPDF_TEXTPAGE text_page);
// 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
@ -62,7 +63,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_CountChars(FPDF_TEXTPAGE text_page);
// 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.
@ -73,16 +74,76 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_CountChars(FPDF_TEXTPAGE text_page);
FPDF_EXPORT unsigned int FPDF_CALLCONV
FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, int index);
// Experimental API.
// Function: FPDFText_GetTextObject
// Get the FPDF_PAGEOBJECT associated with a given character.
// Parameters:
// text_page - Handle to a text page information structure.
// Returned by FPDFText_LoadPage function.
// index - Zero-based index of the character.
// Return value:
// The associated text object for the character at |index|, or NULL on
// error. The returned text object, if non-null, is of type
// |FPDF_PAGEOBJ_TEXT|. The caller does not own the returned object.
//
FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
FPDFText_GetTextObject(FPDF_TEXTPAGE text_page, int index);
// Experimental API.
// Function: FPDFText_IsGenerated
// Get if a character in a page is generated by PDFium.
// Parameters:
// text_page - Handle to a text page information structure.
// Returned by FPDFText_LoadPage function.
// index - Zero-based index of the character.
// Return value:
// 1 if the character is generated by PDFium.
// 0 if the character is not generated by PDFium.
// -1 if there was an error.
//
FPDF_EXPORT int FPDF_CALLCONV
FPDFText_IsGenerated(FPDF_TEXTPAGE text_page, int index);
// Experimental API.
// Function: FPDFText_IsHyphen
// Get if a character in a page is a hyphen.
// Parameters:
// text_page - Handle to a text page information structure.
// Returned by FPDFText_LoadPage function.
// index - Zero-based index of the character.
// Return value:
// 1 if the character is a hyphen.
// 0 if the character is not a hyphen.
// -1 if there was an error.
//
FPDF_EXPORT int FPDF_CALLCONV
FPDFText_IsHyphen(FPDF_TEXTPAGE text_page, int index);
// Experimental API.
// Function: FPDFText_HasUnicodeMapError
// Get if a character in a page has an invalid unicode mapping.
// Parameters:
// text_page - Handle to a text page information structure.
// Returned by FPDFText_LoadPage function.
// index - Zero-based index of the character.
// Return value:
// 1 if the character has an invalid unicode mapping.
// 0 if the character has no known unicode mapping issues.
// -1 if there was an error.
//
FPDF_EXPORT int FPDF_CALLCONV
FPDFText_HasUnicodeMapError(FPDF_TEXTPAGE text_page, int index);
// Function: FPDFText_GetFontSize
// Get the font size of a particular character.
// Parameters:
// text_page - Handle to a text page information structure.
// Returned by FPDFText_LoadPage function.
// Returned by FPDFText_LoadPage function.
// index - Zero-based index of the character.
// Return value:
// The font size of the particular character, measured in points (about
// 1/72 inch).
// This is the typographic size of the font (so called "em size").
// 1/72 inch). This is the typographic size of the font (so called
// "em size").
//
FPDF_EXPORT double FPDF_CALLCONV FPDFText_GetFontSize(FPDF_TEXTPAGE text_page,
int index);
@ -92,19 +153,20 @@ FPDF_EXPORT double FPDF_CALLCONV FPDFText_GetFontSize(FPDF_TEXTPAGE text_page,
// 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.
// 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.
// 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,
@ -112,20 +174,104 @@ FPDFText_GetFontInfo(FPDF_TEXTPAGE text_page,
unsigned long buflen,
int* flags);
// Experimental API.
// Function: FPDFText_GetFontWeight
// Get the font weight of a particular character.
// Parameters:
// text_page - Handle to a text page information structure.
// Returned by FPDFText_LoadPage function.
// index - Zero-based index of the character.
// Return value:
// On success, return the font weight of the particular character. If
// |text_page| is invalid, if |index| is out of bounds, or if the
// character's text object is undefined, return -1.
//
FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetFontWeight(FPDF_TEXTPAGE text_page,
int index);
// Experimental API.
// Function: FPDFText_GetFillColor
// Get the fill color of a particular character.
// Parameters:
// text_page - Handle to a text page information structure.
// Returned by FPDFText_LoadPage function.
// index - Zero-based index of the character.
// R - Pointer to an unsigned int number receiving the
// red value of the fill color.
// G - Pointer to an unsigned int number receiving the
// green value of the fill color.
// B - Pointer to an unsigned int number receiving the
// blue value of the fill color.
// A - Pointer to an unsigned int number receiving the
// alpha value of the fill color.
// Return value:
// Whether the call succeeded. If false, |R|, |G|, |B| and |A| are
// unchanged.
//
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFText_GetFillColor(FPDF_TEXTPAGE text_page,
int index,
unsigned int* R,
unsigned int* G,
unsigned int* B,
unsigned int* A);
// Experimental API.
// Function: FPDFText_GetStrokeColor
// Get the stroke color of a particular character.
// Parameters:
// text_page - Handle to a text page information structure.
// Returned by FPDFText_LoadPage function.
// index - Zero-based index of the character.
// R - Pointer to an unsigned int number receiving the
// red value of the stroke color.
// G - Pointer to an unsigned int number receiving the
// green value of the stroke color.
// B - Pointer to an unsigned int number receiving the
// blue value of the stroke color.
// A - Pointer to an unsigned int number receiving the
// alpha value of the stroke color.
// Return value:
// Whether the call succeeded. If false, |R|, |G|, |B| and |A| are
// unchanged.
//
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFText_GetStrokeColor(FPDF_TEXTPAGE text_page,
int index,
unsigned int* R,
unsigned int* G,
unsigned int* B,
unsigned int* A);
// Experimental API.
// Function: FPDFText_GetCharAngle
// Get character rotation angle.
// Parameters:
// text_page - Handle to a text page information structure.
// Returned by FPDFText_LoadPage function.
// index - Zero-based index of the character.
// Return Value:
// On success, return the angle value in radian. Value will always be
// greater or equal to 0. If |text_page| is invalid, or if |index| is
// out of bounds, then return -1.
//
FPDF_EXPORT float FPDF_CALLCONV FPDFText_GetCharAngle(FPDF_TEXTPAGE text_page,
int index);
// Function: FPDFText_GetCharBox
// Get bounding box of a particular character.
// Parameters:
// text_page - Handle to a text page information structure.
// Returned by FPDFText_LoadPage function.
// 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:
// On success, return TRUE and fill in |left|, |right|, |bottom|, and
// |top|. If |text_page| is invalid, or if |index| is out of bounds,
@ -140,16 +286,54 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetCharBox(FPDF_TEXTPAGE text_page,
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.
// 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.
// the character origin.
// y - Pointer to a double number receiving y coordinate of
// the character origin.
// the character origin.
// Return Value:
// Whether the call succeeded. If false, x and y are unchanged.
// Comments:
@ -166,18 +350,17 @@ FPDFText_GetCharOrigin(FPDF_TEXTPAGE text_page,
// 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.
//
FPDF_EXPORT int FPDF_CALLCONV
FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page,
@ -190,18 +373,21 @@ FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page,
// Extract unicode text string from the page.
// Parameters:
// text_page - Handle to a text page information structure.
// Returned by FPDFText_LoadPage function.
// Returned by FPDFText_LoadPage function.
// start_index - Index for the start characters.
// count - Number of characters to be extracted.
// count - Number of UCS-2 values to be extracted.
// result - A buffer (allocated by application) receiving the
// extracted unicodes.
// The size of the buffer must be able to hold the
// number of characters plus a terminator.
// extracted UCS-2 values. The buffer must be able to
// hold `count` UCS-2 values plus a terminator.
// Return Value:
// Number of characters written into the result buffer, including the
// trailing terminator.
// Comments:
// This function ignores characters without unicode information.
// This function ignores characters without UCS-2 representations.
// It considers all characters on the page, even those that are not
// visible when the page has a cropbox. To filter out the characters
// outside of the cropbox, use FPDF_GetPageBoundingBox() and
// FPDFText_GetCharBox().
//
FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetText(FPDF_TEXTPAGE text_page,
int start_index,
@ -209,22 +395,22 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetText(FPDF_TEXTPAGE text_page,
unsigned short* result);
// Function: FPDFText_CountRects
// Count number of rectangular areas occupied by a segment of texts.
// Counts number of rectangular areas occupied by a segment of text,
// and caches the result for subsequent FPDFText_GetRect() calls.
// Parameters:
// text_page - Handle to a text page information structure.
// Returned by FPDFText_LoadPage function.
// start_index - Index for the start characters.
// count - Number of characters.
// Returned by FPDFText_LoadPage function.
// start_index - Index for the start character.
// count - Number of characters, or -1 for all remaining.
// Return value:
// Number of rectangles. Zero for error.
// Number of rectangles, 0 if text_page is null, or -1 on bad
// start_index.
// Comments:
// This function, along with FPDFText_GetRect can be used by
// applications to detect the position
// on the page for a text segment, so proper areas can be highlighted
// or something.
// FPDFTEXT will automatically merge small character boxes into bigger
// one if those characters
// are on the same line and use same font settings.
// applications to detect the position on the page for a text segment,
// so proper areas can be highlighted. The FPDFText_* functions will
// automatically merge small character boxes into bigger one if those
// characters are on the same line and use same font settings.
//
FPDF_EXPORT int FPDF_CALLCONV FPDFText_CountRects(FPDF_TEXTPAGE text_page,
int start_index,
@ -235,16 +421,16 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_CountRects(FPDF_TEXTPAGE text_page,
// 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:
// On success, return TRUE and fill in |left|, |top|, |right|, and
// |bottom|. If |text_page| is invalid then return FALSE, and the out
@ -263,27 +449,25 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetRect(FPDF_TEXTPAGE text_page,
// Extract unicode text within a rectangular boundary on the page.
// Parameters:
// text_page - Handle to a text page information structure.
// Returned by FPDFText_LoadPage function.
// Returned by FPDFText_LoadPage function.
// left - Left boundary.
// top - Top boundary.
// right - Right boundary.
// bottom - Bottom boundary.
// buffer - A unicode buffer.
// buflen - Number of characters (not bytes) for the buffer,
// excluding an additional terminator.
// buffer - Caller-allocated buffer to receive UTF-16 values.
// buflen - Number of UTF-16 values (not bytes) that `buffer`
// is capable of holding.
// Return Value:
// If buffer is NULL or buflen is zero, return number of characters
// (not bytes) of text present within
// the rectangle, excluding a terminating NUL. Generally you should
// pass a buffer at least one larger
// than this if you want a terminating NUL, which will be provided if
// space is available.
// Otherwise, return number of characters copied into the buffer,
// including the terminating NUL
// when space for it is available.
// If buffer is NULL or buflen is zero, return number of UTF-16
// values (not bytes) of text present within the rectangle, excluding
// a terminating NUL. Generally you should pass a buffer at least one
// larger than this if you want a terminating NUL, which will be
// provided if space is available. Otherwise, return number of UTF-16
// values copied into the buffer, including the terminating NUL when
// space for it is available.
// Comment:
// If the buffer is too small, as much text as will fit is copied into
// it.
// it. May return a split surrogate in that case.
//
FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page,
double left,
@ -306,7 +490,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page,
// 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.
@ -324,7 +508,7 @@ FPDFText_FindStart(FPDF_TEXTPAGE text_page,
// 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.
//
@ -334,7 +518,7 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_FindNext(FPDF_SCHHANDLE handle);
// 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.
//
@ -344,7 +528,7 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_FindPrev(FPDF_SCHHANDLE handle);
// 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.
//
@ -354,7 +538,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetSchResultIndex(FPDF_SCHHANDLE handle);
// 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.
//
@ -364,7 +548,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetSchCount(FPDF_SCHHANDLE handle);
// Release a search context.
// Parameters:
// handle - A search context handle returned by
// FPDFText_FindStart.
// FPDFText_FindStart.
// Return Value:
// None.
//
@ -374,22 +558,18 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFText_FindClose(FPDF_SCHHANDLE handle);
// 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.
//
@ -411,16 +591,16 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFLink_CountWebLinks(FPDF_PAGELINK link_page);
// link_page - Handle returned by FPDFLink_LoadWebLinks.
// link_index - Zero-based index for the link.
// buffer - A unicode buffer for the result.
// buflen - Number of characters (not bytes) for the buffer,
// including an additional terminator.
// buflen - Number of 16-bit code units (not bytes) for the
// buffer, including an additional terminator.
// Return Value:
// If |buffer| is NULL or |buflen| is zero, return the number of
// characters (not bytes) needed to buffer the result (an additional
// 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 characters
// actually copied into the buffer (the additional terminator is also
// included in this count).
// 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.
//
@ -469,6 +649,26 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFLink_GetRect(FPDF_PAGELINK link_page,
double* right,
double* bottom);
// Experimental API.
// Function: FPDFLink_GetTextRange
// Fetch the start char index and char count for a link.
// Parameters:
// link_page - Handle returned by FPDFLink_LoadWebLinks.
// link_index - Zero-based index for the link.
// start_char_index - pointer to int receiving the start char index
// char_count - pointer to int receiving the char count
// Return Value:
// On success, return TRUE and fill in |start_char_index| and
// |char_count|. if |link_page| is invalid or if |link_index| does
// not correspond to a valid link, then return FALSE and the out
// parameters remain unmodified.
//
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFLink_GetTextRange(FPDF_PAGELINK link_page,
int link_index,
int* start_char_index,
int* char_count);
// Function: FPDFLink_CloseWebLinks
// Release resources used by weblink feature.
// Parameters:

View File

@ -0,0 +1,59 @@
// Copyright 2019 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PUBLIC_FPDF_THUMBNAIL_H_
#define PUBLIC_FPDF_THUMBNAIL_H_
#include <stdint.h>
// NOLINTNEXTLINE(build/include)
#include "fpdfview.h"
#ifdef __cplusplus
extern "C" {
#endif
// Experimental API.
// Gets the decoded data from the thumbnail of |page| if it exists.
// This only modifies |buffer| if |buflen| less than or equal to the
// size of the decoded data. Returns the size of the decoded
// data or 0 if thumbnail DNE. Optional, pass null to just retrieve
// the size of the buffer needed.
//
// page - handle to a page.
// buffer - buffer for holding the decoded image data.
// buflen - length of the buffer in bytes.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDFPage_GetDecodedThumbnailData(FPDF_PAGE page,
void* buffer,
unsigned long buflen);
// Experimental API.
// Gets the raw data from the thumbnail of |page| if it exists.
// This only modifies |buffer| if |buflen| is less than or equal to
// the size of the raw data. Returns the size of the raw data or 0
// if thumbnail DNE. Optional, pass null to just retrieve the size
// of the buffer needed.
//
// page - handle to a page.
// buffer - buffer for holding the raw image data.
// buflen - length of the buffer in bytes.
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDFPage_GetRawThumbnailData(FPDF_PAGE page,
void* buffer,
unsigned long buflen);
// Experimental API.
// Returns the thumbnail of |page| as a FPDF_BITMAP. Returns a nullptr
// if unable to access the thumbnail's stream.
//
// page - handle to a page.
FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV
FPDFPage_GetThumbnailAsBitmap(FPDF_PAGE page);
#ifdef __cplusplus
}
#endif
#endif // PUBLIC_FPDF_THUMBNAIL_H_

View File

@ -1,4 +1,4 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -14,203 +14,179 @@
extern "C" {
#endif
/**
* Set "MediaBox" entry to the page dictionary.
*
* page - Handle to a page.
* left - The left of the rectangle.
* bottom - The bottom of the rectangle.
* right - The right of the rectangle.
* top - The top of the rectangle.
*/
// 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.
*/
// 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.
*/
// 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.
*/
// 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.
*/
// 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.
*/
// 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.
*/
// 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.
*/
// Get "BleedBox" entry from the page dictionary.
//
// page - Handle to a page.
// left - Pointer to a float value receiving the left of the rectangle.
// bottom - Pointer to a float value receiving the bottom of the rectangle.
// right - Pointer to a float value receiving the right of the rectangle.
// top - Pointer to a float value receiving the top of the rectangle.
//
// On success, return true and write to the out parameters. Otherwise return
// false and leave the out parameters unmodified.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetBleedBox(FPDF_PAGE page,
float* left,
float* bottom,
float* right,
float* top);
/**
* Get "TrimBox" entry from the page dictionary.
*
* page - Handle to a page.
* left - Pointer to a float value receiving the left of the rectangle.
* bottom - Pointer to a float value receiving the bottom of the rectangle.
* right - Pointer to a float value receiving the right of the rectangle.
* top - Pointer to a float value receiving the top of the rectangle.
*
* On success, return true and write to the out parameters. Otherwise return
* false and leave the out parameters unmodified.
*/
// Get "TrimBox" entry from the page dictionary.
//
// page - Handle to a page.
// left - Pointer to a float value receiving the left of the rectangle.
// bottom - Pointer to a float value receiving the bottom of the rectangle.
// right - Pointer to a float value receiving the right of the rectangle.
// top - Pointer to a float value receiving the top of the rectangle.
//
// On success, return true and write to the out parameters. Otherwise return
// false and leave the out parameters unmodified.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetTrimBox(FPDF_PAGE page,
float* left,
float* bottom,
float* right,
float* top);
/**
* Get "ArtBox" entry from the page dictionary.
*
* page - Handle to a page.
* left - Pointer to a float value receiving the left of the rectangle.
* bottom - Pointer to a float value receiving the bottom of the rectangle.
* right - Pointer to a float value receiving the right of the rectangle.
* top - Pointer to a float value receiving the top of the rectangle.
*
* On success, return true and write to the out parameters. Otherwise return
* false and leave the out parameters unmodified.
*/
// Get "ArtBox" entry from the page dictionary.
//
// page - Handle to a page.
// left - Pointer to a float value receiving the left of the rectangle.
// bottom - Pointer to a float value receiving the bottom of the rectangle.
// right - Pointer to a float value receiving the right of the rectangle.
// top - Pointer to a float value receiving the top of the rectangle.
//
// On success, return true and write to the out parameters. Otherwise return
// false and leave the out parameters unmodified.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetArtBox(FPDF_PAGE page,
float* left,
float* bottom,
float* right,
float* top);
/**
* Apply transforms to |page|.
*
* If |matrix| is provided it will be applied to transform the page.
* If |clipRect| is provided it will be used to clip the resulting page.
* If neither |matrix| or |clipRect| are provided this method returns |false|.
* Returns |true| if transforms are applied.
*
* This function will transform the whole page, and would take effect to all the
* objects in the page.
*
* page - Page handle.
* matrix - Transform matrix.
* clipRect - Clipping rectangle.
*/
// Apply transforms to |page|.
//
// If |matrix| is provided it will be applied to transform the page.
// If |clipRect| is provided it will be used to clip the resulting page.
// If neither |matrix| or |clipRect| are provided this method returns |false|.
// Returns |true| if transforms are applied.
//
// This function will transform the whole page, and would take effect to all the
// objects in the page.
//
// page - Page handle.
// matrix - Transform matrix.
// clipRect - Clipping rectangle.
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPage_TransFormWithClip(FPDF_PAGE page,
const FS_MATRIX* matrix,
const FS_RECTF* clipRect);
/**
* Transform (scale, rotate, shear, move) the clip path of page object.
* page_object - Handle to a page object. Returned by
* FPDFPageObj_NewImageObj().
*
* a - The coefficient "a" of the matrix.
* b - The coefficient "b" of the matrix.
* c - The coefficient "c" of the matrix.
* d - The coefficient "d" of the matrix.
* e - The coefficient "e" of the matrix.
* f - The coefficient "f" of the matrix.
*/
// 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,
@ -220,39 +196,78 @@ FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object,
double e,
double f);
/**
* 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.
*/
// Experimental API.
// Get the clip path of the page object.
//
// page object - Handle to a page object. Returned by e.g.
// FPDFPage_GetObject().
//
// Returns the handle to the clip path, or NULL on failure. The caller does not
// take ownership of the returned FPDF_CLIPPATH. Instead, it remains valid until
// FPDF_ClosePage() is called for the page containing |page_object|.
FPDF_EXPORT FPDF_CLIPPATH FPDF_CALLCONV
FPDFPageObj_GetClipPath(FPDF_PAGEOBJECT page_object);
// Experimental API.
// Get number of paths inside |clip_path|.
//
// clip_path - handle to a clip_path.
//
// Returns the number of objects in |clip_path| or -1 on failure.
FPDF_EXPORT int FPDF_CALLCONV FPDFClipPath_CountPaths(FPDF_CLIPPATH clip_path);
// Experimental API.
// Get number of segments inside one path of |clip_path|.
//
// clip_path - handle to a clip_path.
// path_index - index into the array of paths of the clip path.
//
// Returns the number of segments or -1 on failure.
FPDF_EXPORT int FPDF_CALLCONV
FPDFClipPath_CountPathSegments(FPDF_CLIPPATH clip_path, int path_index);
// Experimental API.
// Get segment in one specific path of |clip_path| at index.
//
// clip_path - handle to a clip_path.
// path_index - the index of a path.
// segment_index - the index of a segment.
//
// Returns the handle to the segment, or NULL on failure. The caller does not
// take ownership of the returned FPDF_PATHSEGMENT. Instead, it remains valid
// until FPDF_ClosePage() is called for the page containing |clip_path|.
FPDF_EXPORT FPDF_PATHSEGMENT FPDF_CALLCONV
FPDFClipPath_GetPathSegment(FPDF_CLIPPATH clip_path,
int path_index,
int segment_index);
// Create a new clip path, with a rectangle inserted.
//
// Caller takes ownership of the returned FPDF_CLIPPATH. It should be freed with
// FPDF_DestroyClipPath().
//
// left - The left of the clip box.
// bottom - The bottom of the clip box.
// right - The right of the clip box.
// top - The top of the clip box.
FPDF_EXPORT FPDF_CLIPPATH FPDF_CALLCONV FPDF_CreateClipPath(float left,
float bottom,
float right,
float top);
/**
* Destroy the clip path.
*
* clipPath - A handle to the clip path. It will be invalid after this call.
*/
// Destroy the clip path.
//
// clipPath - A handle to the clip path. It will be invalid after this call.
FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath);
/**
* Clip the page content, the page content that outside the clipping region
* become invisible.
*
* A clip path will be inserted before the page content stream or content array.
* In this way, the page content will be clipped by this clip path.
*
* page - A page handle.
* clipPath - A handle to the clip path. (Does not take ownership.)
*/
// 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);

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.