pdfium_render/bindings.rs
1//! Defines the [PdfiumLibraryBindings] trait, containing run-time bindings to the FPDF_*
2//! functions exported by the Pdfium library.
3//!
4//! By default, `pdfium-render` attempts to bind against the latest released version
5//! of the Pdfium API. To explicitly bind against an older version, select one of the
6//! crate's Pdfium version feature flags when taking `pdfium-render` as a dependency
7//! in your project's `Cargo.toml`.
8//!
9//! Doc comments on functions in this trait are taken directly from the Pdfium header files
10//! and as such are copyright by the Pdfium authors and Google. They are reproduced here
11//! as a courtesy for API consumers. The original comments can be found in the Pdfium repository at:
12//! <https://pdfium.googlesource.com/pdfium/+/refs/heads/main/public/>
13
14// Include the appropriate implementation of the PdfiumLibraryBindings trait for the
15// target architecture and threading model.
16
17// Conditional compilation is used to compile different implementations of
18// the PdfiumLibraryBindings trait depending on whether we are compiling to a WASM module,
19// a native shared library, or a statically linked library.
20
21#![allow(clippy::too_many_arguments)]
22
23#[cfg(not(target_arch = "wasm32"))]
24#[cfg(not(feature = "static"))]
25pub(crate) mod dynamic;
26
27#[cfg(not(target_arch = "wasm32"))]
28#[cfg(feature = "static")]
29pub(crate) mod static_bindings;
30
31#[cfg(target_arch = "wasm32")]
32pub(crate) mod wasm;
33
34// These implementations are all single-threaded (because Pdfium itself is single-threaded).
35// Any of them can be wrapped by thread_safe::ThreadSafePdfiumBindings to
36// create a thread-safe architecture-specific implementation of the PdfiumLibraryBindings trait.
37
38#[cfg(feature = "thread_safe")]
39pub(crate) mod thread_safe;
40
41// The following dummy declarations are used only when running cargo doc.
42// They allow documentation of any target-specific functionality to be included
43// in documentation generated on a different target.
44
45#[cfg(doc)]
46struct Uint8Array;
47
48#[cfg(doc)]
49struct HDC;
50
51pub mod version;
52
53pub use crate::bindgen::{
54 FPDF_CharsetFontMap, FPDFANNOT_COLORTYPE, FPDF_ACTION, FPDF_ANNOTATION,
55 FPDF_ANNOTATION_SUBTYPE, FPDF_ANNOT_APPEARANCEMODE, FPDF_ATTACHMENT, FPDF_AVAIL, FPDF_BITMAP,
56 FPDF_BOOKMARK, FPDF_BOOL, FPDF_CLIPPATH, FPDF_COLORSCHEME, FPDF_DEST, FPDF_DOCUMENT,
57 FPDF_DUPLEXTYPE, FPDF_DWORD, FPDF_FILEACCESS, FPDF_FILEIDTYPE, FPDF_FILEWRITE, FPDF_FONT,
58 FPDF_FORMFILLINFO, FPDF_FORMHANDLE, FPDF_GLYPHPATH, FPDF_IMAGEOBJ_METADATA,
59 FPDF_JAVASCRIPT_ACTION, FPDF_LIBRARY_CONFIG, FPDF_LINK, FPDF_OBJECT_TYPE, FPDF_PAGE,
60 FPDF_PAGELINK, FPDF_PAGEOBJECT, FPDF_PAGEOBJECTMARK, FPDF_PAGEOBJ_FORM, FPDF_PAGEOBJ_IMAGE,
61 FPDF_PAGEOBJ_PATH, FPDF_PAGEOBJ_SHADING, FPDF_PAGEOBJ_TEXT, FPDF_PAGEOBJ_UNKNOWN,
62 FPDF_PAGERANGE, FPDF_PATHSEGMENT, FPDF_SCHHANDLE, FPDF_SIGNATURE, FPDF_STRUCTELEMENT,
63 FPDF_STRUCTELEMENT_ATTR, FPDF_STRUCTTREE, FPDF_SYSFONTINFO, FPDF_TEXTPAGE,
64 FPDF_TEXT_RENDERMODE, FPDF_WCHAR, FPDF_WIDESTRING, FPDF_XOBJECT, FS_FLOAT, FS_MATRIX,
65 FS_POINTF, FS_QUADPOINTSF, FS_RECTF, FS_SIZEF, FX_DOWNLOADHINTS, FX_FILEAVAIL, IFSDK_PAUSE,
66};
67
68#[cfg(any(
69 feature = "pdfium_future",
70 feature = "pdfium_7350",
71 feature = "pdfium_7215",
72 feature = "pdfium_7123",
73 feature = "pdfium_6996",
74 feature = "pdfium_6721",
75 feature = "pdfium_6666",
76 feature = "pdfium_6611",
77 feature = "pdfium_6569",
78 feature = "pdfium_6555",
79 feature = "pdfium_6490",
80))]
81pub use crate::bindgen::FPDF_STRUCTELEMENT_ATTR_VALUE;
82
83#[cfg(feature = "pdfium_use_skia")]
84pub use crate::bindgen::FPDF_SKIA_CANVAS;
85
86#[cfg(feature = "pdfium_enable_xfa")]
87pub use crate::bindgen::{FPDF_BSTR, FPDF_RESULT};
88
89use crate::bindgen::size_t;
90use crate::bindings::version::PdfiumApiVersion;
91use crate::error::{PdfiumError, PdfiumInternalError};
92use crate::pdf::bitmap::PdfBitmap;
93use crate::pdf::color::PdfColor;
94use crate::pdf::document::page::object::private::internal::PdfPageObjectPrivate;
95use crate::pdf::document::page::object::PdfPageObject;
96use crate::pdf::document::page::PdfPage;
97use crate::pdf::document::PdfDocument;
98use crate::pdf::matrix::PdfMatrix;
99use crate::pdf::rect::PdfRect;
100use crate::prelude::PdfQuadPoints;
101use crate::utils::pixels::{
102 bgra_to_rgba, rgba_to_bgra, unaligned_bgr_to_rgba, unaligned_rgb_to_bgra,
103};
104use crate::utils::utf16le::{
105 get_pdfium_utf16le_bytes_from_str, get_string_from_pdfium_utf16le_bytes,
106};
107use std::os::raw::{
108 c_char, c_double, c_float, c_int, c_long, c_uchar, c_uint, c_ulong, c_ushort, c_void,
109};
110
111/// Platform-independent function bindings to an external Pdfium library.
112/// On most platforms this will be an external shared library loaded dynamically
113/// at runtime, either bundled alongside your compiled Rust application or provided as a system
114/// library by the platform. On WASM, this will be a set of Javascript functions exposed by a
115/// separate WASM module that is imported into the same browser context.
116///
117/// Pdfium's API uses three different string types: classic C-style null-terminated char arrays,
118/// UTF-8 byte arrays, and a UTF-16LE byte array type named `FPDF_WIDESTRING`. For functions that take a
119/// C-style string or a UTF-8 byte array, `pdfium-render`'s binding will take the standard Rust `&str` type.
120/// For functions that take an `FPDF_WIDESTRING`, `pdfium-render` exposes two functions: the vanilla
121/// `FPDF_*()` function that takes an `FPDF_WIDESTRING`, and an additional `FPDF_*_str()` helper function
122/// that takes a standard Rust `&str` and converts it internally to an `FPDF_WIDESTRING` before calling
123/// Pdfium. Examples of functions with additional `_str()` helpers include `FPDFBookmark_Find()`,
124/// `FPDFAnnot_SetStringValue()`, and `FPDFText_SetText()`.
125///
126/// The [PdfiumLibraryBindings::get_pdfium_utf16le_bytes_from_str] and
127/// [PdfiumLibraryBindings::get_string_from_pdfium_utf16le_bytes] functions are provided
128/// for converting to and from UTF-16LE in your own code.
129///
130/// The following Pdfium functions have different signatures in this trait compared to their
131/// native function signatures in Pdfium:
132/// * [PdfiumLibraryBindings::FPDF_LoadDocument]: this function is not available when compiling to WASM.
133/// * [PdfiumLibraryBindings::FPDFBitmap_GetBuffer]: this function is not available when compiling
134/// to WASM. Use the globally-available [PdfiumLibraryBindings::FPDFBitmap_GetBuffer_as_vec]
135/// or the WASM-specific [PdfiumLibraryBindings::FPDFBitmap_GetBuffer_as_array] functions instead.
136pub trait PdfiumLibraryBindings {
137 /// Returns the canonical C-style boolean integer value 1, indicating `true`.
138 #[inline]
139 #[allow(non_snake_case)]
140 fn TRUE(&self) -> FPDF_BOOL {
141 1
142 }
143
144 /// Returns the canonical C-style boolean integer value 0, indicating `false`.
145 #[inline]
146 #[allow(non_snake_case)]
147 fn FALSE(&self) -> FPDF_BOOL {
148 0
149 }
150
151 /// Converts from a C-style boolean integer to a Rust `bool`.
152 ///
153 /// Assumes `PdfiumLibraryBindings::FALSE()` indicates `false` and any other value indicates `true`.
154 #[inline]
155 fn is_true(&self, bool: FPDF_BOOL) -> bool {
156 bool != self.FALSE()
157 }
158
159 /// Converts the given Rust `bool` into a Pdfium `FPDF_BOOL`.
160 #[inline]
161 fn bool_to_pdfium(&self, bool: bool) -> FPDF_BOOL {
162 if bool {
163 self.TRUE()
164 } else {
165 self.FALSE()
166 }
167 }
168
169 /// Converts from a C-style boolean integer to a Rust `Result`.
170 ///
171 /// Assumes `PdfiumLibraryBindings::FALSE()` indicates `false` and any other value indicates `true`.
172 ///
173 /// A value of `PdfiumLibraryBindings::FALSE()` will return a [PdfiumInternalError::Unknown].
174 /// All other values will return `Ok(())`.
175 #[inline]
176 fn to_result(&self, bool: FPDF_BOOL) -> Result<(), PdfiumError> {
177 if self.is_true(bool) {
178 Ok(())
179 } else {
180 Err(PdfiumError::PdfiumLibraryInternalError(
181 PdfiumInternalError::Unknown,
182 ))
183 }
184 }
185
186 /// Converts the given Rust `&str` into an UTF16-LE encoded byte buffer.
187 #[inline]
188 fn get_pdfium_utf16le_bytes_from_str(&self, str: &str) -> Vec<u8> {
189 get_pdfium_utf16le_bytes_from_str(str)
190 }
191
192 /// Converts the bytes in the given buffer from UTF16-LE to a standard Rust `String`.
193 #[inline]
194 #[allow(unused_mut)] // The buffer must be mutable when compiling to WASM.
195 fn get_string_from_pdfium_utf16le_bytes(&self, mut buffer: Vec<u8>) -> Option<String> {
196 get_string_from_pdfium_utf16le_bytes(buffer)
197 }
198
199 /// Converts the given byte array, containing pixel data encoded as three-channel BGR,
200 /// into pixel data encoded as four-channel RGBA. A new alpha channel is created with full opacity.
201 #[inline]
202 fn bgr_to_rgba(&self, bgr: &[u8]) -> Vec<u8> {
203 unaligned_bgr_to_rgba(bgr)
204 }
205
206 /// Converts the given byte array, containing pixel data encoded as four-channel BGRA,
207 /// into pixel data encoded as four-channel RGBA.
208 #[inline]
209 fn bgra_to_rgba(&self, bgra: &[u8]) -> Vec<u8> {
210 bgra_to_rgba(bgra)
211 }
212
213 /// Converts the given byte array, containing pixel data encoded as three-channel RGB,
214 /// into pixel data encoded as four-channel BGRA. A new alpha channel is created with full opacity.
215 #[inline]
216 fn rgb_to_bgra(&self, rgb: &[u8]) -> Vec<u8> {
217 unaligned_rgb_to_bgra(rgb)
218 }
219
220 /// Converts the given byte array, containing pixel data encoded as four-channel RGBA,
221 /// into pixel data encoded as four-channel BGRA.
222 #[inline]
223 fn rgba_to_bgra(&self, rgba: &[u8]) -> Vec<u8> {
224 rgba_to_bgra(rgba)
225 }
226
227 /// Returns Pdfium's internal `FPDF_DOCUMENT` handle for the given [PdfDocument].
228 #[inline]
229 fn get_handle_from_document(&self, document: &PdfDocument) -> FPDF_DOCUMENT {
230 document.handle()
231 }
232
233 /// Returns Pdfium's internal `FPDF_PAGE` handle for the given [PdfPage].
234 #[inline]
235 fn get_handle_from_page(&self, page: &PdfPage) -> FPDF_PAGE {
236 page.page_handle()
237 }
238
239 /// Returns Pdfium's internal `FPDF_PAGEOBJECT` handle for the given [PdfPageObject].
240 #[inline]
241 fn get_handle_from_object(&self, object: &PdfPageObject) -> FPDF_PAGEOBJECT {
242 object.object_handle()
243 }
244
245 /// Returns Pdfium's internal `FPDF_BITMAP` handle for the given [PdfBitmap].
246 #[inline]
247 fn get_handle_from_bitmap(&self, bitmap: &PdfBitmap) -> FPDF_BITMAP {
248 bitmap.handle()
249 }
250
251 /// Returns Pdfium's internal `FS_MATRIX` struct representation for the given [PdfMatrix].
252 #[inline]
253 fn get_fs_matrix_from_matrix(&self, matrix: &PdfMatrix) -> FS_MATRIX {
254 matrix.as_pdfium()
255 }
256
257 /// Returns Pdfium's internal `FS_RECTF` struct representation for the given [PdfRect].
258 #[inline]
259 fn get_fs_rect_from_rect(&self, rect: &PdfRect) -> FS_RECTF {
260 rect.as_pdfium()
261 }
262
263 /// Returns Pdfium's internal `FS_QUADPOINTSF` struct representation for the given [PdfQuadPoints].
264 #[inline]
265 fn get_fs_quad_points_from_quad_points(&self, quad_points: &PdfQuadPoints) -> FS_QUADPOINTSF {
266 quad_points.as_pdfium()
267 }
268
269 /// Returns the given color encoded as a 32-bit hexadecimal 0xAARRGGBB value,
270 /// suitable for passing to Pdfium.
271 #[inline]
272 fn get_dword_from_color(&self, color: &PdfColor) -> FPDF_DWORD {
273 color.as_pdfium_color()
274 }
275
276 /// Returns a tuple comprising the given color encoded as a 32-bit hexadecimal 0xFFRRGGBB
277 /// value and the color's alpha channel encoded as an 8-bit value, suitable for passing
278 /// to Pdfium.
279 #[inline]
280 fn get_dword_and_alpha_from_color(&self, color: &PdfColor) -> (FPDF_DWORD, u8) {
281 color.as_pdfium_color_with_alpha()
282 }
283
284 /// Returns the API version of the Pdfium FPDF_* API currently in use.
285 ///
286 /// By default, `pdfium-render` attempts to bind against the latest released version
287 /// of the Pdfium API. To explicitly bind against an older version, select one of the
288 /// crate's Pdfium version feature flags when taking `pdfium-render` as a dependency
289 /// in your project's `Cargo.toml`.
290 #[inline]
291 fn version(&self) -> PdfiumApiVersion {
292 PdfiumApiVersion::current()
293 }
294
295 /// Initializes the PDFium library and allocate global resources for it.
296 ///
297 /// `config` - configuration information.
298 ///
299 /// You have to call this function before you can call any PDF processing functions.
300 #[allow(non_snake_case)]
301 fn FPDF_InitLibraryWithConfig(&self, config: *const FPDF_LIBRARY_CONFIG);
302
303 /// Initializes the PDFium library (alternative form).
304 ///
305 /// Convenience function to call [PdfiumLibraryBindings::FPDF_InitLibraryWithConfig]
306 /// with a default configuration for backwards compatibility purposes. New code should
307 /// call [PdfiumLibraryBindings::FPDF_InitLibraryWithConfig] instead.
308 /// This will be deprecated in the future.
309 #[allow(non_snake_case)]
310 fn FPDF_InitLibrary(&self);
311
312 /// Releases global resources allocated to the PDFium library by [PdfiumLibraryBindings::FPDF_InitLibrary]
313 /// or [PdfiumLibraryBindings::FPDF_InitLibraryWithConfig]. After this function is called,
314 /// you must not call any PDF processing functions. Calling this function does not automatically
315 /// close other objects. It is recommended to close other objects before closing the library
316 /// with this function.
317 #[allow(non_snake_case)]
318 fn FPDF_DestroyLibrary(&self);
319
320 /// Sets the policy for the sandbox environment.
321 ///
322 /// `policy` - The specified policy for setting, for example `FPDF_POLICY_MACHINETIME_ACCESS`.
323 ///
324 /// `enable` - `true` to enable, `false` to disable the policy.
325 #[allow(non_snake_case)]
326 fn FPDF_SetSandBoxPolicy(&self, policy: FPDF_DWORD, enable: FPDF_BOOL);
327
328 #[cfg(not(target_arch = "wasm32"))]
329 #[cfg(feature = "pdfium_use_win32")]
330 /// Sets printing mode when printing on Windows.
331 ///
332 /// mode - `FPDF_PRINTMODE_EMF` to output EMF (default)
333 ///
334 /// `FPDF_PRINTMODE_TEXTONLY` to output text only (for charstream devices)
335 ///
336 /// `FPDF_PRINTMODE_POSTSCRIPT2` to output level 2 PostScript into
337 /// EMF as a series of GDI comments.
338 ///
339 /// `FPDF_PRINTMODE_POSTSCRIPT3` to output level 3 PostScript into
340 /// EMF as a series of GDI comments.
341 ///
342 /// `FPDF_PRINTMODE_POSTSCRIPT2_PASSTHROUGH` to output level 2
343 /// PostScript via ExtEscape() in PASSTHROUGH mode.
344 ///
345 /// `FPDF_PRINTMODE_POSTSCRIPT3_PASSTHROUGH` to output level 3
346 /// PostScript via ExtEscape() in PASSTHROUGH mode.
347 ///
348 /// `FPDF_PRINTMODE_EMF_IMAGE_MASKS` to output EMF, with more
349 /// efficient processing of documents containing image masks.
350 ///
351 /// `FPDF_PRINTMODE_POSTSCRIPT3_TYPE42` to output level 3
352 /// PostScript with embedded Type 42 fonts, when applicable, into
353 /// EMF as a series of GDI comments.
354 ///
355 /// `FPDF_PRINTMODE_POSTSCRIPT3_TYPE42_PASSTHROUGH` to output level
356 /// 3 PostScript with embedded Type 42 fonts, when applicable,
357 /// via ExtEscape() in PASSTHROUGH mode.
358 ///
359 /// Returns `true` if successful, `false` if unsuccessful (typically invalid input).
360 #[allow(non_snake_case)]
361 fn FPDF_SetPrintMode(&self, mode: c_int);
362
363 /// Gets the last error code when a function fails.
364 ///
365 /// Returns a 32-bit integer indicating error code as defined above.
366 ///
367 /// If the previous SDK call succeeded, the return value of this function is not defined.
368 /// This function only works in conjunction with APIs that mention `FPDF_GetLastError`
369 /// in their documentation.
370 #[allow(non_snake_case)]
371 fn FPDF_GetLastError(&self) -> c_ulong;
372
373 /// Coalesces the given individual R, G, B, and alpha color components into
374 // a 32-bit hexadecimal 0xAARRGGBB value, suitable for passing to Pdfium.
375 #[allow(non_snake_case)]
376 fn FPDF_ARGB(&self, a: u8, r: u8, g: u8, b: u8) -> FPDF_DWORD {
377 PdfColor::new(r, g, b, a).as_pdfium_color()
378 }
379
380 /// Returns the blue component of the given color.
381 #[allow(non_snake_case)]
382 fn FPDF_GetBValue(&self, argb: FPDF_DWORD) -> u8 {
383 PdfColor::from_pdfium(argb).blue()
384 }
385
386 /// Returns the green component of the given color.
387 #[allow(non_snake_case)]
388 fn FPDF_GetGValue(&self, argb: FPDF_DWORD) -> u8 {
389 PdfColor::from_pdfium(argb).green()
390 }
391
392 /// Returns the red component of the given color.
393 #[allow(non_snake_case)]
394 fn FPDF_GetRValue(&self, argb: FPDF_DWORD) -> u8 {
395 PdfColor::from_pdfium(argb).red()
396 }
397
398 /// Returns the alpha component of the given color.
399 #[allow(non_snake_case)]
400 fn FPDF_GetAValue(&self, argb: FPDF_DWORD) -> u8 {
401 PdfColor::from_pdfium(argb).alpha()
402 }
403
404 /// Creates a new empty PDF document. Returns a handle to a new document, or `NULL` on failure.
405 #[allow(non_snake_case)]
406 fn FPDF_CreateNewDocument(&self) -> FPDF_DOCUMENT;
407
408 #[cfg(not(target_arch = "wasm32"))]
409 /// Opens and loads an existing PDF document.
410 ///
411 /// `file_path` - Path to the PDF file (including extension).
412 ///
413 /// `password` - A string used as the password for the PDF file.
414 /// If no password is needed, empty or `NULL` can be used.
415 /// See comments below regarding the encoding.
416 ///
417 /// Returns a handle to the loaded document, or `NULL` on failure.
418 ///
419 /// The loaded document can be closed by [PdfiumLibraryBindings::FPDF_CloseDocument].
420 /// If this function fails, you can use [PdfiumLibraryBindings::FPDF_GetLastError] to retrieve
421 /// the reason why it failed. The encoding for `file_path` is UTF-8. The encoding for
422 /// `password` can be either UTF-8 or Latin-1. PDFs, depending on the security handler
423 /// revision, will only accept one or the other encoding. If `password`'s encoding and
424 /// the PDF's expected encoding do not match, `FPDF_LoadDocument` will automatically
425 /// convert `password` to the other encoding.
426 ///
427 /// This function is not available when compiling to WASM. You must use one of the
428 /// [PdfiumLibraryBindings::FPDF_LoadMemDocument], [PdfiumLibraryBindings::FPDF_LoadMemDocument64],
429 /// or [PdfiumLibraryBindings::FPDF_LoadCustomDocument] functions instead.
430 #[allow(non_snake_case)]
431 fn FPDF_LoadDocument(&self, file_path: &str, password: Option<&str>) -> FPDF_DOCUMENT;
432
433 /// Opens and loads an existing PDF document from memory.
434 ///
435 /// `data_buf` - Pointer to a buffer containing the PDF document.
436 ///
437 /// `size` - Number of bytes in the PDF document.
438 ///
439 /// `password` - A string used as the password for the PDF file.
440 /// If no password is needed, empty or NULL can be used.
441 ///
442 /// Returns a handle to the loaded document, or `NULL` on failure.
443 ///
444 /// The memory buffer must remain valid when the document is open. The loaded document
445 /// can be closed by [PdfiumLibraryBindings::FPDF_CloseDocument]. If this function fails,
446 /// you can use [PdfiumLibraryBindings::FPDF_GetLastError] to retrieve the reason why it failed.
447 ///
448 /// See the comments for [PdfiumLibraryBindings::FPDF_LoadDocument] regarding the encoding for
449 /// `password`.
450 ///
451 /// If PDFium is built with the XFA module, the application should call [PdfiumLibraryBindings::FPDF_LoadXFA]
452 /// function after the PDF document is loaded to support XFA fields defined in the `fpdfformfill.h` file.
453 ///
454 /// Note that all calls to [PdfiumLibraryBindings::FPDF_LoadMemDocument] are
455 /// internally upgraded to [PdfiumLibraryBindings::FPDF_LoadMemDocument64] by `pdfium-render`.
456 #[inline]
457 #[allow(non_snake_case)]
458 fn FPDF_LoadMemDocument(&self, bytes: &[u8], password: Option<&str>) -> FPDF_DOCUMENT {
459 self.FPDF_LoadMemDocument64(bytes, password)
460 }
461
462 /// Opens and loads an existing PDF document from memory.
463 ///
464 /// `data_buf` - Pointer to a buffer containing the PDF document.
465 ///
466 /// `size` - Number of bytes in the PDF document.
467 ///
468 /// `password` - A string used as the password for the PDF file.
469 /// If no password is needed, empty or `NULL` can be used.
470 ///
471 /// Returns a handle to the loaded document, or `NULL` on failure.
472 ///
473 /// The memory buffer must remain valid when the document is open. The loaded document
474 /// can be closed by [PdfiumLibraryBindings::FPDF_CloseDocument]. If this function fails,
475 /// you can use [PdfiumLibraryBindings::FPDF_GetLastError] to retrieve the reason why it failed.
476 ///
477 /// See the comments for [PdfiumLibraryBindings::FPDF_LoadDocument] regarding the encoding for
478 /// `password`.
479 ///
480 /// If PDFium is built with the XFA module, the application should call [PdfiumLibraryBindings::FPDF_LoadXFA]
481 /// function after the PDF document loaded to support XFA fields defined in the `fpdfformfill.h` file.
482 #[allow(non_snake_case)]
483 fn FPDF_LoadMemDocument64(&self, data_buf: &[u8], password: Option<&str>) -> FPDF_DOCUMENT;
484
485 /// Loads a PDF document from a custom access descriptor.
486 ///
487 /// `pFileAccess` - A structure for accessing the file.
488 ///
489 /// `password` - Optional password for decrypting the PDF file.
490 ///
491 /// Returns a handle to the loaded document, or `NULL` on failure.
492 ///
493 /// The application must keep the file resources `pFileAccess` points to valid until the
494 /// returned `FPDF_DOCUMENT` is closed. `pFileAccess` itself does not need to outlive the
495 /// `FPDF_DOCUMENT`. The loaded document can be closed with [PdfiumLibraryBindings::FPDF_CloseDocument].
496 ///
497 /// See the comments for [PdfiumLibraryBindings::FPDF_LoadDocument] regarding the encoding for
498 /// `password`.
499 ///
500 /// If PDFium is built with the XFA module, the application should call [PdfiumLibraryBindings::FPDF_LoadXFA]
501 /// function after the PDF document loaded to support XFA fields defined in the `fpdfformfill.h` file.
502 #[allow(non_snake_case)]
503 fn FPDF_LoadCustomDocument(
504 &self,
505 pFileAccess: *mut FPDF_FILEACCESS,
506 password: Option<&str>,
507 ) -> FPDF_DOCUMENT;
508
509 /// Saves a copy of the specified document in a custom way.
510 ///
511 /// `document` - Handle to document, as returned by [PdfiumLibraryBindings::FPDF_LoadDocument]
512 /// or [PdfiumLibraryBindings::FPDF_CreateNewDocument].
513 ///
514 /// `pFileWrite` - A pointer to a custom file write structure.
515 ///
516 /// `flags` - The creating flags.
517 ///
518 /// Returns `true` on success, `false` on failure.
519 #[allow(non_snake_case)]
520 fn FPDF_SaveAsCopy(
521 &self,
522 document: FPDF_DOCUMENT,
523 pFileWrite: *mut FPDF_FILEWRITE,
524 flags: FPDF_DWORD,
525 ) -> FPDF_BOOL;
526
527 /// Same as [PdfiumLibraryBindings::FPDF_SaveAsCopy], except the file version of the
528 /// saved document can be specified by the caller.
529 ///
530 /// `document` - Handle to document.
531 ///
532 /// `pFileWrite` - A pointer to a custom file write structure.
533 ///
534 /// `flags` - The creating flags.
535 ///
536 /// `fileVersion` - The PDF file version. File version: 14 for 1.4,
537 /// 15 for 1.5, etc.
538 ///
539 /// Returns `true` on success, `false` on failure.
540 #[allow(non_snake_case)]
541 fn FPDF_SaveWithVersion(
542 &self,
543 document: FPDF_DOCUMENT,
544 pFileWrite: *mut FPDF_FILEWRITE,
545 flags: FPDF_DWORD,
546 fileVersion: c_int,
547 ) -> FPDF_BOOL;
548
549 /// Creates a document availability provider.
550 ///
551 /// `file_avail` - pointer to file availability interface.
552 ///
553 /// `file` - pointer to a file access interface.
554 ///
555 /// Returns a handle to the document availability provider, or `NULL` on error.
556 ///
557 /// [PdfiumLibraryBindings::FPDFAvail_Destroy] must be called when done with the
558 /// availability provider.
559 #[allow(non_snake_case)]
560 fn FPDFAvail_Create(
561 &self,
562 file_avail: *mut FX_FILEAVAIL,
563 file: *mut FPDF_FILEACCESS,
564 ) -> FPDF_AVAIL;
565
566 /// Destroys the `avail` document availability provider.
567 ///
568 /// `avail` - handle to document availability provider to be destroyed.
569 #[allow(non_snake_case)]
570 fn FPDFAvail_Destroy(&self, avail: FPDF_AVAIL);
571
572 /// Checks if the document is ready for loading; if not, gets download hints.
573 ///
574 /// `avail` - handle to document availability provider.
575 ///
576 /// `hints` - pointer to a download hints interface.
577 ///
578 /// Returns one of:
579 ///
580 /// `PDF_DATA_ERROR`: A common error is returned. Data availability unknown.
581 ///
582 /// `PDF_DATA_NOTAVAIL`: Data not yet available.
583 ///
584 /// `PDF_DATA_AVAIL`: Data available.
585 ///
586 /// Applications should call this function whenever new data arrives, and process
587 /// all the generated download hints, if any, until the function returns
588 /// `PDF_DATA_ERROR` or `PDF_DATA_AVAIL`.
589 ///
590 /// If `hints` is `NULL`, the function just checks current document availability.
591 ///
592 /// Once all data is available, call [PdfiumLibraryBindings::FPDFAvail_GetDocument] to get
593 /// a document handle.
594 #[allow(non_snake_case)]
595 fn FPDFAvail_IsDocAvail(&self, avail: FPDF_AVAIL, hints: *mut FX_DOWNLOADHINTS) -> c_int;
596
597 /// Gets a document from the availability provider.
598 ///
599 /// `avail` - handle to document availability provider.
600 ///
601 /// `password` - password for decrypting the PDF file. Optional.
602 ///
603 /// Returns a handle to the document.
604 ///
605 /// When [PdfiumLibraryBindings::FPDFAvail_IsDocAvail] returns `TRUE`, call
606 /// [PdfiumLibraryBindings::FPDFAvail_GetDocument] to\n retrieve the document handle.
607 /// See the comments for [PdfiumLibraryBindings::FPDF_LoadDocument] regarding the encoding
608 /// for `password`.
609 #[allow(non_snake_case)]
610 fn FPDFAvail_GetDocument(&self, avail: FPDF_AVAIL, password: Option<&str>) -> FPDF_DOCUMENT;
611
612 /// Gets the page number for the first available page in a linearized PDF.
613 ///
614 /// `doc` - document handle.
615 ///
616 /// Returns the zero-based index for the first available page.
617 ///
618 /// For most linearized PDFs, the first available page will be the first page,
619 /// however, some PDFs might make another page the first available page.
620 ///
621 /// For non-linearized PDFs, this function will always return zero.
622 #[allow(non_snake_case)]
623 fn FPDFAvail_GetFirstPageNum(&self, doc: FPDF_DOCUMENT) -> c_int;
624
625 /// Checks if `page_index` is ready for loading, if not, get the `FX_DOWNLOADHINTS`.
626 ///
627 /// `avail` - handle to document availability provider.
628 ///
629 /// `page_index` - index number of the page. Zero for the first page.
630 ///
631 /// `hints` - pointer to a download hints interface. Populated if
632 /// `page_index` is not available.
633 ///
634 /// Returns one of:
635 ///
636 /// `PDF_DATA_ERROR`: A common error is returned. Data availability unknown.
637 ///
638 /// `PDF_DATA_NOTAVAIL`: Data not yet available.
639 ///
640 /// `PDF_DATA_AVAIL`: Data available.
641 ///
642 /// This function can be called only after [PdfiumLibraryBindings::FPDFAvail_GetDocument]
643 /// is called. Applications should call this function whenever new data arrives and process
644 /// all the generated download `hints`, if any, until this function returns `PDF_DATA_ERROR`
645 /// or `PDF_DATA_AVAIL`. Applications can then perform page loading.
646 ///
647 /// If `hints` is `NULL`, the function just check current availability of specified page.
648 #[allow(non_snake_case)]
649 fn FPDFAvail_IsPageAvail(
650 &self,
651 avail: FPDF_AVAIL,
652 page_index: c_int,
653 hints: *mut FX_DOWNLOADHINTS,
654 ) -> c_int;
655
656 /// Checks if form data is ready for initialization; if not, get the `FX_DOWNLOADHINTS`.
657 ///
658 /// `avail` - handle to document availability provider.
659 ///
660 /// `hints` - pointer to a download hints interface. Populated if form is not
661 /// ready for initialization.
662 ///
663 /// Returns one of:
664 ///
665 /// `PDF_FORM_ERROR`: A common error, in general incorrect parameters.
666 ///
667 /// `PDF_FORM_NOTAVAIL`: Data not available.
668 ///
669 /// `PDF_FORM_AVAIL`: Data available.
670 ///
671 /// `PDF_FORM_NOTEXIST`: No form data.
672 ///
673 /// This function can be called only after [PdfiumLibraryBindings::FPDFAvail_GetDocument]
674 /// is called. The application should call this function whenever new data arrives and
675 /// process all the generated download `hints`, if any, until the function returns
676 /// `PDF_FORM_ERROR`, `PDF_FORM_AVAIL` or `PDF_FORM_NOTEXIST`.
677 ///
678 /// If `hints` is `NULL`, the function just check current form availability.
679 ///
680 /// Applications can then perform page loading. It is recommend to call
681 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment] when `PDF_FORM_AVAIL` is returned.
682 #[allow(non_snake_case)]
683 fn FPDFAvail_IsFormAvail(&self, avail: FPDF_AVAIL, hints: *mut FX_DOWNLOADHINTS) -> c_int;
684
685 /// Checks whether a document is a linearized PDF.
686 ///
687 /// `avail` - handle to document availability provider.
688 ///
689 /// Returns one of:
690 ///
691 /// `PDF_LINEARIZED`
692 ///
693 /// `PDF_NOT_LINEARIZED`
694 ///
695 /// `PDF_LINEARIZATION_UNKNOWN`
696 ///
697 /// [PdfiumLibraryBindings::FPDFAvail_IsLinearized] will return `PDF_LINEARIZED` or
698 /// `PDF_NOT_LINEARIZED` once we have received 1kb of data. If the file's size is less
699 /// than 1kb, it returns `PDF_LINEARIZATION_UNKNOWN` as there is insufficient information
700 // to determine if the PDF is linearlized.
701 #[allow(non_snake_case)]
702 fn FPDFAvail_IsLinearized(&self, avail: FPDF_AVAIL) -> c_int;
703
704 /// Closes a loaded PDF page.
705 ///
706 /// `page` - Handle to the loaded page.
707 #[allow(non_snake_case)]
708 fn FPDF_ClosePage(&self, page: FPDF_PAGE);
709
710 /// Closes a loaded PDF document.
711 ///
712 /// `document` - Handle to the loaded document.
713 #[allow(non_snake_case)]
714 fn FPDF_CloseDocument(&self, document: FPDF_DOCUMENT);
715
716 /// Converts the screen coordinates of a point to page coordinates.
717 ///
718 /// `page` - Handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
719 ///
720 /// `start_x` - Left pixel position of the display area in device coordinates.
721 ///
722 /// `start_y` - Top pixel position of the display area in device coordinates.
723 ///
724 /// `size_x` - Horizontal size (in pixels) for displaying the page.
725 ///
726 /// `size_y` - Vertical size (in pixels) for displaying the page.
727 ///
728 /// `rotate` - Page orientation:
729 /// 0 (normal)
730 /// 1 (rotated 90 degrees clockwise)
731 /// 2 (rotated 180 degrees)
732 /// 3 (rotated 90 degrees counter-clockwise)
733 ///
734 /// `device_x` - X value in device coordinates to be converted.
735 ///
736 /// `device_y` - Y value in device coordinates to be converted.
737 ///
738 /// `page_x` - A pointer to a double receiving the converted X
739 /// value in page coordinates.
740 ///
741 /// `page_y` - A pointer to a double receiving the converted Y
742 /// value in page coordinates.
743 ///
744 /// Returns `true` if the conversion succeeds, and `page_x` and `page_y`
745 /// successfully receives the converted coordinates.
746 ///
747 /// The page coordinate system has its origin at the left-bottom corner of the page,
748 /// with the X-axis on the bottom going to the right, and the Y-axis on the left side going up.
749 /// This coordinate system can be altered when you zoom, scroll, or rotate a page; however,
750 /// a point on the page should always have the same coordinate values in the page coordinate
751 /// system. The device coordinate system is device dependent. For screen device, its origin
752 /// is at the left-top corner of the window. This origin can be altered by the Windows coordinate
753 /// transformation utilities.
754 ///
755 /// You must make sure the `start_x`, `start_y`, `size_x`, `size_y` and `rotate` parameters
756 /// have exactly same values as you used in the [PdfiumLibraryBindings::FPDF_RenderPage] function call.
757 #[allow(non_snake_case)]
758 #[allow(clippy::too_many_arguments)]
759 fn FPDF_DeviceToPage(
760 &self,
761 page: FPDF_PAGE,
762 start_x: c_int,
763 start_y: c_int,
764 size_x: c_int,
765 size_y: c_int,
766 rotate: c_int,
767 device_x: c_int,
768 device_y: c_int,
769 page_x: *mut c_double,
770 page_y: *mut c_double,
771 ) -> FPDF_BOOL;
772
773 /// Converts the page coordinates of a point to screen coordinates.
774 ///
775 /// `page` - Handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
776 ///
777 /// `start_x` - Left pixel position of the display area in device coordinates.
778 ///
779 /// `start_y` - Top pixel position of the display area in device coordinates.
780 ///
781 /// `size_x` - Horizontal size (in pixels) for displaying the page.
782 ///
783 /// `size_y` - Vertical size (in pixels) for displaying the page.
784 ///
785 /// `rotate` - Page orientation:
786 /// 0 (normal)
787 /// 1 (rotated 90 degrees clockwise)
788 /// 2 (rotated 180 degrees)
789 /// 3 (rotated 90 degrees counter-clockwise)
790 ///
791 /// `page_x` - X value in page coordinates.
792 ///
793 /// `page_y` - Y value in page coordinate.
794 ///
795 /// `device_x` - A pointer to an integer receiving the result X value in device coordinates.
796 ///
797 /// `device_y` - A pointer to an integer receiving the result Y value in device coordinates.
798 ///
799 /// Returns `true` if the conversion succeeds, and `device_x` and `device_y`
800 /// successfully receives the converted coordinates.
801 ///
802 /// Refer to [PdfiumLibraryBindings::FPDF_DeviceToPage] for comments on coordinate systems.
803 #[allow(non_snake_case)]
804 #[allow(clippy::too_many_arguments)]
805 fn FPDF_PageToDevice(
806 &self,
807 page: FPDF_PAGE,
808 start_x: c_int,
809 start_y: c_int,
810 size_x: c_int,
811 size_y: c_int,
812 rotate: c_int,
813 page_x: c_double,
814 page_y: c_double,
815 device_x: *mut c_int,
816 device_y: *mut c_int,
817 ) -> FPDF_BOOL;
818
819 /// Gets the file version of the given PDF document.
820 ///
821 /// `doc` - Handle to a document.
822 ///
823 /// `fileVersion` - The PDF file version. File version: 14 for 1.4, 15
824 /// for 1.5, etc.
825 ///
826 /// Returns `true` on success, `false` on failure.
827 ///
828 /// If the document was created by [PdfiumLibraryBindings::FPDF_CreateNewDocument],
829 /// then this function will always fail.
830 #[allow(non_snake_case)]
831 fn FPDF_GetFileVersion(&self, doc: FPDF_DOCUMENT, fileVersion: *mut c_int) -> FPDF_BOOL;
832
833 /// Returns whether the document's cross reference table is valid or not.
834 ///
835 /// `document` - Handle to a document. Returned by [PdfiumLibraryBindings::FPDF_LoadDocument].
836 ///
837 /// Returns `true` if the PDF parser did not encounter problems parsing the cross reference table,
838 /// or `false` if the parser could not parse the cross reference table and the table had to be
839 /// rebuilt from other data within the document.
840 ///
841 /// The return value may change over time as the PDF parser evolves.
842 #[allow(non_snake_case)]
843 fn FPDF_DocumentHasValidCrossReferenceTable(&self, document: FPDF_DOCUMENT) -> FPDF_BOOL;
844
845 /// Gets the byte offsets of trailer ends.
846 ///
847 /// `document` - Handle to document. Returned by [PdfiumLibraryBindings::FPDF_LoadDocument].
848 ///
849 /// `buffer` - The address of a buffer that receives the byte offsets.
850 ///
851 /// `length` - The size, in ints, of `buffer`.
852 ///
853 /// Returns the number of ints in the buffer on success, 0 on error.
854 ///
855 /// `buffer` is an array of integers that describes the exact byte offsets of the
856 /// trailer ends in the document. If `length` is less than the returned length,
857 /// or `document` or `buffer` is `NULL`, `buffer` will not be modified.
858 #[allow(non_snake_case)]
859 fn FPDF_GetTrailerEnds(
860 &self,
861 document: FPDF_DOCUMENT,
862 buffer: *mut c_uint,
863 length: c_ulong,
864 ) -> c_ulong;
865
866 /// Gets the file permission flags of the document.
867 ///
868 /// `document` - Handle to a document. Returned by [PdfiumLibraryBindings::FPDF_LoadDocument].
869 ///
870 /// Returns a 32-bit integer indicating permission flags. Please refer to the PDF Reference
871 /// for detailed descriptions. If the document is not protected or was unlocked
872 /// by the owner, `0xffffffff` will be returned.
873 #[allow(non_snake_case)]
874 fn FPDF_GetDocPermissions(&self, document: FPDF_DOCUMENT) -> c_ulong;
875
876 #[cfg(any(
877 feature = "pdfium_future",
878 feature = "pdfium_7350",
879 feature = "pdfium_7215",
880 feature = "pdfium_7123",
881 feature = "pdfium_6996",
882 feature = "pdfium_6721",
883 feature = "pdfium_6666",
884 feature = "pdfium_6611",
885 feature = "pdfium_6569",
886 feature = "pdfium_6569",
887 feature = "pdfium_6555",
888 feature = "pdfium_6490",
889 feature = "pdfium_6406",
890 feature = "pdfium_6337",
891 feature = "pdfium_6295",
892 ))]
893 /// Gets user file permission flags of the document.
894 ///
895 /// `document` - Handle to a document. Returned by [PdfiumLibraryBindings::FPDF_LoadDocument].
896 ///
897 /// Returns a 32-bit integer indicating permission flags. Please refer to the PDF Reference
898 /// for detailed descriptions. If the document is not protected, `0xffffffff` will be returned.
899 /// Always returns user permissions, even if the document was unlocked by the owner.
900 #[allow(non_snake_case)]
901 fn FPDF_GetDocUserPermissions(&self, document: FPDF_DOCUMENT) -> c_ulong;
902
903 /// Gets the revision for the security handler.
904 ///
905 /// `document` - Handle to a document. Returned by [PdfiumLibraryBindings::FPDF_LoadDocument].
906 ///
907 /// Returns the security handler revision number. Please refer to the PDF Reference
908 /// for a detailed description. If the document is not protected, `-1` will be returned.
909 #[allow(non_snake_case)]
910 fn FPDF_GetSecurityHandlerRevision(&self, document: FPDF_DOCUMENT) -> c_int;
911
912 /// Gets the total number of pages in the document.
913 ///
914 /// `document` - Handle to a document. Returned by [PdfiumLibraryBindings::FPDF_LoadDocument].
915 ///
916 /// Returns the total number of pages in the document."]
917 #[allow(non_snake_case)]
918 fn FPDF_GetPageCount(&self, document: FPDF_DOCUMENT) -> c_int;
919
920 /// Loads a page inside the document.
921 ///
922 /// `document` - Handle to a document. Returned by [PdfiumLibraryBindings::FPDF_LoadDocument].
923 ///
924 /// `page_index` - Index number of the page. `0` for the first page.
925 ///
926 /// Returns a handle to the loaded page, or `NULL` if page load fails.
927 ///
928 /// The loaded page can be rendered to devices using [PdfiumLibraryBindings::FPDF_RenderPage].
929 /// The loaded page can be closed using [PdfiumLibraryBindings::FPDF_ClosePage].
930 #[allow(non_snake_case)]
931 fn FPDF_LoadPage(&self, document: FPDF_DOCUMENT, page_index: c_int) -> FPDF_PAGE;
932
933 /// Starts rendering page contents to a device independent bitmap progressively with a
934 /// specified color scheme for the content.
935 ///
936 /// `bitmap` - Handle to the device independent bitmap (as the
937 /// output buffer). Bitmap handle can be created by
938 /// [PdfiumLibraryBindings::FPDFBitmap_Create] function.
939 ///
940 /// `page` - Handle to the page as returned by [PdfiumLibraryBindings::FPDF_LoadPage]
941 /// function.
942 ///
943 /// `start_x` - Left pixel position of the display area in the bitmap coordinate.
944 ///
945 /// `start_y` - Top pixel position of the display area in the bitmap coordinate.
946 ///
947 /// `size_x` - Horizontal size (in pixels) for displaying the page.
948 ///
949 /// `size_y` - Vertical size (in pixels) for displaying the page.
950 ///
951 /// `rotate` - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
952 /// 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
953 ///
954 /// `flags` - 0 for normal display, or combination of flags defined in `fpdfview.h`.
955 /// With `FPDF_ANNOT` flag, it renders all annotations that does not require
956 /// user-interaction, which are all annotations except widget and popup
957 /// annotations.
958 ///
959 /// `color_scheme` - Color scheme to be used in rendering the `page`.
960 /// If `NULL`, this function will work similar to [PdfiumLibraryBindings::FPDF_RenderPageBitmap_Start].
961 ///
962 /// `pause` - The `IFSDK_PAUSE` interface, a callback mechanism allowing the
963 /// page progressive rendering process to be paused.
964 ///
965 /// Returns the rendering status. See flags for progressive process status for details.
966 #[allow(non_snake_case)]
967 fn FPDF_RenderPageBitmapWithColorScheme_Start(
968 &self,
969 bitmap: FPDF_BITMAP,
970 page: FPDF_PAGE,
971 start_x: c_int,
972 start_y: c_int,
973 size_x: c_int,
974 size_y: c_int,
975 rotate: c_int,
976 flags: c_int,
977 color_scheme: *const FPDF_COLORSCHEME,
978 pause: *mut IFSDK_PAUSE,
979 ) -> c_int;
980
981 /// Starts rendering page contents to a device independent bitmap progressively.
982 ///
983 /// `bitmap` - Handle to the device independent bitmap (as the
984 /// output buffer). Bitmap handle can be created by
985 /// [PdfiumLibraryBindings::FPDFBitmap_Create].
986 ///
987 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
988 ///
989 /// `start_x` - Left pixel position of the display area in the
990 /// bitmap coordinates.
991 ///
992 /// `start_y` - Top pixel position of the display area in the bitmap coordinates.
993 ///
994 /// `size_x` - Horizontal size (in pixels) for displaying the page.
995 ///
996 /// `size_y` - Vertical size (in pixels) for displaying the page.
997 ///
998 /// `rotate` - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),
999 /// 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
1000 ///
1001 /// `flags` - 0 for normal display, or combination of flags defined in `fpdfview.h`.
1002 /// With `FPDF_ANNOT` flag, it renders all annotations that does not require
1003 /// user-interaction, which are all annotations except widget and popup annotations.
1004 ///
1005 /// `pause` - The `IFSDK_PAUSE` interface, a callback mechanism allowing the
1006 /// page rendering process to be paused.
1007 ///
1008 /// Returns the rendering status. See flags for progressive process status for details.
1009 #[allow(non_snake_case)]
1010 fn FPDF_RenderPageBitmap_Start(
1011 &self,
1012 bitmap: FPDF_BITMAP,
1013 page: FPDF_PAGE,
1014 start_x: c_int,
1015 start_y: c_int,
1016 size_x: c_int,
1017 size_y: c_int,
1018 rotate: c_int,
1019 flags: c_int,
1020 pause: *mut IFSDK_PAUSE,
1021 ) -> c_int;
1022
1023 /// Continues rendering a PDF page.
1024 ///
1025 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage()].
1026 ///
1027 /// `pause` - The `IFSDK_PAUSE` interface, a callback mechanism allowing
1028 /// the page rendering process to be paused before it's finished.
1029 /// This can be `NULL` if you don't want to pause.
1030 ///
1031 /// Returns the rendering status. See flags for progressive process status for details.
1032 #[allow(non_snake_case)]
1033 fn FPDF_RenderPage_Continue(&self, page: FPDF_PAGE, pause: *mut IFSDK_PAUSE) -> c_int;
1034
1035 /// Releases the resource allocate during page rendering. Needs to be called after finishing
1036 /// rendering or after cancelling the rendering.
1037 ///
1038 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage()].
1039 #[allow(non_snake_case)]
1040 fn FPDF_RenderPage_Close(&self, page: FPDF_PAGE);
1041
1042 /// Imports pages into a `FPDF_DOCUMENT`.
1043 ///
1044 /// `dest_doc` - The destination document for the pages.
1045 ///
1046 /// `src_doc` - The document to be imported.
1047 ///
1048 /// `page_indices` - An array of page indices to be imported. The first page index is
1049 /// zero. If `page_indices` is `NULL`, all pages from `src_doc`
1050 /// are imported.
1051 ///
1052 /// `length` - The length of the `page_indices` array.
1053 ///
1054 /// `index` - The page index at which to insert the first imported page
1055 /// into `dest_doc`. The first page index is zero.
1056 ///
1057 /// Returns `true` on success. Returns `false` if any pages in `page_indices` are invalid.
1058 ///
1059 /// A [vec]-friendly helper function is available for this function.
1060 /// See [PdfiumLibraryBindings::FPDF_ImportPagesByIndex_vec].
1061 #[allow(non_snake_case)]
1062 fn FPDF_ImportPagesByIndex(
1063 &self,
1064 dest_doc: FPDF_DOCUMENT,
1065 src_doc: FPDF_DOCUMENT,
1066 page_indices: *const c_int,
1067 length: c_ulong,
1068 index: c_int,
1069 ) -> FPDF_BOOL;
1070
1071 /// A [vec]-friendly helper function for [PdfiumLibraryBindings::FPDF_ImportPagesByIndex].
1072 ///
1073 /// Imports pages into a `FPDF_DOCUMENT`.
1074 ///
1075 /// `dest_doc` - The destination document for the pages.
1076 ///
1077 /// `src_doc` - The document to be imported.
1078 ///
1079 /// `page_indices` - A [vec] of page indices to be imported. The first page index is zero.
1080 ///
1081 /// `index` - The page index at which to insert the first imported page
1082 /// into `dest_doc`. The first page index is zero.
1083 ///
1084 /// Returns `true` on success. Returns `false` if any pages in `page_indices` are invalid.
1085 #[inline]
1086 #[allow(non_snake_case)]
1087 fn FPDF_ImportPagesByIndex_vec(
1088 &self,
1089 dest_doc: FPDF_DOCUMENT,
1090 src_doc: FPDF_DOCUMENT,
1091 page_indices: Vec<c_int>,
1092 index: c_int,
1093 ) -> FPDF_BOOL {
1094 self.FPDF_ImportPagesByIndex(
1095 dest_doc,
1096 src_doc,
1097 page_indices.as_ptr(),
1098 page_indices.len() as c_ulong,
1099 index,
1100 )
1101 }
1102
1103 /// Imports pages into a `FPDF_DOCUMENT`.
1104 ///
1105 /// `dest_doc` - The destination document for the pages.
1106 ///
1107 /// `src_doc` - The document to be imported.
1108 ///
1109 /// `pagerange` - A page range string, such as "1,3,5-7". The first page index is one.
1110 /// If `pagerange` is `NULL`, all pages from `src_doc` are imported.
1111 ///
1112 /// `index` - The page index at which to insert the first imported page into
1113 /// `dest_doc`. The first page index is zero.
1114 ///
1115 /// Returns `true` on success. Returns `false` if any pages in `pagerange` is invalid
1116 /// or if `pagerange` cannot be read.
1117 #[allow(non_snake_case)]
1118 fn FPDF_ImportPages(
1119 &self,
1120 dest_doc: FPDF_DOCUMENT,
1121 src_doc: FPDF_DOCUMENT,
1122 pagerange: &str,
1123 index: c_int,
1124 ) -> FPDF_BOOL;
1125
1126 /// Creates a new document from `src_doc`. The pages of `src_doc` will be combined to provide
1127 /// `num_pages_on_x_axis`, `num_pages_on_y_axis` pages per `output_doc` page.
1128 ///
1129 /// `src_doc` - The document to be imported.
1130 ///
1131 /// `output_width` - The output page width in PDF "user space" units.
1132 ///
1133 /// `output_height` - The output page height in PDF "user space" units.
1134 ///
1135 /// `num_pages_on_x_axis` - The number of pages on X Axis.
1136 ///
1137 /// `num_pages_on_y_axis` - The number of pages on Y Axis.
1138 ///
1139 /// Returns a handle to the created document, or `NULL` on failure.
1140 ///
1141 /// The total number of pages per page = num_pages_on_x_axis * num_pages_on_y_axis.
1142 #[allow(non_snake_case)]
1143 fn FPDF_ImportNPagesToOne(
1144 &self,
1145 src_doc: FPDF_DOCUMENT,
1146 output_width: c_float,
1147 output_height: c_float,
1148 num_pages_on_x_axis: size_t,
1149 num_pages_on_y_axis: size_t,
1150 ) -> FPDF_DOCUMENT;
1151
1152 /// Creates a template to generate form xobjects from `src_doc`'s page at `src_page_index`,
1153 /// for use in `dest_doc`.
1154 ///
1155 /// Returns a handle on success, or `NULL` on failure. Caller owns the newly created object.
1156 #[allow(non_snake_case)]
1157 fn FPDF_NewXObjectFromPage(
1158 &self,
1159 dest_doc: FPDF_DOCUMENT,
1160 src_doc: FPDF_DOCUMENT,
1161 src_page_index: c_int,
1162 ) -> FPDF_XOBJECT;
1163
1164 /// Closes an `FPDF_XOBJECT` handle created by [PdfiumLibraryBindings::FPDF_NewXObjectFromPage].
1165 /// `FPDF_PAGEOBJECT`s created from the `FPDF_XOBJECT` handle are not affected.
1166 #[allow(non_snake_case)]
1167 fn FPDF_CloseXObject(&self, xobject: FPDF_XOBJECT);
1168
1169 /// Creates a new form object from an `FPDF_XOBJECT` object.
1170 ///
1171 /// Returns a new form object on success, or `NULL` on failure. Caller owns the newly created object.
1172 #[allow(non_snake_case)]
1173 fn FPDF_NewFormObjectFromXObject(&self, xobject: FPDF_XOBJECT) -> FPDF_PAGEOBJECT;
1174
1175 /// Copies the viewer preferences from `src_doc` into `dest_doc`.
1176 ///
1177 /// `dest_doc` - Document to write the viewer preferences into.
1178 ///
1179 /// `src_doc` - Document to read the viewer preferences from.
1180 ///
1181 /// Returns `true` on success.
1182 #[allow(non_snake_case)]
1183 fn FPDF_CopyViewerPreferences(
1184 &self,
1185 dest_doc: FPDF_DOCUMENT,
1186 src_doc: FPDF_DOCUMENT,
1187 ) -> FPDF_BOOL;
1188
1189 /// Gets page width.
1190 ///
1191 /// `page` - Handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
1192 ///
1193 /// Returns the page width (excluding non-displayable area) measured in points.
1194 /// One point is 1/72 inch (around 0.3528 mm).
1195 ///
1196 /// Note that changing the rotation of the page affects the return value.
1197 #[allow(non_snake_case)]
1198 fn FPDF_GetPageWidthF(&self, page: FPDF_PAGE) -> c_float;
1199
1200 /// Gets page width.
1201 ///
1202 /// `page` - Handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
1203 ///
1204 /// Returns the page width (excluding non-displayable area) measured in points.
1205 /// One point is 1/72 inch (around 0.3528 mm).
1206 ///
1207 /// Note: prefer the [PdfiumLibraryBindings::FPDF_GetPageWidthF] function above.
1208 /// This function will be deprecated in the future.
1209 ///
1210 /// Note that changing the rotation of the page affects the return value.
1211 #[deprecated(
1212 since = "0.8.25",
1213 note = "Prefer FPDF_GetPageWidthF() over FPDF_GetPageWidth(). FPDF_GetPageWidth() is deprecated and will likely be removed in a future version of Pdfium."
1214 )]
1215 #[allow(non_snake_case)]
1216 fn FPDF_GetPageWidth(&self, page: FPDF_PAGE) -> f64;
1217
1218 /// Gets page height.
1219 ///
1220 /// `page` - Handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
1221 ///
1222 /// Returns the page height (excluding non-displayable area) measured in points.
1223 /// One point is 1/72 inch (around 0.3528 mm).
1224 ///
1225 /// Note that changing the rotation of the page affects the return value.
1226 #[allow(non_snake_case)]
1227 fn FPDF_GetPageHeightF(&self, page: FPDF_PAGE) -> c_float;
1228
1229 /// Gets page height.
1230 ///
1231 /// `page` - Handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
1232 ///
1233 /// Returns the page height (excluding non-displayable area) measured in points.
1234 /// One point is 1/72 inch (around 0.3528 mm).
1235 ///
1236 /// Note: prefer the [PdfiumLibraryBindings::FPDF_GetPageHeightF] function above.
1237 /// This function will be deprecated in the future.
1238 ///
1239 /// Note that changing the rotation of the page affects the return value.
1240 #[deprecated(
1241 since = "0.8.25",
1242 note = "Prefer FPDF_GetPageHeightF() over FPDF_GetPageHeight(). FPDF_GetPageHeight() is deprecated and will likely be removed in a future version of Pdfium."
1243 )]
1244 #[allow(non_snake_case)]
1245 fn FPDF_GetPageHeight(&self, page: FPDF_PAGE) -> f64;
1246
1247 /// Gets the character index in the `text_page` internal character list.
1248 ///
1249 /// `text_page` - a text page information structure.
1250 ///
1251 /// `nTextIndex` - index of the text returned from [PdfiumLibraryBindings::FPDFText_GetText].
1252 ///
1253 /// Returns the index of the character in the internal character list, or `-1` for error.
1254 #[allow(non_snake_case)]
1255 fn FPDFText_GetCharIndexFromTextIndex(
1256 &self,
1257 text_page: FPDF_TEXTPAGE,
1258 nTextIndex: c_int,
1259 ) -> c_int;
1260
1261 /// Gets the text index in the `text_page` internal character list.
1262 ///
1263 /// `text_page` - a text page information structure.
1264 ///
1265 /// `nCharIndex` - index of the character in internal character list.
1266 ///
1267 /// Returns the index of the text returned from [PdfiumLibraryBindings::FPDFText_GetText],
1268 /// or `-1` for error.
1269 #[allow(non_snake_case)]
1270 fn FPDFText_GetTextIndexFromCharIndex(
1271 &self,
1272 text_page: FPDF_TEXTPAGE,
1273 nCharIndex: c_int,
1274 ) -> c_int;
1275
1276 /// Gets the total number of signatures in the document.
1277 ///
1278 /// `document` - Handle to document. Returned by [PdfiumLibraryBindings::FPDF_LoadDocument].
1279 ///
1280 /// Returns the total number of signatures in the document on success, or `-1` on error.
1281 #[allow(non_snake_case)]
1282 fn FPDF_GetSignatureCount(&self, document: FPDF_DOCUMENT) -> c_int;
1283
1284 /// Gets the nth signature in the document.
1285 ///
1286 /// `document` - Handle to document. Returned by [PdfiumLibraryBindings::FPDF_LoadDocument].
1287 ///
1288 /// `index` - Index into the array of signatures of the document.
1289 ///
1290 /// Returns the handle to the signature, or `NULL` on failure. The caller
1291 /// does not take ownership of the returned `FPDF_SIGNATURE`. Instead, it
1292 /// remains valid until [PdfiumLibraryBindings::FPDF_CloseDocument] is called for the document.
1293 #[allow(non_snake_case)]
1294 fn FPDF_GetSignatureObject(&self, document: FPDF_DOCUMENT, index: c_int) -> FPDF_SIGNATURE;
1295
1296 /// Gets the contents of a signature object.
1297 ///
1298 /// `signature` - Handle to the signature object. Returned by
1299 /// [PdfiumLibraryBindings::FPDF_GetSignatureObject].
1300 ///
1301 /// `buffer` - The address of a buffer that receives the contents.
1302 ///
1303 /// `length` - The size, in bytes, of `buffer`.
1304 ///
1305 /// Returns the number of bytes in the contents on success, or `0` on error.
1306 /// For public-key signatures, `buffer` is either a DER-encoded PKCS#1 binary or
1307 /// a DER-encoded PKCS#7 binary. If `length` is less than the returned length, or
1308 /// `buffer` is `NULL`, `buffer` will not be modified.
1309 #[allow(non_snake_case)]
1310 fn FPDFSignatureObj_GetContents(
1311 &self,
1312 signature: FPDF_SIGNATURE,
1313 buffer: *mut c_void,
1314 length: c_ulong,
1315 ) -> c_ulong;
1316
1317 /// Gets the byte range of a signature object.
1318 ///
1319 /// `signature` - Handle to the signature object. Returned by
1320 /// [PdfiumLibraryBindings::FPDF_GetSignatureObject].
1321 ///
1322 /// `buffer` - The address of a buffer that receives the byte range.
1323 ///
1324 /// `length` - The size, in `int`s, of `buffer`.
1325 ///
1326 /// Returns the number of `int`s in the byte range on success, or `0` on error.
1327 /// `buffer` is an array of pairs of integers (starting byte offset, length in bytes)
1328 /// that describes the exact byte range for the digest calculation. If `length` is
1329 /// less than the returned length, or `buffer` is `NULL`, `buffer` will not be modified.
1330 #[allow(non_snake_case)]
1331 fn FPDFSignatureObj_GetByteRange(
1332 &self,
1333 signature: FPDF_SIGNATURE,
1334 buffer: *mut c_int,
1335 length: c_ulong,
1336 ) -> c_ulong;
1337
1338 /// Gets the encoding of the value of a signature object.
1339 ///
1340 /// `signature` - Handle to the signature object. Returned by
1341 /// [PdfiumLibraryBindings::FPDF_GetSignatureObject].
1342 ///
1343 /// `buffer` - The address of a buffer that receives the encoding.
1344 ///
1345 /// `length` - The size, in bytes, of `buffer`.
1346 ///
1347 /// Returns the number of bytes in the encoding name (including the trailing `NUL` character)
1348 /// on success, or `0` on error. The `buffer` is always encoded in 7-bit ASCII.
1349 /// If `length` is less than the returned length, or `buffer` is `NULL`, `buffer` will
1350 // not be modified.
1351 #[allow(non_snake_case)]
1352 fn FPDFSignatureObj_GetSubFilter(
1353 &self,
1354 signature: FPDF_SIGNATURE,
1355 buffer: *mut c_char,
1356 length: c_ulong,
1357 ) -> c_ulong;
1358
1359 /// Gets the reason (comment) of the signature object.
1360 ///
1361 /// `signature` - Handle to the signature object. Returned by
1362 /// [PdfiumLibraryBindings::FPDF_GetSignatureObject].
1363 ///
1364 /// `buffer` - The address of a buffer that receives the reason.
1365 ///
1366 /// `length` - The size, in bytes, of `buffer`.
1367 ///
1368 /// Returns the number of bytes in the reason on success, or `0` on error.
1369 /// Regardless of the platform, the `buffer` is always in UTF-16LE encoding. The
1370 /// string is terminated by a UTF16 `NUL` character. If `length` is less than the
1371 /// returned length, or `buffer` is `NULL`, `buffer` will not be modified.
1372 #[allow(non_snake_case)]
1373 fn FPDFSignatureObj_GetReason(
1374 &self,
1375 signature: FPDF_SIGNATURE,
1376 buffer: *mut c_void,
1377 length: c_ulong,
1378 ) -> c_ulong;
1379
1380 /// Gets the time of signing of a signature object.
1381 ///
1382 /// `signature` - Handle to the signature object. Returned by
1383 /// [PdfiumLibraryBindings::FPDF_GetSignatureObject].
1384 ///
1385 /// `buffer` - The address of a buffer that receives the time.
1386 ///
1387 /// `length` - The size, in bytes, of `buffer`.
1388 ///
1389 /// Returns the number of bytes in the encoding name (including the
1390 /// trailing `NUL` character) on success, or `0` on error.
1391 /// The `buffer` is always encoded in 7-bit ASCII. If `length` is less than the
1392 /// returned length, or `buffer` is `NULL`, `buffer` will not be modified.
1393 /// The format of time is expected to be `D:YYYYMMDDHHMMSS+XX'YY'`, i.e. its
1394 /// precision is seconds, with timezone information. This value should be used
1395 /// only when the time of signing is not available in the PKCS#7 binary signature.
1396 #[allow(non_snake_case)]
1397 fn FPDFSignatureObj_GetTime(
1398 &self,
1399 signature: FPDF_SIGNATURE,
1400 buffer: *mut c_char,
1401 length: c_ulong,
1402 ) -> c_ulong;
1403
1404 /// Gets the DocMDP (modification detection and prevention) permission of a signature object.
1405 ///
1406 /// `signature` - Handle to the signature object. Returned by
1407 /// [PdfiumLibraryBindings::FPDF_GetSignatureObject].
1408 ///
1409 /// Returns the permission (`1`, `2`, or `3`) on success, or `0` on error.
1410 ///
1411 /// `1` - No changes to the document are permitted; any change
1412 /// to the document invalidates the signature.
1413 ///
1414 /// `2` - Permitted changes are filling in forms, instantiating page
1415 /// templates, and signing; other changes invalidate the signature.
1416 ///
1417 /// `3` - Permitted changes are the same as for level 2, as well as
1418 /// annotation creation, deletion, and modification; other changes
1419 /// invalidate the signature.
1420 #[allow(non_snake_case)]
1421 fn FPDFSignatureObj_GetDocMDPPermission(&self, signature: FPDF_SIGNATURE) -> c_uint;
1422
1423 /// Gets the structure tree for a page.
1424 ///
1425 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
1426 ///
1427 /// Return value: a handle to the structure tree, or `NULL` on error. The caller owns the
1428 /// returned handle and must use [PdfiumLibraryBindings::FPDF_StructTree_Close] to release it.
1429 ///
1430 /// The handle should be released before `page` is released.
1431 #[allow(non_snake_case)]
1432 fn FPDF_StructTree_GetForPage(&self, page: FPDF_PAGE) -> FPDF_STRUCTTREE;
1433
1434 /// Releases a resource allocated by [PdfiumLibraryBindings::FPDF_StructTree_GetForPage].
1435 ///
1436 /// `struct_tree` - Handle to the structure tree, as returned by
1437 /// [PdfiumLibraryBindings::FPDF_StructTree_GetForPage].
1438 #[allow(non_snake_case)]
1439 fn FPDF_StructTree_Close(&self, struct_tree: FPDF_STRUCTTREE);
1440
1441 /// Counts the number of children for the structure tree.
1442 ///
1443 /// `struct_tree` - Handle to the structure tree, as returned by
1444 /// [PdfiumLibraryBindings::FPDF_StructTree_GetForPage].
1445 ///
1446 /// Return value: the number of children, or -1 on error.
1447 #[allow(non_snake_case)]
1448 fn FPDF_StructTree_CountChildren(&self, struct_tree: FPDF_STRUCTTREE) -> c_int;
1449
1450 /// Gets a child in the structure tree.
1451 ///
1452 /// `struct_tree` - Handle to the structure tree, as returned by
1453 /// [PdfiumLibraryBindings::FPDF_StructTree_GetForPage].
1454 ///
1455 /// `index` - The index for the child, 0-based.
1456 ///
1457 /// Return value: the child at the n-th index or `NULL` on error. The caller does not
1458 /// own the handle. The handle remains valid as long as `struct_tree` remains valid.
1459 ///
1460 /// The `index` must be less than the [PdfiumLibraryBindings::FPDF_StructTree_CountChildren] return value.
1461 #[allow(non_snake_case)]
1462 fn FPDF_StructTree_GetChildAtIndex(
1463 &self,
1464 struct_tree: FPDF_STRUCTTREE,
1465 index: c_int,
1466 ) -> FPDF_STRUCTELEMENT;
1467
1468 /// Gets the alt text for a given element.
1469 ///
1470 /// `struct_element` - Handle to the struct element.
1471 ///
1472 /// `buffer` - A buffer for output the alt text. May be `NULL`.
1473 ///
1474 /// `buflen` - The length of the buffer, in bytes. May be 0.
1475 ///
1476 /// Returns the number of bytes in the alt text, including the terminating `NUL` character.
1477 /// The number of bytes is returned regardless of the `buffer` and `buflen` parameters.
1478 ///
1479 /// Regardless of the platform, the `buffer` is always in UTF-16LE encoding.
1480 /// The string is terminated by a UTF16 `NUL` character. If `buflen` is less than the
1481 /// required length, or `buffer` is `NULL`, `buffer` will not be modified.
1482 #[allow(non_snake_case)]
1483 fn FPDF_StructElement_GetAltText(
1484 &self,
1485 struct_element: FPDF_STRUCTELEMENT,
1486 buffer: *mut c_void,
1487 buflen: c_ulong,
1488 ) -> c_ulong;
1489
1490 /// Gets the actual text for a given element.
1491 ///
1492 /// `struct_element` - Handle to the struct element.
1493 ///
1494 /// `buffer` - A buffer for output the actual text. May be `NULL`.
1495 ///
1496 /// `buflen` - The length of the buffer, in bytes. May be 0.
1497 ///
1498 /// Returns the number of bytes in the actual text, including the terminating `NUL` character.
1499 /// The number of bytes is returned regardless of the `buffer` and `buflen` parameters.
1500 ///
1501 /// Regardless of the platform, the `buffer` is always in UTF-16LE encoding.
1502 /// The string is terminated by a UTF16 `NUL` character. If `buflen` is less than the
1503 /// required length, or `buffer` is `NULL`, `buffer` will not be modified.
1504 #[allow(non_snake_case)]
1505 fn FPDF_StructElement_GetActualText(
1506 &self,
1507 struct_element: FPDF_STRUCTELEMENT,
1508 buffer: *mut c_void,
1509 buflen: c_ulong,
1510 ) -> c_ulong;
1511
1512 /// Gets the ID for a given element.
1513 ///
1514 /// `struct_element` - Handle to the struct element.
1515 ///
1516 /// `buffer` - A buffer for output the ID string. May be `NULL`.
1517 ///
1518 /// `buflen` - The length of the buffer, in bytes. May be 0.
1519 ///
1520 /// Returns the number of bytes in the ID string, including the terminating `NUL`
1521 /// character. The number of bytes is returned regardless of the `buffer` and `buflen`
1522 /// parameters.
1523 ///
1524 /// Regardless of the platform, the `buffer` is always in UTF-16LE encoding.
1525 /// The string is terminated by a UTF16 `NUL` character. If `buflen` is less than the
1526 /// required length, or `buffer` is `NULL`, `buffer` will not be modified.
1527 #[allow(non_snake_case)]
1528 fn FPDF_StructElement_GetID(
1529 &self,
1530 struct_element: FPDF_STRUCTELEMENT,
1531 buffer: *mut c_void,
1532 buflen: c_ulong,
1533 ) -> c_ulong;
1534
1535 /// Gets the case-insensitive IETF BCP 47 language code for an element.
1536 ///
1537 /// `struct_element` - Handle to the struct element.
1538 ///
1539 /// `buffer` - A buffer for output the lang string. May be `NULL`.
1540 ///
1541 /// `buflen` - The length of the buffer, in bytes. May be 0.
1542 ///
1543 /// Returns the number of bytes in the ID string, including the terminating `NUL`
1544 /// character. The number of bytes is returned regardless of the `buffer` and `buflen`
1545 /// parameters.
1546 ///
1547 /// Regardless of the platform, the `buffer` is always in UTF-16LE encoding.
1548 /// The string is terminated by a UTF16 `NUL` character. If `buflen` is less than the
1549 /// required length, or `buffer` is `NULL`, `buffer` will not be modified.
1550 #[allow(non_snake_case)]
1551 fn FPDF_StructElement_GetLang(
1552 &self,
1553 struct_element: FPDF_STRUCTELEMENT,
1554 buffer: *mut c_void,
1555 buflen: c_ulong,
1556 ) -> c_ulong;
1557
1558 /// Gets a struct element attribute of type `name` or `string`.
1559 ///
1560 /// `struct_element` - Handle to the struct element.
1561 ///
1562 /// `attr_name` - The name of the attribute to retrieve.
1563 ///
1564 /// `buffer` - A buffer for output. May be `NULL`.
1565 ///
1566 /// `buflen` - The length of the buffer, in bytes. May be 0.
1567 ///
1568 /// Returns the number of bytes in the attribute value, including the terminating `NUL`
1569 /// character. The number of bytes is returned regardless of the `buffer` and `buflen`
1570 /// parameters.
1571 ///
1572 /// Regardless of the platform, the `buffer` is always in UTF-16LE encoding.
1573 /// The string is terminated by a UTF16 `NUL` character. If `buflen` is less than the
1574 /// required length, or `buffer` is `NULL`, `buffer` will not be modified.
1575 #[allow(non_snake_case)]
1576 fn FPDF_StructElement_GetStringAttribute(
1577 &self,
1578 struct_element: FPDF_STRUCTELEMENT,
1579 attr_name: &str,
1580 buffer: *mut c_void,
1581 buflen: c_ulong,
1582 ) -> c_ulong;
1583
1584 /// Gets the marked content ID for a given element.
1585 ///
1586 /// `struct_element` - Handle to the struct element.
1587 ///
1588 /// Returns the marked content ID of the element. If no ID exists, returns 1.
1589 ///
1590 /// [PdfiumLibraryBindings::FPDF_StructElement_GetMarkedContentIdAtIndex] may be able to
1591 /// extract more marked content IDs out of `struct_element`. This API may be deprecated
1592 /// in the future.
1593 #[allow(non_snake_case)]
1594 fn FPDF_StructElement_GetMarkedContentID(&self, struct_element: FPDF_STRUCTELEMENT) -> c_int;
1595
1596 /// Gets the type (/S) for a given element.
1597 ///
1598 /// `struct_element` - Handle to the struct element.
1599 ///
1600 /// `buffer` - A buffer for output. May be `NULL`.
1601 ///
1602 /// `buflen` - The length of the buffer, in bytes. May be 0.
1603 ///
1604 /// Returns the number of bytes in the type, including the terminating `NUL`
1605 /// character. The number of bytes is returned regardless of the `buffer` and `buflen`
1606 /// parameters.
1607 ///
1608 /// Regardless of the platform, the `buffer` is always in UTF-16LE encoding.
1609 /// The string is terminated by a UTF16 `NUL` character. If `buflen` is less than the
1610 /// required length, or `buffer` is `NULL`, `buffer` will not be modified.
1611 #[allow(non_snake_case)]
1612 fn FPDF_StructElement_GetType(
1613 &self,
1614 struct_element: FPDF_STRUCTELEMENT,
1615 buffer: *mut c_void,
1616 buflen: c_ulong,
1617 ) -> c_ulong;
1618
1619 /// Gets the object type (/Type) for a given element.
1620 ///
1621 /// `struct_element` - Handle to the struct element.
1622 ///
1623 /// `buffer` - A buffer for output. May be `NULL`.
1624 ///
1625 /// `buflen` - The length of the buffer, in bytes. May be 0.
1626 ///
1627 /// Returns the number of bytes in the object type, including the terminating `NUL`
1628 /// character. The number of bytes is returned regardless of the `buffer` and `buflen`
1629 /// parameters.
1630 ///
1631 /// Regardless of the platform, the `buffer` is always in UTF-16LE encoding.
1632 /// The string is terminated by a UTF16 `NUL` character. If `buflen` is less than the
1633 /// required length, or `buffer` is `NULL`, `buffer` will not be modified.
1634 #[allow(non_snake_case)]
1635 fn FPDF_StructElement_GetObjType(
1636 &self,
1637 struct_element: FPDF_STRUCTELEMENT,
1638 buffer: *mut c_void,
1639 buflen: c_ulong,
1640 ) -> c_ulong;
1641
1642 /// Gets the title (/T) for a given element.
1643 ///
1644 /// `struct_element` - Handle to the struct element.
1645 ///
1646 /// `buffer` - A buffer for output. May be `NULL`.
1647 ///
1648 /// `buflen` - The length of the buffer, in bytes. May be 0.
1649 ///
1650 /// Returns the number of bytes in the title, including the terminating `NUL` character.
1651 /// The number of bytes is returned regardless of the `buffer` and `buflen` parameters.
1652 ///
1653 /// Regardless of the platform, the `buffer` is always in UTF-16LE encoding.
1654 /// The string is terminated by a UTF16 `NUL` character. If `buflen` is less than the
1655 /// required length, or `buffer` is `NULL`, `buffer` will not be modified.
1656 #[allow(non_snake_case)]
1657 fn FPDF_StructElement_GetTitle(
1658 &self,
1659 struct_element: FPDF_STRUCTELEMENT,
1660 buffer: *mut c_void,
1661 buflen: c_ulong,
1662 ) -> c_ulong;
1663
1664 /// Counts the number of children for the structure element.
1665 ///
1666 /// `struct_element` - Handle to the struct element.
1667 ///
1668 /// Returns the number of children, or -1 on error.
1669 #[allow(non_snake_case)]
1670 fn FPDF_StructElement_CountChildren(&self, struct_element: FPDF_STRUCTELEMENT) -> c_int;
1671
1672 /// Gets a child in the structure element.
1673 ///
1674 /// `struct_element` - Handle to the struct element.
1675 ///
1676 /// `index` - The index for the child, 0-based.
1677 ///
1678 /// Returns the child at the n-th index, or `NULL` on error.
1679 ///
1680 /// If the child exists but is not an element, then this function will return `NULL`.
1681 /// This will also return `NULL` for out-of-bounds indices.
1682 ///
1683 /// The `index` must be less than the [PdfiumLibraryBindings::FPDF_StructElement_CountChildren]
1684 /// return value.
1685 #[allow(non_snake_case)]
1686 fn FPDF_StructElement_GetChildAtIndex(
1687 &self,
1688 struct_element: FPDF_STRUCTELEMENT,
1689 index: c_int,
1690 ) -> FPDF_STRUCTELEMENT;
1691
1692 #[cfg(any(
1693 feature = "pdfium_future",
1694 feature = "pdfium_7350",
1695 feature = "pdfium_7215",
1696 feature = "pdfium_7123",
1697 feature = "pdfium_6996",
1698 feature = "pdfium_6721",
1699 feature = "pdfium_6666",
1700 feature = "pdfium_6611",
1701 feature = "pdfium_6569",
1702 feature = "pdfium_6555",
1703 feature = "pdfium_6490",
1704 feature = "pdfium_6406",
1705 feature = "pdfium_6337",
1706 feature = "pdfium_6295",
1707 feature = "pdfium_6259",
1708 feature = "pdfium_6164",
1709 feature = "pdfium_6124",
1710 feature = "pdfium_6110",
1711 feature = "pdfium_6084",
1712 ))]
1713 /// Gets the child's content id.
1714 ///
1715 /// `struct_element` - Handle to the struct element.
1716 ///
1717 /// `index` - The index for the child, 0-based.
1718 ///
1719 /// Returns the marked content ID of the child. If no ID exists, returns -1.
1720 ///
1721 /// If the child exists but is not a stream or object, then this function will return -1.
1722 /// This will also return -1 for out of bounds indices. Compared to
1723 /// [PdfiumLibraryBindings::FPDF_StructElement_GetMarkedContentIdAtIndex],
1724 /// it is scoped to the current page.
1725 ///
1726 /// The `index` must be less than the [PdfiumLibraryBindings::FPDF_StructElement_CountChildren]
1727 /// return value.
1728 #[allow(non_snake_case)]
1729 fn FPDF_StructElement_GetChildMarkedContentID(
1730 &self,
1731 struct_element: FPDF_STRUCTELEMENT,
1732 index: c_int,
1733 ) -> c_int;
1734
1735 /// Gets the parent of the structure element.
1736 ///
1737 /// `struct_element` - Handle to the struct element.
1738 ///
1739 /// Returns the parent structure element, or `NULL` on error.
1740 ///
1741 /// If structure element is StructTreeRoot, then this function will return `NULL`.
1742 #[allow(non_snake_case)]
1743 fn FPDF_StructElement_GetParent(
1744 &self,
1745 struct_element: FPDF_STRUCTELEMENT,
1746 ) -> FPDF_STRUCTELEMENT;
1747
1748 /// Counts the number of attributes for the structure element.
1749 ///
1750 /// `struct_element` - Handle to the struct element.
1751 ///
1752 /// Returns the number of attributes, or -1 on error.
1753 #[allow(non_snake_case)]
1754 fn FPDF_StructElement_GetAttributeCount(&self, struct_element: FPDF_STRUCTELEMENT) -> c_int;
1755
1756 /// Gets an attribute object in the structure element.
1757 ///
1758 /// `struct_element` - Handle to the struct element.
1759 ///
1760 /// `index` - The index for the attribute object, 0-based.
1761 ///
1762 /// Returns the attribute object at the n-th index, or `NULL` on error.
1763 ///
1764 /// If the attribute object exists but is not a dict, then this function will return `NULL`.
1765 /// This will also return `NULL` for out-of-bounds indices. The caller does not own the handle.
1766 /// The handle remains valid as long as `struct_element` remains valid.
1767 ///
1768 /// The `index` must be less than the [PdfiumLibraryBindings::FPDF_StructElement_GetAttributeCount]
1769 /// return value.
1770 #[allow(non_snake_case)]
1771 fn FPDF_StructElement_GetAttributeAtIndex(
1772 &self,
1773 struct_element: FPDF_STRUCTELEMENT,
1774 index: c_int,
1775 ) -> FPDF_STRUCTELEMENT_ATTR;
1776
1777 /// Counts the number of attributes in a structure element attribute map.
1778 ///
1779 /// `struct_attribute` - Handle to the struct element attribute.
1780 ///
1781 /// Returns the number of attributes, or -1 on error.
1782 #[allow(non_snake_case)]
1783 fn FPDF_StructElement_Attr_GetCount(&self, struct_attribute: FPDF_STRUCTELEMENT_ATTR) -> c_int;
1784
1785 /// Gets the name of an attribute in a structure element attribute map.
1786 ///
1787 /// `struct_attribute` - Handle to the struct element attribute.
1788 ///
1789 /// `index` - The index of attribute in the map.
1790 ///
1791 /// `buffer` - A buffer for output. May be `NULL`. This is only
1792 /// modified if `buflen` is longer than the length
1793 /// of the key. Optional, pass `NULL` to just
1794 /// retrieve the size of the buffer needed.
1795 ///
1796 /// `buflen` - The length of the buffer.
1797 ///
1798 /// `out_buflen` - A pointer to variable that will receive the
1799 /// minimum buffer size to contain the key. Not
1800 /// filled if `FALSE` is returned.
1801 ///
1802 /// Returns `true` if the operation was successful.
1803 #[allow(non_snake_case)]
1804 fn FPDF_StructElement_Attr_GetName(
1805 &self,
1806 struct_attribute: FPDF_STRUCTELEMENT_ATTR,
1807 index: c_int,
1808 buffer: *mut c_void,
1809 buflen: c_ulong,
1810 out_buflen: *mut c_ulong,
1811 ) -> FPDF_BOOL;
1812
1813 #[cfg(any(
1814 feature = "pdfium_future",
1815 feature = "pdfium_7350",
1816 feature = "pdfium_7215",
1817 feature = "pdfium_7123",
1818 feature = "pdfium_6996",
1819 feature = "pdfium_6721",
1820 feature = "pdfium_6666",
1821 feature = "pdfium_6611",
1822 feature = "pdfium_6569",
1823 feature = "pdfium_6555",
1824 feature = "pdfium_6490",
1825 ))]
1826 /// Gets a handle to a value for an attribute in a structure element attribute map.
1827 ///
1828 /// `struct_attribute` - Handle to the struct element attribute.
1829 ///
1830 /// `name` - The attribute name.
1831 ///
1832 /// Returns a handle to the value associated with the input, if any. Returns `NULL`
1833 /// on failure. The caller does not own the handle.
1834 ///
1835 /// The handle remains valid as long as `struct_attribute` remains valid.
1836 #[allow(non_snake_case)]
1837 fn FPDF_StructElement_Attr_GetValue(
1838 &self,
1839 struct_attribute: FPDF_STRUCTELEMENT_ATTR,
1840 name: &str,
1841 ) -> FPDF_STRUCTELEMENT_ATTR_VALUE;
1842
1843 #[cfg(any(
1844 feature = "pdfium_6406",
1845 feature = "pdfium_6337",
1846 feature = "pdfium_6295",
1847 feature = "pdfium_6259",
1848 feature = "pdfium_6164",
1849 feature = "pdfium_6124",
1850 feature = "pdfium_6110",
1851 feature = "pdfium_6084",
1852 feature = "pdfium_6043",
1853 feature = "pdfium_6015",
1854 feature = "pdfium_5961",
1855 ))]
1856 /// Gets the type of an attribute in a structure element attribute map.
1857 ///
1858 /// `struct_attribute` - Handle to the struct element attribute.
1859 ///
1860 /// `name` - The attribute name.
1861 ///
1862 /// Returns the type of the value, or `FPDF_OBJECT_UNKNOWN` in case of failure.
1863 #[allow(non_snake_case)]
1864 fn FPDF_StructElement_Attr_GetType(
1865 &self,
1866 struct_attribute: FPDF_STRUCTELEMENT_ATTR,
1867 name: &str,
1868 ) -> FPDF_OBJECT_TYPE;
1869
1870 #[cfg(any(
1871 feature = "pdfium_future",
1872 feature = "pdfium_7350",
1873 feature = "pdfium_7215",
1874 feature = "pdfium_7123",
1875 feature = "pdfium_6996",
1876 feature = "pdfium_6721",
1877 feature = "pdfium_6666",
1878 feature = "pdfium_6611",
1879 feature = "pdfium_6569",
1880 feature = "pdfium_6555",
1881 feature = "pdfium_6490",
1882 ))]
1883 /// Gets the type of an attribute in a structure element attribute map.
1884 ///
1885 /// `value` - Handle to the value.
1886 ///
1887 /// Returns the type of the value, or `FPDF_OBJECT_UNKNOWN` in case of failure. Note that
1888 /// this will never return `FPDF_OBJECT_REFERENCE`, as references are always dereferenced.
1889 #[allow(non_snake_case)]
1890 fn FPDF_StructElement_Attr_GetType(
1891 &self,
1892 value: FPDF_STRUCTELEMENT_ATTR_VALUE,
1893 ) -> FPDF_OBJECT_TYPE;
1894
1895 #[cfg(any(
1896 feature = "pdfium_6406",
1897 feature = "pdfium_6337",
1898 feature = "pdfium_6295",
1899 feature = "pdfium_6259",
1900 feature = "pdfium_6164",
1901 feature = "pdfium_6124",
1902 feature = "pdfium_6110",
1903 feature = "pdfium_6084",
1904 feature = "pdfium_6043",
1905 feature = "pdfium_6015",
1906 feature = "pdfium_5961",
1907 ))]
1908 /// Gets the value of a boolean attribute in an attribute map by name as `FPDF_BOOL`.
1909 /// [PdfiumLibraryBindings::FPDF_StructElement_Attr_GetType] should have returned
1910 /// `FPDF_OBJECT_BOOLEAN` for this property.
1911 ///
1912 /// `struct_attribute` - Handle to the struct element attribute.
1913 ///
1914 /// `name` - The attribute name.
1915 ///
1916 /// `out_value` - A pointer to variable that will receive the
1917 /// value. Not filled if `FALSE` is returned.
1918 ///
1919 /// Returns `true` if the name maps to a boolean value.
1920 #[allow(non_snake_case)]
1921 fn FPDF_StructElement_Attr_GetBooleanValue(
1922 &self,
1923 struct_attribute: FPDF_STRUCTELEMENT_ATTR,
1924 name: &str,
1925 out_value: *mut FPDF_BOOL,
1926 ) -> FPDF_BOOL;
1927
1928 #[cfg(any(
1929 feature = "pdfium_future",
1930 feature = "pdfium_7350",
1931 feature = "pdfium_7215",
1932 feature = "pdfium_7123",
1933 feature = "pdfium_6996",
1934 feature = "pdfium_6721",
1935 feature = "pdfium_6666",
1936 feature = "pdfium_6611",
1937 feature = "pdfium_6569",
1938 feature = "pdfium_6555",
1939 feature = "pdfium_6490",
1940 ))]
1941 /// Gets the value of a boolean attribute in an attribute map as `FPDF_BOOL`.
1942 /// [PdfiumLibraryBindings::FPDF_StructElement_Attr_GetType] should have returned
1943 /// `FPDF_OBJECT_BOOLEAN` for this property.
1944 ///
1945 /// `value` - Handle to the value.
1946 ///
1947 /// `out_value` - A pointer to variable that will receive the value. Not
1948 /// filled if false is returned.
1949 ///
1950 /// Returns `true` if the attribute maps to a boolean value.
1951 #[allow(non_snake_case)]
1952 fn FPDF_StructElement_Attr_GetBooleanValue(
1953 &self,
1954 value: FPDF_STRUCTELEMENT_ATTR_VALUE,
1955 out_value: *mut FPDF_BOOL,
1956 ) -> FPDF_BOOL;
1957
1958 #[cfg(any(
1959 feature = "pdfium_6406",
1960 feature = "pdfium_6337",
1961 feature = "pdfium_6295",
1962 feature = "pdfium_6259",
1963 feature = "pdfium_6164",
1964 feature = "pdfium_6124",
1965 feature = "pdfium_6110",
1966 feature = "pdfium_6084",
1967 feature = "pdfium_6043",
1968 feature = "pdfium_6015",
1969 feature = "pdfium_5961",
1970 ))]
1971 /// Gets the value of a number attribute in an attribute map by name as float.
1972 /// [PdfiumLibraryBindings::FPDF_StructElement_Attr_GetType] should have returned
1973 /// `FPDF_OBJECT_NUMBER` for this property.
1974 ///
1975 /// `struct_attribute` - Handle to the struct element attribute.
1976 ///
1977 /// `name` - The attribute name.
1978 ///
1979 /// `out_value` - A pointer to variable that will receive the
1980 /// value. Not filled if `FALSE` is returned.
1981 ///
1982 /// Returns `true` if the name maps to a number value.
1983 #[allow(non_snake_case)]
1984 fn FPDF_StructElement_Attr_GetNumberValue(
1985 &self,
1986 struct_attribute: FPDF_STRUCTELEMENT_ATTR,
1987 name: &str,
1988 out_value: *mut f32,
1989 ) -> FPDF_BOOL;
1990
1991 #[cfg(any(
1992 feature = "pdfium_future",
1993 feature = "pdfium_7350",
1994 feature = "pdfium_7215",
1995 feature = "pdfium_7123",
1996 feature = "pdfium_6996",
1997 feature = "pdfium_6721",
1998 feature = "pdfium_6666",
1999 feature = "pdfium_6611",
2000 feature = "pdfium_6569",
2001 feature = "pdfium_6555",
2002 feature = "pdfium_6490",
2003 ))]
2004 /// Gets the value of a number attribute in an attribute map as float.
2005 /// [PdfiumLibraryBindings::FPDF_StructElement_Attr_GetType] should have returned
2006 /// `FPDF_OBJECT_NUMBER` for this property.
2007 ///
2008 /// `value` - Handle to the value.
2009 ///
2010 /// `out_value` - A pointer to variable that will receive the value. Not
2011 /// filled if false is returned.
2012 ///
2013 /// Returns `true` if the attribute maps to a number value.
2014 #[allow(non_snake_case)]
2015 fn FPDF_StructElement_Attr_GetNumberValue(
2016 &self,
2017 value: FPDF_STRUCTELEMENT_ATTR_VALUE,
2018 out_value: *mut f32,
2019 ) -> FPDF_BOOL;
2020
2021 #[cfg(any(
2022 feature = "pdfium_6406",
2023 feature = "pdfium_6337",
2024 feature = "pdfium_6295",
2025 feature = "pdfium_6259",
2026 feature = "pdfium_6164",
2027 feature = "pdfium_6124",
2028 feature = "pdfium_6110",
2029 feature = "pdfium_6084",
2030 feature = "pdfium_6043",
2031 feature = "pdfium_6015",
2032 feature = "pdfium_5961",
2033 ))]
2034 /// Gets the value of a string attribute in an attribute map by name as string.
2035 /// [PdfiumLibraryBindings::FPDF_StructElement_Attr_GetType] should have returned
2036 /// `FPDF_OBJECT_STRING` or `FPDF_OBJECT_NAME` for this property.
2037 ///
2038 /// `struct_attribute` - Handle to the struct element attribute.
2039 ///
2040 /// `name` - The attribute name.
2041 ///
2042 /// `buffer` - A buffer for holding the returned key in
2043 /// UTF-16LE. This is only modified if `buflen` is
2044 /// longer than the length of the key. Optional,
2045 /// pass `NULL` to just retrieve the size of the
2046 /// buffer needed.
2047 ///
2048 /// `buflen` - The length of the buffer.
2049 ///
2050 /// `out_buflen` - A pointer to variable that will receive the
2051 /// minimum buffer size to contain the key. Not
2052 /// filled if `false` is returned.
2053 ///
2054 /// Returns `true` if the name maps to a string value.
2055 #[allow(non_snake_case)]
2056 fn FPDF_StructElement_Attr_GetStringValue(
2057 &self,
2058 struct_attribute: FPDF_STRUCTELEMENT_ATTR,
2059 name: &str,
2060 buffer: *mut c_void,
2061 buflen: c_ulong,
2062 out_buflen: *mut c_ulong,
2063 ) -> FPDF_BOOL;
2064
2065 #[cfg(any(
2066 feature = "pdfium_future",
2067 feature = "pdfium_7350",
2068 feature = "pdfium_7215",
2069 feature = "pdfium_7123",
2070 feature = "pdfium_6996",
2071 feature = "pdfium_6721",
2072 feature = "pdfium_6666",
2073 feature = "pdfium_6611",
2074 feature = "pdfium_6569",
2075 feature = "pdfium_6555",
2076 feature = "pdfium_6490",
2077 ))]
2078 /// Gets the value of a string attribute in an attribute map as string.
2079 /// [PdfiumLibraryBindings::FPDF_StructElement_Attr_GetType] should have returned
2080 /// `FPDF_OBJECT_STRING` or `FPDF_OBJECT_NAME` for this property.
2081 ///
2082 /// `value` - Handle to the value.
2083 ///
2084 /// `buffer` - A buffer for holding the returned key in UTF-16LE.
2085 /// This is only modified if `buflen` is longer than the
2086 /// length of the key. Optional, pass `NULL` to just
2087 /// retrieve the size of the buffer needed.
2088 ///
2089 /// `buflen` - The length of the buffer.
2090 ///
2091 /// `out_buflen` - A pointer to variable that will receive the minimum
2092 /// buffer size to contain the key. Not filled if `false` is
2093 /// returned.
2094 ///
2095 /// Returns `true` if the attribute maps to a string value.
2096 #[allow(non_snake_case)]
2097 fn FPDF_StructElement_Attr_GetStringValue(
2098 &self,
2099 value: FPDF_STRUCTELEMENT_ATTR_VALUE,
2100 buffer: *mut c_void,
2101 buflen: c_ulong,
2102 out_buflen: *mut c_ulong,
2103 ) -> FPDF_BOOL;
2104
2105 #[cfg(any(
2106 feature = "pdfium_6406",
2107 feature = "pdfium_6337",
2108 feature = "pdfium_6295",
2109 feature = "pdfium_6259",
2110 feature = "pdfium_6164",
2111 feature = "pdfium_6124",
2112 feature = "pdfium_6110",
2113 feature = "pdfium_6084",
2114 feature = "pdfium_6043",
2115 feature = "pdfium_6015",
2116 feature = "pdfium_5961",
2117 ))]
2118 /// Gets the value of a blob attribute in an attribute map by name as string.
2119 ///
2120 /// `struct_attribute` - Handle to the struct element attribute.
2121 ///
2122 /// `name` - The attribute name.
2123 ///
2124 /// `buffer` - A buffer for holding the returned value. This
2125 /// is only modified if |buflen| is at least as
2126 /// long as the length of the value. Optional, pass
2127 /// `NULL` to just retrieve the size of the buffer
2128 /// needed.
2129 ///
2130 /// `buflen` - The length of the buffer.
2131 ///
2132 /// `out_buflen` - A pointer to variable that will receive the
2133 /// minimum buffer size to contain the key. Not
2134 /// filled if `FALSE` is returned.
2135 ///
2136 /// Returns `TRUE` if the name maps to a string value.
2137 #[allow(non_snake_case)]
2138 fn FPDF_StructElement_Attr_GetBlobValue(
2139 &self,
2140 struct_attribute: FPDF_STRUCTELEMENT_ATTR,
2141 name: &str,
2142 buffer: *mut c_void,
2143 buflen: c_ulong,
2144 out_buflen: *mut c_ulong,
2145 ) -> FPDF_BOOL;
2146
2147 #[cfg(any(
2148 feature = "pdfium_future",
2149 feature = "pdfium_7350",
2150 feature = "pdfium_7215",
2151 feature = "pdfium_7123",
2152 feature = "pdfium_6996",
2153 feature = "pdfium_6721",
2154 feature = "pdfium_6666",
2155 feature = "pdfium_6611",
2156 feature = "pdfium_6569",
2157 feature = "pdfium_6555",
2158 feature = "pdfium_6490",
2159 ))]
2160 /// Gets the value of a blob attribute in an attribute map as string.
2161 ///
2162 /// `value` - Handle to the value.
2163 ///
2164 /// `buffer` - A buffer for holding the returned value. This is only
2165 /// modified if `buflen` is at least as long as the length
2166 /// of the value. Optional, pass `NULL` to just retrieve the
2167 /// size of the buffer needed.
2168 ///
2169 /// `buflen` - The length of the buffer.
2170 ///
2171 /// `out_buflen` - A pointer to variable that will receive the minimum buffer size
2172 /// to contain the key. Not filled if `false` is returned.
2173 ///
2174 /// Returns `true` if the attribute maps to a string value.
2175 #[allow(non_snake_case)]
2176 fn FPDF_StructElement_Attr_GetBlobValue(
2177 &self,
2178 value: FPDF_STRUCTELEMENT_ATTR_VALUE,
2179 buffer: *mut c_void,
2180 buflen: c_ulong,
2181 out_buflen: *mut c_ulong,
2182 ) -> FPDF_BOOL;
2183
2184 #[cfg(any(
2185 feature = "pdfium_future",
2186 feature = "pdfium_7350",
2187 feature = "pdfium_7215",
2188 feature = "pdfium_7123",
2189 feature = "pdfium_6996",
2190 feature = "pdfium_6721",
2191 feature = "pdfium_6666",
2192 feature = "pdfium_6611",
2193 feature = "pdfium_6569",
2194 feature = "pdfium_6555",
2195 feature = "pdfium_6490",
2196 ))]
2197 /// Counts the number of children values in an attribute.
2198 ///
2199 /// `value` - Handle to the value.
2200 ///
2201 /// Returns the number of children, or -1 on error.
2202 #[allow(non_snake_case)]
2203 fn FPDF_StructElement_Attr_CountChildren(&self, value: FPDF_STRUCTELEMENT_ATTR_VALUE) -> c_int;
2204
2205 #[cfg(any(
2206 feature = "pdfium_future",
2207 feature = "pdfium_7350",
2208 feature = "pdfium_7215",
2209 feature = "pdfium_7123",
2210 feature = "pdfium_6996",
2211 feature = "pdfium_6721",
2212 feature = "pdfium_6666",
2213 feature = "pdfium_6611",
2214 feature = "pdfium_6569",
2215 feature = "pdfium_6555",
2216 feature = "pdfium_6490",
2217 ))]
2218 /// Gets a child from an attribute.
2219 ///
2220 /// `value` - Handle to the value.
2221 ///
2222 /// `index` - The index for the child, 0-based.
2223 ///
2224 /// Returns the child at the n-th index, or `NULL` on error.
2225 ///
2226 /// The `index` must be less than the [PdfiumLibraryBindings::FPDF_StructElement_Attr_CountChildren]
2227 /// return value.
2228 #[allow(non_snake_case)]
2229 fn FPDF_StructElement_Attr_GetChildAtIndex(
2230 &self,
2231 value: FPDF_STRUCTELEMENT_ATTR_VALUE,
2232 index: c_int,
2233 ) -> FPDF_STRUCTELEMENT_ATTR_VALUE;
2234
2235 /// Gets the count of marked content ids for a given element.
2236 ///
2237 /// `struct_element` - Handle to the struct element.
2238 ///
2239 /// Returns the count of marked content ids or -1 if none exists.
2240 #[allow(non_snake_case)]
2241 fn FPDF_StructElement_GetMarkedContentIdCount(
2242 &self,
2243 struct_element: FPDF_STRUCTELEMENT,
2244 ) -> c_int;
2245
2246 /// Gets the marked content id at a given index for a given element.
2247 ///
2248 /// `struct_element` - Handle to the struct element.
2249 ///
2250 /// `index` - The index of the marked content id, 0-based.
2251 ///
2252 /// Returns the marked content ID of the element. If no ID exists, returns -1.
2253 ///
2254 /// The `index` must be less than the [PdfiumLibraryBindings::FPDF_StructElement_GetMarkedContentIdCount]
2255 /// return value.
2256 ///
2257 /// This function will likely supersede [PdfiumLibraryBindings::FPDF_StructElement_GetMarkedContentID].
2258 #[allow(non_snake_case)]
2259 fn FPDF_StructElement_GetMarkedContentIdAtIndex(
2260 &self,
2261 struct_element: FPDF_STRUCTELEMENT,
2262 index: c_int,
2263 ) -> c_int;
2264
2265 /// Creates a new PDF page.
2266 ///
2267 /// `document` - handle to document.
2268 ///
2269 /// `page_index` - suggested 0-based index of the page to create. If it is larger
2270 /// than document's current last index(L), the created page index
2271 /// is the next available index -- L+1.
2272 ///
2273 /// `width` - the page width in points.
2274 ///
2275 /// `height` - the page height in points.
2276 ///
2277 /// Returns the handle to the new page or `NULL` on failure.
2278 ///
2279 /// The page should be closed with [PdfiumLibraryBindings::FPDF_ClosePage()] when finished as
2280 /// with any other page in the document.
2281 #[allow(non_snake_case)]
2282 fn FPDFPage_New(
2283 &self,
2284 document: FPDF_DOCUMENT,
2285 page_index: c_int,
2286 width: c_double,
2287 height: c_double,
2288 ) -> FPDF_PAGE;
2289
2290 /// Deletes the page at `page_index`.
2291 ///
2292 /// `document` - handle to document.
2293 ///
2294 /// `page_index` - the index of the page to delete.
2295 #[allow(non_snake_case)]
2296 fn FPDFPage_Delete(&self, document: FPDF_DOCUMENT, page_index: c_int);
2297
2298 #[cfg(any(
2299 feature = "pdfium_future",
2300 feature = "pdfium_7350",
2301 feature = "pdfium_7215",
2302 feature = "pdfium_7123",
2303 feature = "pdfium_6996",
2304 feature = "pdfium_6721",
2305 feature = "pdfium_6666",
2306 feature = "pdfium_6611",
2307 feature = "pdfium_6569",
2308 feature = "pdfium_6555",
2309 feature = "pdfium_6490",
2310 feature = "pdfium_6406",
2311 feature = "pdfium_6337",
2312 feature = "pdfium_6295",
2313 feature = "pdfium_6259",
2314 feature = "pdfium_6164",
2315 feature = "pdfium_6124",
2316 feature = "pdfium_6110",
2317 feature = "pdfium_6084",
2318 feature = "pdfium_6043",
2319 ))]
2320 /// Moves the given pages to a new index position.
2321 ///
2322 /// `page_indices` - the ordered list of pages to move. No duplicates allowed.
2323 ///
2324 /// `page_indices_len` - the number of elements in `page_indices`
2325 ///
2326 /// `dest_page_index` - the new index position to which the pages in
2327 /// `page_indices` are moved.
2328 ///
2329 /// Returns `true` on success. If it returns `false`, the document may be left in an
2330 /// indeterminate state.
2331 ///
2332 /// Example: The PDF document starts out with pages [A, B, C, D], with indices
2333 /// [0, 1, 2, 3].
2334 ///
2335 /// > Move(doc, [3, 2], 2, 1); // returns `true`. The document now has pages [A, D, C, B].
2336 /// >
2337 /// > Move(doc, [0, 4, 3], 3, 1); // returns `false` because index 4 is out of range.
2338 /// >
2339 /// > Move(doc, [0, 3, 1], 3, 2); // returns `false` because index 2 is out of range for 3 page indices.
2340 /// >
2341 /// > Move(doc, [2, 2], 2, 0); // returns `false` because [2, 2] contains duplicates.
2342 #[allow(non_snake_case)]
2343 fn FPDF_MovePages(
2344 &self,
2345 document: FPDF_DOCUMENT,
2346 page_indices: *const c_int,
2347 page_indices_len: c_ulong,
2348 dest_page_index: c_int,
2349 ) -> FPDF_BOOL;
2350
2351 /// Gets the rotation of `page`.
2352 ///
2353 /// `page` - handle to a page
2354 ///
2355 /// Returns one of the following indicating the page rotation:
2356 ///
2357 /// `0` - No rotation.
2358 ///
2359 /// `1` - Rotated 90 degrees clockwise.
2360 ///
2361 /// `2` - Rotated 180 degrees clockwise.
2362 ///
2363 /// `3` - Rotated 270 degrees clockwise.
2364 #[allow(non_snake_case)]
2365 fn FPDFPage_GetRotation(&self, page: FPDF_PAGE) -> c_int;
2366
2367 /// Sets rotation for `page`.
2368 ///
2369 /// `page` - handle to a page.
2370 ///
2371 /// `rotate` - the rotation value, one of:
2372 ///
2373 /// 0 - No rotation.
2374 ///
2375 /// 1 - Rotated 90 degrees clockwise.
2376 ///
2377 /// 2 - Rotated 180 degrees clockwise.
2378 ///
2379 /// 3 - Rotated 270 degrees clockwise.
2380 #[allow(non_snake_case)]
2381 fn FPDFPage_SetRotation(&self, page: FPDF_PAGE, rotate: c_int);
2382
2383 /// Gets the bounding box of the page. This is the intersection between
2384 /// its media box and its crop box.
2385 ///
2386 /// `page` - Handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
2387 ///
2388 /// `rect` - Pointer to a rect to receive the page bounding box.
2389 /// On an error, `rect` won't be filled.
2390 ///
2391 /// Returns `true` on success.
2392 #[allow(non_snake_case)]
2393 fn FPDF_GetPageBoundingBox(&self, page: FPDF_PAGE, rect: *mut FS_RECTF) -> FPDF_BOOL;
2394
2395 /// Gets the size of the page at the given index.
2396 ///
2397 /// `document` - Handle to document. Returned by [PdfiumLibraryBindings::FPDF_LoadDocument].
2398 ///
2399 /// `page_index` - Page index, zero for the first page.
2400 ///
2401 /// `size` - Pointer to a `FS_SIZEF` to receive the page size (in points).
2402 ///
2403 /// Returns non-zero value for success, `0` for error (document or page not found).
2404 #[allow(non_snake_case)]
2405 fn FPDF_GetPageSizeByIndexF(
2406 &self,
2407 document: FPDF_DOCUMENT,
2408 page_index: c_int,
2409 size: *mut FS_SIZEF,
2410 ) -> FPDF_BOOL;
2411
2412 /// Gets the size of the page at the given index.
2413 ///
2414 /// `document` - Handle to document. Returned by [PdfiumLibraryBindings::FPDF_LoadDocument].
2415 ///
2416 /// `page_index` - Page index, zero for the first page.
2417 ///
2418 /// `width` - Pointer to a double to receive the page width (in points).
2419 ///
2420 /// `height` - Pointer to a double to receive the page height (in points).
2421 ///
2422 /// Returns non-zero for success, `0` for error (document or page not found).
2423 ///
2424 /// Note: prefer [PdfiumLibraryBindings::FPDF_GetPageSizeByIndexF]. This function
2425 /// will be deprecated in the future.
2426 #[allow(non_snake_case)]
2427 fn FPDF_GetPageSizeByIndex(
2428 &self,
2429 document: FPDF_DOCUMENT,
2430 page_index: c_int,
2431 width: *mut f64,
2432 height: *mut f64,
2433 ) -> c_int;
2434
2435 /// Gets "MediaBox" entry from the page dictionary.
2436 ///
2437 /// `page` - Handle to a page.
2438 ///
2439 /// `left` - Pointer to a float value receiving the left of the rectangle.
2440 ///
2441 /// `bottom` - Pointer to a float value receiving the bottom of the rectangle.
2442 ///
2443 /// `right` - Pointer to a float value receiving the right of the rectangle.
2444 ///
2445 /// `top` - Pointer to a float value receiving the top of the rectangle.
2446 ///
2447 /// On success, returns `true` and writes to the out parameters. Otherwise returns `false`
2448 /// and leaves the out parameters unmodified.
2449 #[allow(non_snake_case)]
2450 fn FPDFPage_GetMediaBox(
2451 &self,
2452 page: FPDF_PAGE,
2453 left: *mut c_float,
2454 bottom: *mut c_float,
2455 right: *mut c_float,
2456 top: *mut c_float,
2457 ) -> FPDF_BOOL;
2458
2459 /// Gets "CropBox" entry from the page dictionary.
2460 ///
2461 /// `page` - Handle to a page.
2462 ///
2463 /// `left` - Pointer to a float value receiving the left of the rectangle.
2464 ///
2465 /// `bottom` - Pointer to a float value receiving the bottom of the rectangle.
2466 ///
2467 /// `right` - Pointer to a float value receiving the right of the rectangle.
2468 ///
2469 /// `top` - Pointer to a float value receiving the top of the rectangle.
2470 ///
2471 /// On success, returns `true` and writes to the out parameters. Otherwise returns `false`
2472 /// and leaves the out parameters unmodified.
2473 #[allow(non_snake_case)]
2474 fn FPDFPage_GetCropBox(
2475 &self,
2476 page: FPDF_PAGE,
2477 left: *mut c_float,
2478 bottom: *mut c_float,
2479 right: *mut c_float,
2480 top: *mut c_float,
2481 ) -> FPDF_BOOL;
2482
2483 /// Gets "BleedBox" entry from the page dictionary.
2484 ///
2485 /// `page` - Handle to a page.
2486 ///
2487 /// `left` - Pointer to a float value receiving the left of the rectangle.
2488 ///
2489 /// `bottom` - Pointer to a float value receiving the bottom of the rectangle.
2490 ///
2491 /// `right` - Pointer to a float value receiving the right of the rectangle.
2492 ///
2493 /// `top` - Pointer to a float value receiving the top of the rectangle.
2494 ///
2495 /// On success, returns `true` and writes to the out parameters. Otherwise returns `false`
2496 /// and leaves the out parameters unmodified.
2497 #[allow(non_snake_case)]
2498 fn FPDFPage_GetBleedBox(
2499 &self,
2500 page: FPDF_PAGE,
2501 left: *mut c_float,
2502 bottom: *mut c_float,
2503 right: *mut c_float,
2504 top: *mut c_float,
2505 ) -> FPDF_BOOL;
2506
2507 /// Gets "TrimBox" entry from the page dictionary.
2508 ///
2509 /// `page` - Handle to a page.
2510 ///
2511 /// `left` - Pointer to a float value receiving the left of the rectangle.
2512 ///
2513 /// `bottom` - Pointer to a float value receiving the bottom of the rectangle.
2514 ///
2515 /// `right` - Pointer to a float value receiving the right of the rectangle.
2516 ///
2517 /// `top` - Pointer to a float value receiving the top of the rectangle.
2518 ///
2519 /// On success, returns `true` and writes to the out parameters. Otherwise returns `false`
2520 /// and leaves the out parameters unmodified.
2521 #[allow(non_snake_case)]
2522 fn FPDFPage_GetTrimBox(
2523 &self,
2524 page: FPDF_PAGE,
2525 left: *mut c_float,
2526 bottom: *mut c_float,
2527 right: *mut c_float,
2528 top: *mut c_float,
2529 ) -> FPDF_BOOL;
2530
2531 /// Gets "ArtBox" entry from the page dictionary.
2532 ///
2533 /// `page` - Handle to a page.
2534 ///
2535 /// `left` - Pointer to a float value receiving the left of the rectangle.
2536 ///
2537 /// `bottom` - Pointer to a float value receiving the bottom of the rectangle.
2538 ///
2539 /// `right` - Pointer to a float value receiving the right of the rectangle.
2540 ///
2541 /// `top` - Pointer to a float value receiving the top of the rectangle.
2542 ///
2543 /// On success, returns `true` and writes to the out parameters. Otherwise returns `false`
2544 /// and leaves the out parameters unmodified.
2545 #[allow(non_snake_case)]
2546 fn FPDFPage_GetArtBox(
2547 &self,
2548 page: FPDF_PAGE,
2549 left: *mut c_float,
2550 bottom: *mut c_float,
2551 right: *mut c_float,
2552 top: *mut c_float,
2553 ) -> FPDF_BOOL;
2554
2555 /// Sets "MediaBox" entry to the page dictionary.
2556 ///
2557 /// `page` - Handle to a page.
2558 ///
2559 /// `left` - The left of the rectangle.
2560 ///
2561 /// `bottom` - The bottom of the rectangle.
2562 ///
2563 /// `right` - The right of the rectangle.
2564 ///
2565 /// `top` - The top of the rectangle.
2566 #[allow(non_snake_case)]
2567 fn FPDFPage_SetMediaBox(
2568 &self,
2569 page: FPDF_PAGE,
2570 left: c_float,
2571 bottom: c_float,
2572 right: c_float,
2573 top: c_float,
2574 );
2575
2576 /// Sets "CropBox" entry in the page dictionary.
2577 ///
2578 /// `page` - Handle to a page.
2579 ///
2580 /// `left` - The left of the rectangle.
2581 ///
2582 /// `bottom` - The bottom of the rectangle.
2583 ///
2584 /// `right` - The right of the rectangle.
2585 ///
2586 /// `top` - The top of the rectangle.
2587 #[allow(non_snake_case)]
2588 fn FPDFPage_SetCropBox(
2589 &self,
2590 page: FPDF_PAGE,
2591 left: c_float,
2592 bottom: c_float,
2593 right: c_float,
2594 top: c_float,
2595 );
2596
2597 /// Sets "BleedBox" entry in the page dictionary.
2598 ///
2599 /// `page` - Handle to a page.
2600 ///
2601 /// `left` - The left of the rectangle.
2602 ///
2603 /// `bottom` - The bottom of the rectangle.
2604 ///
2605 /// `right` - The right of the rectangle.
2606 ///
2607 /// `top` - The top of the rectangle.
2608 #[allow(non_snake_case)]
2609 fn FPDFPage_SetBleedBox(
2610 &self,
2611 page: FPDF_PAGE,
2612 left: c_float,
2613 bottom: c_float,
2614 right: c_float,
2615 top: c_float,
2616 );
2617
2618 /// Sets "TrimBox" entry in the page dictionary.
2619 ///
2620 /// `page` - Handle to a page.
2621 ///
2622 /// `left` - The left of the rectangle.
2623 ///
2624 /// `bottom` - The bottom of the rectangle.
2625 ///
2626 /// `right` - The right of the rectangle.
2627 ///
2628 /// `top` - The top of the rectangle.
2629 #[allow(non_snake_case)]
2630 fn FPDFPage_SetTrimBox(
2631 &self,
2632 page: FPDF_PAGE,
2633 left: c_float,
2634 bottom: c_float,
2635 right: c_float,
2636 top: c_float,
2637 );
2638
2639 /// Sets "ArtBox" entry in the page dictionary.
2640 ///
2641 /// `page` - Handle to a page.
2642 ///
2643 /// `left` - The left of the rectangle.
2644 ///
2645 /// `bottom` - The bottom of the rectangle.
2646 ///
2647 /// `right` - The right of the rectangle.
2648 ///
2649 /// `top` - The top of the rectangle.
2650 #[allow(non_snake_case)]
2651 fn FPDFPage_SetArtBox(
2652 &self,
2653 page: FPDF_PAGE,
2654 left: c_float,
2655 bottom: c_float,
2656 right: c_float,
2657 top: c_float,
2658 );
2659
2660 /// Applies transforms to `page`.
2661 ///
2662 /// If `matrix` is provided, it will be applied to transform the page.
2663 /// If `clipRect` is provided, it will be used to clip the resulting page.
2664 /// If neither `matrix` nor `clipRect` are provided, this method returns `false`.
2665 ///
2666 /// Returns `true` if transforms are applied. This function will transform the whole page,
2667 /// and will take effect on all the objects on the page.
2668 ///
2669 /// `page` - Page handle.
2670 ///
2671 /// `matrix` - Transform matrix.
2672 ///
2673 /// `clipRect` - Clipping rectangle.
2674 #[allow(non_snake_case)]
2675 fn FPDFPage_TransFormWithClip(
2676 &self,
2677 page: FPDF_PAGE,
2678 matrix: *const FS_MATRIX,
2679 clipRect: *const FS_RECTF,
2680 ) -> FPDF_BOOL;
2681
2682 /// Transforms (scale, rotate, shear, move) the clip path of page object.
2683 ///
2684 /// `page_object` - Handle to a page object. Returned by [PdfiumLibraryBindings::FPDFPageObj_NewImageObj].
2685 ///
2686 /// `a` - The coefficient "a" of the transformation matrix.
2687 ///
2688 /// `b` - The coefficient "b" of the matrix.
2689 ///
2690 /// `c` - The coefficient "c" of the matrix.
2691 ///
2692 /// `d` - The coefficient "d" of the matrix.
2693 ///
2694 /// `e` - The coefficient "e" of the matrix.
2695 ///
2696 /// `f` - The coefficient "f" of the matrix.
2697 #[allow(non_snake_case)]
2698 #[allow(clippy::too_many_arguments)]
2699 fn FPDFPageObj_TransformClipPath(
2700 &self,
2701 page_object: FPDF_PAGEOBJECT,
2702 a: f64,
2703 b: f64,
2704 c: f64,
2705 d: f64,
2706 e: f64,
2707 f: f64,
2708 );
2709
2710 /// Gets the clip path of the page object.
2711 ///
2712 /// `page object` - Handle to a page object. Returned by e.g.
2713 /// [PdfiumLibraryBindings::FPDFPage_GetObject].
2714 ///
2715 /// Returns the handle to the clip path, or `NULL` on failure. The caller does not
2716 /// take ownership of the returned `FPDF_CLIPPATH`. Instead, it remains valid until
2717 /// [PdfiumLibraryBindings::FPDF_ClosePage] is called for the page containing `page_object`.
2718 #[allow(non_snake_case)]
2719 fn FPDFPageObj_GetClipPath(&self, page_object: FPDF_PAGEOBJECT) -> FPDF_CLIPPATH;
2720
2721 /// Gets the number of paths inside `clip_path`.
2722 ///
2723 /// `clip_path` - handle to a clip path.
2724 ///
2725 /// Returns the number of objects in `clip_path`, or `-1` on failure.
2726 #[allow(non_snake_case)]
2727 fn FPDFClipPath_CountPaths(&self, clip_path: FPDF_CLIPPATH) -> c_int;
2728
2729 /// Gets the number of segments inside one path of `clip_path`.
2730 ///
2731 /// `clip_path` - handle to a clip path.
2732 ///
2733 /// `path_index` - index into the array of paths of the clip path.
2734 ///
2735 /// Returns the number of segments, or `-1` on failure.
2736 #[allow(non_snake_case)]
2737 fn FPDFClipPath_CountPathSegments(&self, clip_path: FPDF_CLIPPATH, path_index: c_int) -> c_int;
2738
2739 /// Gets a specific segment in a specific path of `clip_path`.
2740 ///
2741 /// `clip_path` - handle to a clip path.
2742 ///
2743 /// `path_index` - the index of a path.
2744 ///
2745 /// `segment_index` - the index of a segment.
2746 ///
2747 /// Returns the handle to the segment, or `NULL` on failure. The caller does not
2748 /// take ownership of the returned `FPDF_PATHSEGMENT`. Instead, it remains valid
2749 /// until [PdfiumLibraryBindings::FPDF_ClosePage] is called for the page containing `clip_path`.
2750 #[allow(non_snake_case)]
2751 fn FPDFClipPath_GetPathSegment(
2752 &self,
2753 clip_path: FPDF_CLIPPATH,
2754 path_index: c_int,
2755 segment_index: c_int,
2756 ) -> FPDF_PATHSEGMENT;
2757
2758 /// Creates a new clip path, with a rectangle inserted.
2759 ///
2760 /// Caller takes ownership of the returned `FPDF_CLIPPATH`. It should be freed with
2761 /// [PdfiumLibraryBindings::FPDF_DestroyClipPath].
2762 ///
2763 /// `left` - The left of the clip box.
2764 ///
2765 /// `bottom` - The bottom of the clip box.
2766 ///
2767 /// `right` - The right of the clip box.
2768 ///
2769 /// `top` - The top of the clip box.
2770 #[allow(non_snake_case)]
2771 fn FPDF_CreateClipPath(&self, left: f32, bottom: f32, right: f32, top: f32) -> FPDF_CLIPPATH;
2772
2773 /// Destroys a clip path.
2774 ///
2775 /// `clipPath` - A handle to the clip path. It will be invalid after this call.
2776 #[allow(non_snake_case)]
2777 fn FPDF_DestroyClipPath(&self, clipPath: FPDF_CLIPPATH);
2778
2779 /// Clips the page content. Content outside the clipping region will become invisible.
2780 ///
2781 /// A clip path will be inserted before the page content stream or content array.
2782 /// In this way, the page content will be clipped by this clip path.
2783 ///
2784 /// `page` - A page handle.
2785 ///
2786 /// `clipPath` - A handle to the clip path. The caller does not take ownership.
2787 #[allow(non_snake_case)]
2788 fn FPDFPage_InsertClipPath(&self, page: FPDF_PAGE, clipPath: FPDF_CLIPPATH);
2789
2790 /// Checks if `page` contains transparency.
2791 ///
2792 /// `page` - handle to a page.
2793 ///
2794 /// Returns `true` if `page` contains transparency.
2795 #[allow(non_snake_case)]
2796 fn FPDFPage_HasTransparency(&self, page: FPDF_PAGE) -> FPDF_BOOL;
2797
2798 /// Generates the content of `page`. Before you save `page` to a file or reload `page`,
2799 /// you must call this function or any changes to `page` will be lost.
2800 ///
2801 /// `page` - handle to a page.
2802 ///
2803 /// Returns `true` on success.
2804 #[allow(non_snake_case)]
2805 fn FPDFPage_GenerateContent(&self, page: FPDF_PAGE) -> FPDF_BOOL;
2806
2807 /// Transforms all annotations in `page`.
2808 ///
2809 /// `page` - handle to a page.
2810 ///
2811 /// `a` - matrix value.
2812 ///
2813 /// `b` - matrix value.
2814 ///
2815 /// `c` - matrix value.
2816 ///
2817 /// `d` - matrix value.
2818 ///
2819 /// `e` - matrix value.
2820 ///
2821 /// `f` - matrix value.
2822 ///
2823 /// The matrix is composed as:
2824 ///
2825 /// `|a c e|`
2826 ///
2827 /// `|b d f|`
2828 ///
2829 /// and can be used to scale, rotate, shear, and translate the `page` annotations.
2830 #[allow(non_snake_case)]
2831 #[allow(clippy::too_many_arguments)]
2832 fn FPDFPage_TransformAnnots(
2833 &self,
2834 page: FPDF_PAGE,
2835 a: f64,
2836 b: f64,
2837 c: f64,
2838 d: f64,
2839 e: f64,
2840 f: f64,
2841 );
2842
2843 /// Creates a device independent bitmap (FXDIB).
2844 ///
2845 /// `width` - The number of pixels in width for the bitmap.
2846 /// Must be greater than 0.
2847 ///
2848 /// `height` - The number of pixels in height for the bitmap.
2849 /// Must be greater than 0.
2850 ///
2851 /// `alpha` - A flag indicating whether the alpha channel is used.
2852 /// Non-zero for using alpha, zero for not using.
2853 ///
2854 /// Returns the created bitmap handle, or `NULL` if a parameter error or out of
2855 /// memory.
2856 ///
2857 /// The bitmap always uses 4 bytes per pixel. The first byte is always double word aligned.
2858 /// The byte order is BGRx (the last byte unused if no alpha channel) or BGRA.
2859 /// The pixels in a horizontal line are stored side by side, with the left most pixel
2860 /// stored first (with lower memory address). Each line uses `width * 4` bytes.
2861 /// Lines are stored one after another, with the top most line stored first.
2862 /// There is no gap between adjacent lines.
2863 ///
2864 /// This function allocates enough memory for holding all pixels in the bitmap,
2865 /// but it doesn't initialize the buffer. Applications can use [PdfiumLibraryBindings::FPDFBitmap_FillRect]
2866 /// to fill the bitmap using any color. If the OS allows it, this function can allocate
2867 /// up to 4 GB of memory.
2868 #[allow(non_snake_case)]
2869 fn FPDFBitmap_Create(&self, width: c_int, height: c_int, alpha: c_int) -> FPDF_BITMAP;
2870
2871 /// Creates a device independent bitmap (FXDIB).
2872 ///
2873 /// `width` - The number of pixels in width for the bitmap.
2874 /// Must be greater than 0.
2875 ///
2876 /// `height` - The number of pixels in height for the bitmap.
2877 /// Must be greater than 0.
2878 ///
2879 /// `format` - A number indicating for bitmap format, as defined above.
2880 ///
2881 /// `first_scan` - A pointer to the first byte of the first line if
2882 /// using an external buffer. If this parameter is `NULL`,
2883 /// then a new buffer will be created.
2884 ///
2885 /// `stride` - Number of bytes for each scan line. The value must
2886 /// be 0 or greater. When the value is 0,
2887 /// `FPDFBitmap_CreateEx()` will automatically calculate
2888 /// the appropriate value using `width` and `format`.
2889 /// When using an external buffer, it is recommended for the caller
2890 /// to pass in the value. When not using an external buffer, it is
2891 /// recommended for the caller to pass in 0.
2892 ///
2893 /// Returns the bitmap handle, or `NULL` if parameter error or out of memory.
2894 ///
2895 /// Similar to [PdfiumLibraryBindings::FPDFBitmap_Create] function, but allows for more
2896 /// formats and an external buffer is supported. The bitmap created by this function
2897 /// can be used in any place that a `FPDF_BITMAP` handle is required.
2898 ///
2899 /// If an external buffer is used, then the caller should destroy the buffer.
2900 /// [PdfiumLibraryBindings::FPDFBitmap_Destroy] will not destroy the buffer.
2901 ///
2902 /// It is recommended to use [PdfiumLibraryBindings::FPDFBitmap_GetStride to get the stride
2903 /// value.
2904 #[allow(non_snake_case)]
2905 fn FPDFBitmap_CreateEx(
2906 &self,
2907 width: c_int,
2908 height: c_int,
2909 format: c_int,
2910 first_scan: *mut c_void,
2911 stride: c_int,
2912 ) -> FPDF_BITMAP;
2913
2914 /// Gets the format of the bitmap.
2915 ///
2916 /// `bitmap` - Handle to the bitmap. Returned by [PdfiumLibraryBindings::FPDFBitmap_Create]
2917 /// or [PdfiumLibraryBindings::FPDFImageObj_GetBitmap].
2918 ///
2919 /// Returns the format of the bitmap.
2920 ///
2921 /// Only formats supported by [PdfiumLibraryBindings::FPDFBitmap_CreateEx] are supported by this
2922 /// function; see the list of such formats above.
2923 #[allow(non_snake_case)]
2924 fn FPDFBitmap_GetFormat(&self, bitmap: FPDF_BITMAP) -> c_int;
2925
2926 #[cfg(any(
2927 feature = "pdfium_6611",
2928 feature = "pdfium_6569",
2929 feature = "pdfium_6555",
2930 feature = "pdfium_6490",
2931 feature = "pdfium_6406",
2932 feature = "pdfium_6337",
2933 feature = "pdfium_6295",
2934 feature = "pdfium_6259",
2935 feature = "pdfium_6164",
2936 feature = "pdfium_6124",
2937 feature = "pdfium_6110",
2938 feature = "pdfium_6084",
2939 feature = "pdfium_6043",
2940 feature = "pdfium_6015",
2941 feature = "pdfium_5961"
2942 ))]
2943 /// Fills a rectangle in a bitmap.
2944 ///
2945 /// `bitmap` - The handle to the bitmap. Returned by
2946 /// [PdfiumLibraryBindings::FPDFBitmap_Create].
2947 ///
2948 /// `left` - The left position. Starting from 0 at the left-most pixel.
2949 ///
2950 /// `top` - The top position. Starting from 0 at the top-most line.
2951 ///
2952 /// `width` - Width in pixels to be filled.
2953 ///
2954 /// `height` - Height in pixels to be filled.
2955 ///
2956 /// `color` - A 32-bit value specifying the color, in 8888 ARGB format.
2957 ///
2958 /// This function sets the color and (optionally) alpha value in the specified region
2959 /// of the bitmap.
2960 ///
2961 /// Note: If the alpha channel is used, this function does _not_ composite the background
2962 /// with the source color, instead the background will be replaced by the source color
2963 /// and the alpha. If the alpha channel is not used, the alpha parameter is ignored.
2964 #[allow(non_snake_case)]
2965 fn FPDFBitmap_FillRect(
2966 &self,
2967 bitmap: FPDF_BITMAP,
2968 left: c_int,
2969 top: c_int,
2970 width: c_int,
2971 height: c_int,
2972 color: FPDF_DWORD,
2973 );
2974
2975 #[cfg(any(
2976 feature = "pdfium_future",
2977 feature = "pdfium_7350",
2978 feature = "pdfium_7215",
2979 feature = "pdfium_7123",
2980 feature = "pdfium_6996",
2981 feature = "pdfium_6721",
2982 feature = "pdfium_6666"
2983 ))]
2984 /// Fills a rectangle in a bitmap.
2985 ///
2986 /// `bitmap` - The handle to the bitmap. Returned by
2987 /// [PdfiumLibraryBindings::FPDFBitmap_Create].
2988 ///
2989 /// `left` - The left position. Starting from 0 at the left-most pixel.
2990 ///
2991 /// `top` - The top position. Starting from 0 at the top-most line.
2992 ///
2993 /// `width` - Width in pixels to be filled.
2994 ///
2995 /// `height` - Height in pixels to be filled.
2996 ///
2997 /// `color` - A 32-bit value specifying the color, in 8888 ARGB format.
2998 ///
2999 /// Returns whether the operation succeeded or not.
3000 ///
3001 /// This function sets the color and (optionally) alpha value in the specified region
3002 /// of the bitmap.
3003 ///
3004 /// Note: If the alpha channel is used, this function does _not_ composite the background
3005 /// with the source color, instead the background will be replaced by the source color
3006 /// and the alpha. If the alpha channel is not used, the alpha parameter is ignored.
3007 #[allow(non_snake_case)]
3008 fn FPDFBitmap_FillRect(
3009 &self,
3010 bitmap: FPDF_BITMAP,
3011 left: c_int,
3012 top: c_int,
3013 width: c_int,
3014 height: c_int,
3015 color: FPDF_DWORD,
3016 ) -> FPDF_BOOL;
3017
3018 #[cfg(not(target_arch = "wasm32"))]
3019 /// Note that this function is not available when compiling to WASM as it cannot be made
3020 /// memory safe. When compiling to WASM, Pdfium's internal pixel data buffer for a bitmap
3021 /// resides in a separate WASM memory module from your Rust application, so any buffer
3022 /// returned by this function is necessarily a copy; mutating that copy does not alter
3023 /// the buffer in Pdfium's WASM module and, since there is no way for `pdfium-render` to
3024 /// know when the caller has finished mutating the copied buffer, there is no reliable way
3025 /// for `pdfium-render` to transfer any changes made to the copy across to Pdfium's
3026 /// WASM module.
3027 ///
3028 /// To avoid having to maintain different code for different platform targets, it is
3029 /// recommended that all callers use the provided [PdfiumLibraryBindings::FPDFBitmap_GetBuffer_as_vec]
3030 /// and [PdfiumLibraryBindings::FPDFBitmap_SetBuffer] convenience functions to retrieve
3031 /// and update the pixel data of a bitmap, instead of directly mutating the buffer
3032 /// returned by this function.
3033 ///
3034 /// Gets the data buffer of a bitmap.
3035 ///
3036 /// `bitmap` - Handle to the bitmap. Returned by [PdfiumLibraryBindings::FPDFBitmap_Create]
3037 /// or [PdfiumLibraryBindings::FPDFImageObj_GetBitmap].
3038 ///
3039 /// Returns the pointer to the first byte of the bitmap buffer.
3040 ///
3041 /// The stride may be more than `width * number of bytes per pixel`.
3042 ///
3043 /// Applications can use this function to get the bitmap buffer pointer,
3044 /// then manipulate any color and/or alpha values for any pixels in the bitmap.
3045 ///
3046 /// Use [PdfiumLibraryBindings::FPDFBitmap_GetFormat] to find out the format of the data.
3047 #[allow(non_snake_case)]
3048 fn FPDFBitmap_GetBuffer(&self, bitmap: FPDF_BITMAP) -> *mut c_void;
3049
3050 // TODO: AJRC - 27/11/24 - remove deprecated item as part of #36
3051 #[deprecated(
3052 since = "0.8.27",
3053 note = "The WASM implementation of FPDFBitmap_GetBuffer() cannot be made memory-safe. Prefer FPDFBitmap_GetBuffer_as_vec() or FPDFBitmap_GetBuffer_as_array() instead."
3054 )]
3055 #[cfg(target_arch = "wasm32")]
3056 #[allow(non_snake_case)]
3057 fn FPDFBitmap_GetBuffer(&self, bitmap: FPDF_BITMAP) -> *const c_void;
3058
3059 #[cfg(not(target_arch = "wasm32"))]
3060 /// This function is not part of the Pdfium API. It is provided by `pdfium-render` as an
3061 /// alternative to directly mutating the data returned by
3062 /// [PdfiumLibraryBindings::FPDFBitmap_GetBuffer].
3063 ///
3064 /// Replaces all pixel data for the given bitmap with the pixel data in the given buffer,
3065 /// returning `true` once the new pixel data has been applied. If the given buffer
3066 /// does not have the same length as the bitmap's current buffer then the current buffer
3067 /// will be unchanged and a value of `false` will be returned.
3068 #[allow(non_snake_case)]
3069 fn FPDFBitmap_SetBuffer(&self, bitmap: FPDF_BITMAP, buffer: &[u8]) -> bool {
3070 let buffer_length =
3071 (self.FPDFBitmap_GetStride(bitmap) * self.FPDFBitmap_GetHeight(bitmap)) as usize;
3072
3073 if buffer.len() != buffer_length {
3074 return false;
3075 }
3076
3077 let buffer_start = self.FPDFBitmap_GetBuffer(bitmap);
3078
3079 let destination =
3080 unsafe { std::slice::from_raw_parts_mut(buffer_start as *mut u8, buffer_length) };
3081
3082 destination.copy_from_slice(buffer);
3083
3084 true
3085 }
3086
3087 #[cfg(target_arch = "wasm32")]
3088 /// This function is not part of the Pdfium API. It is provided by `pdfium-render` as an
3089 /// alternative to directly mutating the data returned by
3090 /// [PdfiumLibraryBindings::FPDFBitmap_GetBuffer].
3091 ///
3092 /// Replaces all pixel data of the given bitmap with the pixel data in the given buffer,
3093 /// returning `true` once the new pixel data has been applied. If the given buffer
3094 /// does not have the same length as the bitmap's current buffer then the current buffer
3095 /// will be unchanged and a value of `false` will be returned.
3096 #[allow(non_snake_case)]
3097 fn FPDFBitmap_SetBuffer(&self, bitmap: FPDF_BITMAP, buffer: &[u8]) -> bool;
3098
3099 #[cfg(not(target_arch = "wasm32"))]
3100 /// Gets the data buffer of a bitmap as a Rust slice.
3101 ///
3102 /// `bitmap` - Handle to the bitmap. Returned by [PdfiumLibraryBindings::FPDFBitmap_Create]
3103 /// or [PdfiumLibraryBindings::FPDFImageObj_GetBitmap].
3104 ///
3105 /// Returns a `&[u8]` slice containing the contents of the bitmap buffer.
3106 ///
3107 /// The stride may be more than `width * number of bytes per pixel`.
3108 ///
3109 /// Use [PdfiumLibraryBindings::FPDFBitmap_GetFormat] to find out the format of the data.
3110 #[allow(non_snake_case)]
3111 fn FPDFBitmap_GetBuffer_as_slice(&self, bitmap: FPDF_BITMAP) -> &[u8] {
3112 let buffer = self.FPDFBitmap_GetBuffer(bitmap);
3113
3114 let len = self.FPDFBitmap_GetStride(bitmap) * self.FPDFBitmap_GetHeight(bitmap);
3115
3116 unsafe { std::slice::from_raw_parts(buffer as *const u8, len as usize) }
3117 }
3118
3119 #[cfg(not(target_arch = "wasm32"))]
3120 /// This function is not part of the Pdfium API. It is provided by `pdfium-render` as a
3121 /// cross-platform neutral way of retrieving the pixel data owned by a bitmap. It is
3122 /// an alternative to Pdfium's [PdfiumLibraryBindings::FPDFBitmap_GetBuffer] function,
3123 /// which is not available when compiling to WASM.
3124 ///
3125 /// To maintain memory safety, this function must copy pixel data from the bitmap
3126 /// buffer into a new [Vec]. This has both memory usage and performance implications.
3127 /// For non-WASM targets, consider using the [PdfiumLibraryBindings::FPDFBitmap_GetBuffer_as_slice]
3128 /// function, which avoids allocation. When compiling to WASM, an equivalent function,
3129 /// [PdfiumLibraryBindings::FPDFBitmap_GetBuffer_as_array], is provided that similarily
3130 /// avoids the need to copy pixel data.
3131 ///
3132 /// Gets the data buffer of a bitmap.
3133 ///
3134 /// `bitmap` - Handle to the bitmap. Returned by [PdfiumLibraryBindings::FPDFBitmap_Create]
3135 /// or [PdfiumLibraryBindings::FPDFImageObj_GetBitmap].
3136 ///
3137 /// Returns a [Vec] containing a copy of the contents of the bitmap buffer.
3138 ///
3139 /// The stride may be more than `width * number of bytes per pixel`.
3140 ///
3141 /// Use [PdfiumLibraryBindings::FPDFBitmap_GetFormat] to find out the format of the data.
3142 ///
3143 /// Use [PdfiumLibraryBindings::FPDFBitmap_SetBuffer] to apply any changes made
3144 /// to the returned [Vec] back to the originating bitmap.
3145 #[inline]
3146 #[allow(non_snake_case)]
3147 fn FPDFBitmap_GetBuffer_as_vec(&self, bitmap: FPDF_BITMAP) -> Vec<u8> {
3148 Vec::from(self.FPDFBitmap_GetBuffer_as_slice(bitmap))
3149 }
3150
3151 #[cfg(target_arch = "wasm32")]
3152 /// Gets the data buffer of a bitmap.
3153 ///
3154 /// `bitmap` - Handle to the bitmap. Returned by [PdfiumLibraryBindings::FPDFBitmap_Create]
3155 /// or [PdfiumLibraryBindings::FPDFImageObj_GetBitmap].
3156 ///
3157 /// Returns a [Vec] containing the contents of the bitmap buffer.
3158 ///
3159 /// The stride may be more than `width * number of bytes per pixel`.
3160 ///
3161 /// Use [PdfiumLibraryBindings::FPDFBitmap_GetFormat] to find out the format of the data.
3162 ///
3163 /// Use [PdfiumLibraryBindings::FPDFBitmap_SetBuffer] to apply any changes made
3164 /// to the returned [Vec] back to the originating bitmap.
3165 #[inline]
3166 #[allow(non_snake_case)]
3167 fn FPDFBitmap_GetBuffer_as_vec(&self, bitmap: FPDF_BITMAP) -> Vec<u8> {
3168 self.FPDFBitmap_GetBuffer_as_array(bitmap).to_vec()
3169 }
3170
3171 // TODO: AJRC - 27/11/24 - remove deprecated item as part of #36
3172 #[deprecated(
3173 since = "0.8.27",
3174 note = "This function has been renamed to better reflect its purpose. Prefer FPDFBitmap_GetBuffer_as_array() instead."
3175 )]
3176 #[cfg(target_arch = "wasm32")]
3177 #[doc(hidden)]
3178 #[inline]
3179 #[allow(non_snake_case)]
3180 fn FPDFBitmap_GetArray(&self, bitmap: FPDF_BITMAP) -> js_sys::Uint8Array {
3181 self.FPDFBitmap_GetBuffer_as_array(bitmap)
3182 }
3183
3184 #[allow(non_snake_case)]
3185 #[cfg(target_arch = "wasm32")]
3186 /// This function is not part of the Pdfium API. It is provided by `pdfium-render` as a
3187 /// more performant WASM-specific variant of [PdfiumLibraryBindings::FPDFBitmap_GetBuffer].
3188 /// Since it avoids a (potentially large) bitmap allocation and copy, it is both faster and
3189 /// more memory efficient than [PdfiumLibraryBindings::FPDFBitmap_GetBuffer].
3190 ///
3191 /// This function is only available when compiling to WASM.
3192 ///
3193 /// Gets the data buffer of a bitmap.
3194 ///
3195 /// `bitmap` - Handle to the bitmap. Returned by [PdfiumLibraryBindings::FPDFBitmap_Create]
3196 /// or [PdfiumLibraryBindings::FPDFImageObj_GetBitmap].
3197 ///
3198 /// Returns a [js_sys::Uint8Array] containing the contents of the bitmap buffer.
3199 ///
3200 /// The stride may be more than `width * number of bytes per pixel`.
3201 ///
3202 /// Use [PdfiumLibraryBindings::FPDFBitmap_GetFormat] to find out the format of the data.
3203 ///
3204 /// Changes made to the returned array will directly mutate the pixel data of the bitmap.
3205 fn FPDFBitmap_GetBuffer_as_array(&self, bitmap: FPDF_BITMAP) -> js_sys::Uint8Array;
3206
3207 #[cfg(doc)]
3208 /// This function is not part of the Pdfium API. It is provided by `pdfium-render` as a
3209 /// more performant WASM-specific variant of [PdfiumLibraryBindings::FPDFBitmap_GetBuffer].
3210 /// Since it avoids a (potentially large) bitmap allocation and copy, it is both faster and
3211 /// more memory efficient than [PdfiumLibraryBindings::FPDFBitmap_GetBuffer].
3212 ///
3213 /// This function is only available when compiling to WASM.
3214 ///
3215 /// Gets the data buffer of a bitmap.
3216 ///
3217 /// `bitmap` - Handle to the bitmap. Returned by [PdfiumLibraryBindings::FPDFBitmap_Create]
3218 /// or [PdfiumLibraryBindings::FPDFImageObj_GetBitmap].
3219 ///
3220 /// Returns a `js_sys::Uint8Array` containing the contents of the bitmap buffer.
3221 ///
3222 /// The stride may be more than `width * number of bytes per pixel`.
3223 ///
3224 /// Use [PdfiumLibraryBindings::FPDFBitmap_GetFormat] to find out the format of the data.
3225 ///
3226 /// Changes made to the returned array will directly mutate the pixel data of the bitmap.
3227 fn FPDFBitmap_GetBuffer_as_array(&self, bitmap: FPDF_BITMAP) -> Uint8Array {}
3228
3229 /// Gets the width of a bitmap.
3230 ///
3231 /// `bitmap` - Handle to the bitmap. Returned by [PdfiumLibraryBindings::FPDFBitmap_Create]
3232 /// or [PdfiumLibraryBindings::FPDFImageObj_GetBitmap].
3233 ///
3234 /// Returns the width of the bitmap in pixels.
3235 #[allow(non_snake_case)]
3236 fn FPDFBitmap_GetWidth(&self, bitmap: FPDF_BITMAP) -> c_int;
3237
3238 /// Gets the height of a bitmap.
3239 ///
3240 /// `bitmap` - Handle to the bitmap. Returned by [PdfiumLibraryBindings::FPDFBitmap_Create]
3241 /// or [PdfiumLibraryBindings::FPDFImageObj_GetBitmap].
3242 ///
3243 /// Returns the height of the bitmap in pixels.
3244 #[allow(non_snake_case)]
3245 fn FPDFBitmap_GetHeight(&self, bitmap: FPDF_BITMAP) -> c_int;
3246
3247 /// Gets the number of bytes for each line in the bitmap buffer.
3248 ///
3249 /// `bitmap` - Handle to the bitmap. Returned by [PdfiumLibraryBindings::FPDFBitmap_Create]
3250 /// or [PdfiumLibraryBindings::FPDFImageObj_GetBitmap].
3251 ///
3252 /// Returns the number of bytes for each line in the bitmap buffer.
3253 ///
3254 /// The stride may be more than `width * number of bytes per pixel`.
3255 #[allow(non_snake_case)]
3256 fn FPDFBitmap_GetStride(&self, bitmap: FPDF_BITMAP) -> c_int;
3257
3258 /// Destroys a bitmap and releases all related buffers.
3259 ///
3260 /// `bitmap` - Handle to the bitmap. Returned by [PdfiumLibraryBindings::FPDFBitmap_Create]
3261 /// or [PdfiumLibraryBindings::FPDFImageObj_GetBitmap].
3262 ///
3263 /// This function will not destroy any external buffers provided when
3264 /// the bitmap was created.
3265 #[allow(non_snake_case)]
3266 fn FPDFBitmap_Destroy(&self, bitmap: FPDF_BITMAP);
3267
3268 #[cfg(not(target_arch = "wasm32"))]
3269 #[cfg(feature = "pdfium_use_win32")]
3270 /// Renders the contents of a page to a device (screen, bitmap, or printer).
3271 /// This function is only supported on Windows.
3272 ///
3273 /// `dc` - Handle to the device context.
3274 ///
3275 /// `page` - Handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
3276 ///
3277 /// `start_x` - Left pixel position of the display area in device coordinates.
3278 ///
3279 /// `start_y` - Top pixel position of the display area in device coordinates.
3280 ///
3281 /// `size_x` - Horizontal size (in pixels) for displaying the page.
3282 ///
3283 /// `size_y` - Vertical size (in pixels) for displaying the page.
3284 ///
3285 /// `rotate` - Page orientation:
3286 /// 0 (normal)
3287 /// 1 (rotated 90 degrees clockwise)
3288 /// 2 (rotated 180 degrees)
3289 /// 3 (rotated 90 degrees counter-clockwise)
3290 ///
3291 /// `flags` - 0 for normal display, or combination of flags defined above.
3292 #[allow(non_snake_case)]
3293 fn FPDF_RenderPage(
3294 &self,
3295 dc: windows::Win32::Graphics::Gdi::HDC,
3296 page: FPDF_PAGE,
3297 start_x: c_int,
3298 start_y: c_int,
3299 size_x: c_int,
3300 size_y: c_int,
3301 rotate: c_int,
3302 flags: c_int,
3303 );
3304
3305 #[cfg(doc)]
3306 /// Renders the contents of a page to a device (screen, bitmap, or printer).
3307 /// This function is only supported on Windows.
3308 ///
3309 /// `dc` - Handle to the device context.
3310 ///
3311 /// `page` - Handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
3312 ///
3313 /// `start_x` - Left pixel position of the display area in device coordinates.
3314 ///
3315 /// `start_y` - Top pixel position of the display area in device coordinates.
3316 ///
3317 /// `size_x` - Horizontal size (in pixels) for displaying the page.
3318 ///
3319 /// `size_y` - Vertical size (in pixels) for displaying the page.
3320 ///
3321 /// `rotate` - Page orientation:
3322 /// 0 (normal)
3323 /// 1 (rotated 90 degrees clockwise)
3324 /// 2 (rotated 180 degrees)
3325 /// 3 (rotated 90 degrees counter-clockwise)
3326 ///
3327 /// `flags` - 0 for normal display, or combination of flags defined above.
3328 #[allow(non_snake_case)]
3329 fn FPDF_RenderPage(
3330 &self,
3331 dc: HDC,
3332 page: FPDF_PAGE,
3333 start_x: c_int,
3334 start_y: c_int,
3335 size_x: c_int,
3336 size_y: c_int,
3337 rotate: c_int,
3338 flags: c_int,
3339 ) {
3340 }
3341
3342 /// Renders contents of a page to a device independent bitmap.
3343 ///
3344 /// `bitmap` - Handle to the device independent bitmap (as the
3345 /// output buffer). The bitmap handle can be created
3346 /// by [PdfiumLibraryBindings::FPDFBitmap_Create] or retrieved from an image
3347 /// object by [PdfiumLibraryBindings::FPDFImageObj_GetBitmap].
3348 ///
3349 /// `page` - Handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
3350 ///
3351 /// `start_x` - Left pixel position of the display area in bitmap coordinates.
3352 ///
3353 /// `start_y` - Top pixel position of the display area in bitmap coordinates.
3354 ///
3355 /// `size_x` - Horizontal size (in pixels) for displaying the page.
3356 ///
3357 /// `size_y` - Vertical size (in pixels) for displaying the page.
3358 ///
3359 /// `rotate` - Page orientation:
3360 /// 0 (normal)
3361 /// 1 (rotated 90 degrees clockwise)
3362 /// 2 (rotated 180 degrees)
3363 /// 3 (rotated 90 degrees counter-clockwise)
3364 ///
3365 /// `flags` - 0 for normal display, or combination of the Page Rendering flags defined above.
3366 /// With the `FPDF_ANNOT` flag, it renders all annotations that do not require
3367 /// user-interaction, which are all annotations except widget and popup annotations.
3368 #[allow(non_snake_case)]
3369 #[allow(clippy::too_many_arguments)]
3370 fn FPDF_RenderPageBitmap(
3371 &self,
3372 bitmap: FPDF_BITMAP,
3373 page: FPDF_PAGE,
3374 start_x: c_int,
3375 start_y: c_int,
3376 size_x: c_int,
3377 size_y: c_int,
3378 rotate: c_int,
3379 flags: c_int,
3380 );
3381
3382 /// Renders contents of a page to a device independent bitmap.
3383 ///
3384 /// `bitmap` - Handle to the device independent bitmap (as the
3385 /// output buffer). The bitmap handle can be created
3386 /// by [PdfiumLibraryBindings::FPDFBitmap_Create] or retrieved by
3387 /// [PdfiumLibraryBindings::FPDFImageObj_GetBitmap].
3388 ///
3389 /// `page` - Handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
3390 ///
3391 /// `matrix` - The transform matrix, which must be invertible.
3392 /// See PDF Reference 1.7, 4.2.2 Common Transformations.
3393 ///
3394 /// `clipping` - The rect to clip to in device coords.
3395 ///
3396 /// `flags` - 0 for normal display, or combination of the Page Rendering flags defined above.
3397 /// With the `FPDF_ANNOT` flag, it renders all annotations that do not require
3398 /// user-interaction, which are all annotations except widget and popup annotations.
3399 ///
3400 /// Note that behavior is undefined if det of `matrix` is 0.
3401 #[allow(non_snake_case)]
3402 fn FPDF_RenderPageBitmapWithMatrix(
3403 &self,
3404 bitmap: FPDF_BITMAP,
3405 page: FPDF_PAGE,
3406 matrix: *const FS_MATRIX,
3407 clipping: *const FS_RECTF,
3408 flags: c_int,
3409 );
3410
3411 #[cfg(feature = "pdfium_use_skia")]
3412 /// Renders contents of a page to a Skia SkCanvas.
3413 ///
3414 /// `canvas` - SkCanvas to render to.
3415 ///
3416 /// `page` - Handle to the page.
3417 ///
3418 /// `size_x` - Horizontal size (in pixels) for displaying the page.
3419 ///
3420 /// `size_y` - Vertical size (in pixels) for displaying the page.
3421 #[allow(non_snake_case)]
3422 fn FPDF_RenderPageSkia(
3423 &self,
3424 canvas: FPDF_SKIA_CANVAS,
3425 page: FPDF_PAGE,
3426 size_x: c_int,
3427 size_y: c_int,
3428 );
3429
3430 /// Checks if an annotation subtype is currently supported for creation.
3431 /// Currently supported subtypes:
3432 ///
3433 /// - circle
3434 ///
3435 /// - file attachment
3436 ///
3437 /// - freetext
3438 ///
3439 /// - highlight
3440 ///
3441 /// - ink
3442 ///
3443 /// - link
3444 ///
3445 /// - popup
3446 ///
3447 /// - square
3448 ///
3449 /// - squiggly
3450 ///
3451 /// - stamp
3452 ///
3453 /// - strikeout
3454 ///
3455 /// - text
3456 ///
3457 /// - underline
3458 ///
3459 /// `subtype` - the subtype to be checked.
3460 ///
3461 /// Returns `true` if this subtype supported.
3462 #[allow(non_snake_case)]
3463 fn FPDFAnnot_IsSupportedSubtype(&self, subtype: FPDF_ANNOTATION_SUBTYPE) -> FPDF_BOOL;
3464
3465 /// Creates an annotation in `page` of the subtype `subtype`. If the specified
3466 /// subtype is illegal or unsupported, then a new annotation will not be created.
3467 /// Must call [PdfiumLibraryBindings::FPDFPage_CloseAnnot] when the annotation returned by this
3468 /// function is no longer needed.
3469 ///
3470 /// `page` - handle to a page.
3471 ///
3472 /// `subtype` - the subtype of the new annotation.
3473 ///
3474 /// Returns a handle to the new annotation object, or `NULL` on failure.
3475 #[allow(non_snake_case)]
3476 fn FPDFPage_CreateAnnot(
3477 &self,
3478 page: FPDF_PAGE,
3479 subtype: FPDF_ANNOTATION_SUBTYPE,
3480 ) -> FPDF_ANNOTATION;
3481
3482 /// Gets the number of annotations in `page`.
3483 ///
3484 /// `page` - handle to a page.
3485 ///
3486 /// Returns the number of annotations in `page`.
3487 #[allow(non_snake_case)]
3488 fn FPDFPage_GetAnnotCount(&self, page: FPDF_PAGE) -> c_int;
3489
3490 /// Gets annotation in `page` at `index`. Must call [PdfiumLibraryBindings::FPDFPage_CloseAnnot] when the
3491 /// annotation returned by this function is no longer needed.
3492 ///
3493 /// `page` - handle to a page.
3494 ///
3495 /// `index` - the index of the annotation.
3496 ///
3497 /// Returns a handle to the annotation object, or `NULL` on failure.
3498 #[allow(non_snake_case)]
3499 fn FPDFPage_GetAnnot(&self, page: FPDF_PAGE, index: c_int) -> FPDF_ANNOTATION;
3500
3501 /// Gets the index of `annot` in `page`. This is the opposite of
3502 /// [PdfiumLibraryBindings::FPDFPage_GetAnnot].
3503 ///
3504 /// `page` - handle to the page that the annotation is on.
3505 ///
3506 /// `annot` - handle to an annotation.
3507 ///
3508 /// Returns the index of `annot`, or -1 on failure.
3509 #[allow(non_snake_case)]
3510 fn FPDFPage_GetAnnotIndex(&self, page: FPDF_PAGE, annot: FPDF_ANNOTATION) -> c_int;
3511
3512 /// Closes an annotation. Must be called when the annotation returned by
3513 /// [PdfiumLibraryBindings::FPDFPage_CreateAnnot] or [PdfiumLibraryBindings::FPDFPage_GetAnnot]
3514 /// is no longer needed. This function does not remove the annotation from the document.
3515 ///
3516 /// `annot` - handle to an annotation.
3517 #[allow(non_snake_case)]
3518 fn FPDFPage_CloseAnnot(&self, annot: FPDF_ANNOTATION);
3519
3520 /// Removes the annotation in `page` at `index`.
3521 ///
3522 /// `page` - handle to a page.
3523 ///
3524 /// `index` - the index of the annotation.
3525 ///
3526 /// Returns `true` if successful.
3527 #[allow(non_snake_case)]
3528 fn FPDFPage_RemoveAnnot(&self, page: FPDF_PAGE, index: c_int) -> FPDF_BOOL;
3529
3530 /// Gets the subtype of an annotation.
3531 ///
3532 /// `annot` - handle to an annotation.
3533 ///
3534 /// Returns the annotation subtype.
3535 #[allow(non_snake_case)]
3536 fn FPDFAnnot_GetSubtype(&self, annot: FPDF_ANNOTATION) -> FPDF_ANNOTATION_SUBTYPE;
3537
3538 /// Checks if an annotation subtype is currently supported for object extraction,
3539 /// update, and removal.
3540 ///
3541 /// Currently supported subtypes: ink and stamp.
3542 ///
3543 /// `subtype` - the subtype to be checked.
3544 ///
3545 /// Returns `true` if this subtype supported.
3546 #[allow(non_snake_case)]
3547 fn FPDFAnnot_IsObjectSupportedSubtype(&self, subtype: FPDF_ANNOTATION_SUBTYPE) -> FPDF_BOOL;
3548
3549 /// Updates `obj` in `annot`. `obj` must be in `annot` already and must have
3550 /// been retrieved by [PdfiumLibraryBindings::FPDFAnnot_GetObject]. Currently, only ink and stamp
3551 /// annotations are supported by this API. Also note that only path, image, and
3552 /// text objects have APIs for modification; see `FPDFPath_*()`, `FPDFText_*()`, and
3553 /// `FPDFImageObj_*()`.
3554 ///
3555 /// `annot` - handle to an annotation.
3556 ///
3557 /// `obj` - handle to the object that `annot` needs to update.
3558 ///
3559 /// Returns `true` if successful.
3560 #[allow(non_snake_case)]
3561 fn FPDFAnnot_UpdateObject(&self, annot: FPDF_ANNOTATION, obj: FPDF_PAGEOBJECT) -> FPDF_BOOL;
3562
3563 /// Adds a new InkStroke, represented by an array of points, to the InkList of
3564 /// `annot`. The API creates an InkList if one doesn't already exist in `annot`.
3565 /// This API works only for ink annotations. Please refer to ISO 32000-1:2008
3566 /// spec, section 12.5.6.13.
3567 ///
3568 /// `annot` - handle to an annotation.
3569 ///
3570 /// `points` - pointer to a `FS_POINTF` array representing input points.
3571 ///
3572 /// `point_count` - number of elements in `points` array. This should not exceed
3573 /// the maximum value that can be represented by an `int32_t`.
3574 ///
3575 /// Returns the 0-based index at which the new InkStroke is added in the InkList
3576 /// of the `annot`. Returns -1 on failure.
3577 #[allow(non_snake_case)]
3578 fn FPDFAnnot_AddInkStroke(
3579 &self,
3580 annot: FPDF_ANNOTATION,
3581 points: *const FS_POINTF,
3582 point_count: size_t,
3583 ) -> c_int;
3584
3585 /// Removes an InkList in `annot`.
3586 ///
3587 /// This API works only for ink annotations.
3588 ///
3589 /// `annot` - handle to an annotation.
3590 ///
3591 /// Return true on successful removal of `/InkList` entry from context of the
3592 /// non-null ink `annot`. Returns `false` on failure.
3593 #[allow(non_snake_case)]
3594 fn FPDFAnnot_RemoveInkList(&self, annot: FPDF_ANNOTATION) -> FPDF_BOOL;
3595
3596 /// Adds `obj` to `annot`. `obj` must have been created by
3597 /// [PdfiumLibraryBindings::FPDFPageObj_CreateNewPath], [PdfiumLibraryBindings::FPDFPageObj_CreateNewRect],
3598 /// [PdfiumLibraryBindings::FPDFPageObj_NewTextObj], or [PdfiumLibraryBindings::FPDFPageObj_NewImageObj], and
3599 /// will be owned by `annot`. Note that an `obj` cannot belong to more than one
3600 /// `annot`. Currently, only ink and stamp annotations are supported by this API.
3601 /// Also note that only path, image, and text objects have APIs for creation.
3602 ///
3603 /// `annot` - handle to an annotation.
3604 ///
3605 /// `obj` - handle to the object that is to be added to `annot`.
3606 ///
3607 /// Returns `true` if successful.
3608 #[allow(non_snake_case)]
3609 fn FPDFAnnot_AppendObject(&self, annot: FPDF_ANNOTATION, obj: FPDF_PAGEOBJECT) -> FPDF_BOOL;
3610
3611 /// Gets the total number of objects in `annot`, including path objects, text
3612 /// objects, external objects, image objects, and shading objects.
3613 ///
3614 /// `annot` - handle to an annotation.
3615 ///
3616 /// Returns the number of objects in `annot`.
3617 #[allow(non_snake_case)]
3618 fn FPDFAnnot_GetObjectCount(&self, annot: FPDF_ANNOTATION) -> c_int;
3619
3620 /// Gets the object in `annot` at `index`.
3621 ///
3622 /// `annot` - handle to an annotation.
3623 ///
3624 /// `index` - the index of the object.
3625 ///
3626 /// Returns a handle to the object, or `NULL` on failure.
3627 #[allow(non_snake_case)]
3628 fn FPDFAnnot_GetObject(&self, annot: FPDF_ANNOTATION, index: c_int) -> FPDF_PAGEOBJECT;
3629
3630 /// Removes the object in `annot` at `index`.
3631 ///
3632 /// `annot` - handle to an annotation.
3633 ///
3634 /// `index` - the index of the object to be removed.
3635 ///
3636 /// Returns `true` if successful.
3637 #[allow(non_snake_case)]
3638 fn FPDFAnnot_RemoveObject(&self, annot: FPDF_ANNOTATION, index: c_int) -> FPDF_BOOL;
3639
3640 /// Sets the color of an annotation. Fails when called on annotations with
3641 /// appearance streams already defined; instead use
3642 /// [PdfiumLibraryBindings::FPDFPageObj_SetStrokeColor] or [PdfiumLibraryBindings::FPDFPageObj_SetFillColor].
3643 ///
3644 /// `annot` - handle to an annotation.
3645 ///
3646 /// `type` - type of the color to be set.
3647 ///
3648 /// `R`, `G`, `B` - buffers to hold the RGB values of the color. Ranges from 0 to 255.
3649 ///
3650 /// `A` - buffers to hold the opacity. Ranges from 0 to 255.
3651 ///
3652 /// Returns `true` if successful.
3653 #[allow(non_snake_case)]
3654 fn FPDFAnnot_SetColor(
3655 &self,
3656 annot: FPDF_ANNOTATION,
3657 color_type: FPDFANNOT_COLORTYPE,
3658 R: c_uint,
3659 G: c_uint,
3660 B: c_uint,
3661 A: c_uint,
3662 ) -> FPDF_BOOL;
3663
3664 /// Gets the color of an annotation. If no color is specified, default to yellow
3665 /// for highlight annotation, black for all else. Fails when called on
3666 /// annotations with appearance streams already defined; instead use
3667 /// [PdfiumLibraryBindings::FPDFPageObj_GetStrokeColor] or [PdfiumLibraryBindings::FPDFPageObj_GetFillColor].
3668 ///
3669 /// `annot` - handle to an annotation.
3670 ///
3671 /// `type` - type of the color requested.
3672 ///
3673 /// `R`, `G`, `B` - buffers to hold the RGB values of the color. Ranges from 0 to 255.
3674 ///
3675 /// `A` - buffer to hold the opacity. Ranges from 0 to 255.
3676 ///
3677 /// Returns `true` if successful.
3678 #[allow(non_snake_case)]
3679 fn FPDFAnnot_GetColor(
3680 &self,
3681 annot: FPDF_ANNOTATION,
3682 color_type: FPDFANNOT_COLORTYPE,
3683 R: *mut c_uint,
3684 G: *mut c_uint,
3685 B: *mut c_uint,
3686 A: *mut c_uint,
3687 ) -> FPDF_BOOL;
3688
3689 /// Checks if the annotation is of a type that has attachment points
3690 /// (i.e. quadpoints). Quadpoints are the vertices of the rectangle that
3691 /// encompasses the texts affected by the annotation. They provide the
3692 /// coordinates in the page where the annotation is attached. Only text markup
3693 /// annotations (i.e. highlight, strikeout, squiggly, and underline) and link
3694 /// annotations have quadpoints.
3695 ///
3696 /// `annot` - handle to an annotation.
3697 ///
3698 /// Returns `true` if the annotation is of a type that has quadpoints.
3699 #[allow(non_snake_case)]
3700 fn FPDFAnnot_HasAttachmentPoints(&self, annot: FPDF_ANNOTATION) -> FPDF_BOOL;
3701
3702 /// Replaces the attachment points (i.e. quadpoints) set of an annotation at
3703 /// `quad_index`. This index needs to be within the result of
3704 /// [PdfiumLibraryBindings::FPDFAnnot_CountAttachmentPoints].
3705 ///
3706 /// If the annotation's appearance stream is defined and this annotation is of a
3707 /// type with quadpoints, then update the bounding box too if the new quadpoints
3708 /// define a bigger one.
3709 ///
3710 /// `annot` - handle to an annotation.
3711 ///
3712 /// `quad_index` - index of the set of quadpoints.
3713 ///
3714 /// `quad_points` - the quadpoints to be set.
3715 ///
3716 /// Returns `true` if successful.
3717 #[allow(non_snake_case)]
3718 fn FPDFAnnot_SetAttachmentPoints(
3719 &self,
3720 annot: FPDF_ANNOTATION,
3721 quad_index: size_t,
3722 quad_points: *const FS_QUADPOINTSF,
3723 ) -> FPDF_BOOL;
3724
3725 /// Appends to the list of attachment points (i.e. quadpoints) of an annotation.
3726 /// If the annotation's appearance stream is defined and this annotation is of a
3727 /// type with quadpoints, then update the bounding box too if the new quadpoints
3728 /// define a bigger one.
3729 ///
3730 /// `annot` - handle to an annotation.
3731 ///
3732 /// `quad_points` - the quadpoints to be set.
3733 ///
3734 /// Returns `true` if successful.
3735 #[allow(non_snake_case)]
3736 fn FPDFAnnot_AppendAttachmentPoints(
3737 &self,
3738 annot: FPDF_ANNOTATION,
3739 quad_points: *const FS_QUADPOINTSF,
3740 ) -> FPDF_BOOL;
3741
3742 /// Gets the number of sets of quadpoints of an annotation.
3743 ///
3744 /// `annot` - handle to an annotation.
3745 ///
3746 /// Returns the number of sets of quadpoints, or 0 on failure.
3747 #[allow(non_snake_case)]
3748 fn FPDFAnnot_CountAttachmentPoints(&self, annot: FPDF_ANNOTATION) -> size_t;
3749
3750 /// Gets the attachment points (i.e. quadpoints) of an annotation.
3751 ///
3752 /// `annot` - handle to an annotation.
3753 ///
3754 /// `quad_index` - index of the set of quadpoints.
3755 ///
3756 /// `quad_points` - receives the quadpoints; must not be `NULL`.
3757 ///
3758 /// Returns `true` if successful.
3759 #[allow(non_snake_case)]
3760 fn FPDFAnnot_GetAttachmentPoints(
3761 &self,
3762 annot: FPDF_ANNOTATION,
3763 quad_index: size_t,
3764 quad_points: *mut FS_QUADPOINTSF,
3765 ) -> FPDF_BOOL;
3766
3767 /// Sets the annotation rectangle defining the location of the annotation. If the
3768 /// annotation's appearance stream is defined and this annotation is of a type
3769 /// without quadpoints, then update the bounding box too if the new rectangle
3770 /// defines a bigger one.
3771 ///
3772 /// `annot` - handle to an annotation.
3773 ///
3774 /// `rect` - the annotation rectangle to be set.
3775 ///
3776 /// Returns `true` if successful.
3777 #[allow(non_snake_case)]
3778 fn FPDFAnnot_SetRect(&self, annot: FPDF_ANNOTATION, rect: *const FS_RECTF) -> FPDF_BOOL;
3779
3780 /// Gets the annotation rectangle defining the location of the annotation.
3781 ///
3782 /// `annot` - handle to an annotation.
3783 ///
3784 /// `rect` - receives the rectangle; must not be `NULL`.
3785 ///
3786 /// Returns `true` if successful.
3787 #[allow(non_snake_case)]
3788 fn FPDFAnnot_GetRect(&self, annot: FPDF_ANNOTATION, rect: *mut FS_RECTF) -> FPDF_BOOL;
3789
3790 /// Gets the vertices of a polygon or polyline annotation. `buffer` is an array of
3791 /// points of the annotation. If `length` is less than the returned length, or
3792 /// `annot` or `buffer` is `NULL`, `buffer` will not be modified.
3793 ///
3794 /// `annot` - handle to an annotation, as returned by e.g. [PdfiumLibraryBindings::FPDFPage_GetAnnot]
3795 ///
3796 /// `buffer` - buffer for holding the points.
3797 ///
3798 /// `length` - length of the buffer in points.
3799 ///
3800 /// Returns the number of points if the annotation is of type polygon or
3801 /// polyline, 0 otherwise.
3802 #[allow(non_snake_case)]
3803 fn FPDFAnnot_GetVertices(
3804 &self,
3805 annot: FPDF_ANNOTATION,
3806 buffer: *mut FS_POINTF,
3807 length: c_ulong,
3808 ) -> c_ulong;
3809
3810 /// Gets the number of paths in the ink list of an ink annotation.
3811 ///
3812 /// `annot` - handle to an annotation, as returned by e.g. [PdfiumLibraryBindings::FPDFPage_GetAnnot]
3813 ///
3814 /// Returns the number of paths in the ink list if the annotation is of type ink,
3815 /// 0 otherwise.
3816 #[allow(non_snake_case)]
3817 fn FPDFAnnot_GetInkListCount(&self, annot: FPDF_ANNOTATION) -> c_ulong;
3818
3819 /// Gets a path in the ink list of an ink annotation. `buffer` is an array of
3820 /// points of the path. If `length` is less than the returned length, or `annot`
3821 /// or `buffer` is `NULL`, `buffer` will not be modified.
3822 ///
3823 /// `annot` - handle to an annotation, as returned by e.g. [PdfiumLibraryBindings::FPDFPage_GetAnnot]
3824 ///
3825 /// `path_index` - index of the path.
3826 ///
3827 /// `buffer` - buffer for holding the points.
3828 ///
3829 /// `length` - length of the buffer in points.
3830 ///
3831 /// Returns the number of points of the path if the annotation is of type ink, 0
3832 /// otherwise.
3833 #[allow(non_snake_case)]
3834 fn FPDFAnnot_GetInkListPath(
3835 &self,
3836 annot: FPDF_ANNOTATION,
3837 path_index: c_ulong,
3838 buffer: *mut FS_POINTF,
3839 length: c_ulong,
3840 ) -> c_ulong;
3841
3842 /// Gets the starting and ending coordinates of a line annotation.
3843 ///
3844 /// `annot` - handle to an annotation, as returned by e.g. [PdfiumLibraryBindings::FPDFPage_GetAnnot]
3845 ///
3846 /// `start` - starting point
3847 ///
3848 /// `end` - ending point
3849 ///
3850 /// Returns `true` if the annotation is of type line and `start` and `end` are not `NULL`.
3851 #[allow(non_snake_case)]
3852 fn FPDFAnnot_GetLine(
3853 &self,
3854 annot: FPDF_ANNOTATION,
3855 start: *mut FS_POINTF,
3856 end: *mut FS_POINTF,
3857 ) -> FPDF_BOOL;
3858
3859 /// Sets the characteristics of the annotation's border (rounded rectangle).
3860 ///
3861 /// `annot` - handle to an annotation.
3862 ///
3863 /// `horizontal_radius` - horizontal corner radius, in default user space units.
3864 ///
3865 /// `vertical_radius` - vertical corner radius, in default user space units.
3866 ///
3867 /// `border_width` - border width, in default user space units.
3868 ///
3869 /// Returns `true` if setting the border for `annot` succeeds.
3870 ///
3871 /// If `annot` contains an appearance stream that overrides the border values,
3872 /// then the appearance stream will be removed on success.
3873 #[allow(non_snake_case)]
3874 fn FPDFAnnot_SetBorder(
3875 &self,
3876 annot: FPDF_ANNOTATION,
3877 horizontal_radius: c_float,
3878 vertical_radius: c_float,
3879 border_width: c_float,
3880 ) -> FPDF_BOOL;
3881
3882 /// Gets the characteristics of the annotation's border (rounded rectangle).
3883 ///
3884 /// `annot` - handle to an annotation.
3885 ///
3886 /// `horizontal_radius` - horizontal corner radius, in default user space units.
3887 ///
3888 /// `vertical_radius` - vertical corner radius, in default user space units.
3889 ///
3890 /// `border_width` - border width, in default user space units.
3891 ///
3892 /// Returns `true` if `horizontal_radius`, `vertical_radius` and `border_width` are not `NULL`.
3893 #[allow(non_snake_case)]
3894 fn FPDFAnnot_GetBorder(
3895 &self,
3896 annot: FPDF_ANNOTATION,
3897 horizontal_radius: *mut c_float,
3898 vertical_radius: *mut c_float,
3899 border_width: *mut c_float,
3900 ) -> FPDF_BOOL;
3901
3902 /// Get the JavaScript of an event of the annotation's additional actions.
3903 ///
3904 /// `buffer` is only modified if `buflen` is large enough to hold the whole
3905 /// JavaScript string. If `buflen` is smaller, the total size of the JavaScript
3906 /// is still returned, but nothing is copied. If there is no JavaScript for
3907 /// `event` in `annot`, an empty string is written to `buf` and 2 is returned,
3908 /// denoting the size of the null terminator in the buffer. On other errors,
3909 /// nothing is written to `buffer` and 0 is returned.
3910 ///
3911 /// `form` - handle to the form fill module, returned by
3912 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment()].
3913 ///
3914 /// `annot` - handle to an interactive form annotation.
3915 ///
3916 /// `event` - event type, one of the `FPDF_ANNOT_AACTION_*` values.
3917 ///
3918 /// `buffer` - buffer for holding the value string, encoded in UTF-16LE.
3919 ///
3920 /// `buflen` - length of the buffer in bytes.
3921 ///
3922 /// Returns the length of the string value in bytes, including the 2-byte null terminator.
3923 #[allow(non_snake_case)]
3924 fn FPDFAnnot_GetFormAdditionalActionJavaScript(
3925 &self,
3926 form: FPDF_FORMHANDLE,
3927 annot: FPDF_ANNOTATION,
3928 event: c_int,
3929 buffer: *mut FPDF_WCHAR,
3930 buflen: c_ulong,
3931 ) -> c_ulong;
3932
3933 /// Gets the alternate name of `annot`, which is an interactive form annotation.
3934 ///
3935 /// `buffer` is only modified if `buflen` is longer than the length of contents.
3936 /// In case of error, nothing will be added to `buffer` and the return value will be 0.
3937 /// Note that return value of empty string is 2 for `\0\0`.
3938 ///
3939 /// `form` - handle to the form fill module, returned by
3940 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment()].
3941 ///
3942 /// `annot` - handle to an interactive form annotation.
3943 ///
3944 /// `buffer` - buffer for holding the alternate name string, encoded in
3945 /// UTF-16LE.
3946 ///
3947 /// `buflen` - length of the buffer in bytes.
3948 ///
3949 /// Returns the length of the string value in bytes.
3950 #[allow(non_snake_case)]
3951 fn FPDFAnnot_GetFormFieldAlternateName(
3952 &self,
3953 form: FPDF_FORMHANDLE,
3954 annot: FPDF_ANNOTATION,
3955 buffer: *mut FPDF_WCHAR,
3956 buflen: c_ulong,
3957 ) -> c_ulong;
3958
3959 /// Check if `annot`'s dictionary has `key` as a key.
3960 ///
3961 /// `annot` - handle to an annotation.
3962 ///
3963 /// `key` - the key to look for, encoded in UTF-8.
3964 ///
3965 /// Returns `true` if `key` exists.
3966 #[allow(non_snake_case)]
3967 fn FPDFAnnot_HasKey(&self, annot: FPDF_ANNOTATION, key: &str) -> FPDF_BOOL;
3968
3969 /// Gets the type of the value corresponding to `key` in `annot`'s dictionary.
3970 ///
3971 /// `annot` - handle to an annotation.
3972 ///
3973 /// `key` - the key to look for, encoded in UTF-8.
3974 ///
3975 /// Returns the type of the dictionary value.
3976 #[allow(non_snake_case)]
3977 fn FPDFAnnot_GetValueType(&self, annot: FPDF_ANNOTATION, key: &str) -> FPDF_OBJECT_TYPE;
3978
3979 /// Sets the string value corresponding to `key` in `annot`'s dictionary,
3980 /// overwriting the existing value if any. The value type would be
3981 /// `FPDF_OBJECT_STRING` after this function call succeeds.
3982 ///
3983 /// `annot` - handle to an annotation.
3984 ///
3985 /// `key` - the key to the dictionary entry to be set, encoded in UTF-8.
3986 ///
3987 /// `value` - the string value to be set, encoded in UTF-16LE.
3988 ///
3989 /// Returns `true` if successful.
3990 ///
3991 /// A [&str]-friendly helper function is available for this function.
3992 /// See [PdfiumLibraryBindings::FPDFAnnot_SetStringValue_str].
3993 #[allow(non_snake_case)]
3994 fn FPDFAnnot_SetStringValue(
3995 &self,
3996 annot: FPDF_ANNOTATION,
3997 key: &str,
3998 value: FPDF_WIDESTRING,
3999 ) -> FPDF_BOOL;
4000
4001 /// A [&str]-friendly helper function for [PdfiumLibraryBindings::FPDFAnnot_SetStringValue].
4002 ///
4003 /// Sets the string value corresponding to `key` in `annot`'s dictionary,
4004 /// overwriting the existing value if any. The value type would be
4005 /// `FPDF_OBJECT_STRING` after this function call succeeds.
4006 ///
4007 /// `annot` - handle to an annotation.
4008 ///
4009 /// `key` - the key to the dictionary entry to be set.
4010 ///
4011 /// `value` - the string value to be set.
4012 ///
4013 /// Returns `true` if successful.
4014 #[inline]
4015 #[allow(non_snake_case)]
4016 fn FPDFAnnot_SetStringValue_str(
4017 &self,
4018 annot: FPDF_ANNOTATION,
4019 key: &str,
4020 value: &str,
4021 ) -> FPDF_BOOL {
4022 self.FPDFAnnot_SetStringValue(
4023 annot,
4024 key,
4025 get_pdfium_utf16le_bytes_from_str(value).as_ptr() as FPDF_WIDESTRING,
4026 )
4027 }
4028
4029 /// Gets the string value corresponding to `key` in `annot`'s dictionary. `buffer`
4030 /// is only modified if `buflen` is longer than the length of contents. Note that
4031 /// if `key` does not exist in the dictionary or if `key`'s corresponding value
4032 /// in the dictionary is not a string (i.e. the value is not of type
4033 /// `FPDF_OBJECT_STRING` or `FPDF_OBJECT_NAME`), then an empty string would be copied
4034 /// to `buffer` and the return value would be 2. On other errors, nothing would
4035 /// be added to `buffer` and the return value would be 0.
4036 ///
4037 /// `annot` - handle to an annotation.
4038 ///
4039 /// `key` - the key to the requested dictionary entry, encoded in UTF-8.
4040 ///
4041 /// `buffer` - buffer for holding the value string, encoded in UTF-16LE.
4042 ///
4043 /// `buflen` - length of the buffer in bytes.
4044 ///
4045 /// Returns the length of the string value in bytes.
4046 #[allow(non_snake_case)]
4047 fn FPDFAnnot_GetStringValue(
4048 &self,
4049 annot: FPDF_ANNOTATION,
4050 key: &str,
4051 buffer: *mut FPDF_WCHAR,
4052 buflen: c_ulong,
4053 ) -> c_ulong;
4054
4055 /// Gets the float value corresponding to `key` in `annot`'s dictionary. Writes
4056 /// value to `value` and returns `true` if `key` exists in the dictionary and
4057 /// `key`'s corresponding value is a number (`FPDF_OBJECT_NUMBER`), `false`
4058 /// otherwise.
4059 ///
4060 /// `annot` - handle to an annotation.
4061 ///
4062 /// `key` - the key to the requested dictionary entry, encoded in UTF-8.
4063 ///
4064 /// `value` - receives the value, must not be `NULL`.
4065 ///
4066 /// Returns `true` if value found.
4067 #[allow(non_snake_case)]
4068 fn FPDFAnnot_GetNumberValue(
4069 &self,
4070 annot: FPDF_ANNOTATION,
4071 key: &str,
4072 value: *mut c_float,
4073 ) -> FPDF_BOOL;
4074
4075 /// Sets the AP (appearance string) in `annot`'s dictionary for a given
4076 /// `appearanceMode`.
4077 ///
4078 /// `annot` - handle to an annotation.
4079 ///
4080 /// `appearanceMode` - the appearance mode (normal, rollover or down) for which
4081 /// to set the AP.
4082 ///
4083 /// `value` - the string value to be set, encoded in UTF-16LE. If
4084 /// `nullptr` is passed, the AP is cleared for that mode. If the
4085 /// mode is Normal, APs for all modes are cleared.
4086 ///
4087 /// Returns `true` if successful.
4088 ///
4089 /// A [&str]-friendly helper function is available for this function.
4090 /// See [PdfiumLibraryBindings::FPDFAnnot_SetAP_str].
4091 #[allow(non_snake_case)]
4092 fn FPDFAnnot_SetAP(
4093 &self,
4094 annot: FPDF_ANNOTATION,
4095 appearanceMode: FPDF_ANNOT_APPEARANCEMODE,
4096 value: FPDF_WIDESTRING,
4097 ) -> FPDF_BOOL;
4098
4099 /// A [&str]-friendly helper function for [PdfiumLibraryBindings::FPDFAnnot_SetAP].
4100 ///
4101 /// Sets the AP (appearance string) in `annot`'s dictionary for a given
4102 /// `appearanceMode`.
4103 ///
4104 /// `annot` - handle to an annotation.
4105 ///
4106 /// `appearanceMode` - the appearance mode (normal, rollover or down) for which
4107 /// to set the AP.
4108 ///
4109 /// `value` - the string value to be set.
4110 ///
4111 /// Returns `true` if successful.
4112 ///
4113 /// Note that this helper function cannot clear appearance strings, since it cannot pass
4114 /// a null pointer for `value`. To clear an appearance string, use [PdfiumLibraryBindings::FPDFAnnot_SetAP].
4115 #[inline]
4116 #[allow(non_snake_case)]
4117 fn FPDFAnnot_SetAP_str(
4118 &self,
4119 annot: FPDF_ANNOTATION,
4120 appearanceMode: FPDF_ANNOT_APPEARANCEMODE,
4121 value: &str,
4122 ) -> FPDF_BOOL {
4123 self.FPDFAnnot_SetAP(
4124 annot,
4125 appearanceMode,
4126 get_pdfium_utf16le_bytes_from_str(value).as_ptr() as FPDF_WIDESTRING,
4127 )
4128 }
4129
4130 /// Gets the AP (appearance string) from `annot`'s dictionary for a given
4131 /// `appearanceMode`.
4132 ///
4133 /// `buffer` is only modified if `buflen` is large enough to hold the whole AP
4134 /// string. If `buflen` is smaller, the total size of the AP is still returned,
4135 /// but nothing is copied.
4136 ///
4137 /// If there is no appearance stream for `annot` in `appearanceMode`, an empty
4138 /// string is written to `buf` and 2 is returned.
4139 ///
4140 /// On other errors, nothing is written to `buffer` and 0 is returned.
4141 ///
4142 /// `annot` - handle to an annotation.
4143 ///
4144 /// `appearanceMode` - the appearance mode (normal, rollover or down) for which
4145 /// to get the AP.
4146 ///
4147 /// `buffer` - buffer for holding the value string, encoded in UTF-16LE.
4148 ///
4149 /// `buflen` - length of the buffer in bytes.
4150 ///
4151 /// Returns the length of the string value in bytes.
4152 #[allow(non_snake_case)]
4153 fn FPDFAnnot_GetAP(
4154 &self,
4155 annot: FPDF_ANNOTATION,
4156 appearanceMode: FPDF_ANNOT_APPEARANCEMODE,
4157 buffer: *mut FPDF_WCHAR,
4158 buflen: c_ulong,
4159 ) -> c_ulong;
4160
4161 /// Gets the annotation corresponding to `key` in `annot`'s dictionary. Common
4162 /// keys for linking annotations include "IRT" and "Popup". Must call
4163 /// [PdfiumLibraryBindings::FPDFPage_CloseAnnot] when the annotation returned by this function
4164 /// is no longer needed.
4165 ///
4166 /// `annot` - handle to an annotation.
4167 ///
4168 /// `key` - the key to the requested dictionary entry, encoded in UTF-8.
4169 ///
4170 /// Returns a handle to the linked annotation object, or `NULL` on failure.
4171 #[allow(non_snake_case)]
4172 fn FPDFAnnot_GetLinkedAnnot(&self, annot: FPDF_ANNOTATION, key: &str) -> FPDF_ANNOTATION;
4173
4174 /// Gets the annotation flags of `annot`.
4175 ///
4176 /// `annot` - handle to an annotation.
4177 ///
4178 /// Returns the annotation flags.
4179 #[allow(non_snake_case)]
4180 fn FPDFAnnot_GetFlags(&self, annot: FPDF_ANNOTATION) -> c_int;
4181
4182 /// Sets the `annot`'s flags to be of the value `flags`.
4183 ///
4184 /// `annot` - handle to an annotation.
4185 ///
4186 /// `flags` - the flag values to be set.
4187 ///
4188 /// Returns `true` if successful.
4189 #[allow(non_snake_case)]
4190 fn FPDFAnnot_SetFlags(&self, annot: FPDF_ANNOTATION, flags: c_int) -> FPDF_BOOL;
4191
4192 /// Gets the annotation flags of `annot`.
4193 ///
4194 /// `handle` - the handle to the form fill module, returned by
4195 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4196 ///
4197 /// `annot` - handle to an interactive form annotation.
4198 ///
4199 /// Returns the annotation flags specific to interactive forms.
4200 #[allow(non_snake_case)]
4201 fn FPDFAnnot_GetFormFieldFlags(&self, form: FPDF_FORMHANDLE, annot: FPDF_ANNOTATION) -> c_int;
4202
4203 #[cfg(any(feature = "pdfium_future", feature = "pdfium_7350"))]
4204 /// Sets the form field flags for an interactive form annotation.
4205 ///
4206 /// `form` - the handle to the form fill module, returned by
4207 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4208 ///
4209 /// `annot` - handle to an interactive form annotation.
4210 ///
4211 /// `flags` - the form field flags to be set.
4212 ///
4213 /// Returns `true` if successful.
4214 #[allow(non_snake_case)]
4215 fn FPDFAnnot_SetFormFieldFlags(
4216 &self,
4217 form: FPDF_FORMHANDLE,
4218 annot: FPDF_ANNOTATION,
4219 flags: c_int,
4220 ) -> FPDF_BOOL;
4221
4222 /// Retrieves an interactive form annotation whose rectangle contains a given
4223 /// point on a page. Must call [PdfiumLibraryBindings::FPDFPage_CloseAnnot] when the
4224 /// annotation returned is no longer needed.
4225 ///
4226 /// `form` - handle to the form fill module, returned by
4227 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4228 ///
4229 /// `page` - handle to the page, returned by [PdfiumLibraryBindings::FPDF_LoadPage] function.
4230 ///
4231 /// `point` - position in PDF "user space".
4232 ///
4233 /// Returns the interactive form annotation whose rectangle contains the given
4234 /// coordinates on the page. If there is no such annotation, return `NULL`.
4235 #[allow(non_snake_case)]
4236 fn FPDFAnnot_GetFormFieldAtPoint(
4237 &self,
4238 form: FPDF_FORMHANDLE,
4239 page: FPDF_PAGE,
4240 point: *const FS_POINTF,
4241 ) -> FPDF_ANNOTATION;
4242
4243 /// Gets the name of `annot`, which is an interactive form annotation.
4244 /// `buffer` is only modified if `buflen` is longer than the length of contents.
4245 /// In case of error, nothing will be added to `buffer` and the return value will
4246 /// be 0. Note that return value of empty string is 2 for "\0\0".
4247 ///
4248 /// `form` - handle to the form fill module, returned by
4249 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4250 ///
4251 /// `annot` - handle to an interactive form annotation.
4252 ///
4253 /// `buffer` - buffer for holding the name string, encoded in UTF-16LE.
4254 ///
4255 /// `buflen` - length of the buffer in bytes.
4256 ///
4257 /// Returns the length of the string value in bytes.
4258 #[allow(non_snake_case)]
4259 fn FPDFAnnot_GetFormFieldName(
4260 &self,
4261 form: FPDF_FORMHANDLE,
4262 annot: FPDF_ANNOTATION,
4263 buffer: *mut FPDF_WCHAR,
4264 buflen: c_ulong,
4265 ) -> c_ulong;
4266
4267 /// Gets the form field type of `annot`, which is an interactive form annotation.
4268 ///
4269 /// `form` - handle to the form fill module, returned by
4270 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4271 ///
4272 /// `annot` - handle to an interactive form annotation.
4273 ///
4274 /// Returns the type of the form field (one of the `FPDF_FORMFIELD_*` values) on
4275 /// success. Returns -1 on error.
4276 #[allow(non_snake_case)]
4277 fn FPDFAnnot_GetFormFieldType(&self, form: FPDF_FORMHANDLE, annot: FPDF_ANNOTATION) -> c_int;
4278
4279 /// Gets the value of `annot`, which is an interactive form annotation.
4280 /// `buffer` is only modified if `buflen` is longer than the length of contents.
4281 /// In case of error, nothing will be added to `buffer` and the return value will
4282 /// be 0. Note that return value of empty string is 2 for "\0\0".
4283 ///
4284 /// `form` - handle to the form fill module, returned by
4285 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4286 ///
4287 /// `annot` - handle to an interactive form annotation.
4288 ///
4289 /// `buffer` - buffer for holding the value string, encoded in UTF-16LE.
4290 ///
4291 /// `buflen` - length of the buffer in bytes.
4292 ///
4293 /// Returns the length of the string value in bytes.
4294 #[allow(non_snake_case)]
4295 fn FPDFAnnot_GetFormFieldValue(
4296 &self,
4297 form: FPDF_FORMHANDLE,
4298 annot: FPDF_ANNOTATION,
4299 buffer: *mut FPDF_WCHAR,
4300 buflen: c_ulong,
4301 ) -> c_ulong;
4302
4303 /// Gets the number of options in the `annot`'s "Opt" dictionary. Intended for
4304 /// use with listbox and combobox widget annotations.
4305 ///
4306 /// `form` - handle to the form fill module, returned by
4307 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4308 ///
4309 /// `annot` - handle to an annotation.
4310 ///
4311 /// Returns the number of options in "Opt" dictionary on success. Return value
4312 /// will be -1 if annotation does not have an "Opt" dictionary or other error.
4313 #[allow(non_snake_case)]
4314 fn FPDFAnnot_GetOptionCount(&self, form: FPDF_FORMHANDLE, annot: FPDF_ANNOTATION) -> c_int;
4315
4316 /// Gets the string value for the label of the option at `index` in `annot`'s
4317 /// "Opt" dictionary. Intended for use with listbox and combobox widget
4318 /// annotations. `buffer` is only modified if `buflen` is longer than the length
4319 /// of contents. If index is out of range or in case of other error, nothing
4320 /// will be added to `buffer` and the return value will be 0. Note that
4321 /// return value of empty string is 2 for "\0\0".
4322 ///
4323 /// `form` - handle to the form fill module, returned by
4324 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4325 ///
4326 /// `annot` - handle to an annotation.
4327 ///
4328 /// `index` - numeric index of the option in the "Opt" array.
4329 ///
4330 /// `buffer` - buffer for holding the value string, encoded in UTF-16LE.
4331 ///
4332 /// `buflen` - length of the buffer in bytes.
4333 ///
4334 /// Returns the length of the string value in bytes.
4335 /// If `annot` does not have an "Opt" array, `index` is out of range or if any
4336 /// other error occurs, returns 0.
4337 #[allow(non_snake_case)]
4338 fn FPDFAnnot_GetOptionLabel(
4339 &self,
4340 form: FPDF_FORMHANDLE,
4341 annot: FPDF_ANNOTATION,
4342 index: c_int,
4343 buffer: *mut FPDF_WCHAR,
4344 buflen: c_ulong,
4345 ) -> c_ulong;
4346
4347 /// Determines whether or not the option at `index` in `annot`'s "Opt" dictionary
4348 /// is selected. Intended for use with listbox and combobox widget annotations.
4349 ///
4350 /// `form` - handle to the form fill module, returned by
4351 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4352 ///
4353 /// `annot` - handle to an annotation.
4354 ///
4355 /// `index` - numeric index of the option in the "Opt" array.
4356 ///
4357 /// Returns `true` if the option at `index` in `annot`'s "Opt" dictionary is selected.
4358 #[allow(non_snake_case)]
4359 fn FPDFAnnot_IsOptionSelected(
4360 &self,
4361 form: FPDF_FORMHANDLE,
4362 annot: FPDF_ANNOTATION,
4363 index: c_int,
4364 ) -> FPDF_BOOL;
4365
4366 /// Gets the float value of the font size for an `annot` with variable text.
4367 /// If 0, the font is to be auto-sized: its size is computed as a function of
4368 /// the height of the annotation rectangle.
4369 ///
4370 /// `form` - handle to the form fill module, returned by
4371 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4372 ///
4373 /// `annot` - handle to an annotation.
4374 ///
4375 /// `value` - Required. Float which will be set to font size on success.
4376 ///
4377 /// Returns `true` if the font size was set in `value`, `false` on error or if
4378 /// `value` not provided.
4379 #[allow(non_snake_case)]
4380 fn FPDFAnnot_GetFontSize(
4381 &self,
4382 form: FPDF_FORMHANDLE,
4383 annot: FPDF_ANNOTATION,
4384 value: *mut c_float,
4385 ) -> FPDF_BOOL;
4386
4387 #[cfg(any(feature = "pdfium_future", feature = "pdfium_7350"))]
4388 /// Experimental API.
4389 /// Set the text color of an annotation.
4390 ///
4391 /// `form` - handle to the form fill module, returned by
4392 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4393 ///
4394 /// `annot` - handle to an annotation.
4395 ///
4396 /// `R` - the red component for the text color.
4397 ///
4398 /// `G` - the green component for the text color.
4399 ///
4400 /// `B` - the blue component for the text color.
4401 ///
4402 /// Returns `true` if successful.
4403 ///
4404 /// Currently supported subtypes: freetext.
4405 /// The range for the color components is 0 to 255.
4406 #[allow(non_snake_case)]
4407 fn FPDFAnnot_SetFontColor(
4408 &self,
4409 form: FPDF_FORMHANDLE,
4410 annot: FPDF_ANNOTATION,
4411 R: c_uint,
4412 G: c_uint,
4413 B: c_uint,
4414 ) -> FPDF_BOOL;
4415
4416 #[cfg(any(
4417 feature = "pdfium_future",
4418 feature = "pdfium_7350",
4419 feature = "pdfium_7215",
4420 feature = "pdfium_7123",
4421 feature = "pdfium_6996",
4422 feature = "pdfium_6721",
4423 feature = "pdfium_6666",
4424 feature = "pdfium_6611",
4425 feature = "pdfium_6569",
4426 feature = "pdfium_6555",
4427 ))]
4428 /// Gets the RGB value of the font color for an `annot` with variable text.
4429 ///
4430 /// `form` - handle to the form fill module, returned by
4431 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4432 ///
4433 /// `annot` - handle to an annotation.
4434 ///
4435 /// `R`, `G`, `B` - buffer to hold the RGB value of the color. Ranges from 0 to 255.
4436 ///
4437 /// Returns `true` if the font color was set, `false` on error or if the font color
4438 /// was not provided.
4439 #[allow(non_snake_case)]
4440 fn FPDFAnnot_GetFontColor(
4441 &self,
4442 form: FPDF_FORMHANDLE,
4443 annot: FPDF_ANNOTATION,
4444 R: *mut c_uint,
4445 G: *mut c_uint,
4446 B: *mut c_uint,
4447 ) -> FPDF_BOOL;
4448
4449 /// Determines if `annot` is a form widget that is checked. Intended for use with
4450 /// checkbox and radio button widgets.
4451 ///
4452 /// `form` - handle to the form fill module, returned by
4453 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4454 ///
4455 /// `annot` - handle to an annotation.
4456 ///
4457 /// Returns `true` if `annot` is a form widget and is checked.
4458 #[allow(non_snake_case)]
4459 fn FPDFAnnot_IsChecked(&self, form: FPDF_FORMHANDLE, annot: FPDF_ANNOTATION) -> FPDF_BOOL;
4460
4461 /// Sets the list of focusable annotation subtypes. Annotations of subtype
4462 /// `FPDF_ANNOT_WIDGET` are by default focusable. New subtypes set using this API
4463 /// will override the existing subtypes.
4464 ///
4465 /// `form` - handle to the form fill module, returned by
4466 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4467 ///
4468 /// `subtypes` - list of annotation subtype which can be tabbed over.
4469 ///
4470 /// `count` - total number of annotation subtype in list.
4471 ///
4472 /// Returns `true` if list of annotation subtype is set successfully.
4473 #[allow(non_snake_case)]
4474 fn FPDFAnnot_SetFocusableSubtypes(
4475 &self,
4476 form: FPDF_FORMHANDLE,
4477 subtypes: *const FPDF_ANNOTATION_SUBTYPE,
4478 count: size_t,
4479 ) -> FPDF_BOOL;
4480
4481 /// Gets the count of focusable annotation subtypes as set by host
4482 /// for a `form`.
4483 ///
4484 /// `form` - handle to the form fill module, returned by
4485 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4486 ///
4487 /// Returns the count of focusable annotation subtypes or `-1` on error.
4488 ///
4489 /// Note: Annotations of type `FPDF_ANNOT_WIDGET` are by default focusable.
4490 #[allow(non_snake_case)]
4491 fn FPDFAnnot_GetFocusableSubtypesCount(&self, form: FPDF_FORMHANDLE) -> c_int;
4492
4493 /// Gets the list of focusable annotation subtype as set by host.
4494 ///
4495 /// `form` - handle to the form fill module, returned by
4496 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4497 ///
4498 /// `subtypes` - receives the list of annotation subtype which can be tabbed
4499 /// over. Caller must have allocated `subtypes` more than or
4500 /// equal to the count obtained from
4501 /// [PdfiumLibraryBindings::FPDFAnnot_GetFocusableSubtypesCount] API.
4502 ///
4503 /// `count` - size of `subtypes`.
4504 ///
4505 /// Returns `true` on success and sets list of annotation subtype to `subtypes`.
4506 ///
4507 /// Note: Annotations of type `FPDF_ANNOT_WIDGET` are by default focusable.
4508 #[allow(non_snake_case)]
4509 fn FPDFAnnot_GetFocusableSubtypes(
4510 &self,
4511 form: FPDF_FORMHANDLE,
4512 subtypes: *mut FPDF_ANNOTATION_SUBTYPE,
4513 count: size_t,
4514 ) -> FPDF_BOOL;
4515
4516 /// Gets `FPDF_LINK` object for `annot`. Intended to use for link annotations.
4517 ///
4518 /// `annot` - handle to an annotation.
4519 ///
4520 /// Returns `FPDF_LINK` from the `FPDF_ANNOTATION` and `NULL` on failure,
4521 /// if the input annot is `NULL`, or input annot's subtype is not link.
4522 #[allow(non_snake_case)]
4523 fn FPDFAnnot_GetLink(&self, annot: FPDF_ANNOTATION) -> FPDF_LINK;
4524
4525 /// Gets the count of annotations in the `annot`'s control group.
4526 ///
4527 /// A group of interactive form annotations is collectively called a form
4528 /// control group. Here, `annot`, an interactive form annotation, should be
4529 /// either a radio button or a checkbox.
4530 ///
4531 /// `form` - handle to the form fill module, returned by
4532 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4533 ///
4534 /// `annot` - handle to an annotation.
4535 ///
4536 /// Returns number of controls in its control group or `-1` on error.
4537 #[allow(non_snake_case)]
4538 fn FPDFAnnot_GetFormControlCount(&self, form: FPDF_FORMHANDLE, annot: FPDF_ANNOTATION)
4539 -> c_int;
4540
4541 /// Gets the index of `annot` in `annot`'s control group.
4542 ///
4543 /// A group of interactive form annotations is collectively called a form
4544 /// control group. Here, `annot`, an interactive form annotation, should be
4545 /// either a radio button or a checkbox.
4546 ///
4547 /// `form` - handle to the form fill module, returned by
4548 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4549 ///
4550 /// `annot` - handle to an annotation.
4551 ///
4552 /// Returns index of a given `annot` in its control group or `-1` on error.
4553 #[allow(non_snake_case)]
4554 fn FPDFAnnot_GetFormControlIndex(&self, form: FPDF_FORMHANDLE, annot: FPDF_ANNOTATION)
4555 -> c_int;
4556
4557 /// Gets the export value of `annot` which is an interactive form annotation.
4558 ///
4559 /// Intended for use with radio button and checkbox widget annotations.
4560 ///
4561 /// `buffer` is only modified if `buflen` is longer than the length of contents.
4562 /// In case of error, nothing will be added to `buffer` and the return value
4563 /// will be 0. Note that return value of empty string is 2 for "\0\0".
4564 ///
4565 /// `form` - handle to the form fill module, returned by
4566 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4567 ///
4568 /// `annot` - handle to an interactive form annotation.
4569 ///
4570 /// `buffer` - buffer for holding the value string, encoded in UTF-16LE.
4571 ///
4572 /// `buflen` - length of the buffer in bytes.
4573 ///
4574 /// Returns the length of the string value in bytes.
4575 #[allow(non_snake_case)]
4576 fn FPDFAnnot_GetFormFieldExportValue(
4577 &self,
4578 form: FPDF_FORMHANDLE,
4579 annot: FPDF_ANNOTATION,
4580 buffer: *mut FPDF_WCHAR,
4581 buflen: c_ulong,
4582 ) -> c_ulong;
4583
4584 /// Add a URI action to `annot`, overwriting the existing action, if any.
4585 ///
4586 /// `annot` - handle to a link annotation.
4587 ///
4588 /// `uri` - the URI to be set, encoded in 7-bit ASCII.
4589 ///
4590 /// Returns `true` if successful.
4591 #[allow(non_snake_case)]
4592 fn FPDFAnnot_SetURI(&self, annot: FPDF_ANNOTATION, uri: &str) -> FPDF_BOOL;
4593
4594 /// Get the attachment from `annot`.
4595 ///
4596 /// `annot` - handle to a file annotation.
4597 ///
4598 /// Returns the handle to the attachment object, or `NULL` on failure.
4599 #[cfg(any(
4600 feature = "pdfium_future",
4601 feature = "pdfium_7350",
4602 feature = "pdfium_7215",
4603 feature = "pdfium_7123",
4604 feature = "pdfium_6996",
4605 feature = "pdfium_6721",
4606 feature = "pdfium_6666",
4607 feature = "pdfium_6611",
4608 feature = "pdfium_6569",
4609 feature = "pdfium_6555",
4610 feature = "pdfium_6490",
4611 feature = "pdfium_6406",
4612 feature = "pdfium_6337",
4613 ))]
4614 #[allow(non_snake_case)]
4615 fn FPDFAnnot_GetFileAttachment(&self, annot: FPDF_ANNOTATION) -> FPDF_ATTACHMENT;
4616
4617 /// Add an embedded file with `name` to `annot`.
4618 ///
4619 /// `annot` - handle to a file annotation.
4620 ///
4621 /// `name` - name of the new attachment.
4622 ///
4623 /// Returns a handle to the new attachment object, or `NULL` on failure.
4624 ///
4625 /// A [&str]-friendly helper function is available for this function.
4626 /// See [PdfiumLibraryBindings::FPDFAnnot_AddFileAttachment_str].
4627 #[cfg(any(
4628 feature = "pdfium_future",
4629 feature = "pdfium_7350",
4630 feature = "pdfium_7215",
4631 feature = "pdfium_7123",
4632 feature = "pdfium_6996",
4633 feature = "pdfium_6721",
4634 feature = "pdfium_6666",
4635 feature = "pdfium_6611",
4636 feature = "pdfium_6569",
4637 feature = "pdfium_6555",
4638 feature = "pdfium_6490",
4639 feature = "pdfium_6406",
4640 feature = "pdfium_6337",
4641 ))]
4642 #[allow(non_snake_case)]
4643 fn FPDFAnnot_AddFileAttachment(
4644 &self,
4645 annot: FPDF_ANNOTATION,
4646 name: FPDF_WIDESTRING,
4647 ) -> FPDF_ATTACHMENT;
4648
4649 /// A [&str]-friendly helper function for [PdfiumLibraryBindings::FPDFAnnot_AddFileAttachment].
4650 ///
4651 /// Add an embedded file with `name` to `annot`.
4652 ///
4653 /// `annot` - handle to a file annotation.
4654 ///
4655 /// `name` - name of the new attachment.
4656 ///
4657 /// Returns a handle to the new attachment object, or `NULL` on failure.
4658 #[cfg(any(
4659 feature = "pdfium_future",
4660 feature = "pdfium_7350",
4661 feature = "pdfium_7215",
4662 feature = "pdfium_7123",
4663 feature = "pdfium_6996",
4664 feature = "pdfium_6721",
4665 feature = "pdfium_6666",
4666 feature = "pdfium_6611",
4667 feature = "pdfium_6569",
4668 feature = "pdfium_6555",
4669 feature = "pdfium_6490",
4670 feature = "pdfium_6406",
4671 feature = "pdfium_6337",
4672 ))]
4673 #[inline]
4674 #[allow(non_snake_case)]
4675 fn FPDFAnnot_AddFileAttachment_str(
4676 &self,
4677 annot: FPDF_ANNOTATION,
4678 name: &str,
4679 ) -> FPDF_ATTACHMENT {
4680 self.FPDFAnnot_AddFileAttachment(
4681 annot,
4682 get_pdfium_utf16le_bytes_from_str(name).as_ptr() as FPDF_WIDESTRING,
4683 )
4684 }
4685
4686 /// Initializes the form fill environment.
4687 ///
4688 /// `document` - Handle to document from [PdfiumLibraryBindings::FPDF_LoadDocument].
4689 ///
4690 /// `formInfo` - Pointer to a `FPDF_FORMFILLINFO` structure.
4691 ///
4692 /// Return Value:
4693 /// Handle to the form fill module, or `NULL` on failure.
4694 ///
4695 /// Comments:
4696 /// This function should be called before any form fill operation.
4697 /// The `FPDF_FORMFILLINFO` passed in via `form_info` must remain valid until
4698 /// the returned `FPDF_FORMHANDLE` is closed.
4699 #[allow(non_snake_case)]
4700 fn FPDFDOC_InitFormFillEnvironment(
4701 &self,
4702 document: FPDF_DOCUMENT,
4703 form_info: *mut FPDF_FORMFILLINFO,
4704 ) -> FPDF_FORMHANDLE;
4705
4706 /// Takes ownership of `form` and exits the form fill environment.
4707 ///
4708 /// `form` - Handle to the form fill module, as returned by
4709 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4710 ///
4711 /// This function is a no-op when `form` is null.
4712 #[allow(non_snake_case)]
4713 fn FPDFDOC_ExitFormFillEnvironment(&self, form: FPDF_FORMHANDLE);
4714
4715 /// This method is required for implementing all the form related
4716 /// functions. Should be invoked after user successfully loaded a
4717 /// PDF page, and [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment] has been invoked.
4718 ///
4719 /// `form` - Handle to the form fill module, as returned by
4720 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4721 #[allow(non_snake_case)]
4722 fn FORM_OnAfterLoadPage(&self, page: FPDF_PAGE, form: FPDF_FORMHANDLE);
4723
4724 /// This method is required for implementing all the form related
4725 /// functions. Should be invoked before user closes the PDF page.
4726 ///
4727 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
4728 ///
4729 /// `form` - Handle to the form fill module, as returned by
4730 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4731 #[allow(non_snake_case)]
4732 fn FORM_OnBeforeClosePage(&self, page: FPDF_PAGE, form: FPDF_FORMHANDLE);
4733
4734 /// Gets the document's page mode.
4735 ///
4736 /// `doc` - Handle to document.
4737 ///
4738 /// Returns one of the `PAGEMODE_*` flags defined above.
4739 /// The page mode defines how the document should be initially displayed.
4740 #[allow(non_snake_case)]
4741 fn FPDFDoc_GetPageMode(&self, document: FPDF_DOCUMENT) -> c_int;
4742
4743 /// Flattens annotations and form fields into the page contents.
4744 ///
4745 /// `page` - handle to the page.
4746 ///
4747 /// `nFlag` - One of the `FLAT_*` values denoting the page usage.
4748 ///
4749 /// Returns one of the `FLATTEN_*` values. Currently, all failures return `FLATTEN_FAIL`
4750 /// with no indication of the cause.
4751 #[allow(non_snake_case)]
4752 fn FPDFPage_Flatten(&self, page: FPDF_PAGE, nFlag: c_int) -> c_int;
4753
4754 /// This method is required for performing document-level JavaScript actions.
4755 /// It should be invoked after the PDF document has been loaded.
4756 ///
4757 /// `form` - Handle to the form fill module, as returned by
4758 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4759 ///
4760 /// If there is document-level JavaScript action embedded in the document, this method
4761 /// will execute the JavaScript action. Otherwise, the method will do nothing.
4762 #[allow(non_snake_case)]
4763 fn FORM_DoDocumentJSAction(&self, form: FPDF_FORMHANDLE);
4764
4765 /// This method is required for performing open-action when the document is opened.
4766 ///
4767 /// `form` - Handle to the form fill module, as returned by
4768 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4769 ///
4770 /// This method will do nothing if there are no open-actions embedded in the document.
4771 #[allow(non_snake_case)]
4772 fn FORM_DoDocumentOpenAction(&self, form: FPDF_FORMHANDLE);
4773
4774 /// This method is required for performing the document's additional-action.
4775 ///
4776 /// `form` - Handle to the form fill module. Returned by
4777 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4778 ///
4779 /// `aaType` - The type of the additional-actions which are defined above.
4780 ///
4781 /// This method will do nothing if there is no document additional-action corresponding
4782 /// to the specified `aaType`.
4783 #[allow(non_snake_case)]
4784 fn FORM_DoDocumentAAction(&self, form: FPDF_FORMHANDLE, aaType: c_int);
4785
4786 /// This method is required for performing the page object's additional-action when
4787 /// opened or closed.
4788 ///
4789 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
4790 ///
4791 /// `form` - Handle to the form fill module, as returned by
4792 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4793 ///
4794 /// `aaType` - The type of the page object's additional-actions
4795 /// which are defined above.
4796 ///
4797 /// This method will do nothing if no additional-action corresponding to the specified
4798 /// `aaType` exists.
4799 #[allow(non_snake_case)]
4800 fn FORM_DoPageAAction(&self, page: FPDF_PAGE, form: FPDF_FORMHANDLE, aaType: c_int);
4801
4802 /// Call this member function when the mouse cursor moves.
4803 ///
4804 /// `form` - Handle to the form fill module, as returned by
4805 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4806 ///
4807 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
4808 ///
4809 /// `modifier` - Indicates whether various virtual keys are down.
4810 ///
4811 /// `page_x` - Specifies the x-coordinate of the cursor in PDF user space.
4812 ///
4813 /// `page_y` - Specifies the y-coordinate of the cursor in PDF user space.
4814 ///
4815 /// Returns `true` on success.
4816 #[allow(non_snake_case)]
4817 fn FORM_OnMouseMove(
4818 &self,
4819 form: FPDF_FORMHANDLE,
4820 page: FPDF_PAGE,
4821 modifier: c_int,
4822 page_x: f64,
4823 page_y: f64,
4824 ) -> FPDF_BOOL;
4825
4826 /// Call this member function when the user scrolls the mouse wheel.
4827 ///
4828 /// `form` - Handle to the form fill module, as returned by
4829 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4830 ///
4831 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
4832 ///
4833 /// `modifier` - Indicates whether various virtual keys are down.
4834 ///
4835 /// `page_coord` - Specifies the coordinates of the cursor in PDF user space.
4836 ///
4837 /// `delta_x` - Specifies the amount of wheel movement on the x-axis,
4838 /// in units of platform-agnostic wheel deltas. Negative
4839 /// values mean left.
4840 ///
4841 /// `delta_y` - Specifies the amount of wheel movement on the y-axis,
4842 /// in units of platform-agnostic wheel deltas. Negative
4843 /// values mean down.
4844 ///
4845 /// Returns `true` indicates success.
4846 ///
4847 /// For `delta_x` and `delta_y`, the caller must normalize platform-specific wheel deltas,
4848 /// e.g. on Windows, a delta value of `240` for a `WM_MOUSEWHEEL` event normalizes to `2`,
4849 /// since Windows defines `WHEEL_DELTA` as 120.
4850 #[allow(non_snake_case)]
4851 fn FORM_OnMouseWheel(
4852 &self,
4853 form: FPDF_FORMHANDLE,
4854 page: FPDF_PAGE,
4855 modifier: c_int,
4856 page_coord: *const FS_POINTF,
4857 delta_x: c_int,
4858 delta_y: c_int,
4859 ) -> FPDF_BOOL;
4860
4861 /// This function focuses the form annotation at a given point. If the annotation at the
4862 /// point already has focus, nothing happens. If there is no annotation at the point,
4863 /// removes form focus.
4864 ///
4865 /// `form` - Handle to the form fill module, as returned by
4866 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4867 ///
4868 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
4869 ///
4870 /// `modifier` - Indicates whether various virtual keys are down.
4871 ///
4872 /// `page_x` - Specifies the x-coordinate of the cursor in PDF user space.
4873 ///
4874 /// `page_y` - Specifies the y-coordinate of the cursor in PDF user space.
4875 ///
4876 /// Returns `true` if there is an annotation at the given point and it has focus.
4877 #[allow(non_snake_case)]
4878 fn FORM_OnFocus(
4879 &self,
4880 form: FPDF_FORMHANDLE,
4881 page: FPDF_PAGE,
4882 modifier: c_int,
4883 page_x: f64,
4884 page_y: f64,
4885 ) -> FPDF_BOOL;
4886
4887 /// Call this member function when the user presses the left mouse button.
4888 ///
4889 /// `form` - Handle to the form fill module, as returned by
4890 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4891 ///
4892 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
4893 ///
4894 /// `modifier` - Indicates whether various virtual keys are down.
4895 ///
4896 /// `page_x` - Specifies the x-coordinate of the cursor in PDF user space.
4897 ///
4898 /// `page_y` - Specifies the y-coordinate of the cursor in PDF user space.
4899 ///
4900 /// Returns `true` on success.
4901 #[allow(non_snake_case)]
4902 fn FORM_OnLButtonDown(
4903 &self,
4904 form: FPDF_FORMHANDLE,
4905 page: FPDF_PAGE,
4906 modifier: c_int,
4907 page_x: f64,
4908 page_y: f64,
4909 ) -> FPDF_BOOL;
4910
4911 /// Same as [PdfiumLibraryBindings::FORM_OnLButtonDown], execpt for the right mouse button.
4912 ///
4913 /// At the present time, has no effect except in XFA builds, but is included for the sake
4914 /// of symmetry.
4915 #[allow(non_snake_case)]
4916 fn FORM_OnRButtonDown(
4917 &self,
4918 form: FPDF_FORMHANDLE,
4919 page: FPDF_PAGE,
4920 modifier: c_int,
4921 page_x: f64,
4922 page_y: f64,
4923 ) -> FPDF_BOOL;
4924
4925 /// Call this member function when the user releases the left mouse button.
4926 ///
4927 /// `form` - Handle to the form fill module, as returned by
4928 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4929 ///
4930 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
4931 ///
4932 /// `modifier` - Indicates whether various virtual keys are down.
4933 ///
4934 /// `page_x` - Specifies the x-coordinate of the cursor in device coordinates.
4935 ///
4936 /// `page_y` - Specifies the y-coordinate of the cursor in device coordinates.
4937 ///
4938 /// Returns `true` on success.
4939 #[allow(non_snake_case)]
4940 fn FORM_OnLButtonUp(
4941 &self,
4942 form: FPDF_FORMHANDLE,
4943 page: FPDF_PAGE,
4944 modifier: c_int,
4945 page_x: f64,
4946 page_y: f64,
4947 ) -> FPDF_BOOL;
4948
4949 /// Same as [PdfiumLibraryBindings::FORM_OnLButtonUp], execpt for the right mouse button.
4950 ///
4951 /// At the present time, has no effect except in XFA builds, but is included for the sake
4952 /// of symmetry.
4953 #[allow(non_snake_case)]
4954 fn FORM_OnRButtonUp(
4955 &self,
4956 form: FPDF_FORMHANDLE,
4957 page: FPDF_PAGE,
4958 modifier: c_int,
4959 page_x: f64,
4960 page_y: f64,
4961 ) -> FPDF_BOOL;
4962
4963 /// Call this member function when the user double clicks the left mouse button.
4964 ///
4965 /// `form` - Handle to the form fill module, as returned by
4966 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4967 ///
4968 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
4969 ///
4970 /// `modifier` - Indicates whether various virtual keys are down.
4971 ///
4972 /// `page_x` - Specifies the x-coordinate of the cursor in PDF user space.
4973 ///
4974 /// `page_y` - Specifies the y-coordinate of the cursor in PDF user space.
4975 ///
4976 /// Returns `true` on success.
4977 #[allow(non_snake_case)]
4978 fn FORM_OnLButtonDoubleClick(
4979 &self,
4980 form: FPDF_FORMHANDLE,
4981 page: FPDF_PAGE,
4982 modifier: c_int,
4983 page_x: f64,
4984 page_y: f64,
4985 ) -> FPDF_BOOL;
4986
4987 /// Call this member function when a non-system key is pressed.
4988 ///
4989 /// `form` - Handle to the form fill module, as returned by
4990 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
4991 ///
4992 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
4993 ///
4994 /// `nKeyCode` - The virtual-key code of the given key (see `fpdf_fwlevent.h`
4995 /// for virtual key codes).
4996 ///
4997 /// `modifier` - Mask of key flags (see `fpdf_fwlevent.h` for key flag values).
4998 ///
4999 /// Returns `true` on success.
5000 #[allow(non_snake_case)]
5001 fn FORM_OnKeyDown(
5002 &self,
5003 form: FPDF_FORMHANDLE,
5004 page: FPDF_PAGE,
5005 nKeyCode: c_int,
5006 modifier: c_int,
5007 ) -> FPDF_BOOL;
5008
5009 /// Call this member function when a non-system key is released.
5010 ///
5011 /// `form` - Handle to the form fill module, as returned by
5012 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5013 ///
5014 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5015 ///
5016 /// `nKeyCode` - The virtual-key code of the given key (see `fpdf_fwlevent.h`
5017 /// for virtual key codes).
5018 ///
5019 /// `modifier` - Mask of key flags (see `fpdf_fwlevent.h` for key flag values).
5020 ///
5021 /// Returns `true` on success.
5022 ///
5023 /// Note: currently unimplemented, always returns `false`. PDFium reserves this API
5024 /// and may implement it in the future on an as-needed basis.
5025 #[allow(non_snake_case)]
5026 fn FORM_OnKeyUp(
5027 &self,
5028 form: FPDF_FORMHANDLE,
5029 page: FPDF_PAGE,
5030 nKeyCode: c_int,
5031 modifier: c_int,
5032 ) -> FPDF_BOOL;
5033
5034 /// Call this member function when a keystroke translates to a non-system character.
5035 ///
5036 /// `form` - Handle to the form fill module, as returned by
5037 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5038 ///
5039 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5040 ///
5041 /// `nChar` - The character code value itself.
5042 ///
5043 /// `modifier` - Mask of key flags (see `fpdf_fwlevent.h` for key flag values).
5044 ///
5045 /// Returns `true` on success.
5046 #[allow(non_snake_case)]
5047 fn FORM_OnChar(
5048 &self,
5049 form: FPDF_FORMHANDLE,
5050 page: FPDF_PAGE,
5051 nChar: c_int,
5052 modifier: c_int,
5053 ) -> FPDF_BOOL;
5054
5055 /// Call this function to obtain the text within the current focused field, if any.
5056 ///
5057 /// `form` - Handle to the form fill module, as returned by
5058 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5059 ///
5060 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5061 ///
5062 /// `buffer` - Buffer for holding the form text, encoded in UTF-16LE.
5063 /// If `NULL`, `buffer` is not modified.
5064 ///
5065 /// `buflen` - Length of `buffer` in bytes. If `buflen` is less than the length
5066 /// of the form text string, `buffer` is not modified.
5067 ///
5068 /// Returns the length in bytes of the text in the focused field.
5069 #[allow(non_snake_case)]
5070 fn FORM_GetFocusedText(
5071 &self,
5072 form: FPDF_FORMHANDLE,
5073 page: FPDF_PAGE,
5074 buffer: *mut c_void,
5075 buflen: c_ulong,
5076 ) -> c_ulong;
5077
5078 /// Call this function to obtain selected text within a form text field or
5079 /// form combo-box text field.
5080 ///
5081 /// `form` - Handle to the form fill module, as returned by
5082 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5083 ///
5084 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5085 ///
5086 /// `buffer` - Buffer for holding the selected text, encoded in UTF-16LE.
5087 /// If `NULL`, `buffer` is not modified.
5088 ///
5089 /// `buflen` - Length of `buffer` in bytes. If `buflen` is less than the length
5090 /// of the selected text string, `buffer` is not modified.
5091 ///
5092 /// Returns the length in bytes of selected text in form text field or form combo-box text field.
5093 #[allow(non_snake_case)]
5094 fn FORM_GetSelectedText(
5095 &self,
5096 form: FPDF_FORMHANDLE,
5097 page: FPDF_PAGE,
5098 buffer: *mut c_void,
5099 buflen: c_ulong,
5100 ) -> c_ulong;
5101
5102 /// Call this function to replace the selected text in a form text field or
5103 /// user-editable form combo-box text field with another text string
5104 /// (which can be empty or non-empty). If there is no selected text, this function will
5105 /// append the replacement text after the current caret position. After the insertion,
5106 /// the inserted text will be selected.
5107 ///
5108 /// `form` - Handle to the form fill module, as returned by
5109 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5110 ///
5111 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5112 ///
5113 /// `wsText` - The text to be inserted, in UTF-16LE format.
5114 #[allow(non_snake_case)]
5115 fn FORM_ReplaceAndKeepSelection(
5116 &self,
5117 form: FPDF_FORMHANDLE,
5118 page: FPDF_PAGE,
5119 wsText: FPDF_WIDESTRING,
5120 );
5121
5122 /// Call this function to replace the selected text in a form text field or
5123 /// user-editable form combo-box text field with another text string
5124 /// (which can be empty or non-empty). If there is no selected text, this function
5125 /// will append the replacement text after the current caret position. After the insertion,
5126 /// the selection range will be set to empty.
5127 ///
5128 /// `form` - Handle to the form fill module, as returned by
5129 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5130 ///
5131 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5132 ///
5133 /// `wsText` - The text to be inserted, in UTF-16LE format.
5134 #[allow(non_snake_case)]
5135 fn FORM_ReplaceSelection(
5136 &self,
5137 form: FPDF_FORMHANDLE,
5138 page: FPDF_PAGE,
5139 wsText: FPDF_WIDESTRING,
5140 );
5141
5142 /// Call this function to select all the text within the currently focused form text field
5143 /// or form combo-box text field.
5144 ///
5145 /// `form` - Handle to the form fill module, as returned by
5146 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5147 ///
5148 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5149 ///
5150 /// Returns `true` if the operation succeeded.
5151 #[allow(non_snake_case)]
5152 fn FORM_SelectAllText(&self, form: FPDF_FORMHANDLE, page: FPDF_PAGE) -> FPDF_BOOL;
5153
5154 /// Finds out if it is possible for the current focused widget in a given form to perform
5155 /// an undo operation.
5156 ///
5157 /// `form` - Handle to the form fill module, as returned by
5158 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5159 ///
5160 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5161 ///
5162 /// Returns `true` if it is possible to undo.
5163 #[allow(non_snake_case)]
5164 fn FORM_CanUndo(&self, form: FPDF_FORMHANDLE, page: FPDF_PAGE) -> FPDF_BOOL;
5165
5166 /// Finds out if it is possible for the current focused widget in a given form to perform
5167 /// a redo operation.
5168 ///
5169 /// `form` - Handle to the form fill module, as returned by
5170 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5171 ///
5172 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5173 ///
5174 /// Returns `true` if it is possible to redo.
5175 #[allow(non_snake_case)]
5176 fn FORM_CanRedo(&self, form: FPDF_FORMHANDLE, page: FPDF_PAGE) -> FPDF_BOOL;
5177
5178 /// Makes the current focused widget perform an undo operation.
5179 ///
5180 /// `form` - Handle to the form fill module, as returned by
5181 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5182 ///
5183 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5184 ///
5185 /// Returns `true` if the undo operation succeeded.
5186 #[allow(non_snake_case)]
5187 fn FORM_Undo(&self, form: FPDF_FORMHANDLE, page: FPDF_PAGE) -> FPDF_BOOL;
5188
5189 /// Makes the current focused widget perform a redo operation.
5190 ///
5191 /// `form` - Handle to the form fill module, as returned by
5192 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5193 ///
5194 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5195 ///
5196 /// Returns `true` if the redo operation succeeded.
5197 #[allow(non_snake_case)]
5198 fn FORM_Redo(&self, form: FPDF_FORMHANDLE, page: FPDF_PAGE) -> FPDF_BOOL;
5199
5200 /// Calls this member function to force to kill the focus of the form field which has focus.
5201 /// If it would kill the focus of a form field, saves the value of form field if was
5202 /// changed by the user.
5203 ///
5204 /// `form` - Handle to the form fill module, as returned by
5205 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5206 ///
5207 /// Returns `true` on success.
5208 #[allow(non_snake_case)]
5209 fn FORM_ForceToKillFocus(&self, form: FPDF_FORMHANDLE) -> FPDF_BOOL;
5210
5211 /// Calls this member function to get the currently focused annotation.
5212 ///
5213 /// `form` - Handle to the form fill module, as returned by
5214 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5215 ///
5216 /// `page_index` - Buffer to hold the index number of the page which contains
5217 /// the focused annotation. `0` for the first page. Can't be `NULL`.
5218 ///
5219 /// `annot` - Buffer to hold the focused annotation. Can't be `NULL`.
5220 ///
5221 /// On success, returns `true` and writes to the out parameters.
5222 /// Otherwise returns `false` and leaves the out parameters unmodified.
5223 /// Will return `true` and set `page_index` to `-1` and `annot` to `NULL`
5224 /// if there is no focused annotation.
5225 ///
5226 /// Note: not currently supported for XFA forms - will report no focused annotation.
5227 /// Must call [PdfiumLibraryBindings::FPDFPage_CloseAnnot] when the annotation returned
5228 /// in `annot` by this function is no longer needed.
5229 #[allow(non_snake_case)]
5230 fn FORM_GetFocusedAnnot(
5231 &self,
5232 form: FPDF_FORMHANDLE,
5233 page_index: *mut c_int,
5234 annot: *mut FPDF_ANNOTATION,
5235 ) -> FPDF_BOOL;
5236
5237 /// Calls this member function to set the currently focused annotation.
5238 ///
5239 /// `form` - Handle to the form fill module, as returned by
5240 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5241 ///
5242 /// `annot` - Handle to an annotation.
5243 ///
5244 /// Returns `true` on success.
5245 ///
5246 /// Note: `annot` must not be `NULL`. To kill focus, use
5247 /// [PdfiumLibraryBindings::FORM_ForceToKillFocus] instead.
5248 #[allow(non_snake_case)]
5249 fn FORM_SetFocusedAnnot(&self, form: FPDF_FORMHANDLE, annot: FPDF_ANNOTATION) -> FPDF_BOOL;
5250
5251 /// Gets the form field type by point.
5252 ///
5253 /// `form` - Handle to the form fill module. Returned by
5254 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5255 ///
5256 /// `page` - Handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5257 ///
5258 /// `page_x` - X position in PDF user space.
5259 ///
5260 /// `page_y` - Y position in PDF user space.
5261 ///
5262 /// Returns the type of the form field. `-1` indicates no field at the given point.
5263 /// See field types above.
5264 #[allow(non_snake_case)]
5265 fn FPDFPage_HasFormFieldAtPoint(
5266 &self,
5267 form: FPDF_FORMHANDLE,
5268 page: FPDF_PAGE,
5269 page_x: f64,
5270 page_y: f64,
5271 ) -> c_int;
5272
5273 /// Gets the form field z-order by point.
5274 ///
5275 /// `form` - Handle to the form fill module. Returned by
5276 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5277 ///
5278 /// `page` - Handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5279 ///
5280 /// `page_x` - X position in PDF user space.
5281 ///
5282 /// `page_y` - Y position in PDF user space.
5283 ///
5284 /// Returns the z-order of the form field. `-1` indicates no field.
5285 /// Higher numbers are closer to the front.
5286 #[allow(non_snake_case)]
5287 fn FPDFPage_FormFieldZOrderAtPoint(
5288 &self,
5289 form: FPDF_FORMHANDLE,
5290 page: FPDF_PAGE,
5291 page_x: f64,
5292 page_y: f64,
5293 ) -> c_int;
5294
5295 /// Sets the highlight color of the specified (or all) form fields in the document.
5296 ///
5297 /// `form` - Handle to the form fill module, as returned by
5298 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5299 ///
5300 /// `doc` - Handle to the document, as returned by
5301 /// [PdfiumLibraryBindings::FPDF_LoadDocument].
5302 ///
5303 /// `fieldType` - A 32-bit integer indicating the type of a form field (defined above).
5304 ///
5305 /// `color` - The highlight color of the form field. Constructed by `0xxxrrggbb`.
5306 ///
5307 /// When the parameter `fieldType` is set to `FPDF_FORMFIELD_UNKNOWN`,
5308 /// the highlight color will be applied to all the form fields in the document.
5309 /// Please refresh the client window to show the highlight immediately if necessary.
5310 #[allow(non_snake_case)]
5311 fn FPDF_SetFormFieldHighlightColor(
5312 &self,
5313 form: FPDF_FORMHANDLE,
5314 field_type: c_int,
5315 color: FPDF_DWORD,
5316 );
5317
5318 /// Sets the transparency of the form field highlight color in the document.
5319 ///
5320 /// `form` - Handle to the form fill module, as returned by
5321 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5322 ///
5323 /// `doc` - Handle to the document, as returned by
5324 /// [PdfiumLibraryBindings::FPDF_LoadDocument].
5325 ///
5326 /// `alpha` - The transparency of the form field highlight color, between `0` - `255`.
5327 #[allow(non_snake_case)]
5328 fn FPDF_SetFormFieldHighlightAlpha(&self, form: FPDF_FORMHANDLE, alpha: c_uchar);
5329
5330 /// Removes the form field highlight color in the document.
5331 ///
5332 /// `form` - Handle to the form fill module, as returned by
5333 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5334 ///
5335 /// Please refresh the client window to remove the highlight immediately if necessary.
5336 #[allow(non_snake_case)]
5337 fn FPDF_RemoveFormFieldHighlight(&self, form: FPDF_FORMHANDLE);
5338
5339 /// Renders form fields and pop-up windows on a page to a device independent bitmap.
5340 ///
5341 /// `form` - Handle to the form fill module, as returned by
5342 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5343 ///
5344 /// `bitmap` - Handle to the device independent bitmap (as the output
5345 /// buffer). Bitmap handles can be created by
5346 /// [PdfiumLibraryBindings::FPDFBitmap_Create].
5347 ///
5348 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5349 ///
5350 /// `start_x` - Left pixel position of the display area in the device coordinates.
5351 ///
5352 /// `start_y` - Top pixel position of the display area in the device coordinates.
5353 ///
5354 /// `size_x` - Horizontal size (in pixels) for displaying the page.
5355 ///
5356 /// `size_y` - Vertical size (in pixels) for displaying the page.
5357 ///
5358 /// `rotate` - Page orientation: `0` (normal), `1` (rotated 90 degrees clockwise),
5359 /// `2` (rotated 180 degrees), `3` (rotated 90 degrees counter-clockwise).
5360 ///
5361 /// `flags` - `0` for normal display, or combination of flags defined above.
5362 ///
5363 /// This function is designed to render annotations that are user-interactive,
5364 /// which are widget annotations (for form fields) and pop-up annotations.
5365 /// With the `FPDF_ANNOT` flag, this function will render a pop-up annotation
5366 /// when users mouse-hover on a non-widget annotation. Regardless of `FPDF_ANNOT` flag,
5367 /// this function will always render widget annotations for form fields.
5368 /// In order to implement the form fill functions, implementation should call this function
5369 /// after rendering functions, such as [PdfiumLibraryBindings::FPDF_RenderPageBitmap]
5370 /// or [PdfiumLibraryBindings::FPDF_RenderPageBitmap_Start], have finished rendering
5371 /// the page contents.
5372 #[allow(non_snake_case)]
5373 #[allow(clippy::too_many_arguments)]
5374 fn FPDF_FFLDraw(
5375 &self,
5376 form: FPDF_FORMHANDLE,
5377 bitmap: FPDF_BITMAP,
5378 page: FPDF_PAGE,
5379 start_x: c_int,
5380 start_y: c_int,
5381 size_x: c_int,
5382 size_y: c_int,
5383 rotate: c_int,
5384 flags: c_int,
5385 );
5386
5387 #[cfg(feature = "pdfium_use_skia")]
5388 #[allow(non_snake_case)]
5389 #[allow(clippy::too_many_arguments)]
5390 /// Renders form fields and pop-up windows on a page to a SKIA canvas.
5391 ///
5392 /// `form` - Handle to the form fill module, as returned by
5393 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5394 ///
5395 /// `bitmap` - Handle to the device independent bitmap (as the output
5396 /// buffer). Bitmap handles can be created by
5397 /// [PdfiumLibraryBindings::FPDFBitmap_Create].
5398 ///
5399 /// `page` - Handle to the page, as returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5400 ///
5401 /// `start_x` - Left pixel position of the display area in the device coordinates.
5402 ///
5403 /// `start_y` - Top pixel position of the display area in the device coordinates.
5404 ///
5405 /// `size_x` - Horizontal size (in pixels) for displaying the page.
5406 ///
5407 /// `size_y` - Vertical size (in pixels) for displaying the page.
5408 ///
5409 /// `rotate` - Page orientation: `0` (normal), `1` (rotated 90 degrees clockwise),
5410 /// `2` (rotated 180 degrees), `3` (rotated 90 degrees counter-clockwise).
5411 ///
5412 /// `flags` - `0` for normal display, or combination of flags defined above.
5413 ///
5414 /// This function is designed to render annotations that are user-interactive,
5415 /// which are widget annotations (for form fields) and pop-up annotations.
5416 /// With the `FPDF_ANNOT` flag, this function will render a pop-up annotation
5417 /// when users mouse-hover on a non-widget annotation. Regardless of `FPDF_ANNOT` flag,
5418 /// this function will always render widget annotations for form fields.
5419 /// In order to implement the form fill functions, implementation should call this function
5420 /// after rendering functions, such as [PdfiumLibraryBindings::FPDF_RenderPageBitmap]
5421 /// or [PdfiumLibraryBindings::FPDF_RenderPageBitmap_Start], have finished rendering
5422 /// the page contents.
5423 fn FPDF_FFLDrawSkia(
5424 &self,
5425 form: FPDF_FORMHANDLE,
5426 canvas: FPDF_SKIA_CANVAS,
5427 page: FPDF_PAGE,
5428 start_x: c_int,
5429 start_y: c_int,
5430 size_x: c_int,
5431 size_y: c_int,
5432 rotate: c_int,
5433 flags: c_int,
5434 );
5435
5436 /// Returns the type of form contained in the PDF document.
5437 ///
5438 /// `document` - Handle to document.
5439 ///
5440 /// Returns an integer value representing one of the `FORMTYPE_*` values.
5441 /// If `document` is `NULL`, then the return value is `FORMTYPE_NONE`.
5442 #[allow(non_snake_case)]
5443 fn FPDF_GetFormType(&self, document: FPDF_DOCUMENT) -> c_int;
5444
5445 /// Selects or deselects the value at the given `index` of the focused annotation.
5446 ///
5447 /// `form` - Handle to the form fill module. Returned by
5448 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5449 ///
5450 /// `page` - Handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5451 ///
5452 /// `index` - `0`-based index of value to be set as selected or unselected.
5453 ///
5454 /// `selected` - `true` to select, `false` to deselect.
5455 ///
5456 /// Returns `true` if the operation succeeded, `false` if the operation failed or
5457 /// the widget is not a supported type.
5458 ///
5459 /// Intended for use with listbox or combo-box widget types. Default implementation is
5460 /// a no-op that will return `false` for widget other types. Not currently supported for
5461 /// XFA forms - will return `false`. Combo-boxes have at most a single value selected at
5462 /// a time which cannot be deselected. Deselect on a combo-box is a no-op that returns `false`.
5463 #[allow(non_snake_case)]
5464 fn FORM_SetIndexSelected(
5465 &self,
5466 form: FPDF_FORMHANDLE,
5467 page: FPDF_PAGE,
5468 index: c_int,
5469 selected: FPDF_BOOL,
5470 ) -> FPDF_BOOL;
5471
5472 /// Returns whether or not the value at `index` of the focused annotation is currently selected.
5473 ///
5474 /// `form` - Handle to the form fill module. Returned by
5475 /// [PdfiumLibraryBindings::FPDFDOC_InitFormFillEnvironment].
5476 ///
5477 /// `page` - Handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
5478 ///
5479 /// `index` - `0`-based index of value to check.
5480 ///
5481 /// Returns `true`if value at `index` is currently selected, `false` if value at `index`
5482 /// is not selected or widget is not a supported type.
5483 ///
5484 /// Intended for use with listbox or combo-box widget types. Default implementation is
5485 /// a no-op that will return `false` for other types. Not currently supported for
5486 /// XFA forms - will return `false`.
5487 #[allow(non_snake_case)]
5488 fn FORM_IsIndexSelected(
5489 &self,
5490 form: FPDF_FORMHANDLE,
5491 page: FPDF_PAGE,
5492 index: c_int,
5493 ) -> FPDF_BOOL;
5494
5495 /// If the document consists of XFA fields, call this method to attempt to load XFA fields.
5496 ///
5497 /// `document` - Handle to document from [PdfiumLibraryBindings::FPDF_LoadDocument].
5498 ///
5499 /// Returns `true` upon success. If XFA support is not built into
5500 /// PDFium, performs no action and always returns `false`.
5501 #[allow(non_snake_case)]
5502 fn FPDF_LoadXFA(&self, document: FPDF_DOCUMENT) -> FPDF_BOOL;
5503
5504 /// Gets the number of JavaScript actions in `document`.
5505 ///
5506 /// `document` - handle to a document.
5507 ///
5508 /// Returns the number of JavaScript actions in `document` or `-1` on error.
5509 #[allow(non_snake_case)]
5510 fn FPDFDoc_GetJavaScriptActionCount(&self, document: FPDF_DOCUMENT) -> c_int;
5511
5512 /// Gets the JavaScript action at `index` in `document`.
5513 ///
5514 /// `document` - handle to a document.
5515 ///
5516 /// `index` - the index of the requested JavaScript action.
5517 ///
5518 /// Returns the handle to the JavaScript action, or `NULL` on failure.
5519 ///
5520 /// Caller owns the returned handle and must close it with
5521 /// [PdfiumLibraryBindings::FPDFDoc_CloseJavaScriptAction].
5522 #[allow(non_snake_case)]
5523 fn FPDFDoc_GetJavaScriptAction(
5524 &self,
5525 document: FPDF_DOCUMENT,
5526 index: c_int,
5527 ) -> FPDF_JAVASCRIPT_ACTION;
5528
5529 /// Closes a loaded `FPDF_JAVASCRIPT_ACTION` object.
5530 ///
5531 /// `javascript` - Handle to a JavaScript action.
5532 #[allow(non_snake_case)]
5533 fn FPDFDoc_CloseJavaScriptAction(&self, javascript: FPDF_JAVASCRIPT_ACTION);
5534
5535 /// Gets the name from the `javascript` handle. `buffer` is only modified if
5536 /// `buflen` is longer than the length of the name. On errors, `buffer` is
5537 /// unmodified and the returned length is `0`.
5538 ///
5539 /// `javascript` - handle to an JavaScript action.
5540 ///
5541 /// `buffer` - buffer for holding the name, encoded in UTF-16LE.
5542 ///
5543 /// `buflen` - length of the buffer in bytes.
5544 ///
5545 /// Returns the length of the JavaScript action name in bytes.
5546 #[allow(non_snake_case)]
5547 fn FPDFJavaScriptAction_GetName(
5548 &self,
5549 javascript: FPDF_JAVASCRIPT_ACTION,
5550 buffer: *mut FPDF_WCHAR,
5551 buflen: c_ulong,
5552 ) -> c_ulong;
5553
5554 /// Gets the script from the `javascript` handle. `buffer` is only modified if
5555 /// `buflen` is longer than the length of the script. On errors, `buffer` is
5556 /// unmodified and the returned length is `0`.
5557 ///
5558 /// `javascript` - handle to an JavaScript action.
5559 ///
5560 /// `buffer` - buffer for holding the name, encoded in UTF-16LE.
5561 ///
5562 /// `buflen` - length of the buffer in bytes.
5563 ///
5564 /// Returns the length of the JavaScript action name in bytes.
5565 #[allow(non_snake_case)]
5566 fn FPDFJavaScriptAction_GetScript(
5567 &self,
5568 javascript: FPDF_JAVASCRIPT_ACTION,
5569 buffer: *mut FPDF_WCHAR,
5570 buflen: c_ulong,
5571 ) -> c_ulong;
5572
5573 /// Returns a pointer to the default character set to TT Font name map. The map is an array of
5574 /// FPDF_CharsetFontMap structs, with its end indicated by a { -1, NULL } entry.
5575 /// Returns a pointer to the Charset Font Map. Note: once [PdfiumLibraryBindings::FPDF_GetDefaultTTFMapCount]
5576 /// and [PdfiumLibraryBindings::FPDF_GetDefaultTTFMapEntry] are no longer experimental,
5577 /// this API will be marked as deprecated. See: <https://crbug.com/348468114>
5578 #[allow(non_snake_case)]
5579 fn FPDF_GetDefaultTTFMap(&self) -> *const FPDF_CharsetFontMap;
5580
5581 #[cfg(any(
5582 feature = "pdfium_future",
5583 feature = "pdfium_7350",
5584 feature = "pdfium_7215",
5585 feature = "pdfium_7123",
5586 feature = "pdfium_6996",
5587 feature = "pdfium_6721",
5588 feature = "pdfium_6666",
5589 feature = "pdfium_6611",
5590 feature = "pdfium_6569",
5591 ))]
5592 /// Returns the number of entries in the default character set to TT Font name map.
5593 #[allow(non_snake_case)]
5594 fn FPDF_GetDefaultTTFMapCount(&self) -> usize;
5595
5596 #[cfg(any(
5597 feature = "pdfium_future",
5598 feature = "pdfium_7350",
5599 feature = "pdfium_7215",
5600 feature = "pdfium_7123",
5601 feature = "pdfium_6996",
5602 feature = "pdfium_6721",
5603 feature = "pdfium_6666",
5604 feature = "pdfium_6611",
5605 feature = "pdfium_6569",
5606 ))]
5607 /// Returns an entry in the default character set to TT Font name map.
5608 ///
5609 /// `index` - The index to the entry in the map to retrieve.
5610 ///
5611 /// Returns a pointer to the entry, if it is in the map, or `NULL` if the index is out
5612 /// of bounds.
5613 #[allow(non_snake_case)]
5614 fn FPDF_GetDefaultTTFMapEntry(&self, index: usize) -> *const FPDF_CharsetFontMap;
5615
5616 /// Adds a system font to the list in PDFium.
5617 ///
5618 /// This function is only called during the system font list building process.
5619 ///
5620 /// `mapper` - Opaque pointer to Foxit font mapper.
5621 ///
5622 /// `face` - The font face name.
5623 ///
5624 /// `charset` - Font character set. See above defined constants.
5625 #[allow(non_snake_case)]
5626 fn FPDF_AddInstalledFont(&self, mapper: *mut c_void, face: &str, charset: c_int);
5627
5628 /// Sets the system font info interface into PDFium.
5629 ///
5630 /// `font_info` - Pointer to a `FPDF_SYSFONTINFO` structure.
5631 ///
5632 /// Platform support implementation should implement required methods of
5633 /// `FFDF_SYSFONTINFO` interface, then call this function during PDFium initialization
5634 /// process.
5635 ///
5636 /// Call this with `NULL` to tell PDFium to stop using a previously set `FPDF_SYSFONTINFO`.
5637 #[allow(non_snake_case)]
5638 fn FPDF_SetSystemFontInfo(&self, font_info: *mut FPDF_SYSFONTINFO);
5639
5640 /// Gets default system font info interface for current platform.
5641 ///
5642 /// Returns a pointer to a `FPDF_SYSFONTINFO` structure describing the default
5643 /// interface, or `NULL` if the platform doesn't have a default interface.
5644 ///
5645 /// Application should call [PdfiumLibraryBindings::FPDF_FreeDefaultSystemFontInfo]
5646 /// to free the returned pointer. For some platforms, PDFium implements a default version
5647 /// of system font info interface. The default implementation can be passed to
5648 /// [PdfiumLibraryBindings::FPDF_SetSystemFontInfo].
5649 #[allow(non_snake_case)]
5650 fn FPDF_GetDefaultSystemFontInfo(&self) -> *mut FPDF_SYSFONTINFO;
5651
5652 /// Frees a default system font info interface.
5653 ///
5654 /// `font_info` - Pointer to a `FPDF_SYSFONTINFO` structure.
5655 ///
5656 /// This function should be called on the output from
5657 /// [PdfiumLibraryBindings::FPDF_GetDefaultSystemFontInfo] once it is no longer needed.
5658 #[allow(non_snake_case)]
5659 fn FPDF_FreeDefaultSystemFontInfo(&self, font_info: *mut FPDF_SYSFONTINFO);
5660
5661 /// Gets the first child of `bookmark`, or the first top-level bookmark item.
5662 ///
5663 /// `document` - handle to the document.
5664 ///
5665 /// `bookmark` - handle to the current bookmark. Pass `NULL` for the first top
5666 /// level item.
5667 ///
5668 /// Returns a handle to the first child of `bookmark` or the first top-level
5669 /// bookmark item. `NULL` if no child or top-level bookmark found.
5670 /// Note that another name for the bookmarks is the document outline, as
5671 /// described in ISO 32000-1:2008, section 12.3.3.
5672 #[allow(non_snake_case)]
5673 fn FPDFBookmark_GetFirstChild(
5674 &self,
5675 document: FPDF_DOCUMENT,
5676 bookmark: FPDF_BOOKMARK,
5677 ) -> FPDF_BOOKMARK;
5678
5679 /// Gets the next sibling of `bookmark`.
5680 ///
5681 /// `document` - handle to the document.
5682 ///
5683 /// `bookmark` - handle to the current bookmark.
5684 ///
5685 /// Returns a handle to the next sibling of `bookmark`, or `NULL` if this is the
5686 /// last bookmark at this level.
5687 ///
5688 /// Note that the caller is responsible for handling circular bookmark
5689 /// references, as may arise from malformed documents.
5690 #[allow(non_snake_case)]
5691 fn FPDFBookmark_GetNextSibling(
5692 &self,
5693 document: FPDF_DOCUMENT,
5694 bookmark: FPDF_BOOKMARK,
5695 ) -> FPDF_BOOKMARK;
5696
5697 /// Gets the title of `bookmark`.
5698 ///
5699 /// `bookmark` - handle to the bookmark.
5700 ///
5701 /// `buffer` - buffer for the title. May be `NULL`.
5702 ///
5703 /// `buflen` - the length of the buffer in bytes. May be 0.
5704 ///
5705 /// Returns the number of bytes in the title, including the terminating `NUL`
5706 /// character. The number of bytes is returned regardless of the `buffer` and
5707 /// `buflen` parameters.
5708 ///
5709 /// Regardless of the platform, the `buffer` is always in UTF-16LE encoding. The
5710 /// string is terminated by a UTF16 `NUL` character. If `buflen` is less than the
5711 /// required length, or `buffer` is `NULL`, `buffer` will not be modified.
5712 #[allow(non_snake_case)]
5713 fn FPDFBookmark_GetTitle(
5714 &self,
5715 bookmark: FPDF_BOOKMARK,
5716 buffer: *mut c_void,
5717 buflen: c_ulong,
5718 ) -> c_ulong;
5719
5720 /// Gets the number of children of `bookmark`.
5721 ///
5722 /// `bookmark` - handle to the bookmark.
5723 ///
5724 /// Returns a signed integer that represents the number of sub-items the given
5725 /// bookmark has. If the value is positive, child items shall be shown by default
5726 /// (open state). If the value is negative, child items shall be hidden by
5727 /// default (closed state). Please refer to PDF 32000-1:2008, Table 153.
5728 /// Returns 0 if the bookmark has no children or is invalid.
5729 #[allow(non_snake_case)]
5730 fn FPDFBookmark_GetCount(&self, bookmark: FPDF_BOOKMARK) -> c_int;
5731
5732 /// Finds the bookmark with `title` in `document`.
5733 ///
5734 /// `document` - handle to the document.
5735 ///
5736 /// `title` - the UTF-16LE encoded Unicode title for which to search.
5737 ///
5738 /// Returns the handle to the bookmark, or `NULL` if `title` can't be found.
5739 ///
5740 /// `FPDFBookmark_Find()` will always return the first bookmark found even if
5741 /// multiple bookmarks have the same `title`.
5742 ///
5743 /// A [&str]-friendly helper function is available for this function.
5744 /// See [PdfiumLibraryBindings::FPDFBookmark_Find_str].
5745 #[allow(non_snake_case)]
5746 fn FPDFBookmark_Find(&self, document: FPDF_DOCUMENT, title: FPDF_WIDESTRING) -> FPDF_BOOKMARK;
5747
5748 /// A [&str]-friendly helper function for [PdfiumLibraryBindings::FPDFBookmark_Find].
5749 ///
5750 /// Finds the bookmark with `title` in `document`.
5751 ///
5752 /// `document` - handle to the document.
5753 ///
5754 /// `title` - the title for which to search.
5755 ///
5756 /// Returns the handle to the bookmark, or `NULL` if `title` can't be found.
5757 ///
5758 /// `FPDFBookmark_Find_str()` will always return the first bookmark found even if
5759 /// multiple bookmarks have the same `title`.
5760 #[inline]
5761 #[allow(non_snake_case)]
5762 fn FPDFBookmark_Find_str(&self, document: FPDF_DOCUMENT, title: &str) -> FPDF_BOOKMARK {
5763 self.FPDFBookmark_Find(
5764 document,
5765 get_pdfium_utf16le_bytes_from_str(title).as_ptr() as FPDF_WIDESTRING,
5766 )
5767 }
5768
5769 /// Gets the destination associated with `bookmark`.
5770 ///
5771 /// `document` - handle to the document.
5772 ///
5773 /// `bookmark` - handle to the bookmark.
5774 ///
5775 /// Returns the handle to the destination data, or `NULL` if no destination is
5776 /// associated with `bookmark`.
5777 #[allow(non_snake_case)]
5778 fn FPDFBookmark_GetDest(&self, document: FPDF_DOCUMENT, bookmark: FPDF_BOOKMARK) -> FPDF_DEST;
5779
5780 /// Gets the action associated with `bookmark`.
5781 ///
5782 /// `bookmark` - handle to the bookmark.
5783 ///
5784 /// Returns the handle to the action data, or `NULL` if no action is associated
5785 /// with `bookmark`.
5786 ///
5787 /// If this function returns a valid handle, it is valid as long as `bookmark` is
5788 /// valid.
5789 ///
5790 /// If this function returns `NULL`, `FPDFBookmark_GetDest()` should be called to get
5791 /// the `bookmark` destination data.
5792 #[allow(non_snake_case)]
5793 fn FPDFBookmark_GetAction(&self, bookmark: FPDF_BOOKMARK) -> FPDF_ACTION;
5794
5795 /// Gets the type of `action`.
5796 ///
5797 /// `action` - handle to the action.
5798 ///
5799 /// Returns one of:
5800 /// - `PDFACTION_UNSUPPORTED`
5801 /// - `PDFACTION_GOTO`
5802 /// - `PDFACTION_REMOTEGOTO`
5803 /// - `PDFACTION_URI`
5804 /// - `PDFACTION_LAUNCH`
5805 #[allow(non_snake_case)]
5806 fn FPDFAction_GetType(&self, action: FPDF_ACTION) -> c_ulong;
5807
5808 /// Gets the destination of `action`.
5809 ///
5810 /// `document` - handle to the document.
5811 ///
5812 /// `action` - handle to the action. `action` must be a `PDFACTION_GOTO` or
5813 /// `PDFACTION_REMOTEGOTO`.
5814 ///
5815 /// Returns a handle to the destination data, or `NULL` on error, typically
5816 /// because the arguments were bad or the action was of the wrong type.
5817 ///
5818 /// In the case of `PDFACTION_REMOTEGOTO`, you must first call
5819 /// `FPDFAction_GetFilePath()`, then load the document at that path, then pass
5820 /// the document handle from that document as `document` to `FPDFAction_GetDest()`.
5821 #[allow(non_snake_case)]
5822 fn FPDFAction_GetDest(&self, document: FPDF_DOCUMENT, action: FPDF_ACTION) -> FPDF_DEST;
5823
5824 /// Gets the file path of `action`.
5825 ///
5826 /// `action` - handle to the action. `action` must be a `PDFACTION_LAUNCH` or
5827 /// `PDFACTION_REMOTEGOTO`.
5828 ///
5829 /// `buffer` - a buffer for output the path string. May be `NULL`.
5830 ///
5831 /// `buflen` - the length of the buffer, in bytes. May be 0.
5832 ///
5833 /// Returns the number of bytes in the file path, including the trailing `NUL`
5834 /// character, or 0 on error, typically because the arguments were bad or the
5835 /// action was of the wrong type.
5836 ///
5837 /// Regardless of the platform, the `buffer` is always in UTF-8 encoding.
5838 /// If `buflen` is less than the returned length, or `buffer` is `NULL`, `buffer`
5839 /// will not be modified.
5840 #[allow(non_snake_case)]
5841 fn FPDFAction_GetFilePath(
5842 &self,
5843 action: FPDF_ACTION,
5844 buffer: *mut c_void,
5845 buflen: c_ulong,
5846 ) -> c_ulong;
5847
5848 /// Gets the URI path of `action`.
5849 ///
5850 /// `document` - handle to the document.
5851 ///
5852 /// `action` - handle to the action. Must be a `PDFACTION_URI`.
5853 ///
5854 /// `buffer` - a buffer for the path string. May be `NULL`.
5855 ///
5856 /// `buflen` - the length of the buffer, in bytes. May be 0.
5857 ///
5858 /// Returns the number of bytes in the URI path, including the trailing `NUL`
5859 /// character, or 0 on error, typically because the arguments were bad or the
5860 /// action was of the wrong type.
5861 ///
5862 /// The `buffer` may contain badly encoded data. The caller should validate the
5863 /// output, i.e. check to see if it is UTF-8.
5864 ///
5865 /// If `buflen` is less than the returned length, or `buffer` is `NULL`, buffer`
5866 /// will not be modified.
5867 ///
5868 /// Historically, the documentation for this API claimed `buffer` is always
5869 /// encoded in 7-bit ASCII, but did not actually enforce it.
5870 /// <https://pdfium.googlesource.com/pdfium.git/+/d609e84cee2e14a18333247485af91df48a40592>
5871 /// added that enforcement, but that did not work well for real world PDFs that
5872 /// used UTF-8. As of this writing, this API reverted back to its original
5873 /// behavior prior to commit d609e84cee.
5874 #[allow(non_snake_case)]
5875 fn FPDFAction_GetURIPath(
5876 &self,
5877 document: FPDF_DOCUMENT,
5878 action: FPDF_ACTION,
5879 buffer: *mut c_void,
5880 buflen: c_ulong,
5881 ) -> c_ulong;
5882
5883 /// Gets the page index of `dest`.
5884 ///
5885 /// `document` - handle to the document.
5886 ///
5887 /// `dest` - handle to the destination.
5888 ///
5889 /// Returns the 0-based page index containing `dest`. Returns -1 on error.
5890 #[allow(non_snake_case)]
5891 fn FPDFDest_GetDestPageIndex(&self, document: FPDF_DOCUMENT, dest: FPDF_DEST) -> c_int;
5892
5893 /// Gets the view (fit type) specified by `dest`.
5894 ///
5895 /// `dest` - handle to the destination.
5896 ///
5897 /// `pNumParams` - receives the number of view parameters, which is at most 4.
5898 ///
5899 /// `pParams` - buffer to write the view parameters. Must be at least 4
5900 /// `FS_FLOAT`s long.
5901 ///
5902 /// Returns one of the `PDFDEST_VIEW_*` constants, or `PDFDEST_VIEW_UNKNOWN_MODE` if
5903 /// `dest` does not specify a view.
5904 #[allow(non_snake_case)]
5905 fn FPDFDest_GetView(
5906 &self,
5907 dest: FPDF_DEST,
5908 pNumParams: *mut c_ulong,
5909 pParams: *mut FS_FLOAT,
5910 ) -> c_ulong;
5911
5912 /// Gets the (`x`, `y`, `zoom`) location of `dest` in the destination page, if the
5913 /// destination is in `page /XYZ x y zoom` syntax.
5914 ///
5915 /// `dest` - handle to the destination.
5916 ///
5917 /// `hasXVal` - out parameter; true if the `x` value is not null
5918 ///
5919 /// `hasYVal` - out parameter; true if the `y` value is not null
5920 ///
5921 /// `hasZoomVal` - out parameter; true if the `zoom` value is not null
5922 ///
5923 /// `x` - out parameter; the `x` coordinate, in page coordinates.
5924 ///
5925 /// `y` - out parameter; the `y` coordinate, in page coordinates.
5926 ///
5927 /// `zoom` - out parameter; the `zoom` value.
5928 ///
5929 /// Returns `true` on successfully reading the `/XYZ` value.
5930 ///
5931 /// Note the `x`, `y`, `zoom` values are only set if the corresponding `hasXVal`,
5932 /// `hasYVal`, or `hasZoomVal` flags are true.
5933 #[allow(non_snake_case)]
5934 #[allow(clippy::too_many_arguments)]
5935 fn FPDFDest_GetLocationInPage(
5936 &self,
5937 dest: FPDF_DEST,
5938 hasXVal: *mut FPDF_BOOL,
5939 hasYVal: *mut FPDF_BOOL,
5940 hasZoomVal: *mut FPDF_BOOL,
5941 x: *mut FS_FLOAT,
5942 y: *mut FS_FLOAT,
5943 zoom: *mut FS_FLOAT,
5944 ) -> FPDF_BOOL;
5945
5946 /// Finds a link at point (`x`, `y`) on `page`.
5947 ///
5948 /// `page` - handle to the document page.
5949 ///
5950 /// `x` - the `x` coordinate, in the page coordinate system.
5951 ///
5952 /// `y` - the `y` coordinate, in the page coordinate system.
5953 ///
5954 /// Returns a handle to the link, or `NULL` if no link found at the given point.
5955 ///
5956 /// You can convert coordinates from screen coordinates to page coordinates using
5957 /// `FPDF_DeviceToPage()`.
5958 #[allow(non_snake_case)]
5959 fn FPDFLink_GetLinkAtPoint(&self, page: FPDF_PAGE, x: c_double, y: c_double) -> FPDF_LINK;
5960
5961 /// Finds the Z-order of link at point (`x`, `y`) on `page`.
5962 ///
5963 /// `page` - handle to the document page.
5964 ///
5965 /// `x` - the `x` coordinate, in the page coordinate system.
5966 ///
5967 /// `y` - the `y` coordinate, in the page coordinate system.
5968 ///
5969 /// Returns the Z-order of the link, or -1 if no link found at the given point.
5970 /// Larger Z-order numbers are closer to the front.
5971 ///
5972 /// You can convert coordinates from screen coordinates to page coordinates using
5973 /// `FPDF_DeviceToPage()`.
5974 #[allow(non_snake_case)]
5975 fn FPDFLink_GetLinkZOrderAtPoint(&self, page: FPDF_PAGE, x: c_double, y: c_double) -> c_int;
5976
5977 /// Gets destination info for `link`.
5978 ///
5979 /// `document` - handle to the document.
5980 ///
5981 /// `link` - handle to the link.
5982 ///
5983 /// Returns a handle to the destination, or `NULL` if there is no destination
5984 /// associated with the link. In this case, you should call `FPDFLink_GetAction()`
5985 /// to retrieve the action associated with `link`.
5986 #[allow(non_snake_case)]
5987 fn FPDFLink_GetDest(&self, document: FPDF_DOCUMENT, link: FPDF_LINK) -> FPDF_DEST;
5988
5989 /// Gets action info for `link`.
5990 ///
5991 /// `link` - handle to the link.
5992 ///
5993 /// Returns a handle to the action associated to `link`, or `NULL` if no action.
5994 /// If this function returns a valid handle, it is valid as long as `link` is
5995 /// valid.
5996 #[allow(non_snake_case)]
5997 fn FPDFLink_GetAction(&self, link: FPDF_LINK) -> FPDF_ACTION;
5998
5999 /// Enumerates all the link annotations in `page`.
6000 ///
6001 /// `page` - handle to the page.
6002 ///
6003 /// `start_pos` - the start position, should initially be 0 and is updated with
6004 /// the next start position on return.
6005 ///
6006 /// `link_annot` - the link handle for `startPos`.
6007 ///
6008 /// Returns `true` on success.
6009 #[allow(non_snake_case)]
6010 fn FPDFLink_Enumerate(
6011 &self,
6012 page: FPDF_PAGE,
6013 start_pos: *mut c_int,
6014 link_annot: *mut FPDF_LINK,
6015 ) -> FPDF_BOOL;
6016
6017 /// Gets `FPDF_ANNOTATION` object for `link_annot`.
6018 ///
6019 /// `page` - handle to the page in which `FPDF_LINK` object is present.
6020 ///
6021 /// `link_annot` - handle to link annotation.
6022 ///
6023 /// Returns `FPDF_ANNOTATION` from the `FPDF_LINK` or `NULL` on failure,
6024 /// if the input link annot or page is `NULL`.
6025 #[allow(non_snake_case)]
6026 fn FPDFLink_GetAnnot(&self, page: FPDF_PAGE, link_annot: FPDF_LINK) -> FPDF_ANNOTATION;
6027
6028 /// Gets the rectangle for `link_annot`.
6029 ///
6030 /// `link_annot` - handle to the link annotation.
6031 ///
6032 /// `rect` - the annotation rectangle.
6033 ///
6034 /// Returns `true` on success.
6035 #[allow(non_snake_case)]
6036 fn FPDFLink_GetAnnotRect(&self, link_annot: FPDF_LINK, rect: *mut FS_RECTF) -> FPDF_BOOL;
6037
6038 /// Gets the count of quadrilateral points to the `link_annot`.
6039 ///
6040 /// `link_annot` - handle to the link annotation.
6041 ///
6042 /// Returns the count of quadrilateral points.
6043 #[allow(non_snake_case)]
6044 fn FPDFLink_CountQuadPoints(&self, link_annot: FPDF_LINK) -> c_int;
6045
6046 /// Gets the quadrilateral points for the specified `quad_index` in `link_annot`.
6047 ///
6048 /// `link_annot` - handle to the link annotation.
6049 ///
6050 /// `quad_index` - the specified quad point index.
6051 ///
6052 /// `quad_points` - receives the quadrilateral points.
6053 ///
6054 /// Returns `true` on success.
6055 #[allow(non_snake_case)]
6056 fn FPDFLink_GetQuadPoints(
6057 &self,
6058 link_annot: FPDF_LINK,
6059 quad_index: c_int,
6060 quad_points: *mut FS_QUADPOINTSF,
6061 ) -> FPDF_BOOL;
6062
6063 /// Gets an additional-action from `page`.
6064 ///
6065 /// `page` - handle to the page, as returned by `FPDF_LoadPage()`.
6066 ///
6067 /// `aa_type` - the type of the page object's additional-action, defined
6068 /// in `public/fpdf_formfill.h`
6069 ///
6070 /// Returns the handle to the action data, or `NULL` if there is no
6071 /// additional-action of type `aa_type`.
6072 ///
6073 /// If this function returns a valid handle, it is valid as long as `page` is
6074 /// valid.
6075 #[allow(non_snake_case)]
6076 fn FPDF_GetPageAAction(&self, page: FPDF_PAGE, aa_type: c_int) -> FPDF_ACTION;
6077
6078 /// Gets the file identifier defined in the trailer of `document`.
6079 ///
6080 /// `document` - handle to the document.
6081 ///
6082 /// `id_type` - the file identifier type to retrieve.
6083 ///
6084 /// `buffer` - a buffer for the file identifier. May be `NULL`.
6085 ///
6086 /// `buflen` - the length of the buffer, in bytes. May be 0.
6087 ///
6088 /// Returns the number of bytes in the file identifier, including the `NUL`
6089 /// terminator.
6090 ///
6091 /// The `buffer` is always a byte string. The `buffer` is followed by a `NUL`
6092 /// terminator. If `buflen` is less than the returned length, or `buffer` is
6093 /// `NULL`, `buffer` will not be modified.
6094 #[allow(non_snake_case)]
6095 fn FPDF_GetFileIdentifier(
6096 &self,
6097 document: FPDF_DOCUMENT,
6098 id_type: FPDF_FILEIDTYPE,
6099 buffer: *mut c_void,
6100 buflen: c_ulong,
6101 ) -> c_ulong;
6102
6103 /// Gets meta-data `tag` content from `document`.
6104 ///
6105 /// `document` - handle to the document.
6106 ///
6107 /// `tag` - the tag to retrieve. The tag can be one of:
6108 /// Title, Author, Subject, Keywords, Creator, Producer,
6109 /// CreationDate, or ModDate.
6110 /// For detailed explanations of these tags and their respective
6111 /// values, please refer to PDF Reference 1.6, section 10.2.1,
6112 /// "Document Information Dictionary".
6113 ///
6114 /// `buffer` - a buffer for the tag. May be `NULL`.
6115 ///
6116 /// `buflen` - the length of the buffer, in bytes. May be 0.
6117 ///
6118 /// Returns the number of bytes in the tag, including trailing zeros.
6119 ///
6120 /// The |buffer| is always encoded in UTF-16LE. The `buffer` is followed by two
6121 /// bytes of zeros indicating the end of the string. If `buflen` is less than
6122 /// the returned length, or `buffer` is `NULL`, `buffer` will not be modified.
6123 ///
6124 /// For linearized files, `FPDFAvail_IsFormAvail()` must be called before this, and
6125 /// it must have returned `PDF_FORM_AVAIL` or `PDF_FORM_NOTEXIST`. Before that, there
6126 /// is no guarantee the metadata has been loaded.
6127 #[allow(non_snake_case)]
6128 fn FPDF_GetMetaText(
6129 &self,
6130 document: FPDF_DOCUMENT,
6131 tag: &str,
6132 buffer: *mut c_void,
6133 buflen: c_ulong,
6134 ) -> c_ulong;
6135
6136 /// Gets the page label for `page_index` from `document`.
6137 ///
6138 /// `document` - handle to the document.
6139 ///
6140 /// `page_index` - the 0-based index of the page.
6141 ///
6142 /// `buffer` - a buffer for the page label. May be `NULL`.
6143 ///
6144 /// `buflen` - the length of the buffer, in bytes. May be 0.
6145 ///
6146 /// Returns the number of bytes in the page label, including trailing zeros.
6147 ///
6148 /// The `buffer` is always encoded in UTF-16LE. The `buffer` is followed by two
6149 /// bytes of zeros indicating the end of the string. If `buflen` is less than
6150 /// the returned length, or `buffer` is `NULL`, `buffer` will not be modified.
6151 #[allow(non_snake_case)]
6152 fn FPDF_GetPageLabel(
6153 &self,
6154 document: FPDF_DOCUMENT,
6155 page_index: c_int,
6156 buffer: *mut c_void,
6157 buflen: c_ulong,
6158 ) -> c_ulong;
6159
6160 #[cfg(feature = "pdfium_enable_xfa")]
6161 /// Gets the number of valid packets in the XFA entry.
6162 ///
6163 /// `document` - handle to the document.
6164 ///
6165 /// Returns the number of valid packets, or `-1` on error.
6166 #[allow(non_snake_case)]
6167 fn FPDF_GetXFAPacketCount(&self, document: FPDF_DOCUMENT) -> c_int;
6168
6169 #[cfg(feature = "pdfium_enable_xfa")]
6170 /// Gets the name of a packet in the XFA array.
6171 ///
6172 /// `document` - handle to the document.
6173 ///
6174 /// `index` - index number of the packet. `0` for the first packet.
6175 ///
6176 /// `buffer` - buffer for holding the name of the XFA packet.
6177 ///
6178 /// `buflen` - length of `buffer` in bytes.
6179 ///
6180 /// Returns the length of the packet name in bytes, or `0` on error.
6181 /// `document` must be valid and `index` must be in the range `[0, N)`, where `N` is
6182 /// the value returned by [PdfiumLibraryBindings::FPDF_GetXFAPacketCount].
6183 /// `buffer` is only modified if it is non-`NULL` and `buflen` is greater than or
6184 /// equal to the length of the packet name. The packet name includes a terminating `NUL` character.
6185 /// `buffer` is unmodified on error.
6186 #[allow(non_snake_case)]
6187 fn FPDF_GetXFAPacketName(
6188 &self,
6189 document: FPDF_DOCUMENT,
6190 index: c_int,
6191 buffer: *mut c_void,
6192 buflen: c_ulong,
6193 ) -> c_ulong;
6194
6195 #[cfg(feature = "pdfium_enable_xfa")]
6196 /// Gets the content of a packet in the XFA array.
6197 ///
6198 /// `document` - handle to the document.
6199 ///
6200 /// `index` - index number of the packet. `0` for the first packet.
6201 ///
6202 /// `buffer` - buffer for holding the content of the XFA packet.
6203 ///
6204 /// `buflen` - length of `buffer` in bytes.
6205 ///
6206 /// `out_buflen` - pointer to the variable that will receive the minimum
6207 /// buffer size needed to contain the content of the XFA packet.
6208 ///
6209 /// Returns `true` if the operation succeeded, `false` if not.
6210 ///
6211 /// `document` must be valid and `index` must be in the range `[0, N)`, where `N` is
6212 /// the value returned by [PdfiumLibraryBindings::FPDF_GetXFAPacketCount].
6213 /// `out_buflen` must not be `NULL`. When the aforementioned arguments are valid,
6214 /// the operation succeeds, and `out_buflen` receives the content size. `buffer` is
6215 /// only modified if `buffer` is non-`NULL` and long enough to contain the content.
6216 /// Callers must check both the return value and that the input `buflen` is no less than
6217 /// the returned `out_buflen` before using the data in `buffer`.
6218 #[allow(non_snake_case)]
6219 fn FPDF_GetXFAPacketContent(
6220 &self,
6221 document: FPDF_DOCUMENT,
6222 index: c_int,
6223 buffer: *mut c_void,
6224 buflen: c_ulong,
6225 out_buflen: *mut c_ulong,
6226 ) -> FPDF_BOOL;
6227
6228 #[cfg(feature = "pdfium_enable_v8")]
6229 #[cfg(not(target_arch = "wasm32"))] // pdfium_enable_v8 feature not supported on WASM
6230 /// Returns a space-separated string of command line flags that are recommended to be
6231 /// passed into V8 via `V8::SetFlagsFromString` prior to initializing the PDFium library.
6232 ///
6233 /// Returns a `NUL`-terminated string of the form `--flag1 --flag2`.
6234 /// The caller must not attempt to modify or free the result.
6235 #[allow(non_snake_case)]
6236 fn FPDF_GetRecommendedV8Flags(&self) -> *const c_char;
6237
6238 #[cfg(feature = "pdfium_enable_v8")]
6239 #[cfg(not(target_arch = "wasm32"))] // pdfium_enable_v8 feature not supported on WASM
6240 /// A helper function for initializing V8 isolates that will use PDFium's internal
6241 /// memory management.
6242 ///
6243 /// Returns a pointer to a suitable `v8::ArrayBuffer::Allocator`, returned
6244 /// as `void` for C compatibility. Use is optional, but allows external creation of
6245 /// isolates matching the ones PDFium will make when none is provided via
6246 /// `FPDF_LIBRARY_CONFIG::m_pIsolate`. Can only be called when the library is in an
6247 /// uninitialized or destroyed state.
6248 #[allow(non_snake_case)]
6249 fn FPDF_GetArrayBufferAllocatorSharedInstance(&self) -> *mut c_void;
6250
6251 #[cfg(feature = "pdfium_enable_xfa")]
6252 /// A helper function to initialize a `FPDF_BSTR`.
6253 #[allow(non_snake_case)]
6254 fn FPDF_BStr_Init(&self, bstr: *mut FPDF_BSTR) -> FPDF_RESULT;
6255
6256 #[cfg(feature = "pdfium_enable_xfa")]
6257 /// A helper function to copy string data into the `FPDF_BSTR`.
6258 #[allow(non_snake_case)]
6259 fn FPDF_BStr_Set(
6260 &self,
6261 bstr: *mut FPDF_BSTR,
6262 cstr: *const c_char,
6263 length: c_int,
6264 ) -> FPDF_RESULT;
6265
6266 #[cfg(feature = "pdfium_enable_xfa")]
6267 /// A helper function to clear a `FPDF_BSTR`.
6268 #[allow(non_snake_case)]
6269 fn FPDF_BStr_Clear(&self, bstr: *mut FPDF_BSTR) -> FPDF_RESULT;
6270
6271 /// Prepares information about all characters in a page.
6272 ///
6273 /// `page` - handle to the page. Returned by [PdfiumLibraryBindings::FPDF_LoadPage].
6274 ///
6275 /// Returns a handle to the text page information structure, or `NULL` if something goes wrong.
6276 ///
6277 /// Application must call [PdfiumLibraryBindings::FPDFText_ClosePage] to release the
6278 /// text page information.
6279 #[allow(non_snake_case)]
6280 fn FPDFText_LoadPage(&self, page: FPDF_PAGE) -> FPDF_TEXTPAGE;
6281
6282 /// Releases all resources allocated for a text page information structure.
6283 ///
6284 /// `text_page` - handle to a text page information structure.
6285 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6286 #[allow(non_snake_case)]
6287 fn FPDFText_ClosePage(&self, text_page: FPDF_TEXTPAGE);
6288
6289 /// Gets the number of characters in a page.
6290 ///
6291 /// `text_page` - handle to a text page information structure.
6292 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6293 ///
6294 /// Returns the number of characters in the page, or `-1` for error.
6295 /// Generated characters, like additional space characters, new line characters,
6296 /// are also counted.
6297 ///
6298 /// Characters in a page form a "stream"; inside the stream, each character has an index.
6299 /// We will use the index parameters in many of the `FPDFTEXT` functions. The
6300 /// first character in the page has an index value of zero.
6301 #[allow(non_snake_case)]
6302 fn FPDFText_CountChars(&self, text_page: FPDF_TEXTPAGE) -> c_int;
6303
6304 /// Gets the Unicode of a character in a page.
6305 ///
6306 /// `text_page` - handle to a text page information structure.
6307 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6308 ///
6309 /// `index` - zero-based index of the character.
6310 ///
6311 /// Returns the Unicode of the particular character. If a character is not encoded in
6312 /// Unicode and Foxit engine can't convert to Unicode, the return value will be zero.
6313 #[allow(non_snake_case)]
6314 fn FPDFText_GetUnicode(&self, text_page: FPDF_TEXTPAGE, index: c_int) -> c_uint;
6315
6316 #[cfg(any(
6317 feature = "pdfium_future",
6318 feature = "pdfium_7350",
6319 feature = "pdfium_7215",
6320 feature = "pdfium_7123",
6321 feature = "pdfium_6996",
6322 feature = "pdfium_6721",
6323 feature = "pdfium_6666",
6324 feature = "pdfium_6611",
6325 ))]
6326 /// Gets the `FPDF_PAGEOBJECT` associated with a given character.
6327 ///
6328 /// `text_page` - handle to a text page information structure.
6329 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6330 ///
6331 /// `index` - zero-based index of the character.
6332 ///
6333 /// Returns the associated text object for the character at `index`, or `NULL` on error.
6334 /// The returned text object, if non-`NULL`, is of type `FPDF_PAGEOBJ_TEXT`.
6335 /// The caller does not own the returned object.
6336 #[allow(non_snake_case)]
6337 fn FPDFText_GetTextObject(&self, text_page: FPDF_TEXTPAGE, index: c_int) -> FPDF_PAGEOBJECT;
6338
6339 /// Returns whether or not a character in a page is generated by PDFium.
6340 ///
6341 /// `text_page` - handle to a text page information structure.
6342 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6343 ///
6344 /// `index` - zero-based index of the character.
6345 ///
6346 /// Returns `1` if the character is generated by PDFium, `0` if the character is not
6347 /// generated by PDFium, or `-1` if there was an error.
6348 #[allow(non_snake_case)]
6349 fn FPDFText_IsGenerated(&self, text_page: FPDF_TEXTPAGE, index: c_int) -> c_int;
6350
6351 #[cfg(any(
6352 feature = "pdfium_future",
6353 feature = "pdfium_7350",
6354 feature = "pdfium_7215",
6355 feature = "pdfium_7123",
6356 feature = "pdfium_6996",
6357 feature = "pdfium_6721",
6358 feature = "pdfium_6666",
6359 feature = "pdfium_6611",
6360 feature = "pdfium_6569",
6361 feature = "pdfium_6555",
6362 feature = "pdfium_6490",
6363 feature = "pdfium_6406",
6364 feature = "pdfium_6337",
6365 feature = "pdfium_6295",
6366 feature = "pdfium_6259",
6367 feature = "pdfium_6164",
6368 feature = "pdfium_6124",
6369 feature = "pdfium_6110",
6370 feature = "pdfium_6084",
6371 feature = "pdfium_6043",
6372 feature = "pdfium_6015",
6373 ))]
6374 // Returns whether or not a character in a page is a hyphen.
6375 ///
6376 /// `text_page` - Handle to a text page information structure.
6377 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6378 ///
6379 /// `index` - Zero-based index of the character.
6380 ///
6381 /// Returns `1` if the character is a hyphen, `0` if the character is not a hyphen,
6382 /// or `-1` if there was an error.
6383 #[allow(non_snake_case)]
6384 fn FPDFText_IsHyphen(&self, text_page: FPDF_TEXTPAGE, index: c_int) -> c_int;
6385
6386 /// Returns whether or not a character in a page has an invalid unicode mapping.
6387 ///
6388 /// `text_page` - Handle to a text page information structure.
6389 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6390 ///
6391 /// `index` - Zero-based index of the character.
6392 ///
6393 /// Returns `1` if the character has an invalid unicode mapping, `0` if the character
6394 /// has no known unicode mapping issues, or `-1` if there was an error.
6395 #[allow(non_snake_case)]
6396 fn FPDFText_HasUnicodeMapError(&self, text_page: FPDF_TEXTPAGE, index: c_int) -> c_int;
6397
6398 /// Gets the font size of a particular character.
6399 ///
6400 /// `text_page` - Handle to a text page information structure.
6401 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6402 ///
6403 /// `index` - Zero-based index of the character.
6404 ///
6405 /// Returns the font size of the particular character, measured in points (about 1/72 inch).
6406 /// This is the typographic size of the font (so called "em size").
6407 #[allow(non_snake_case)]
6408 fn FPDFText_GetFontSize(&self, text_page: FPDF_TEXTPAGE, index: c_int) -> c_double;
6409
6410 /// Gets the font name and flags of a particular character.
6411 ///
6412 /// `text_page` - Handle to a text page information structure.
6413 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6414 ///
6415 /// `index` - Zero-based index of the character.
6416 ///
6417 /// `buffer` - A buffer receiving the font name.
6418 ///
6419 /// `buflen` - The length of `buffer` in bytes.
6420 ///
6421 /// `flags` - Optional pointer to an int receiving the font flags.
6422 /// These flags should be interpreted per PDF spec 1.7
6423 /// Section 5.7.1, "Font Descriptor Flags".
6424 ///
6425 /// On success, returns the length of the font name, including the trailing `NUL` character,
6426 /// in bytes. If this length is less than or equal to `length`, `buffer` is set to the
6427 /// font name, `flags` is set to the font flags. `buffer` is in UTF-8 encoding.
6428 /// Returns `0` on failure.
6429 #[allow(non_snake_case)]
6430 fn FPDFText_GetFontInfo(
6431 &self,
6432 text_page: FPDF_TEXTPAGE,
6433 index: c_int,
6434 buffer: *mut c_void,
6435 buflen: c_ulong,
6436 flags: *mut c_int,
6437 ) -> c_ulong;
6438
6439 /// Gets the font weight of a particular character.
6440 ///
6441 /// `text_page` - Handle to a text page information structure.
6442 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6443 ///
6444 /// `index` - Zero-based index of the character.
6445 ///
6446 /// On success, returns the font weight of the particular character. If `text_page`
6447 /// is invalid, if `index` is out of bounds, or if the character's text object is
6448 /// undefined, return `-1`.
6449 #[allow(non_snake_case)]
6450 fn FPDFText_GetFontWeight(&self, text_page: FPDF_TEXTPAGE, index: c_int) -> c_int;
6451
6452 #[cfg(any(
6453 feature = "pdfium_6569",
6454 feature = "pdfium_6555",
6455 feature = "pdfium_6490",
6456 feature = "pdfium_6406",
6457 feature = "pdfium_6337",
6458 feature = "pdfium_6295",
6459 feature = "pdfium_6259",
6460 feature = "pdfium_6164",
6461 feature = "pdfium_6124",
6462 feature = "pdfium_6110",
6463 feature = "pdfium_6084",
6464 feature = "pdfium_6043",
6465 feature = "pdfium_6015",
6466 feature = "pdfium_5961"
6467 ))]
6468 /// Gets the text rendering mode of character.
6469 ///
6470 /// `text_page` - Handle to a text page information structure.
6471 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6472 ///
6473 /// `index` - Zero-based index of the character.
6474 ///
6475 /// On success, returns the render mode value. A valid value is of type
6476 /// `FPDF_TEXT_RENDERMODE`. If `text_page` is invalid, if `index` is out of bounds,
6477 /// or if the text object is undefined, then returns `FPDF_TEXTRENDERMODE_UNKNOWN`.
6478 #[allow(non_snake_case)]
6479 fn FPDFText_GetTextRenderMode(
6480 &self,
6481 text_page: FPDF_TEXTPAGE,
6482 index: c_int,
6483 ) -> FPDF_TEXT_RENDERMODE;
6484
6485 /// Gets the fill color of a particular character.
6486 ///
6487 /// `text_page` - Handle to a text page information structure.
6488 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6489 ///
6490 /// `index` - Zero-based index of the character.
6491 ///
6492 /// `R` - Pointer to an unsigned int number receiving the
6493 /// red value of the fill color.
6494 ///
6495 /// `G` - Pointer to an unsigned int number receiving the
6496 /// green value of the fill color.
6497 ///
6498 /// `B` - Pointer to an unsigned int number receiving the
6499 /// blue value of the fill color.
6500 ///
6501 /// `A` - Pointer to an unsigned int number receiving the
6502 /// alpha value of the fill color.
6503 ///
6504 /// Returns whether the call succeeded. If false, `R`, `G`, `B` and `A` are unchanged.
6505 #[allow(non_snake_case)]
6506 fn FPDFText_GetFillColor(
6507 &self,
6508 text_page: FPDF_TEXTPAGE,
6509 index: c_int,
6510 R: *mut c_uint,
6511 G: *mut c_uint,
6512 B: *mut c_uint,
6513 A: *mut c_uint,
6514 ) -> FPDF_BOOL;
6515
6516 /// Gets the stroke color of a particular character.
6517 ///
6518 /// `text_page` - Handle to a text page information structure.
6519 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6520 ///
6521 /// `index` - Zero-based index of the character.
6522 ///
6523 /// `R` - Pointer to an unsigned int number receiving the
6524 /// red value of the stroke color.
6525 ///
6526 /// `G` - Pointer to an unsigned int number receiving the
6527 /// green value of the stroke color.
6528 ///
6529 /// `B` - Pointer to an unsigned int number receiving the
6530 /// blue value of the stroke color.
6531 ///
6532 /// `A` - Pointer to an unsigned int number receiving the
6533 /// alpha value of the stroke color.
6534 ///
6535 /// Returns whether the call succeeded. If false, `R`, `G`, `B` and `A` are unchanged.
6536 #[allow(non_snake_case)]
6537 fn FPDFText_GetStrokeColor(
6538 &self,
6539 text_page: FPDF_TEXTPAGE,
6540 index: c_int,
6541 R: *mut c_uint,
6542 G: *mut c_uint,
6543 B: *mut c_uint,
6544 A: *mut c_uint,
6545 ) -> FPDF_BOOL;
6546
6547 /// Gets character rotation angle.
6548 ///
6549 /// `text_page` - Handle to a text page information structure.
6550 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6551 ///
6552 /// `index` - Zero-based index of the character.
6553 ///
6554 /// On success, returns the angle value in radians. Value will always be greater or
6555 /// equal to `0`. If `text_page` is invalid, or if `index` is out of bounds,
6556 /// then returns `-1`.
6557 #[allow(non_snake_case)]
6558 fn FPDFText_GetCharAngle(&self, text_page: FPDF_TEXTPAGE, index: c_int) -> c_float;
6559
6560 /// Gets bounding box of a particular character.
6561 ///
6562 /// `text_page` - Handle to a text page information structure.
6563 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6564 ///
6565 /// `index` - Zero-based index of the character.
6566 ///
6567 /// `left` - Pointer to a double number receiving left position
6568 /// of the character box.
6569 ///
6570 /// `right` - Pointer to a double number receiving right position
6571 /// of the character box.
6572 ///
6573 /// `bottom` - Pointer to a double number receiving bottom position
6574 /// of the character box.
6575 ///
6576 /// `top` - Pointer to a double number receiving top position of
6577 /// the character box.
6578 ///
6579 /// On success, returns `true` and fills in `left`, `right`, `bottom`, and `top`.
6580 /// If `text_page` is invalid, or if `index` is out of bounds, then returns `false`,
6581 /// and the out parameters remain unmodified.
6582 ///
6583 /// All positions are measured in PDF user space.
6584 #[allow(non_snake_case)]
6585 fn FPDFText_GetCharBox(
6586 &self,
6587 text_page: FPDF_TEXTPAGE,
6588 index: c_int,
6589 left: *mut c_double,
6590 right: *mut c_double,
6591 bottom: *mut c_double,
6592 top: *mut c_double,
6593 ) -> FPDF_BOOL;
6594
6595 /// Gets a "loose" bounding box of a particular character, i.e., covering the entire
6596 /// glyph bounds, without taking the actual glyph shape into account.
6597 ///
6598 /// `text_page` - Handle to a text page information structure.
6599 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6600 ///
6601 /// `index` - Zero-based index of the character.
6602 ///
6603 /// `rect` - Pointer to a `FS_RECTF` receiving the character box.
6604 ///
6605 /// On success, returns `true` and fills in `rect`. If `text_page` is invalid, or if
6606 /// `index` is out of bounds, then returns `false`, and the `rect` out parameter
6607 /// remains unmodified.
6608 ///
6609 /// All positions are measured in PDF "user space".
6610 #[allow(non_snake_case)]
6611 fn FPDFText_GetLooseCharBox(
6612 &self,
6613 text_page: FPDF_TEXTPAGE,
6614 index: c_int,
6615 rect: *mut FS_RECTF,
6616 ) -> FPDF_BOOL;
6617
6618 /// Gets the effective transformation matrix for a particular character.
6619 ///
6620 /// `text_page` - Handle to a text page information structure.
6621 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6622 ///
6623 /// `index` - Zero-based index of the character.
6624 ///
6625 /// `matrix` - Pointer to a `FS_MATRIX` receiving the transformation matrix.
6626 ///
6627 /// On success, returns `true` and fills in `matrix`. If `text_page` is invalid, or if
6628 /// `index` is out of bounds, or if `matrix` is `NULL`, then returns `false`, and
6629 /// `matrix` remains unmodified.
6630 #[allow(non_snake_case)]
6631 fn FPDFText_GetMatrix(
6632 &self,
6633 text_page: FPDF_TEXTPAGE,
6634 index: c_int,
6635 matrix: *mut FS_MATRIX,
6636 ) -> FPDF_BOOL;
6637
6638 /// Gets the origin of a particular character.
6639 ///
6640 /// `text_page` - Handle to a text page information structure.
6641 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6642 ///
6643 /// `index` - Zero-based index of the character.
6644 ///
6645 /// `x` - Pointer to a double number receiving x coordinate of
6646 /// the character origin.
6647 ///
6648 /// `y` - Pointer to a double number receiving y coordinate of
6649 /// the character origin.
6650 ///
6651 /// Returns whether the call succeeded. If `false`, `x` and `y` are unchanged.
6652 ///
6653 /// All positions are measured in PDF "user space".
6654 #[allow(non_snake_case)]
6655 fn FPDFText_GetCharOrigin(
6656 &self,
6657 text_page: FPDF_TEXTPAGE,
6658 index: c_int,
6659 x: *mut c_double,
6660 y: *mut c_double,
6661 ) -> FPDF_BOOL;
6662
6663 /// Gets the index of a character at or nearby a certain position on the page.
6664 ///
6665 /// `text_page` - Handle to a text page information structure.
6666 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6667 ///
6668 /// `x` - X position in PDF "user space".
6669 ///
6670 /// `y` - Y position in PDF "user space".
6671 ///
6672 /// `xTolerance` - An x-axis tolerance value for character hit detection,
6673 /// in point units.
6674 ///
6675 /// `yTolerance` - A y-axis tolerance value for character hit detection,
6676 /// in point units.
6677 ///
6678 /// Returns the zero-based index of the character at, or nearby, the point `(x, y)`.
6679 /// If there is no character at or nearby the point, the return value will be `-1`.
6680 /// If an error occurs, `-3` will be returned.
6681 #[allow(non_snake_case)]
6682 fn FPDFText_GetCharIndexAtPos(
6683 &self,
6684 text_page: FPDF_TEXTPAGE,
6685 x: c_double,
6686 y: c_double,
6687 xTolerance: c_double,
6688 yTolerance: c_double,
6689 ) -> c_int;
6690
6691 /// Extracts a unicode text string from the page.
6692 ///
6693 /// `text_page` - Handle to a text page information structure.
6694 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6695 ///
6696 /// `start_index` - Index for the start characters.
6697 ///
6698 /// `count` - Number of `UCS-2` values to be extracted.
6699 ///
6700 /// `result` - A buffer (allocated by application) receiving the extracted
6701 /// `UCS-2` values. The buffer must be able to hold `count`
6702 /// `UCS-2` values plus a terminator.
6703 ///
6704 /// Returns the number of characters written into the `result` buffer, including the
6705 /// trailing terminator.
6706 ///
6707 /// This function ignores characters without `UCS-2` representations. It considers
6708 /// all characters on the page, even those that are not visible when the page has
6709 /// a cropbox. To filter out the characters outside of the cropbox, use
6710 /// [PdfiumLibraryBindings::FPDF_GetPageBoundingBox] and [PdfiumLibraryBindings::FPDFText_GetCharBox].
6711 #[allow(non_snake_case)]
6712 fn FPDFText_GetText(
6713 &self,
6714 text_page: FPDF_TEXTPAGE,
6715 start_index: c_int,
6716 count: c_int,
6717 result: *mut c_ushort,
6718 ) -> c_int;
6719
6720 /// Counts the number of rectangular areas occupied by a segment of text,
6721 /// and caches the result for subsequent [PdfiumLibraryBindings::FPDFText_GetRect] calls.
6722 ///
6723 /// `text_page` - Handle to a text page information structure.
6724 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6725 ///
6726 /// `start_index` - Index for the start character.
6727 ///
6728 /// `count` - Number of characters, or `-1` for all remaining.
6729 ///
6730 /// Returns the number of rectangles, `0` if `text_page` is `NULL`, or `-1` on bad `start_index`.
6731 ///
6732 /// This function, along with [PdfiumLibraryBindings::FPDFText_GetRect], can be used by
6733 /// applications to detect the position on the page for a text segment, so proper areas
6734 /// can be highlighted. The `FPDFText_*` functions will automatically merge small character
6735 /// boxes into bigger one if those characters are on the same line and use same font settings.
6736 #[allow(non_snake_case)]
6737 fn FPDFText_CountRects(
6738 &self,
6739 text_page: FPDF_TEXTPAGE,
6740 start_index: c_int,
6741 count: c_int,
6742 ) -> c_int;
6743
6744 /// Gets a rectangular area from the result generated by
6745 /// [PdfiumLibraryBindings::FPDFText_CountRects].
6746 ///
6747 /// `text_page` - Handle to a text page information structure.
6748 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6749 ///
6750 /// `rect_index` - Zero-based index for the rectangle.
6751 ///
6752 /// `left` - Pointer to a double value receiving the rectangle left boundary.
6753 ///
6754 /// `top` - Pointer to a double value receiving the rectangle top boundary.
6755 ///
6756 /// `right` - Pointer to a double value receiving the rectangle right boundary.
6757 ///
6758 /// `bottom` - Pointer to a double value receiving the rectangle bottom boundary.
6759 ///
6760 /// On success, returns `true` and fills in `left`, `top`, `right`, and `bottom`.
6761 /// If `text_page` is invalid then returns `false`, and the out parameters remain unmodified.
6762 /// If `text_page` is valid but `rect_index` is out of bounds, then returns `false`
6763 /// and sets the out parameters to `0`.
6764 #[allow(non_snake_case)]
6765 fn FPDFText_GetRect(
6766 &self,
6767 text_page: FPDF_TEXTPAGE,
6768 rect_index: c_int,
6769 left: *mut c_double,
6770 top: *mut c_double,
6771 right: *mut c_double,
6772 bottom: *mut c_double,
6773 ) -> FPDF_BOOL;
6774
6775 /// Extracts unicode text within a rectangular boundary on the page.
6776 ///
6777 /// `text_page` - Handle to a text page information structure.
6778 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6779 ///
6780 /// `left` - Left boundary.
6781 ///
6782 /// `top` - Top boundary.
6783 ///
6784 /// `right` - Right boundary.
6785 ///
6786 /// `bottom` - Bottom boundary.
6787 ///
6788 /// `buffer` - Caller-allocated buffer to receive `UTF-16` values.
6789 ///
6790 /// `buflen` - Number of `UTF-16` values **(not bytes)** that `buffer`
6791 /// is capable of holding.
6792 ///
6793 /// If `buffer` is `NULL` or `buflen` is zero, then returns the number of `UTF-16`
6794 /// values **(not bytes)** of text present within the rectangle, excluding
6795 /// a terminating `NUL`. Generally you should pass a buffer at least one larger than this
6796 /// if you want a terminating `NUL`, which will be provided if space is available.
6797 /// Otherwise, return number of `UTF-16` values copied into the buffer, including the
6798 /// terminating `NUL` when space for it is available.
6799 ///
6800 /// If `buffer` is too small, as much text as will fit is copied into it. May return
6801 /// a split surrogate in that case.
6802 #[allow(non_snake_case)]
6803 #[allow(clippy::too_many_arguments)]
6804 fn FPDFText_GetBoundedText(
6805 &self,
6806 text_page: FPDF_TEXTPAGE,
6807 left: c_double,
6808 top: c_double,
6809 right: c_double,
6810 bottom: c_double,
6811 buffer: *mut c_ushort,
6812 buflen: c_int,
6813 ) -> c_int;
6814
6815 /// Starts a search.
6816 ///
6817 /// `text_page` - Handle to a text page information structure.
6818 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6819 ///
6820 /// `findwhat` - A unicode match pattern.
6821 ///
6822 /// `flags` - Option flags.
6823 ///
6824 /// `start_index` - Start from this character. `-1` for end of the page.
6825 ///
6826 /// Returns a handle for the search context. [PdfiumLibraryBindings::FPDFText_FindClose]
6827 /// must be called to release this handle.
6828 ///
6829 /// A [&str]-friendly helper function is available for this function.
6830 /// See [PdfiumLibraryBindings::FPDFText_FindStart_str].
6831 #[allow(non_snake_case)]
6832 fn FPDFText_FindStart(
6833 &self,
6834 text_page: FPDF_TEXTPAGE,
6835 findwhat: FPDF_WIDESTRING,
6836 flags: c_ulong,
6837 start_index: c_int,
6838 ) -> FPDF_SCHHANDLE;
6839
6840 /// A [&str]-friendly helper function for [PdfiumLibraryBindings::FPDFText_FindStart].
6841 ///
6842 /// Starts a search.
6843 ///
6844 /// `text_page` - Handle to a text page information structure.
6845 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage].
6846 ///
6847 /// `findwhat` - A unicode match pattern.
6848 ///
6849 /// `flags` - Option flags.
6850 ///
6851 /// `start_index` - Start from this character. `-1` for end of the page.
6852 ///
6853 /// Returns a handle for the search context. [PdfiumLibraryBindings::FPDFText_FindClose]
6854 /// must be called to release this handle.
6855 #[allow(non_snake_case)]
6856 fn FPDFText_FindStart_str(
6857 &self,
6858 text_page: FPDF_TEXTPAGE,
6859 findwhat: &str,
6860 flags: c_ulong,
6861 start_index: c_int,
6862 ) -> FPDF_SCHHANDLE {
6863 self.FPDFText_FindStart(
6864 text_page,
6865 get_pdfium_utf16le_bytes_from_str(findwhat).as_ptr() as FPDF_WIDESTRING,
6866 flags,
6867 start_index,
6868 )
6869 }
6870
6871 /// Searches in the direction from page start to end.
6872 ///
6873 /// `handle` - A search context handle returned by
6874 /// [PdfiumLibraryBindings::FPDFText_FindStart].
6875 ///
6876 /// Returns whether or not a match is found.
6877 #[allow(non_snake_case)]
6878 fn FPDFText_FindNext(&self, handle: FPDF_SCHHANDLE) -> FPDF_BOOL;
6879
6880 /// Searches in the direction from page end to start.
6881 ///
6882 /// `handle` - A search context handle returned by
6883 /// [PdfiumLibraryBindings::FPDFText_FindStart].
6884 ///
6885 /// Returns whether or not a match is found.
6886 #[allow(non_snake_case)]
6887 fn FPDFText_FindPrev(&self, handle: FPDF_SCHHANDLE) -> FPDF_BOOL;
6888
6889 /// Gets the starting character index of the search result.
6890 ///
6891 /// `handle` - A search context handle returned by
6892 /// [PdfiumLibraryBindings::FPDFText_FindStart].
6893 ///
6894 /// Returns the index for the starting character.
6895 #[allow(non_snake_case)]
6896 fn FPDFText_GetSchResultIndex(&self, handle: FPDF_SCHHANDLE) -> c_int;
6897
6898 /// Gets the number of matched characters in the search result.
6899 ///
6900 /// `handle` - A search context handle returned by
6901 /// [PdfiumLibraryBindings::FPDFText_FindStart].
6902 ///
6903 /// Returns the number of matched characters.
6904 #[allow(non_snake_case)]
6905 fn FPDFText_GetSchCount(&self, handle: FPDF_SCHHANDLE) -> c_int;
6906
6907 /// Releases a search context.
6908 ///
6909 /// `handle` - A search context handle returned by
6910 /// [PdfiumLibraryBindings::FPDFText_FindStart].
6911 #[allow(non_snake_case)]
6912 fn FPDFText_FindClose(&self, handle: FPDF_SCHHANDLE);
6913
6914 /// Prepares information about weblinks in a page.
6915 ///
6916 /// `text_page` - Handle to a text page information structure.
6917 /// Returned by [PdfiumLibraryBindings::FPDFText_LoadPage] function.
6918 ///
6919 /// Returns a handle to the page's links information structure, or `NULL` if something goes wrong.
6920 ///
6921 /// Weblinks are those links implicitly embedded in PDF pages. PDF also has a type of annotation
6922 /// called "link" (FPDFTEXT doesn't deal with that kind of link). FPDFTEXT weblink feature is
6923 /// useful for automatically detecting links in the page contents. For example, things like
6924 /// <https://www.example.com> will be detected, so applications can allow user to click on
6925 /// those characters to activate the link, even the PDF doesn't come with link annotations.
6926 ///
6927 /// [PdfiumLibraryBindings::FPDFLink_CloseWebLinks] must be called to release resources.
6928 #[allow(non_snake_case)]
6929 fn FPDFLink_LoadWebLinks(&self, text_page: FPDF_TEXTPAGE) -> FPDF_PAGELINK;
6930
6931 /// Counts the number of detected web links.
6932 ///
6933 /// `link_page` - Handle returned by [PdfiumLibraryBindings::FPDFLink_LoadWebLinks].
6934 ///
6935 /// Returns the umber of detected web links.
6936 #[allow(non_snake_case)]
6937 fn FPDFLink_CountWebLinks(&self, link_page: FPDF_PAGELINK) -> c_int;
6938
6939 /// Gets the URL information for a detected web link.
6940 ///
6941 /// `link_page` - Handle returned by [PdfiumLibraryBindings::FPDFLink_LoadWebLinks].
6942 ///
6943 /// `link_index` - Zero-based index of the link.
6944 ///
6945 /// `buffer` - A unicode buffer for the result.
6946 ///
6947 /// `buflen` - Number of 16-bit code units (not bytes) for the buffer,
6948 /// including an additional terminator.
6949 ///
6950 /// If `buffer` is `NULL` or `buflen` is zero, returns the number of 16-bit code units
6951 /// (not bytes) needed to buffer the result (an additional terminator is included in this count).
6952 /// Otherwise, copies the result into `buffer`, truncating at `buflen` if the result is
6953 /// too large to fit, and returns the number of 16-bit code units actually copied into
6954 // the buffer (the additional terminator is also included in this count).
6955 ///
6956 /// If `link_index` does not correspond to a valid link, then the result is an empty string.
6957 #[allow(non_snake_case)]
6958 fn FPDFLink_GetURL(
6959 &self,
6960 link_page: FPDF_PAGELINK,
6961 link_index: c_int,
6962 buffer: *mut c_ushort,
6963 buflen: c_int,
6964 ) -> c_int;
6965
6966 /// Counts the number of rectangular areas for a given link.
6967 ///
6968 /// `link_page` - Handle returned by [PdfiumLibraryBindings::FPDFLink_LoadWebLinks].
6969 ///
6970 /// `link_index` - Zero-based index of the link.
6971 ///
6972 /// Returns the number of rectangular areas for the link. If `link_index` does not
6973 /// correspond to a valid link, then returns `0`.
6974 #[allow(non_snake_case)]
6975 fn FPDFLink_CountRects(&self, link_page: FPDF_PAGELINK, link_index: c_int) -> c_int;
6976
6977 /// Gets the boundaries of one rectangular area for a given link.
6978 ///
6979 /// `link_page` - Handle returned by [PdfiumLibraryBindings::FPDFLink_LoadWebLinks].
6980 ///
6981 /// `link_index` - Zero-based index of the link.
6982 ///
6983 /// `rect_index` - Zero-based index of the rectangle.
6984 ///
6985 /// `left` - Pointer to a double value receiving the rectangle left boundary.
6986 ///
6987 /// `top` - Pointer to a double value receiving the rectangle top boundary.
6988 ///
6989 /// `right` - Pointer to a double value receiving the rectangle right boundary.
6990 ///
6991 /// `bottom` - Pointer to a double value receiving the rectangle bottom boundary.
6992 ///
6993 /// On success, returns `true` and fills in `left`, `top`, `right`, and `bottom`.
6994 /// If `link_page` is invalid or if `link_index` does not correspond to a valid link,
6995 /// then returns `false`, and the out parameters remain unmodified.
6996 #[allow(non_snake_case)]
6997 #[allow(clippy::too_many_arguments)]
6998 fn FPDFLink_GetRect(
6999 &self,
7000 link_page: FPDF_PAGELINK,
7001 link_index: c_int,
7002 rect_index: c_int,
7003 left: *mut c_double,
7004 top: *mut c_double,
7005 right: *mut c_double,
7006 bottom: *mut c_double,
7007 ) -> FPDF_BOOL;
7008
7009 /// Gets the start char index and char count for a link.
7010 ///
7011 /// `link_page` - Handle returned by [PdfiumLibraryBindings::FPDFLink_LoadWebLinks].
7012 ///
7013 /// `link_index` - Zero-based index for the link.
7014 ///
7015 /// `start_char_index` - pointer to int receiving the start char index
7016 ///
7017 /// `char_count` - pointer to int receiving the char count
7018 ///
7019 /// On success, returns `true` and fills in `start_char_index` and `char_count`.
7020 /// If `link_page` is invalid or if `link_index` does not correspond to a valid link,
7021 /// then returns `false` and the out parameters remain unmodified.
7022 #[allow(non_snake_case)]
7023 fn FPDFLink_GetTextRange(
7024 &self,
7025 link_page: FPDF_PAGELINK,
7026 link_index: c_int,
7027 start_char_index: *mut c_int,
7028 char_count: *mut c_int,
7029 ) -> FPDF_BOOL;
7030
7031 /// Releases resources used by weblink feature.
7032 ///
7033 /// `link_page` - Handle returned by [PdfiumLibraryBindings::FPDFLink_LoadWebLinks].
7034 #[allow(non_snake_case)]
7035 fn FPDFLink_CloseWebLinks(&self, link_page: FPDF_PAGELINK);
7036
7037 /// Gets the decoded data from the thumbnail of `page`, if it exists.
7038 ///
7039 /// `page` - handle to a page.
7040 ///
7041 /// `buffer` - buffer for holding the decoded image data.
7042 ///
7043 /// `buflen` - length of the buffer in bytes.
7044 ///
7045 /// This only modifies `buffer` if `buflen` is less than or equal to the size of the
7046 /// decoded data. Returns the size of the decoded data, or `0` if thumbnail does not exist.
7047 /// Optionally, pass `NULL` to just retrieve the size of the buffer needed.
7048 #[allow(non_snake_case)]
7049 fn FPDFPage_GetDecodedThumbnailData(
7050 &self,
7051 page: FPDF_PAGE,
7052 buffer: *mut c_void,
7053 buflen: c_ulong,
7054 ) -> c_ulong;
7055
7056 /// Gets the raw data from the thumbnail of `page`, if it exists.
7057 ///
7058 /// `page` - handle to a page.
7059 ///
7060 /// `buffer` - buffer for holding the raw image data.
7061 ///
7062 /// `buflen` - length of the buffer in bytes.
7063 ///
7064 /// This only modifies `buffer` if `buflen` is less than or equal to the size of the
7065 /// raw data. Returns the size of the raw data, or `0` if thumbnail does not exist.
7066 /// Optionally, pass `NULL` to just retrieve the size of the buffer needed.
7067 #[allow(non_snake_case)]
7068 fn FPDFPage_GetRawThumbnailData(
7069 &self,
7070 page: FPDF_PAGE,
7071 buffer: *mut c_void,
7072 buflen: c_ulong,
7073 ) -> c_ulong;
7074
7075 /// Returns the thumbnail of `page` as a `FPDF_BITMAP`.
7076 ///
7077 /// `page` - handle to a page.
7078 ///
7079 /// Returns `NULL` if unable to access the thumbnail's stream.
7080 #[allow(non_snake_case)]
7081 fn FPDFPage_GetThumbnailAsBitmap(&self, page: FPDF_PAGE) -> FPDF_BITMAP;
7082
7083 /// Gets the number of page objects inside `form_object`.
7084 ///
7085 /// `form_object` - handle to a form object.
7086 ///
7087 /// Returns the number of objects in `form_object` on success, or `-1` on error.
7088 #[allow(non_snake_case)]
7089 fn FPDFFormObj_CountObjects(&self, form_object: FPDF_PAGEOBJECT) -> c_int;
7090
7091 /// Gets the page object in `form_object` at `index`.
7092 ///
7093 /// `form_object` - handle to a form object.
7094 ///
7095 /// `index` - the zero-based index of a page object.
7096 ///
7097 /// Returns the handle to the page object, or `NULL` on error.
7098 #[allow(non_snake_case)]
7099 fn FPDFFormObj_GetObject(
7100 &self,
7101 form_object: FPDF_PAGEOBJECT,
7102 index: c_ulong,
7103 ) -> FPDF_PAGEOBJECT;
7104
7105 #[cfg(any(
7106 feature = "pdfium_future",
7107 feature = "pdfium_7350",
7108 feature = "pdfium_7215"
7109 ))]
7110 /// Removes `page_object` from `form_object`.
7111 ///
7112 /// `form_object` - handle to a form object.
7113 ///
7114 /// `page_object` - handle to a page object to be removed from the form.
7115 ///
7116 /// Returns `true` on success.
7117 ///
7118 /// Ownership of the removed `page_object` is transferred to the caller.
7119 /// Call [PdfiumLibraryBindings::FPDFPageObj_Destroy]` on the removed page_object to free it.
7120 #[allow(non_snake_case)]
7121 fn FPDFFormObj_RemoveObject(
7122 &self,
7123 form_object: FPDF_PAGEOBJECT,
7124 page_object: FPDF_PAGEOBJECT,
7125 ) -> FPDF_BOOL;
7126
7127 /// Creates a new text object using a loaded font.
7128 ///
7129 /// `document` - handle to the document.
7130 ///
7131 /// `font` - handle to the font object.
7132 ///
7133 /// `font_size` - the font size for the new text object.
7134 ///
7135 /// Returns a handle to a new text object, or `NULL` on failure.
7136 #[allow(non_snake_case)]
7137 fn FPDFPageObj_CreateTextObj(
7138 &self,
7139 document: FPDF_DOCUMENT,
7140 font: FPDF_FONT,
7141 font_size: c_float,
7142 ) -> FPDF_PAGEOBJECT;
7143
7144 /// Gets the text rendering mode of a text object.
7145 ///
7146 /// `text` - the handle to the text object.
7147 ///
7148 /// Returns one of the known `FPDF_TEXT_RENDERMODE` enum values on success,
7149 /// `FPDF_TEXTRENDERMODE_UNKNOWN` on error.
7150 #[allow(non_snake_case)]
7151 fn FPDFTextObj_GetTextRenderMode(&self, text: FPDF_PAGEOBJECT) -> FPDF_TEXT_RENDERMODE;
7152
7153 /// Sets the text rendering mode of a text object.
7154 ///
7155 /// `text` - the handle to the text object.
7156 ///
7157 /// `render_mode` - the `FPDF_TEXT_RENDERMODE` enum value to be set (cannot set to
7158 /// `FPDF_TEXTRENDERMODE_UNKNOWN`).
7159 ///
7160 /// Returns `true` on success.
7161 #[allow(non_snake_case)]
7162 fn FPDFTextObj_SetTextRenderMode(
7163 &self,
7164 text: FPDF_PAGEOBJECT,
7165 render_mode: FPDF_TEXT_RENDERMODE,
7166 ) -> FPDF_BOOL;
7167
7168 /// Gets the text of a text object.
7169 ///
7170 /// `text_object` - the handle to the text object.
7171 ///
7172 /// `text_page` - the handle to the text page.
7173 ///
7174 /// `buffer` - the address of a buffer that receives the text.
7175 ///
7176 /// `length` - the size, in bytes, of `buffer`.
7177 ///
7178 /// Returns the number of bytes in the text (including the trailing `NUL` character)
7179 /// on success, `0` on error. Regardless of the platform, the `buffer` is always in
7180 /// UTF-16LE encoding. If `length` is less than the returned length, or `buffer` is
7181 /// `NULL`, `buffer` will not be modified.
7182 #[allow(non_snake_case)]
7183 fn FPDFTextObj_GetText(
7184 &self,
7185 text_object: FPDF_PAGEOBJECT,
7186 text_page: FPDF_TEXTPAGE,
7187 buffer: *mut FPDF_WCHAR,
7188 length: c_ulong,
7189 ) -> c_ulong;
7190
7191 /// Gets a bitmap rasterization of `text_object`. To render correctly, the caller
7192 /// must provide the `document` associated with `text_object`. If there is a `page`
7193 /// associated with `text_object`, the caller should provide that as well.
7194 /// The returned bitmap will be owned by the caller, and [PdfiumLibraryBindings::FPDFBitmap_Destroy]
7195 /// must be called on the returned bitmap when it is no longer needed.
7196 ///
7197 /// `document` - handle to a document associated with `text_object`.
7198 ///
7199 /// `page` - handle to an optional page associated with `text_object`.
7200 ///
7201 /// `text_object` - handle to a text object.
7202 ///
7203 /// `scale` - the scaling factor, which must be greater than `0`.
7204 ///
7205 /// Returns the bitmap or `NULL` on failure.
7206 #[allow(non_snake_case)]
7207 fn FPDFTextObj_GetRenderedBitmap(
7208 &self,
7209 document: FPDF_DOCUMENT,
7210 page: FPDF_PAGE,
7211 text_object: FPDF_PAGEOBJECT,
7212 scale: f32,
7213 ) -> FPDF_BITMAP;
7214
7215 /// Gets the font of a text object.
7216 ///
7217 /// `text` - the handle to the text object.
7218 ///
7219 /// Returns a handle to the font object held by `text` which retains ownership.
7220 #[allow(non_snake_case)]
7221 fn FPDFTextObj_GetFont(&self, text: FPDF_PAGEOBJECT) -> FPDF_FONT;
7222
7223 /// Gets the font size of a text object.
7224 ///
7225 /// `text` - handle to a text.
7226 ///
7227 /// `size` - pointer to the font size of the text object, measured in points
7228 /// (about 1/72 inch).
7229 ///
7230 /// Returns `true` on success.
7231 #[allow(non_snake_case)]
7232 fn FPDFTextObj_GetFontSize(&self, text: FPDF_PAGEOBJECT, size: *mut c_float) -> FPDF_BOOL;
7233
7234 /// Closes a loaded PDF font.
7235 ///
7236 /// `font` - Handle to the loaded font.
7237 #[allow(non_snake_case)]
7238 fn FPDFFont_Close(&self, font: FPDF_FONT);
7239
7240 /// Moves a path's current point.
7241 ///
7242 /// `path` - the handle to the path object.
7243 ///
7244 /// `x` - the horizontal position of the new current point.
7245 ///
7246 /// `y` - the vertical position of the new current point.
7247 ///
7248 /// Note that no line will be created between the previous current point and the
7249 /// new one. Returns `true` on success.
7250 #[allow(non_snake_case)]
7251 fn FPDFPath_MoveTo(&self, path: FPDF_PAGEOBJECT, x: c_float, y: c_float) -> FPDF_BOOL;
7252
7253 /// Adds a line between the current point and a new point in the path.
7254 ///
7255 /// `path` - the handle to the path object.
7256 ///
7257 /// `x` - the horizontal position of the new point.
7258 ///
7259 /// `y` - the vertical position of the new point.
7260 ///
7261 /// The path's current point is changed to `(x, y)`. Returns `true` on success,
7262 /// `false` otherwise.
7263 #[allow(non_snake_case)]
7264 fn FPDFPath_LineTo(&self, path: FPDF_PAGEOBJECT, x: c_float, y: c_float) -> FPDF_BOOL;
7265
7266 /// Adds a cubic Bezier curve to the given path, starting at the current point.
7267 ///
7268 /// `path` - the handle to the path object.
7269 ///
7270 /// `x1` - the horizontal position of the first Bezier control point.
7271 ///
7272 /// `y1` - the vertical position of the first Bezier control point.
7273 ///
7274 /// `x2` - the horizontal position of the second Bezier control point.
7275 ///
7276 /// `y2` - the vertical position of the second Bezier control point.
7277 ///
7278 /// `x3` - the horizontal position of the ending point of the Bezier curve.
7279 ///
7280 /// `y3` - the vertical position of the ending point of the Bezier curve.
7281 ///
7282 /// Returns `true` on success.
7283 #[allow(non_snake_case)]
7284 #[allow(clippy::too_many_arguments)]
7285 fn FPDFPath_BezierTo(
7286 &self,
7287 path: FPDF_PAGEOBJECT,
7288 x1: c_float,
7289 y1: c_float,
7290 x2: c_float,
7291 y2: c_float,
7292 x3: c_float,
7293 y3: c_float,
7294 ) -> FPDF_BOOL;
7295
7296 /// Closes the current subpath of a given path.
7297 ///
7298 /// `path` - the handle to the path object.
7299 ///
7300 /// This will add a line between the current point and the initial point of the subpath,
7301 /// thus terminating the current subpath. Returns `true` on success.
7302 #[allow(non_snake_case)]
7303 fn FPDFPath_Close(&self, path: FPDF_PAGEOBJECT) -> FPDF_BOOL;
7304
7305 /// Sets the drawing mode of a path.
7306 ///
7307 /// `path` - the handle to the path object.
7308 ///
7309 /// `fillmode` - the filling mode to be set: one of the `FPDF_FILLMODE_*` flags.
7310 ///
7311 /// `stroke` - a boolean specifying if the path should be stroked or not.
7312 ///
7313 /// Returns `true` on success.
7314 #[allow(non_snake_case)]
7315 fn FPDFPath_SetDrawMode(
7316 &self,
7317 path: FPDF_PAGEOBJECT,
7318 fillmode: c_int,
7319 stroke: FPDF_BOOL,
7320 ) -> FPDF_BOOL;
7321
7322 /// Gets the drawing mode of a path.
7323 ///
7324 /// `path` - the handle to the path object.
7325 ///
7326 /// `fillmode` - the filling mode of the path: one of the `FPDF_FILLMODE_*` flags.
7327 ///
7328 /// `stroke` - a boolean specifying if the path is stroked or not.
7329 ///
7330 /// Returns `true` on success.
7331 #[allow(non_snake_case)]
7332 fn FPDFPath_GetDrawMode(
7333 &self,
7334 path: FPDF_PAGEOBJECT,
7335 fillmode: *mut c_int,
7336 stroke: *mut FPDF_BOOL,
7337 ) -> FPDF_BOOL;
7338
7339 /// Creates a new text object using one of the standard PDF fonts.
7340 ///
7341 /// `document` - handle to the document.
7342 ///
7343 /// `font` - string containing the font name, without spaces.
7344 ///
7345 /// `font_size` - the font size for the new text object.
7346 ///
7347 /// Returns a handle to a new text object, or `NULL` on failure.
7348 #[allow(non_snake_case)]
7349 fn FPDFPageObj_NewTextObj(
7350 &self,
7351 document: FPDF_DOCUMENT,
7352 font: &str,
7353 font_size: c_float,
7354 ) -> FPDF_PAGEOBJECT;
7355
7356 /// Sets the text for a text object. If it had text, it will be replaced.
7357 ///
7358 /// `text_object` - handle to the text object.
7359 ///
7360 /// `text` - the UTF-16LE encoded string containing the text to be added.
7361 ///
7362 /// Returns `true` on success.
7363 ///
7364 /// A [&str]-friendly helper function is available for this function.
7365 /// See [PdfiumLibraryBindings::FPDFText_SetText_str].
7366 #[allow(non_snake_case)]
7367 fn FPDFText_SetText(&self, text_object: FPDF_PAGEOBJECT, text: FPDF_WIDESTRING) -> FPDF_BOOL;
7368
7369 /// A [&str]-friendly helper function for [PdfiumLibraryBindings::FPDFText_SetText].
7370 ///
7371 /// Sets the text for a text object. If it had text, it will be replaced.
7372 ///
7373 /// `text_object` - handle to the text object.
7374 ///
7375 /// `text` - the string containing the text to be added.
7376 ///
7377 /// Returns `true` on success.
7378 #[inline]
7379 #[allow(non_snake_case)]
7380 fn FPDFText_SetText_str(&self, text_object: FPDF_PAGEOBJECT, text: &str) -> FPDF_BOOL {
7381 self.FPDFText_SetText(
7382 text_object,
7383 get_pdfium_utf16le_bytes_from_str(text).as_ptr() as FPDF_WIDESTRING,
7384 )
7385 }
7386
7387 /// Sets the text using charcodes for a text object. If it had text, it will be replaced.
7388 ///
7389 /// `text_object` - handle to the text object.
7390 ///
7391 /// `charcodes` - pointer to an array of charcodes to be added.
7392 ///
7393 /// `count` - number of elements in |charcodes|.
7394 ///
7395 /// Returns `true` on success.
7396 #[allow(non_snake_case)]
7397 fn FPDFText_SetCharcodes(
7398 &self,
7399 text_object: FPDF_PAGEOBJECT,
7400 charcodes: *const c_uint,
7401 count: size_t,
7402 ) -> FPDF_BOOL;
7403
7404 /// Returns a font object loaded from a stream of data. The font is loaded into the
7405 /// document. Various font data structures, such as the ToUnicode data, are auto-generated
7406 /// based on the inputs.
7407 ///
7408 /// `document` - handle to the document.
7409 ///
7410 /// `data` - the stream of font data, which will be copied by the font object.
7411 ///
7412 /// `size` - the size of the font data, in bytes.
7413 ///
7414 /// `font_type` - `FPDF_FONT_TYPE1` or `FPDF_FONT_TRUETYPE` depending on the font type.
7415 ///
7416 /// `cid` - a boolean specifying if the font is a CID font or not.
7417 ///
7418 /// The loaded font can be closed using [PdfiumLibraryBindings::FPDFFont_Close].
7419 /// Returns `NULL` on failure.
7420 #[allow(non_snake_case)]
7421 fn FPDFText_LoadFont(
7422 &self,
7423 document: FPDF_DOCUMENT,
7424 data: *const c_uchar,
7425 size: c_uint,
7426 font_type: c_int,
7427 cid: FPDF_BOOL,
7428 ) -> FPDF_FONT;
7429
7430 /// Loads one of the standard 14 fonts per PDF spec 1.7 page 416. The preferred way
7431 /// of using font style is using a dash to separate the name from the style,
7432 /// for example `Helvetica-BoldItalic`.
7433 ///
7434 /// `document` - handle to the document.
7435 ///
7436 /// `font` - string containing the font name, without spaces.
7437 ///
7438 /// The loaded font can be closed using [PdfiumLibraryBindings::FPDFFont_Close].
7439 /// Returns `NULL` on failure.
7440 #[allow(non_snake_case)]
7441 fn FPDFText_LoadStandardFont(&self, document: FPDF_DOCUMENT, font: &str) -> FPDF_FONT;
7442
7443 #[cfg(any(
7444 feature = "pdfium_future",
7445 feature = "pdfium_7350",
7446 feature = "pdfium_7215",
7447 feature = "pdfium_7123",
7448 feature = "pdfium_6996",
7449 feature = "pdfium_6721",
7450 feature = "pdfium_6666",
7451 feature = "pdfium_6611",
7452 feature = "pdfium_6569",
7453 feature = "pdfium_6555",
7454 feature = "pdfium_6490",
7455 feature = "pdfium_6406",
7456 feature = "pdfium_6337",
7457 feature = "pdfium_6295",
7458 ))]
7459 /// Returns a font object loaded from a stream of data for a type 2 CID font. The font
7460 /// is loaded into the document. Unlike [PdfiumLibraryBindings::FPDFText_LoadFont],
7461 /// the ToUnicode data and the CIDToGIDMap data are caller provided, instead of being
7462 /// auto-generated.
7463 ///
7464 /// `document` - handle to the document.
7465 ///
7466 /// `font_data` - the stream of font data, which will be copied
7467 /// by the font object.
7468 ///
7469 /// `font_data_size` - the size of the font data, in bytes.
7470 ///
7471 /// `to_unicode_cmap` - the ToUnicode data.
7472 ///
7473 /// `cid_to_gid_map_data` - the stream of CIDToGIDMap data.
7474 ///
7475 /// `cid_to_gid_map_data_size` - the size of the CIDToGIDMap data, in bytes.
7476 ///
7477 /// The loaded font can be closed using [PdfiumLibraryBindings::FPDFFont_Close].
7478 /// Returns `NULL` on failure.
7479 #[allow(non_snake_case)]
7480 fn FPDFText_LoadCidType2Font(
7481 &self,
7482 document: FPDF_DOCUMENT,
7483 font_data: *const u8,
7484 font_data_size: u32,
7485 to_unicode_cmap: &str,
7486 cid_to_gid_map_data: *const u8,
7487 cid_to_gid_map_data_size: u32,
7488 ) -> FPDF_FONT;
7489
7490 /// Inserts `page_object` into `page`.
7491 ///
7492 /// `page` - handle to a page
7493 ///
7494 /// `page_object` - handle to a page object. The `page_object` will be
7495 /// automatically freed.
7496 #[allow(non_snake_case)]
7497 fn FPDFPage_InsertObject(&self, page: FPDF_PAGE, page_obj: FPDF_PAGEOBJECT);
7498
7499 #[cfg(any(feature = "pdfium_future", feature = "pdfium_7350"))]
7500 /// Inserts `page_object` into `page` at the specified `index`.
7501 ///
7502 /// `page` - handle to a page
7503 ///
7504 /// `page_object` - handle to a page object as previously obtained by
7505 /// [PdfiumLibraryBindings::FPDFPageObj_CreateNewPath],
7506 /// [PdfiumLibraryBindings::FPDFPageObj_CreateNewRect],
7507 /// [PdfiumLibraryBindings::FPDFPageObj_NewTextObj], or
7508 /// [PdfiumLibraryBindings::FPDFPageObj_NewImageObj].
7509 /// Ownership of the object is transferred back to PDFium.
7510 ///
7511 /// `index` - the index position to insert the object at. If index equals
7512 /// the current object count, the object will be appended to the
7513 /// end. If index is greater than the object count, the function
7514 /// will fail and return false.
7515 ///f
7516 /// Returns `true` on success.
7517 #[allow(non_snake_case)]
7518 fn FPDFPage_InsertObjectAtIndex(
7519 &self,
7520 page: FPDF_PAGE,
7521 page_object: FPDF_PAGEOBJECT,
7522 index: usize,
7523 ) -> FPDF_BOOL;
7524
7525 /// Removes `page_object` from `page`.
7526 ///
7527 /// `page` - handle to a page
7528 ///
7529 /// `page_object` - handle to a page object to be removed.
7530 ///
7531 /// Returns `true` on success. Ownership is transferred to the caller.
7532 /// Call [PdfiumLibraryBindings::FPDFPageObj_Destroy] to free it. Note that when removing
7533 /// a `page_object` of type `FPDF_PAGEOBJ_TEXT`, all `FPDF_TEXTPAGE` handles for `page`
7534 /// are no longer valid.
7535 #[allow(non_snake_case)]
7536 fn FPDFPage_RemoveObject(&self, page: FPDF_PAGE, page_obj: FPDF_PAGEOBJECT) -> FPDF_BOOL;
7537
7538 /// Gets the number of page objects inside `page`.
7539 ///
7540 /// `page` - handle to a page.
7541 ///
7542 /// Returns the number of objects in `page`.
7543 #[allow(non_snake_case)]
7544 fn FPDFPage_CountObjects(&self, page: FPDF_PAGE) -> c_int;
7545
7546 /// Gets the object in `page` at `index`.
7547 ///
7548 /// `page` - handle to a page.
7549 ///
7550 /// `index` - the index of a page object.
7551 ///
7552 /// Returns the handle to the page object, or `NULL` on failure.
7553 #[allow(non_snake_case)]
7554 fn FPDFPage_GetObject(&self, page: FPDF_PAGE, index: c_int) -> FPDF_PAGEOBJECT;
7555
7556 /// Destroys `page_object` by releasing its resources. `page_object` must have
7557 /// been created by [PdfiumLibraryBindings::FPDFPageObj_CreateNewPath],
7558 /// [PdfiumLibraryBindings::FPDFPageObj_CreateNewRect],
7559 /// [PdfiumLibraryBindings::FPDFPageObj_NewTextObj] or
7560 /// [PdfiumLibraryBindings::FPDFPageObj_NewImageObj]. This function must be called
7561 /// on newly-created objects if they are not added to a page through
7562 /// [PdfiumLibraryBindings::FPDFPage_InsertObject] or to an annotation through
7563 /// [PdfiumLibraryBindings::FPDFAnnot_AppendObject].
7564 ///
7565 /// `page_object` - handle to a page object.
7566 #[allow(non_snake_case)]
7567 fn FPDFPageObj_Destroy(&self, page_obj: FPDF_PAGEOBJECT);
7568
7569 /// Checks if `page` contains transparency.
7570 ///
7571 /// `page` - handle to a page.
7572 ///
7573 /// Returns `true` if `page` contains transparency.
7574 #[allow(non_snake_case)]
7575 fn FPDFPageObj_HasTransparency(&self, page_object: FPDF_PAGEOBJECT) -> FPDF_BOOL;
7576
7577 /// Gets the type of `page_object`.
7578 ///
7579 /// `page_object` - handle to a page object.
7580 ///
7581 /// Returns one of the `FPDF_PAGEOBJ_*` values on success, or `FPDF_PAGEOBJ_UNKNOWN` on error.
7582 #[allow(non_snake_case)]
7583 fn FPDFPageObj_GetType(&self, page_object: FPDF_PAGEOBJECT) -> c_int;
7584
7585 #[cfg(any(
7586 feature = "pdfium_future",
7587 feature = "pdfium_7350",
7588 feature = "pdfium_7215",
7589 feature = "pdfium_7123",
7590 feature = "pdfium_6996"
7591 ))]
7592 /// Gets the active state for `page_object` within its containing page.
7593 ///
7594 /// `page_object` - handle to a page object.
7595 ///
7596 /// `active` - pointer to variable that will receive `true` if the page object
7597 /// is active. This is a required parameter. Not filled if this
7598 /// function returns `false`.
7599 ///
7600 /// For page objects where `active` is filled with `false`, the `page_object` is
7601 /// treated as if it wasn't in the document even though it is still held
7602 /// internally.
7603 ///
7604 /// Returns `true` if the operation succeeded, `false` if it failed.
7605 #[allow(non_snake_case)]
7606 fn FPDFPageObj_GetIsActive(
7607 &self,
7608 page_object: FPDF_PAGEOBJECT,
7609 active: *mut FPDF_BOOL,
7610 ) -> FPDF_BOOL;
7611
7612 #[cfg(any(
7613 feature = "pdfium_future",
7614 feature = "pdfium_7350",
7615 feature = "pdfium_7215",
7616 feature = "pdfium_7123",
7617 feature = "pdfium_6996"
7618 ))]
7619 /// Sets whether `page_object` is active within its containing page.
7620 ///
7621 /// `page_object` - handle to a page object.
7622 ///
7623 /// `active` - a boolean specifying if the object is active.
7624 ///
7625 /// Returns `true` on success.
7626 ///
7627 /// Page objects all start in the active state by default, and remain in that
7628 /// state unless this function is called.
7629 ///
7630 /// When `active` is false, this makes the `page_object` be treated as if it
7631 /// wasn't in the document even though it is still held internally.
7632 #[allow(non_snake_case)]
7633 fn FPDFPageObj_SetIsActive(&self, page_object: FPDF_PAGEOBJECT, active: FPDF_BOOL)
7634 -> FPDF_BOOL;
7635
7636 /// Transforms `page_object` by the given matrix.
7637 ///
7638 /// `page_object` - handle to a page object.
7639 ///
7640 /// `a` - matrix value.
7641 ///
7642 /// `b` - matrix value.
7643 ///
7644 /// `c` - matrix value.
7645 ///
7646 /// `d` - matrix value.
7647 ///
7648 /// `e` - matrix value.
7649 ///
7650 /// `f` - matrix value.
7651 ///
7652 /// The matrix is composed as:
7653 ///
7654 /// `a c e`
7655 ///
7656 /// `b d f`
7657 ///
7658 /// and can be used to scale, rotate, shear and translate the `page_object`.
7659 #[allow(non_snake_case)]
7660 #[allow(clippy::too_many_arguments)]
7661 fn FPDFPageObj_Transform(
7662 &self,
7663 page_object: FPDF_PAGEOBJECT,
7664 a: c_double,
7665 b: c_double,
7666 c: c_double,
7667 d: c_double,
7668 e: c_double,
7669 f: c_double,
7670 );
7671
7672 #[cfg(any(
7673 feature = "pdfium_future",
7674 feature = "pdfium_7350",
7675 feature = "pdfium_7215",
7676 feature = "pdfium_7123",
7677 feature = "pdfium_6996",
7678 feature = "pdfium_6721",
7679 feature = "pdfium_6666",
7680 feature = "pdfium_6611",
7681 ))]
7682 /// Transforms `page_object` by the given matrix.
7683 ///
7684 /// `page_object` - handle to a page object.
7685 ///
7686 /// `matrix` - the transform matrix.
7687 ///
7688 /// Returns `true on success.
7689 ///
7690 /// This can be used to scale, rotate, shear and translate the `page_object`.
7691 /// It is an improved version of [PdfiumLibraryBindings::FPDFPageObj_Transform]
7692 /// that does not do unnecessary double to float conversions, and only uses 1 parameter
7693 /// for the matrix. It also returns whether the operation succeeded or not.
7694 #[allow(non_snake_case)]
7695 fn FPDFPageObj_TransformF(
7696 &self,
7697 page_object: FPDF_PAGEOBJECT,
7698 matrix: *const FS_MATRIX,
7699 ) -> FPDF_BOOL;
7700
7701 /// Gets the transform matrix of a page object.
7702 ///
7703 /// `page_object` - handle to a page object.
7704 ///
7705 /// `matrix` - pointer to struct to receive the matrix value.
7706 ///
7707 /// The matrix is composed as:
7708 ///
7709 /// `a c e`
7710 ///
7711 /// `b d f`
7712 ///
7713 /// and used to scale, rotate, shear and translate the page object. For page objects
7714 /// outside form objects, the matrix values are relative to the page that contains it.
7715 /// For page objects inside form objects, the matrix values are relative to the form
7716 /// that contains it.
7717 ///
7718 /// Returns `true` on success.
7719 #[allow(non_snake_case)]
7720 fn FPDFPageObj_GetMatrix(
7721 &self,
7722 page_object: FPDF_PAGEOBJECT,
7723 matrix: *mut FS_MATRIX,
7724 ) -> FPDF_BOOL;
7725
7726 /// Sets the transform matrix of a page object.
7727 ///
7728 /// `page_object` - handle to a page object.
7729 ///
7730 /// `matrix` - pointer to struct with the matrix value.
7731 ///
7732 /// The matrix is composed as:
7733 ///
7734 /// `a c e`
7735 ///
7736 /// `b d f`
7737 ///
7738 /// and can be used to scale, rotate, shear and translate the page object.
7739 ///
7740 /// Returns `true` on success.
7741 #[allow(non_snake_case)]
7742 fn FPDFPageObj_SetMatrix(&self, path: FPDF_PAGEOBJECT, matrix: *const FS_MATRIX) -> FPDF_BOOL;
7743
7744 /// Creates a new image object.
7745 ///
7746 /// `document` - handle to a document.
7747 ///
7748 /// Returns a handle to a new image object.
7749 #[allow(non_snake_case)]
7750 fn FPDFPageObj_NewImageObj(&self, document: FPDF_DOCUMENT) -> FPDF_PAGEOBJECT;
7751
7752 #[cfg(any(
7753 feature = "pdfium_future",
7754 feature = "pdfium_7350",
7755 feature = "pdfium_7215",
7756 feature = "pdfium_7123",
7757 feature = "pdfium_6996",
7758 feature = "pdfium_6721",
7759 feature = "pdfium_6666",
7760 feature = "pdfium_6611",
7761 ))]
7762 /// Gets the marked content ID for the object.
7763 ///
7764 /// `page_object` - handle to a page object.
7765 ///
7766 /// Returns the page object's marked content ID, or -1 on error.
7767 #[allow(non_snake_case)]
7768 fn FPDFPageObj_GetMarkedContentID(&self, page_object: FPDF_PAGEOBJECT) -> c_int;
7769
7770 /// Gets the number of content marks in `page_object`.
7771 ///
7772 /// `page_object` - handle to a page object.
7773 ///
7774 /// Returns the number of content marks in `page_object`, or -1 in case of failure.
7775 #[allow(non_snake_case)]
7776 fn FPDFPageObj_CountMarks(&self, page_object: FPDF_PAGEOBJECT) -> c_int;
7777
7778 /// Gets content mark in `page_object` at `index`.
7779 ///
7780 /// `page_object` - handle to a page object.
7781 ///
7782 /// `index` - the index of a page object.
7783 ///
7784 /// Returns the handle to the content mark, or `NULL` on failure. The handle is
7785 /// still owned by the library, and it should not be freed directly. It becomes
7786 /// invalid if the page object is destroyed, either directly or indirectly by
7787 /// unloading the page.
7788 #[allow(non_snake_case)]
7789 fn FPDFPageObj_GetMark(
7790 &self,
7791 page_object: FPDF_PAGEOBJECT,
7792 index: c_ulong,
7793 ) -> FPDF_PAGEOBJECTMARK;
7794
7795 /// Adds a new content mark to a `page_object`.
7796 ///
7797 /// `page_object` - handle to a page object.
7798 ///
7799 /// `name` - the name (tag) of the mark.
7800 ///
7801 /// Returns the handle to the content mark, or `NULL` on failure. The handle is
7802 /// still owned by the library, and it should not be freed directly. It becomes
7803 /// invalid if the page object is destroyed, either directly or indirectly by
7804 /// unloading the page.
7805 #[allow(non_snake_case)]
7806 fn FPDFPageObj_AddMark(&self, page_object: FPDF_PAGEOBJECT, name: &str) -> FPDF_PAGEOBJECTMARK;
7807
7808 /// Removes a content `mark` from a `page_object`. The mark handle will be invalid
7809 /// after the removal.
7810 ///
7811 /// `page_object` - handle to a page object.
7812 ///
7813 /// `mark` - handle to a content mark in that object to remove.
7814 ///
7815 /// Returns `true` if the operation succeeded, `false` if it failed.
7816 #[allow(non_snake_case)]
7817 fn FPDFPageObj_RemoveMark(
7818 &self,
7819 page_object: FPDF_PAGEOBJECT,
7820 mark: FPDF_PAGEOBJECTMARK,
7821 ) -> FPDF_BOOL;
7822
7823 #[cfg(any(
7824 feature = "pdfium_future",
7825 feature = "pdfium_7350",
7826 feature = "pdfium_7215",
7827 feature = "pdfium_7123",
7828 feature = "pdfium_6996"
7829 ))]
7830 /// Gets the name of a content mark.
7831 ///
7832 /// `mark` - handle to a content mark.
7833 ///
7834 /// `buffer` - buffer for holding the returned name in UTF-16LE. This is only
7835 /// modified if `buflen` is large enough to store the name.
7836 /// Optional, pass `null` to just retrieve the size of the buffer
7837 /// needed.
7838 ///
7839 /// `buflen` - length of the buffer in bytes.
7840 ///
7841 /// `out_buflen` - pointer to variable that will receive the minimum buffer size
7842 /// in bytes to contain the name. This is a required parameter.
7843 /// Not filled if `false` is returned.
7844 ///
7845 /// Returns `true` if the operation succeeded, `false` if it failed.
7846 #[allow(non_snake_case)]
7847 fn FPDFPageObjMark_GetName(
7848 &self,
7849 mark: FPDF_PAGEOBJECTMARK,
7850 buffer: *mut FPDF_WCHAR,
7851 buflen: c_ulong,
7852 out_buflen: *mut c_ulong,
7853 ) -> FPDF_BOOL;
7854
7855 #[cfg(any(
7856 feature = "pdfium_6721",
7857 feature = "pdfium_6666",
7858 feature = "pdfium_6611",
7859 feature = "pdfium_6569",
7860 feature = "pdfium_6555",
7861 feature = "pdfium_6490",
7862 feature = "pdfium_6406",
7863 feature = "pdfium_6337",
7864 feature = "pdfium_6295",
7865 feature = "pdfium_6259",
7866 feature = "pdfium_6164",
7867 feature = "pdfium_6124",
7868 feature = "pdfium_6110",
7869 feature = "pdfium_6084",
7870 feature = "pdfium_6043",
7871 feature = "pdfium_6015",
7872 feature = "pdfium_5961",
7873 ))]
7874 /// Gets the name of a content mark.
7875 ///
7876 /// `mark` - handle to a content mark.
7877 ///
7878 /// `buffer` - buffer for holding the returned name in UTF-16LE. This is only
7879 /// modified if `buflen` is longer than the length of the name.
7880 /// Optional, pass `null` to just retrieve the size of the buffer needed.
7881 ///
7882 /// `buflen` - length of the buffer.
7883 ///
7884 /// `out_buflen` - pointer to variable that will receive the minimum buffer size
7885 /// to contain the name. Not filled if `false` is returned.
7886 ///
7887 /// Returns `true` if the operation succeeded, `false` if it failed.
7888 #[allow(non_snake_case)]
7889 fn FPDFPageObjMark_GetName(
7890 &self,
7891 mark: FPDF_PAGEOBJECTMARK,
7892 buffer: *mut c_void,
7893 buflen: c_ulong,
7894 out_buflen: *mut c_ulong,
7895 ) -> FPDF_BOOL;
7896
7897 /// Gets the number of key/value pair parameters in `mark`.
7898 ///
7899 /// `mark` - handle to a content mark.
7900 ///
7901 /// Returns the number of key/value pair parameters `mark`, or `-1` in case of failure.
7902 #[allow(non_snake_case)]
7903 fn FPDFPageObjMark_CountParams(&self, mark: FPDF_PAGEOBJECTMARK) -> c_int;
7904
7905 #[cfg(any(
7906 feature = "pdfium_future",
7907 feature = "pdfium_7350",
7908 feature = "pdfium_7215",
7909 feature = "pdfium_7123",
7910 feature = "pdfium_6996"
7911 ))]
7912 /// Gets the key of a property in a content mark.
7913 ///
7914 /// `mark` - handle to a content mark.
7915 ///
7916 /// `index` - index of the property.
7917 ///
7918 /// `buffer` - buffer for holding the returned key in UTF-16LE. This is only
7919 /// modified if `buflen` is large enough to store the key.
7920 /// Optional, pass `null` to just retrieve the size of the buffer needed.
7921 ///
7922 /// `buflen` - length of the buffer in bytes.
7923 ///
7924 /// `out_buflen` - pointer to variable that will receive the minimum buffer size
7925 /// in bytes to contain the name. This is a required parameter.
7926 /// Not filled if `false` is returned.
7927 ///
7928 /// Returns `true` if the operation was successful.
7929 #[allow(non_snake_case)]
7930 fn FPDFPageObjMark_GetParamKey(
7931 &self,
7932 mark: FPDF_PAGEOBJECTMARK,
7933 index: c_ulong,
7934 buffer: *mut FPDF_WCHAR,
7935 buflen: c_ulong,
7936 out_buflen: *mut c_ulong,
7937 ) -> FPDF_BOOL;
7938
7939 #[cfg(any(
7940 feature = "pdfium_6721",
7941 feature = "pdfium_6666",
7942 feature = "pdfium_6611",
7943 feature = "pdfium_6569",
7944 feature = "pdfium_6555",
7945 feature = "pdfium_6490",
7946 feature = "pdfium_6406",
7947 feature = "pdfium_6337",
7948 feature = "pdfium_6295",
7949 feature = "pdfium_6259",
7950 feature = "pdfium_6164",
7951 feature = "pdfium_6124",
7952 feature = "pdfium_6110",
7953 feature = "pdfium_6084",
7954 feature = "pdfium_6043",
7955 feature = "pdfium_6015",
7956 feature = "pdfium_5961",
7957 ))]
7958 /// Gets the key of a property in a content mark.
7959 ///
7960 /// `mark` - handle to a content mark.
7961 ///
7962 /// `index` - index of the property.
7963 ///
7964 /// `buffer` - buffer for holding the returned key in UTF-16LE. This is only
7965 /// modified if `buflen` is longer than the length of the key.
7966 /// Optional, pass `null` to just retrieve the size of the buffer needed.
7967 ///
7968 /// `buflen` - length of the buffer.
7969 ///
7970 /// `out_buflen` - pointer to variable that will receive the minimum buffer size
7971 /// to contain the key. Not filled if `false` is returned.
7972 ///
7973 /// Returns `true` if the operation was successful.
7974 #[allow(non_snake_case)]
7975 fn FPDFPageObjMark_GetParamKey(
7976 &self,
7977 mark: FPDF_PAGEOBJECTMARK,
7978 index: c_ulong,
7979 buffer: *mut c_void,
7980 buflen: c_ulong,
7981 out_buflen: *mut c_ulong,
7982 ) -> FPDF_BOOL;
7983
7984 /// Gets the type of the value of a property in a content mark by key.
7985 ///
7986 /// `mark` - handle to a content mark.
7987 ///
7988 /// `key` - string key of the property.
7989 ///
7990 /// Returns the type of the value, or `FPDF_OBJECT_UNKNOWN` in case of failure.
7991 #[allow(non_snake_case)]
7992 fn FPDFPageObjMark_GetParamValueType(
7993 &self,
7994 mark: FPDF_PAGEOBJECTMARK,
7995 key: &str,
7996 ) -> FPDF_OBJECT_TYPE;
7997
7998 /// Gets the value of a number property in a content mark by key as int.
7999 /// [PdfiumLibraryBindings::FPDFPageObjMark_GetParamValueType] should have returned
8000 /// `FPDF_OBJECT_NUMBER` for this property.
8001 ///
8002 /// `mark` - handle to a content mark.
8003 ///
8004 /// `key` - string key of the property.
8005 ///
8006 /// `out_value` - pointer to variable that will receive the value. Not filled if
8007 /// `false` is returned.
8008 ///
8009 /// Returns `true` if the key maps to a number value.
8010 #[allow(non_snake_case)]
8011 fn FPDFPageObjMark_GetParamIntValue(
8012 &self,
8013 mark: FPDF_PAGEOBJECTMARK,
8014 key: &str,
8015 out_value: *mut c_int,
8016 ) -> FPDF_BOOL;
8017
8018 #[cfg(any(
8019 feature = "pdfium_future",
8020 feature = "pdfium_7350",
8021 feature = "pdfium_7215",
8022 feature = "pdfium_7123",
8023 feature = "pdfium_6996"
8024 ))]
8025 /// Gets the value of a string property in a content mark by key.
8026 ///
8027 /// `mark` - handle to a content mark.
8028 ///
8029 /// `key` - string key of the property.
8030 ///
8031 /// `buffer` - buffer for holding the returned value in UTF-16LE. This is
8032 /// only modified if `buflen` is large enough to store the value.
8033 /// Optional, pass `null` to just retrieve the size of the buffer needed.
8034 ///
8035 /// `buflen` - length of the buffer in bytes.
8036 ///
8037 /// `out_buflen` - pointer to variable that will receive the minimum buffer size
8038 /// in bytes to contain the name. This is a required parameter.
8039 /// Not filled if `false` is returned.
8040 ///
8041 /// Returns `true` if the key maps to a string/blob value.
8042 #[allow(non_snake_case)]
8043 fn FPDFPageObjMark_GetParamStringValue(
8044 &self,
8045 mark: FPDF_PAGEOBJECTMARK,
8046 key: &str,
8047 buffer: *mut FPDF_WCHAR,
8048 buflen: c_ulong,
8049 out_buflen: *mut c_ulong,
8050 ) -> FPDF_BOOL;
8051
8052 #[cfg(any(
8053 feature = "pdfium_6721",
8054 feature = "pdfium_6666",
8055 feature = "pdfium_6611",
8056 feature = "pdfium_6569",
8057 feature = "pdfium_6555",
8058 feature = "pdfium_6490",
8059 feature = "pdfium_6406",
8060 feature = "pdfium_6337",
8061 feature = "pdfium_6295",
8062 feature = "pdfium_6259",
8063 feature = "pdfium_6164",
8064 feature = "pdfium_6124",
8065 feature = "pdfium_6110",
8066 feature = "pdfium_6084",
8067 feature = "pdfium_6043",
8068 feature = "pdfium_6015",
8069 feature = "pdfium_5961",
8070 ))]
8071 /// Gets the value of a string property in a content mark by key.
8072 ///
8073 /// `mark` - handle to a content mark.
8074 ///
8075 /// `key` - string key of the property.
8076 ///
8077 /// `buffer` - buffer for holding the returned value in UTF-16LE. This is
8078 /// only modified if `buflen` is longer than the length of the value.
8079 /// Optional, pass `null` to just retrieve the size of the buffer needed.
8080 ///
8081 /// `buflen` - length of the buffer.
8082 ///
8083 /// `out_buflen` - pointer to variable that will receive the minimum buffer size
8084 /// to contain the value. Not filled if `false` is returned.
8085 ///
8086 /// Returns `true` if the key maps to a string/blob value.
8087 #[allow(non_snake_case)]
8088 fn FPDFPageObjMark_GetParamStringValue(
8089 &self,
8090 mark: FPDF_PAGEOBJECTMARK,
8091 key: &str,
8092 buffer: *mut c_void,
8093 buflen: c_ulong,
8094 out_buflen: *mut c_ulong,
8095 ) -> FPDF_BOOL;
8096
8097 #[cfg(any(
8098 feature = "pdfium_future",
8099 feature = "pdfium_7350",
8100 feature = "pdfium_7215",
8101 feature = "pdfium_7123",
8102 feature = "pdfium_6996"
8103 ))]
8104 /// Gets the value of a blob property in a content mark by key.
8105 ///
8106 /// `mark` - handle to a content mark.
8107 ///
8108 /// `key` - string key of the property.
8109 ///
8110 /// `buffer` - buffer for holding the returned value. This is only modified
8111 /// if `buflen` is large enough to store the value. Optional, pass `null`
8112 /// to just retrieve the size of the buffer needed.
8113 ///
8114 /// `buflen` - length of the buffer in bytes.
8115 ///
8116 /// `out_buflen` - pointer to variable that will receive the minimum buffer size
8117 /// in bytes to contain the name. This is a required parameter.
8118 /// Not filled if `false` is returned.
8119 ///
8120 /// Returns `true` if the key maps to a string/blob value.
8121 #[allow(non_snake_case)]
8122 fn FPDFPageObjMark_GetParamBlobValue(
8123 &self,
8124 mark: FPDF_PAGEOBJECTMARK,
8125 key: &str,
8126 buffer: *mut c_uchar,
8127 buflen: c_ulong,
8128 out_buflen: *mut c_ulong,
8129 ) -> FPDF_BOOL;
8130
8131 #[cfg(any(
8132 feature = "pdfium_6721",
8133 feature = "pdfium_6666",
8134 feature = "pdfium_6611",
8135 feature = "pdfium_6569",
8136 feature = "pdfium_6555",
8137 feature = "pdfium_6490",
8138 feature = "pdfium_6406",
8139 feature = "pdfium_6337",
8140 feature = "pdfium_6295",
8141 feature = "pdfium_6259",
8142 feature = "pdfium_6164",
8143 feature = "pdfium_6124",
8144 feature = "pdfium_6110",
8145 feature = "pdfium_6084",
8146 feature = "pdfium_6043",
8147 feature = "pdfium_6015",
8148 feature = "pdfium_5961",
8149 ))]
8150 /// Gets the value of a blob property in a content mark by key.
8151 ///
8152 /// `mark` - handle to a content mark.
8153 ///
8154 /// `key` - string key of the property.
8155 ///
8156 /// `buffer` - buffer for holding the returned value. This is only modified
8157 /// if `buflen` is at least as long as the length of the value.
8158 /// Optional, pass `null` to just retrieve the size of the buffer needed.
8159 ///
8160 /// `buflen` - length of the buffer.
8161 ///
8162 /// `out_buflen` - pointer to variable that will receive the minimum buffer size
8163 /// to contain the value. Not filled if `false` is returned.
8164 ///
8165 /// Returns `true` if the key maps to a string/blob value.
8166 #[allow(non_snake_case)]
8167 fn FPDFPageObjMark_GetParamBlobValue(
8168 &self,
8169 mark: FPDF_PAGEOBJECTMARK,
8170 key: &str,
8171 buffer: *mut c_void,
8172 buflen: c_ulong,
8173 out_buflen: *mut c_ulong,
8174 ) -> FPDF_BOOL;
8175
8176 /// Sets the value of an int property in a content mark by key. If a parameter
8177 /// with key `key` exists, its value is set to `value`. Otherwise, it is added as
8178 /// a new parameter.
8179 ///
8180 /// `document` - handle to the document.
8181 ///
8182 /// `page_object` - handle to the page object with the mark.
8183 ///
8184 /// `mark` - handle to a content mark.
8185 ///
8186 /// `key` - string key of the property.
8187 ///
8188 /// `value` - int value to set.
8189 ///
8190 /// Returns `true` if the operation succeeded.
8191 #[allow(non_snake_case)]
8192 fn FPDFPageObjMark_SetIntParam(
8193 &self,
8194 document: FPDF_DOCUMENT,
8195 page_object: FPDF_PAGEOBJECT,
8196 mark: FPDF_PAGEOBJECTMARK,
8197 key: &str,
8198 value: c_int,
8199 ) -> FPDF_BOOL;
8200
8201 /// Sets the value of a string property in a content mark by key. If a parameter
8202 /// with key `key` exists, its value is set to `value`. Otherwise, it is added as
8203 /// a new parameter.
8204 ///
8205 /// `document` - handle to the document.
8206 ///
8207 /// `page_object` - handle to the page object with the mark.
8208 ///
8209 /// `mark` - handle to a content mark.
8210 ///
8211 /// `key` - string key of the property.
8212 ///
8213 /// `value` - string value to set.
8214 ///
8215 /// Returns `true` if the operation succeeded.
8216 #[allow(non_snake_case)]
8217 fn FPDFPageObjMark_SetStringParam(
8218 &self,
8219 document: FPDF_DOCUMENT,
8220 page_object: FPDF_PAGEOBJECT,
8221 mark: FPDF_PAGEOBJECTMARK,
8222 key: &str,
8223 value: &str,
8224 ) -> FPDF_BOOL;
8225
8226 #[cfg(any(
8227 feature = "pdfium_future",
8228 feature = "pdfium_7350",
8229 feature = "pdfium_7215",
8230 feature = "pdfium_7123",
8231 feature = "pdfium_6996"
8232 ))]
8233 /// Sets the value of a blob property in a content mark by key. If a parameter
8234 /// with key `key` exists, its value is set to `value`. Otherwise, it is added as
8235 /// a new parameter.
8236 ///
8237 /// `document` - handle to the document.
8238 ///
8239 /// `page_object` - handle to the page object with the mark.
8240 ///
8241 /// `mark` - handle to a content mark.
8242 ///
8243 /// `key` - string key of the property.
8244 ///
8245 /// `value` - pointer to blob value to set.
8246 ///
8247 /// `value_len` - size in bytes of `value`.
8248 ///
8249 /// Returns `true` if the operation succeeded.
8250 #[allow(non_snake_case)]
8251 fn FPDFPageObjMark_SetBlobParam(
8252 &self,
8253 document: FPDF_DOCUMENT,
8254 page_object: FPDF_PAGEOBJECT,
8255 mark: FPDF_PAGEOBJECTMARK,
8256 key: &str,
8257 value: *const c_uchar,
8258 value_len: c_ulong,
8259 ) -> FPDF_BOOL;
8260
8261 #[cfg(any(
8262 feature = "pdfium_6721",
8263 feature = "pdfium_6666",
8264 feature = "pdfium_6611",
8265 feature = "pdfium_6569",
8266 feature = "pdfium_6555",
8267 feature = "pdfium_6490",
8268 feature = "pdfium_6406",
8269 feature = "pdfium_6337",
8270 feature = "pdfium_6295",
8271 feature = "pdfium_6259",
8272 feature = "pdfium_6164",
8273 feature = "pdfium_6124",
8274 feature = "pdfium_6110",
8275 feature = "pdfium_6084",
8276 feature = "pdfium_6043",
8277 feature = "pdfium_6015",
8278 feature = "pdfium_5961",
8279 ))]
8280 /// Sets the value of a blob property in a content mark by key. If a parameter
8281 /// with key `key` exists, its value is set to `value`. Otherwise, it is added as
8282 /// a new parameter.
8283 ///
8284 /// `document` - handle to the document.
8285 ///
8286 /// `page_object` - handle to the page object with the mark.
8287 ///
8288 /// `mark` - handle to a content mark.
8289 ///
8290 /// `key` - string key of the property.
8291 ///
8292 /// `value` - pointer to blob value to set.
8293 ///
8294 /// `value_len` - size in bytes of `value`.
8295 ///
8296 /// Returns `true` if the operation succeeded.
8297 #[allow(non_snake_case)]
8298 fn FPDFPageObjMark_SetBlobParam(
8299 &self,
8300 document: FPDF_DOCUMENT,
8301 page_object: FPDF_PAGEOBJECT,
8302 mark: FPDF_PAGEOBJECTMARK,
8303 key: &str,
8304 value: *mut c_void,
8305 value_len: c_ulong,
8306 ) -> FPDF_BOOL;
8307
8308 /// Removes a property from a content mark by key.
8309 ///
8310 /// `page_object` - handle to the page object with the mark.
8311 ///
8312 /// `mark` - handle to a content mark.
8313 ///
8314 /// `key` - string key of the property.
8315 ///
8316 /// Returns `true` if the operation succeeded.
8317 #[allow(non_snake_case)]
8318 fn FPDFPageObjMark_RemoveParam(
8319 &self,
8320 page_object: FPDF_PAGEOBJECT,
8321 mark: FPDF_PAGEOBJECTMARK,
8322 key: &str,
8323 ) -> FPDF_BOOL;
8324
8325 /// Loads an image from a JPEG image file and then set it into `image_object`.
8326 ///
8327 /// `pages` - pointer to the start of all loaded pages, may be `NULL`.
8328 ///
8329 /// `count` - number of `pages`, may be `0`.
8330 ///
8331 /// `image_object` - handle to an image object.
8332 ///
8333 /// `file_access` - file access handler which specifies the JPEG image file.
8334 ///
8335 /// Returns `true` on success.
8336 ///
8337 /// The image object might already have an associated image, which is shared and
8338 /// cached by the loaded pages. In that case, we need to clear the cached image
8339 /// for all the loaded pages. Pass `pages` and page count (`count`) to this API
8340 /// to clear the image cache. If the image is not previously shared, or `NULL` is a
8341 /// valid `pages` value.
8342 #[allow(non_snake_case)]
8343 fn FPDFImageObj_LoadJpegFile(
8344 &self,
8345 pages: *mut FPDF_PAGE,
8346 count: c_int,
8347 image_object: FPDF_PAGEOBJECT,
8348 file_access: *mut FPDF_FILEACCESS,
8349 ) -> FPDF_BOOL;
8350
8351 /// Loads an image from a JPEG image file and then set it into `image_object`.
8352 ///
8353 /// `pages` - pointer to the start of all loaded pages, may be `NULL`.
8354 ///
8355 /// `count` - number of `pages`, may be `0`.
8356 ///
8357 /// `image_object` - handle to an image object.
8358 ///
8359 /// `file_access` - file access handler which specifies the JPEG image file.
8360 ///
8361 /// Returns `true` on success.
8362 ///
8363 /// The image object might already have an associated image, which is shared and
8364 /// cached by the loaded pages. In that case, we need to clear the cached image
8365 /// for all the loaded pages. Pass `pages` and page count (`count`) to this API
8366 /// to clear the image cache. If the image is not previously shared, or `NULL` is a
8367 /// valid `pages` value. This function loads the JPEG image inline, so the image
8368 /// content is copied to the file. This allows `file_access` and its associated
8369 /// data to be deleted after this function returns.
8370 #[allow(non_snake_case)]
8371 fn FPDFImageObj_LoadJpegFileInline(
8372 &self,
8373 pages: *mut FPDF_PAGE,
8374 count: c_int,
8375 image_object: FPDF_PAGEOBJECT,
8376 file_access: *mut FPDF_FILEACCESS,
8377 ) -> FPDF_BOOL;
8378
8379 /// Sets the transform matrix of `image_object`.
8380 ///
8381 /// `image_object` - handle to an image object.
8382 ///
8383 /// `a` - matrix value.
8384 ///
8385 /// `b` - matrix value.
8386 ///
8387 /// `c` - matrix value.
8388 ///
8389 /// `d` - matrix value.
8390 ///
8391 /// `e` - matrix value.
8392 ///
8393 /// `f` - matrix value.
8394 ///
8395 /// The matrix is composed as:
8396 ///
8397 /// `|a c e|`
8398 ///
8399 /// `|b d f|`
8400 ///
8401 /// and can be used to scale, rotate, shear and translate the `image_object`.
8402 ///
8403 /// Returns `true` on success.
8404 #[allow(non_snake_case)]
8405 #[allow(clippy::too_many_arguments)]
8406 #[deprecated(
8407 note = "Prefer FPDFPageObj_SetMatrix() over FPDFImageObj_SetMatrix(). FPDFImageObj_SetMatrix() is deprecated and will likely be removed in a future version of Pdfium."
8408 )]
8409 fn FPDFImageObj_SetMatrix(
8410 &self,
8411 image_object: FPDF_PAGEOBJECT,
8412 a: c_double,
8413 b: c_double,
8414 c: c_double,
8415 d: c_double,
8416 e: c_double,
8417 f: c_double,
8418 ) -> FPDF_BOOL;
8419
8420 /// Sets `bitmap` to `image_object`.
8421 ///
8422 /// `pages` - pointer to the start of all loaded pages, may be `NULL`.
8423 ///
8424 /// `count` - number of `pages`, may be `0`.
8425 ///
8426 /// `image_object` - handle to an image object.
8427 ///
8428 /// `bitmap` - handle of the bitmap.
8429 ///
8430 /// Returns `true` on success.
8431 #[allow(non_snake_case)]
8432 fn FPDFImageObj_SetBitmap(
8433 &self,
8434 pages: *mut FPDF_PAGE,
8435 count: c_int,
8436 image_object: FPDF_PAGEOBJECT,
8437 bitmap: FPDF_BITMAP,
8438 ) -> FPDF_BOOL;
8439
8440 /// Gets a bitmap rasterization of `image_object`. [PdfiumLibraryBindings::FPDFImageObj_GetBitmap]
8441 /// only operates on `image_object` and does not take the associated image mask into
8442 /// account. It also ignores the matrix for `image_object`. The returned bitmap will be
8443 /// owned by the caller, and [PdfiumLibraryBindings::FPDFBitmap_Destroy] must be called on
8444 /// the returned bitmap when it is no longer needed.
8445 ///
8446 /// `image_object` - handle to an image object.
8447 ///
8448 /// Returns the bitmap.
8449 #[allow(non_snake_case)]
8450 fn FPDFImageObj_GetBitmap(&self, image_object: FPDF_PAGEOBJECT) -> FPDF_BITMAP;
8451
8452 /// Gets a bitmap rasterization of `image_object` that takes the image mask and
8453 /// image matrix into account. To render correctly, the caller must provide the
8454 /// `document` associated with `image_object`. If there is a `page` associated
8455 /// with `image_object`, the caller should provide that as well.
8456 ///
8457 /// The returned bitmap will be owned by the caller, and [PdfiumLibraryBindings::FPDFBitmap_Destroy]
8458 /// must be called on the returned bitmap when it is no longer needed.
8459 ///
8460 /// `document` - handle to a document associated with `image_object`.
8461 ///
8462 /// `page` - handle to an optional page associated with `image_object`.
8463 ///
8464 /// `image_object` - handle to an image object.
8465 ///
8466 /// Returns the bitmap or `NULL` on failure.
8467 #[allow(non_snake_case)]
8468 fn FPDFImageObj_GetRenderedBitmap(
8469 &self,
8470 document: FPDF_DOCUMENT,
8471 page: FPDF_PAGE,
8472 image_object: FPDF_PAGEOBJECT,
8473 ) -> FPDF_BITMAP;
8474
8475 /// Gets the decoded image data of `image_object`. The decoded data is the uncompressed
8476 /// image data, i.e. the raw image data after having all filters applied. `buffer` is
8477 /// only modified if `buflen` is longer than the length of the decoded image data.
8478 ///
8479 /// `image_object` - handle to an image object.
8480 ///
8481 /// `buffer` - buffer for holding the decoded image data.
8482 ///
8483 /// `buflen` - length of the buffer in bytes.
8484 ///
8485 /// Returns the length of the decoded image data.
8486 #[allow(non_snake_case)]
8487 fn FPDFImageObj_GetImageDataDecoded(
8488 &self,
8489 image_object: FPDF_PAGEOBJECT,
8490 buffer: *mut c_void,
8491 buflen: c_ulong,
8492 ) -> c_ulong;
8493
8494 /// Gets the raw image data of `image_object`. The raw data is the image data as
8495 /// stored in the PDF without applying any filters. `buffer` is only modified if
8496 /// `buflen` is longer than the length of the raw image data.
8497 ///
8498 /// `image_object` - handle to an image object.
8499 ///
8500 /// `buffer` - buffer for holding the raw image data.
8501 ///
8502 /// `buflen` - length of the buffer in bytes.
8503 ///
8504 /// Returns the length of the raw image data.
8505 #[allow(non_snake_case)]
8506 fn FPDFImageObj_GetImageDataRaw(
8507 &self,
8508 image_object: FPDF_PAGEOBJECT,
8509 buffer: *mut c_void,
8510 buflen: c_ulong,
8511 ) -> c_ulong;
8512
8513 /// Gets the number of filters (i.e. decoders) of the image in `image_object`.
8514 ///
8515 /// `image_object` - handle to an image object.
8516 ///
8517 /// Returns the number of `image_object`'s filters.
8518 #[allow(non_snake_case)]
8519 fn FPDFImageObj_GetImageFilterCount(&self, image_object: FPDF_PAGEOBJECT) -> c_int;
8520
8521 /// Gets the filter at `index` of `image_object`'s list of filters. Note that the
8522 /// filters need to be applied in order, i.e. the first filter should be applied
8523 /// first, then the second, etc. `buffer` is only modified if `buflen` is longer
8524 /// than the length of the filter string.
8525 ///
8526 /// `image_object` - handle to an image object.
8527 ///
8528 /// `index` - the index of the filter requested.
8529 ///
8530 /// `buffer` - buffer for holding filter string, encoded in UTF-8.
8531 ///
8532 /// `buflen` - length of the buffer.
8533 ///
8534 /// Returns the length of the filter string.
8535 #[allow(non_snake_case)]
8536 fn FPDFImageObj_GetImageFilter(
8537 &self,
8538 image_object: FPDF_PAGEOBJECT,
8539 index: c_int,
8540 buffer: *mut c_void,
8541 buflen: c_ulong,
8542 ) -> c_ulong;
8543
8544 /// Gets the image metadata of `image_object`, including dimension, DPI, bits per pixel,
8545 /// and colorspace. If the `image_object` is not an image object or if it does not have
8546 /// an image, then the return value will be false. Otherwise, failure to retrieve any
8547 /// specific parameter would result in its value being `0`.
8548 ///
8549 /// `image_object` - handle to an image object.
8550 ///
8551 /// `page` - handle to the page that `image_object` is on. Required for
8552 /// retrieving the image's bits per pixel and colorspace.
8553 ///
8554 /// `metadata` - receives the image metadata; must not be `NULL`.
8555 ///
8556 /// Returns `true` if successful.
8557 #[allow(non_snake_case)]
8558 fn FPDFImageObj_GetImageMetadata(
8559 &self,
8560 image_object: FPDF_PAGEOBJECT,
8561 page: FPDF_PAGE,
8562 metadata: *mut FPDF_IMAGEOBJ_METADATA,
8563 ) -> FPDF_BOOL;
8564
8565 /// Gets the image size in pixels. This is a faster method to get only image size.
8566 ///
8567 /// `image_object` - handle to an image object.
8568 ///
8569 /// `width` - receives the image width in pixels; must not be `NULL`.
8570 ///
8571 /// `height` - receives the image height in pixels; must not be `NULL`.
8572 ///
8573 /// Returns `true` if successful.
8574 #[allow(non_snake_case)]
8575 fn FPDFImageObj_GetImagePixelSize(
8576 &self,
8577 image_object: FPDF_PAGEOBJECT,
8578 width: *mut c_uint,
8579 height: *mut c_uint,
8580 ) -> FPDF_BOOL;
8581
8582 #[cfg(any(
8583 feature = "pdfium_future",
8584 feature = "pdfium_7350",
8585 feature = "pdfium_7215",
8586 feature = "pdfium_7123",
8587 feature = "pdfium_6996"
8588 ))]
8589 /// Gets the ICC profile decoded data of `image_object`.
8590 ///
8591 /// If the given `image_object` is not an image object, or if it does not have
8592 /// an image, then the return value will be `false`. This function also returns
8593 /// `false` if the `image_object` has no ICC profile.
8594 ///
8595 /// `buffer` is only modified if ICC profile exists and `buflen` is longer than
8596 /// the length of the ICC profile decoded data.
8597 ///
8598 /// `image_object` - handle to an image object; must not be `NULL`.
8599 ///
8600 /// `page` - handle to the page containing `image_object`; must not be
8601 /// `NULL`. Required for retrieving the image's colorspace.
8602 ///
8603 /// `buffer` - Buffer to receive ICC profile data; may be `NULL` if querying
8604 /// required size via `out_buflen`.
8605 ///
8606 /// `buflen` - Length of the buffer in bytes. Ignored if `buffer` is `NULL`.
8607 ///
8608 /// `out_buflen` - Pointer to receive the ICC profile data size in bytes; must
8609 /// not be `NULL`. Will be set if this function returns `true`.
8610 ///
8611 /// Returns `true` if `out_buflen` is not `NULL` and an ICC profile exists for the
8612 /// given `image_object`.
8613 #[allow(non_snake_case)]
8614 fn FPDFImageObj_GetIccProfileDataDecoded(
8615 &self,
8616 image_object: FPDF_PAGEOBJECT,
8617 page: FPDF_PAGE,
8618 buffer: *mut u8,
8619 buflen: usize,
8620 out_buflen: *mut usize,
8621 ) -> FPDF_BOOL;
8622
8623 /// Creates a new path object at an initial position.
8624 ///
8625 /// `x` - initial horizontal position.
8626 ///
8627 /// `y` - initial vertical position.
8628 ///
8629 /// Returns a handle to a new path object.
8630 #[allow(non_snake_case)]
8631 fn FPDFPageObj_CreateNewPath(&self, x: c_float, y: c_float) -> FPDF_PAGEOBJECT;
8632
8633 /// Creates a closed path consisting of a rectangle.
8634 ///
8635 /// `x` - horizontal position for the left boundary of the rectangle.
8636 ///
8637 /// `y` - vertical position for the bottom boundary of the rectangle.
8638 ///
8639 /// `w` - width of the rectangle.
8640 ///
8641 /// `h` - height of the rectangle.
8642 ///
8643 /// Returns a handle to the new path object.
8644 #[allow(non_snake_case)]
8645 fn FPDFPageObj_CreateNewRect(
8646 &self,
8647 x: c_float,
8648 y: c_float,
8649 w: c_float,
8650 h: c_float,
8651 ) -> FPDF_PAGEOBJECT;
8652
8653 /// Gets the bounding box of `page_object`.
8654 ///
8655 /// `page_object` - handle to a page object.
8656 ///
8657 /// `left` - pointer where the left coordinate will be stored.
8658 ///
8659 /// `bottom` - pointer where the bottom coordinate will be stored.
8660 ///
8661 /// `right` - pointer where the right coordinate will be stored.
8662 ///
8663 /// `top` - pointer where the top coordinate will be stored.
8664 ///
8665 /// On success, returns `true` and fills in the four coordinates.
8666 #[allow(non_snake_case)]
8667 fn FPDFPageObj_GetBounds(
8668 &self,
8669 page_object: FPDF_PAGEOBJECT,
8670 left: *mut c_float,
8671 bottom: *mut c_float,
8672 right: *mut c_float,
8673 top: *mut c_float,
8674 ) -> FPDF_BOOL;
8675
8676 /// Gets the quad points that bounds `page_object`.
8677 ///
8678 /// `page_object` - handle to a page object.
8679 ///
8680 /// `quad_points` - pointer where the quadrilateral points will be stored.
8681 ///
8682 /// On success, returns `true` and fills in `quad_points`.
8683 ///
8684 /// Similar to [PdfiumLibraryBindings::FPDFPageObj_GetBounds], this returns the bounds
8685 /// of a page object. When the object is rotated by a non-multiple of 90 degrees,
8686 /// this API returns a tighter bound that cannot be represented with just the four sides
8687 /// of a rectangle.
8688 ///
8689 /// Currently only works the following `page_object` types: `FPDF_PAGEOBJ_TEXT` and `FPDF_PAGEOBJ_IMAGE`.
8690 #[allow(non_snake_case)]
8691 fn FPDFPageObj_GetRotatedBounds(
8692 &self,
8693 page_object: FPDF_PAGEOBJECT,
8694 quad_points: *mut FS_QUADPOINTSF,
8695 ) -> FPDF_BOOL;
8696
8697 /// Sets the blend mode of `page_object`.
8698 ///
8699 /// `page_object` - handle to a page object.
8700 ///
8701 /// `blend_mode` - string containing the blend mode.
8702 ///
8703 /// Blend mode can be one of following: `Color`, `ColorBurn`, `ColorDodge`, `Darken`,
8704 /// `Difference`, `Exclusion`, `HardLight`, `Hue`, `Lighten`, `Luminosity`, `Multiply`,
8705 /// `Normal`, `Overlay`, `Saturation`, `Screen`, `SoftLight`.
8706 #[allow(non_snake_case)]
8707 fn FPDFPageObj_SetBlendMode(&self, page_object: FPDF_PAGEOBJECT, blend_mode: &str);
8708
8709 /// Sets the stroke RGBA of a page object. Range of values: `0` - `255`.
8710 ///
8711 /// `page_object` - the handle to the page object.
8712 ///
8713 /// `R` - the red component for the object's stroke color.
8714 ///
8715 /// `G` - the green component for the object's stroke color.
8716 ///
8717 /// `B` - the blue component for the object's stroke color.
8718 ///
8719 /// `A` - the stroke alpha for the object.
8720 ///
8721 /// Returns `true` on success.
8722 #[allow(non_snake_case)]
8723 fn FPDFPageObj_SetStrokeColor(
8724 &self,
8725 page_object: FPDF_PAGEOBJECT,
8726 R: c_uint,
8727 G: c_uint,
8728 B: c_uint,
8729 A: c_uint,
8730 ) -> FPDF_BOOL;
8731
8732 /// Gets the stroke RGBA of a page object. Range of values: `0` - `255`.
8733 ///
8734 /// `page_object` - the handle to the page object.
8735 ///
8736 /// `R` - the red component of the path stroke color.
8737 ///
8738 /// `G` - the green component of the object's stroke color.
8739 ///
8740 /// `B` - the blue component of the object's stroke color.
8741 ///
8742 /// `A` - the stroke alpha of the object.
8743 ///
8744 /// Returns `true` on success.
8745 #[allow(non_snake_case)]
8746 fn FPDFPageObj_GetStrokeColor(
8747 &self,
8748 page_object: FPDF_PAGEOBJECT,
8749 R: *mut c_uint,
8750 G: *mut c_uint,
8751 B: *mut c_uint,
8752 A: *mut c_uint,
8753 ) -> FPDF_BOOL;
8754
8755 /// Sets the stroke width of a page object.
8756 ///
8757 /// `path` - the handle to the page object.
8758 ///
8759 /// `width` - the width of the stroke.
8760 ///
8761 /// Returns `true` on success.
8762 #[allow(non_snake_case)]
8763 fn FPDFPageObj_SetStrokeWidth(&self, page_object: FPDF_PAGEOBJECT, width: c_float)
8764 -> FPDF_BOOL;
8765
8766 /// Gets the stroke width of a page object.
8767 ///
8768 /// `path` - the handle to the page object.
8769 ///
8770 /// `width` - the width of the stroke.
8771 ///
8772 /// Returns `true` on success.
8773 #[allow(non_snake_case)]
8774 fn FPDFPageObj_GetStrokeWidth(
8775 &self,
8776 page_object: FPDF_PAGEOBJECT,
8777 width: *mut c_float,
8778 ) -> FPDF_BOOL;
8779
8780 /// Gets the line join of `page_object`.
8781 ///
8782 /// `page_object` - handle to a page object.
8783 ///
8784 /// Returns the line join, or `-1` on failure.
8785 ///
8786 /// Line join can be one of following: `FPDF_LINEJOIN_MITER`, `FPDF_LINEJOIN_ROUND`,
8787 /// `FPDF_LINEJOIN_BEVEL`.
8788 #[allow(non_snake_case)]
8789 fn FPDFPageObj_GetLineJoin(&self, page_object: FPDF_PAGEOBJECT) -> c_int;
8790
8791 /// Sets the line join of `page_object`.
8792 ///
8793 /// `page_object` - handle to a page object.
8794 ///
8795 /// `line_join` - line join
8796 ///
8797 /// Line join can be one of following: `FPDF_LINEJOIN_MITER`, `FPDF_LINEJOIN_ROUND`,
8798 /// `FPDF_LINEJOIN_BEVEL`.
8799 #[allow(non_snake_case)]
8800 fn FPDFPageObj_SetLineJoin(&self, page_object: FPDF_PAGEOBJECT, line_join: c_int) -> FPDF_BOOL;
8801
8802 /// Gets the line cap of `page_object`.
8803 ///
8804 /// `page_object` - handle to a page object.
8805 ///
8806 /// Returns the line cap, or `-1` on failure.
8807 ///
8808 /// Line cap can be one of following: `FPDF_LINECAP_BUTT`, `FPDF_LINECAP_ROUND`,
8809 /// `FPDF_LINECAP_PROJECTING_SQUARE`.
8810 #[allow(non_snake_case)]
8811 fn FPDFPageObj_GetLineCap(&self, page_object: FPDF_PAGEOBJECT) -> c_int;
8812
8813 /// Sets the line cap of `page_object`.
8814 ///
8815 /// `page_object` - handle to a page object.
8816 ///
8817 /// `line_cap` - line cap
8818 ///
8819 /// Line cap can be one of following: `FPDF_LINECAP_BUTT`, `FPDF_LINECAP_ROUND`,
8820 /// `FPDF_LINECAP_PROJECTING_SQUARE`.
8821 #[allow(non_snake_case)]
8822 fn FPDFPageObj_SetLineCap(&self, page_object: FPDF_PAGEOBJECT, line_cap: c_int) -> FPDF_BOOL;
8823
8824 /// Sets the fill RGBA of a page object. Range of values: `0` - `255`.
8825 ///
8826 /// `page_object` - the handle to the page object.
8827 ///
8828 /// `R` - the red component for the object's fill color.
8829 ///
8830 /// `G` - the green component for the object's fill color.
8831 ///
8832 /// `B` - the blue component for the object's fill color.
8833 ///
8834 /// `A` - the fill alpha for the object.
8835 ///
8836 /// Returns `true` on success.
8837 #[allow(non_snake_case)]
8838 fn FPDFPageObj_SetFillColor(
8839 &self,
8840 page_object: FPDF_PAGEOBJECT,
8841 R: c_uint,
8842 G: c_uint,
8843 B: c_uint,
8844 A: c_uint,
8845 ) -> FPDF_BOOL;
8846
8847 /// Gets the fill RGBA of a page object. Range of values: `0` - `255`.
8848 ///
8849 /// `page_object` - the handle to the page object.
8850 ///
8851 /// `R` - the red component of the object's fill color.
8852 ///
8853 /// `G` - the green component of the object's fill color.
8854 ///
8855 /// `B` - the blue component of the object's fill color.
8856 ///
8857 /// `A` - the fill alpha of the object.
8858 ///
8859 /// Returns `true` on success.
8860 #[allow(non_snake_case)]
8861 fn FPDFPageObj_GetFillColor(
8862 &self,
8863 page_object: FPDF_PAGEOBJECT,
8864 R: *mut c_uint,
8865 G: *mut c_uint,
8866 B: *mut c_uint,
8867 A: *mut c_uint,
8868 ) -> FPDF_BOOL;
8869
8870 /// Gets the line dash `phase` of `page_object`.
8871 ///
8872 /// `page_object` - handle to a page object.
8873 ///
8874 /// `phase` - pointer where the dashing phase will be stored.
8875 ///
8876 /// Returns `true` on success.
8877 #[allow(non_snake_case)]
8878 fn FPDFPageObj_GetDashPhase(
8879 &self,
8880 page_object: FPDF_PAGEOBJECT,
8881 phase: *mut c_float,
8882 ) -> FPDF_BOOL;
8883
8884 /// Sets the line dash phase of `page_object`.
8885 ///
8886 /// `page_object` - handle to a page object.
8887 ///
8888 /// `phase` - line dash phase.
8889 ///
8890 /// Returns `true` on success.
8891 #[allow(non_snake_case)]
8892 fn FPDFPageObj_SetDashPhase(&self, page_object: FPDF_PAGEOBJECT, phase: c_float) -> FPDF_BOOL;
8893
8894 /// Gets the line dash array of `page_object`.
8895 ///
8896 /// `page_object` - handle to a page object.
8897 ///
8898 /// Returns the line dash array size, or `-1` on failure.
8899 #[allow(non_snake_case)]
8900 fn FPDFPageObj_GetDashCount(&self, page_object: FPDF_PAGEOBJECT) -> c_int;
8901
8902 /// Gets the line dash array of `page_object`.
8903 ///
8904 /// `page_object` - handle to a page object.
8905 ///
8906 /// `dash_array` - pointer where the dashing array will be stored.
8907 ///
8908 /// `dash_count` - number of elements in `dash_array`.
8909 ///
8910 /// Returns `true` on success.
8911 #[allow(non_snake_case)]
8912 fn FPDFPageObj_GetDashArray(
8913 &self,
8914 page_object: FPDF_PAGEOBJECT,
8915 dash_array: *mut c_float,
8916 dash_count: size_t,
8917 ) -> FPDF_BOOL;
8918
8919 /// Sets the line dash array of `page_object`.
8920 ///
8921 /// `page_object` - handle to a page object.
8922 ///
8923 /// `dash_array` - the dash array.
8924 ///
8925 /// `dash_count` - number of elements in `dash_array`.
8926 ///
8927 /// `phase` - the line dash phase.
8928 ///
8929 /// Returns `true` on success.
8930 #[allow(non_snake_case)]
8931 fn FPDFPageObj_SetDashArray(
8932 &self,
8933 page_object: FPDF_PAGEOBJECT,
8934 dash_array: *const c_float,
8935 dash_count: size_t,
8936 phase: c_float,
8937 ) -> FPDF_BOOL;
8938
8939 /// Gets the number of segments inside `path`.
8940 ///
8941 /// `path` - handle to a path.
8942 ///
8943 /// A segment is a single command, created by e.g. [PdfiumLibraryBindings::FPDFPath_MoveTo],
8944 /// [PdfiumLibraryBindings::FPDFPath_LineTo], or [PdfiumLibraryBindings::FPDFPath_BezierTo].
8945 ///
8946 /// Returns the number of objects in `path`, or `-1` on failure.
8947 #[allow(non_snake_case)]
8948 fn FPDFPath_CountSegments(&self, path: FPDF_PAGEOBJECT) -> c_int;
8949
8950 /// Gets segment in `path` at `index`.
8951 ///
8952 /// `path` - handle to a path.
8953 ///
8954 /// `index` - the index of a segment.
8955 ///
8956 /// Returns the handle to the segment, or `NULL` on failure.
8957 #[allow(non_snake_case)]
8958 fn FPDFPath_GetPathSegment(&self, path: FPDF_PAGEOBJECT, index: c_int) -> FPDF_PATHSEGMENT;
8959
8960 /// Gets coordinates of `segment`.
8961 ///
8962 /// `segment` - handle to a segment.
8963 ///
8964 /// `x` - the horizontal position of the segment.
8965 ///
8966 /// `y` - the vertical position of the segment.
8967 ///
8968 /// Returns `true` on success, otherwise `x` and `y` is not set.
8969 #[allow(non_snake_case)]
8970 fn FPDFPathSegment_GetPoint(
8971 &self,
8972 segment: FPDF_PATHSEGMENT,
8973 x: *mut c_float,
8974 y: *mut c_float,
8975 ) -> FPDF_BOOL;
8976
8977 /// Gets the type of `segment`.
8978 ///
8979 /// `segment` - handle to a segment.
8980 ///
8981 /// Returns one of the `FPDF_SEGMENT_*` values on success, or `FPDF_SEGMENT_UNKNOWN`
8982 /// on error.
8983 #[allow(non_snake_case)]
8984 fn FPDFPathSegment_GetType(&self, segment: FPDF_PATHSEGMENT) -> c_int;
8985
8986 /// Indicates whether or not the `segment` closes the current subpath of a given path.
8987 ///
8988 /// `segment` - handle to a segment.
8989 ///
8990 /// Returns close flag for non-`NULL` segment.
8991 #[allow(non_snake_case)]
8992 fn FPDFPathSegment_GetClose(&self, segment: FPDF_PATHSEGMENT) -> FPDF_BOOL;
8993
8994 #[cfg(any(
8995 feature = "pdfium_future",
8996 feature = "pdfium_7350",
8997 feature = "pdfium_7215",
8998 feature = "pdfium_7123",
8999 feature = "pdfium_6996",
9000 feature = "pdfium_6721",
9001 feature = "pdfium_6666"
9002 ))]
9003 /// Gets the base name of a font.
9004 ///
9005 /// `font` - the handle to the font object.
9006 ///
9007 /// `buffer` - the address of a buffer that receives the base font name.
9008 ///
9009 /// `length` - the size, in bytes, of `buffer`.
9010 ///
9011 /// Returns the number of bytes in the base name (including the trailing `NUL`
9012 /// character) on success, 0 on error. The base name is typically the font's
9013 /// PostScript name. See descriptions of "BaseFont" in ISO 32000-1:2008 spec.
9014 ///
9015 /// Regardless of the platform, the `buffer` is always in UTF-8 encoding.
9016 /// If `length` is less than the returned length, or `buffer` is `NULL`, `buffer`
9017 /// will not be modified.
9018 #[allow(non_snake_case)]
9019 fn FPDFFont_GetBaseFontName(
9020 &self,
9021 font: FPDF_FONT,
9022 buffer: *mut c_char,
9023 length: size_t,
9024 ) -> size_t;
9025
9026 #[cfg(any(
9027 feature = "pdfium_future",
9028 feature = "pdfium_7350",
9029 feature = "pdfium_7215",
9030 feature = "pdfium_7123",
9031 feature = "pdfium_6996",
9032 feature = "pdfium_6721",
9033 feature = "pdfium_6666"
9034 ))]
9035 /// Gets the family name of a font.
9036 ///
9037 /// `font` - the handle to the font object.
9038 ///
9039 /// `buffer` - the address of a buffer that receives the font name.
9040 ///
9041 /// `length` - the size, in bytes, of `buffer`.
9042 ///
9043 /// Returns the number of bytes in the family name (including the trailing `NUL`
9044 /// character) on success, 0 on error.
9045 ///
9046 /// Regardless of the platform, the `buffer` is always in UTF-8 encoding.
9047 /// If `length` is less than the returned length, or `buffer` is `NULL`, `buffer`
9048 /// will not be modified.
9049 #[allow(non_snake_case)]
9050 fn FPDFFont_GetFamilyName(
9051 &self,
9052 font: FPDF_FONT,
9053 buffer: *mut c_char,
9054 length: size_t,
9055 ) -> size_t;
9056
9057 #[cfg(feature = "pdfium_6611")]
9058 /// Gets the family name of a font.
9059 ///
9060 /// `font` - the handle to the font object.
9061 ///
9062 /// `buffer` - the address of a buffer that receives the font name.
9063 ///
9064 /// `length` - the size, in bytes, of `buffer`.
9065 ///
9066 /// Returns the number of bytes in the family name (including the trailing `NUL`
9067 /// character) on success, 0 on error.
9068 ///
9069 /// Regardless of the platform, the `buffer` is always in UTF-8 encoding.
9070 /// If `length` is less than the returned length, or `buffer` is `NULL`, `buffer`
9071 /// will not be modified.
9072 #[allow(non_snake_case)]
9073 fn FPDFFont_GetFamilyName(
9074 &self,
9075 font: FPDF_FONT,
9076 buffer: *mut c_char,
9077 length: c_ulong,
9078 ) -> c_ulong;
9079
9080 #[cfg(any(
9081 feature = "pdfium_6569",
9082 feature = "pdfium_6555",
9083 feature = "pdfium_6490",
9084 feature = "pdfium_6406",
9085 feature = "pdfium_6337",
9086 feature = "pdfium_6295",
9087 feature = "pdfium_6259",
9088 feature = "pdfium_6164",
9089 feature = "pdfium_6124",
9090 feature = "pdfium_6110",
9091 feature = "pdfium_6084",
9092 feature = "pdfium_6043",
9093 feature = "pdfium_6015",
9094 feature = "pdfium_5961"
9095 ))]
9096 /// Gets the font name of a font.
9097 ///
9098 /// `font` - the handle to the font object.
9099 ///
9100 /// `buffer` - the address of a buffer that receives the font name.
9101 ///
9102 /// `length` - the size, in bytes, of `buffer`.
9103 ///
9104 /// Returns the number of bytes in the font name (including the trailing `NUL`
9105 /// character) on success, 0 on error.
9106 ///
9107 /// Regardless of the platform, the `buffer` is always in UTF-8 encoding.
9108 /// If `length` is less than the returned length, or `buffer` is `NULL`, `buffer`
9109 /// will not be modified.
9110 #[allow(non_snake_case)]
9111 fn FPDFFont_GetFontName(
9112 &self,
9113 font: FPDF_FONT,
9114 buffer: *mut c_char,
9115 length: c_ulong,
9116 ) -> c_ulong;
9117
9118 /// Gets the decoded data from the `font` object.
9119 ///
9120 /// `font` - The handle to the font object. (Required)
9121 ///
9122 /// `buffer` - The address of a buffer that receives the font data.
9123 ///
9124 /// `buflen` - Length of the buffer.
9125 ///
9126 /// `out_buflen` - Pointer to variable that will receive the minimum buffer size
9127 /// to contain the font data. Not filled if the return value is
9128 /// `false`. (Required)
9129 ///
9130 /// Returns `true` on success. In which case, `out_buflen` will be filled, and
9131 /// `buffer` will be filled if it is large enough. Returns `false` if any of the
9132 /// required parameters are `NULL`.
9133 ///
9134 /// The decoded data is the uncompressed font data. i.e. the raw font data after
9135 /// having all stream filters applied, when the data is embedded.
9136 ///
9137 /// If the font is not embedded, then this API will instead return the data for
9138 /// the substitution font it is using.
9139 #[allow(non_snake_case)]
9140 fn FPDFFont_GetFontData(
9141 &self,
9142 font: FPDF_FONT,
9143 buffer: *mut u8,
9144 buflen: size_t,
9145 out_buflen: *mut size_t,
9146 ) -> FPDF_BOOL;
9147
9148 /// Gets whether `font` is embedded or not.
9149 ///
9150 /// `font` - the handle to the font object.
9151 ///
9152 /// Returns 1 if the font is embedded, 0 if it not, or -1 on failure.
9153 #[allow(non_snake_case)]
9154 fn FPDFFont_GetIsEmbedded(&self, font: FPDF_FONT) -> c_int;
9155
9156 /// Gets the descriptor flags of a font.
9157 ///
9158 /// `font` - the handle to the font object.
9159 ///
9160 /// Returns the bit flags specifying various characteristics of the font as
9161 /// defined in ISO 32000-1:2008, table 123, or -1 on failure.
9162 #[allow(non_snake_case)]
9163 fn FPDFFont_GetFlags(&self, font: FPDF_FONT) -> c_int;
9164
9165 /// Gets the font weight of a font.
9166 ///
9167 /// `font` - the handle to the font object.
9168 ///
9169 /// Returns the font weight, or -1 on failure. Typical values include 400 (normal) and 700 (bold).
9170 #[allow(non_snake_case)]
9171 fn FPDFFont_GetWeight(&self, font: FPDF_FONT) -> c_int;
9172
9173 /// Gets the italic angle of a font.
9174 ///
9175 /// `font` - the handle to the font object.
9176 ///
9177 /// `angle` - pointer where the italic angle will be stored.
9178 ///
9179 /// The italic angle of a `font` is defined as degrees counterclockwise
9180 /// from vertical. For a font that slopes to the right, this will be negative.
9181 ///
9182 /// Returns `true` on success; `angle` unmodified on failure.
9183 #[allow(non_snake_case)]
9184 fn FPDFFont_GetItalicAngle(&self, font: FPDF_FONT, angle: *mut c_int) -> FPDF_BOOL;
9185
9186 /// Gets ascent distance of a font.
9187 ///
9188 /// `font` - the handle to the font object.
9189 ///
9190 /// `font_size` - the size of the `font`.
9191 ///
9192 /// `ascent` - pointer where the font ascent will be stored.
9193 ///
9194 /// Ascent is the maximum distance in points above the baseline reached by the
9195 /// glyphs of the `font`. One point is 1/72 inch (around 0.3528 mm).
9196 ///
9197 /// Returns `true` on success; `ascent` unmodified on failure.
9198 #[allow(non_snake_case)]
9199 fn FPDFFont_GetAscent(
9200 &self,
9201 font: FPDF_FONT,
9202 font_size: c_float,
9203 ascent: *mut c_float,
9204 ) -> FPDF_BOOL;
9205
9206 /// Gets descent distance of a font.
9207 ///
9208 /// `font` - the handle to the font object.
9209 ///
9210 /// `font_size` - the size of the `font`.
9211 ///
9212 /// `descent` - pointer where the font descent will be stored.
9213 ///
9214 /// Descent is the maximum distance in points below the baseline reached by the
9215 /// glyphs of the `font`. One point is 1/72 inch (around 0.3528 mm).
9216 ///
9217 /// Returns `true` on success; `descent` unmodified on failure.
9218 #[allow(non_snake_case)]
9219 fn FPDFFont_GetDescent(
9220 &self,
9221 font: FPDF_FONT,
9222 font_size: c_float,
9223 descent: *mut c_float,
9224 ) -> FPDF_BOOL;
9225
9226 /// Gets the width of a glyph in a font.
9227 ///
9228 /// `font` - the handle to the font object.
9229 ///
9230 /// `glyph` - the glyph.
9231 ///
9232 /// `font_size` - the size of the font.
9233 ///
9234 /// `width` - pointer where the glyph width will be stored.
9235 ///
9236 /// Glyph width is the distance from the end of the prior glyph to the next
9237 /// glyph. This will be the vertical distance for vertical writing.
9238 ///
9239 /// Returns `true` on success; `width` unmodified on failure.
9240 #[allow(non_snake_case)]
9241 fn FPDFFont_GetGlyphWidth(
9242 &self,
9243 font: FPDF_FONT,
9244 glyph: c_uint,
9245 font_size: c_float,
9246 width: *mut c_float,
9247 ) -> FPDF_BOOL;
9248
9249 /// Gets the glyphpath describing how to draw a font glyph.
9250 ///
9251 /// `font` - the handle to the font object.
9252 ///
9253 /// `glyph` - the glyph being drawn.
9254 ///
9255 /// `font_size` - the size of the font.
9256 ///
9257 /// Returns the handle to the segment, or `NULL` on faiure.
9258 #[allow(non_snake_case)]
9259 fn FPDFFont_GetGlyphPath(
9260 &self,
9261 font: FPDF_FONT,
9262 glyph: c_uint,
9263 font_size: c_float,
9264 ) -> FPDF_GLYPHPATH;
9265
9266 /// Gets the number of segments inside `glyphpath`.
9267 ///
9268 /// `glyphpath` - handle to a glyph path.
9269 ///
9270 /// Returns the number of objects in `glyphpath` or -1 on failure.
9271 #[allow(non_snake_case)]
9272 fn FPDFGlyphPath_CountGlyphSegments(&self, glyphpath: FPDF_GLYPHPATH) -> c_int;
9273
9274 /// Gets the segment in `glyphpath` at `index`.
9275 ///
9276 /// `glyphpath` - handle to a glyph path.
9277 ///
9278 /// `index` - the index of a segment.
9279 ///
9280 /// Returns the handle to the segment, or `NULL` on faiure.
9281 #[allow(non_snake_case)]
9282 fn FPDFGlyphPath_GetGlyphPathSegment(
9283 &self,
9284 glyphpath: FPDF_GLYPHPATH,
9285 index: c_int,
9286 ) -> FPDF_PATHSEGMENT;
9287
9288 /// Whether the PDF document prefers to be scaled or not.
9289 ///
9290 /// `document` - Handle to the loaded document.
9291 #[allow(non_snake_case)]
9292 fn FPDF_VIEWERREF_GetPrintScaling(&self, document: FPDF_DOCUMENT) -> FPDF_BOOL;
9293
9294 /// Returns the number of copies to be printed.
9295 ///
9296 /// `document` - Handle to the loaded document.
9297 ///
9298 /// Returns the number of copies to be printed.
9299 #[allow(non_snake_case)]
9300 fn FPDF_VIEWERREF_GetNumCopies(&self, document: FPDF_DOCUMENT) -> c_int;
9301
9302 /// Page numbers to initialize print dialog box when file is printed.
9303 ///
9304 /// `document` - Handle to the loaded document.
9305 ///
9306 /// Returns the print page range to be used for printing.
9307 #[allow(non_snake_case)]
9308 fn FPDF_VIEWERREF_GetPrintPageRange(&self, document: FPDF_DOCUMENT) -> FPDF_PAGERANGE;
9309
9310 /// Returns the number of elements in a `FPDF_PAGERANGE`.
9311 ///
9312 /// `pagerange` - Handle to the page range.
9313 ///
9314 /// Returns the number of elements in the page range. Returns 0 on error.
9315 #[allow(non_snake_case)]
9316 fn FPDF_VIEWERREF_GetPrintPageRangeCount(&self, pagerange: FPDF_PAGERANGE) -> size_t;
9317
9318 /// Returns an element from a `FPDF_PAGERANGE`.
9319 ///
9320 /// `pagerange` - Handle to the page range.
9321 ///
9322 /// `index` - Index of the element.
9323 ///
9324 /// Returns the value of the element in the page range at a given index.
9325 /// Returns -1 on error.
9326 #[allow(non_snake_case)]
9327 fn FPDF_VIEWERREF_GetPrintPageRangeElement(
9328 &self,
9329 pagerange: FPDF_PAGERANGE,
9330 index: size_t,
9331 ) -> c_int;
9332
9333 /// Returns the paper handling option to be used when printing from the print dialog.
9334 ///
9335 /// `document` - Handle to the loaded document.
9336 ///
9337 /// Returns the paper handling option to be used when printing.
9338 #[allow(non_snake_case)]
9339 fn FPDF_VIEWERREF_GetDuplex(&self, document: FPDF_DOCUMENT) -> FPDF_DUPLEXTYPE;
9340
9341 /// Gets the contents for a viewer ref, with a given key. The value must
9342 /// be of type "name".
9343 ///
9344 /// `document` - Handle to the loaded document.
9345 ///
9346 /// `key` - Name of the key in the viewer pref dictionary,
9347 /// encoded in UTF-8.
9348 ///
9349 /// `buffer` - Caller-allocate buffer to receive the key, or `NULL`
9350 /// to query the required length.
9351 ///
9352 /// `length` - Length of the buffer.
9353 ///
9354 /// Returns the number of bytes in the contents, including the `NULL` terminator.
9355 /// Thus if the return value is 0, then that indicates an error, such
9356 /// as when `document` is invalid. If `length` is less than the required length, or
9357 /// `buffer` is `NULL`, `buffer` will not be modified.
9358 #[allow(non_snake_case)]
9359 fn FPDF_VIEWERREF_GetName(
9360 &self,
9361 document: FPDF_DOCUMENT,
9362 key: &str,
9363 buffer: *mut c_char,
9364 length: c_ulong,
9365 ) -> c_ulong;
9366
9367 /// Gets the count of named destinations in the PDF document.
9368 ///
9369 /// `document` - Handle to a document
9370 ///
9371 /// Returns the count of named destinations.
9372 #[allow(non_snake_case)]
9373 fn FPDF_CountNamedDests(&self, document: FPDF_DOCUMENT) -> FPDF_DWORD;
9374
9375 /// Gets a the destination handle for the given name.
9376 ///
9377 /// `document` - Handle to the loaded document.
9378 ///
9379 /// `name` - The name of a destination.
9380 ///
9381 /// Returns a handle to the destination.
9382 #[allow(non_snake_case)]
9383 fn FPDF_GetNamedDestByName(&self, document: FPDF_DOCUMENT, name: &str) -> FPDF_DEST;
9384
9385 /// Gets the named destination by index.
9386 ///
9387 /// `document` - Handle to a document
9388 ///
9389 /// `index` - The index of a named destination.
9390 ///
9391 /// `buffer` - The buffer to store the destination name, used as `wchar_t*`.
9392 ///
9393 /// `buflen [in/out]` - Size of the buffer in bytes on input,
9394 /// length of the result in bytes on output
9395 /// or -1 if the buffer is too small.
9396 ///
9397 /// Returns the destination handle for a given index, or `NULL` if there is no
9398 /// named destination corresponding to `index`.
9399 ///
9400 /// Call this function twice to get the name of the named destination:
9401 /// * First time pass in `buffer` as `NULL` and get `buflen`.
9402 /// * Second time pass in allocated `buffer` and `buflen` to retrieve `buffer`,
9403 /// which should be used as `wchar_t*`.
9404 ///
9405 /// If `buflen` is not sufficiently large, it will be set to -1 upon return.
9406 #[allow(non_snake_case)]
9407 fn FPDF_GetNamedDest(
9408 &self,
9409 document: FPDF_DOCUMENT,
9410 index: c_int,
9411 buffer: *mut c_void,
9412 buflen: *mut c_long,
9413 ) -> FPDF_DEST;
9414
9415 /// Gets the number of embedded files in `document`.
9416 ///
9417 /// `document` - handle to a document.
9418 ///
9419 /// Returns the number of embedded files in `document`.
9420 #[allow(non_snake_case)]
9421 fn FPDFDoc_GetAttachmentCount(&self, document: FPDF_DOCUMENT) -> c_int;
9422
9423 /// Adds an embedded file with `name` in `document`. If `name` is empty, or if
9424 /// `name` is the name of a existing embedded file in `document`, or if
9425 /// `document`'s embedded file name tree is too deep (i.e. `document` has too
9426 /// many embedded files already), then a new attachment will not be added.
9427 ///
9428 /// `document` - handle to a document.
9429 ///
9430 /// `name` - name of the new attachment.
9431 ///
9432 /// Returns a handle to the new attachment object, or NULL on failure.
9433 ///
9434 /// A [&str]-friendly helper function is available for this function.
9435 /// See [PdfiumLibraryBindings::FPDFDoc_AddAttachment_str].
9436 #[allow(non_snake_case)]
9437 fn FPDFDoc_AddAttachment(
9438 &self,
9439 document: FPDF_DOCUMENT,
9440 name: FPDF_WIDESTRING,
9441 ) -> FPDF_ATTACHMENT;
9442
9443 /// A [&str]-friendly helper function for [PdfiumLibraryBindings::FPDFDoc_AddAttachment].
9444 ///
9445 /// Adds an embedded file with `name` in `document`. If `name` is empty, or if
9446 /// `name` is the name of a existing embedded file in `document`, or if
9447 /// `document`'s embedded file name tree is too deep (i.e. `document` has too
9448 /// many embedded files already), then a new attachment will not be added.
9449 ///
9450 /// `document` - handle to a document.
9451 ///
9452 /// `name` - name of the new attachment.
9453 ///
9454 /// Returns a handle to the new attachment object, or `NULL` on failure.
9455 #[allow(non_snake_case)]
9456 fn FPDFDoc_AddAttachment_str(&self, document: FPDF_DOCUMENT, name: &str) -> FPDF_ATTACHMENT {
9457 self.FPDFDoc_AddAttachment(
9458 document,
9459 get_pdfium_utf16le_bytes_from_str(name).as_ptr() as FPDF_WIDESTRING,
9460 )
9461 }
9462
9463 /// Gets the embedded attachment at `index` in `document`. Note that the returned
9464 /// attachment handle is only valid while `document` is open.
9465 ///
9466 /// `document` - handle to a document.
9467 ///
9468 /// `index` - the index of the requested embedded file.
9469 ///
9470 /// Returns the handle to the attachment object, or `NULL` on failure.
9471 #[allow(non_snake_case)]
9472 fn FPDFDoc_GetAttachment(&self, document: FPDF_DOCUMENT, index: c_int) -> FPDF_ATTACHMENT;
9473
9474 /// Deletes the embedded attachment at `index` in `document`. Note that this does
9475 /// not remove the attachment data from the PDF file; it simply removes the
9476 /// file's entry in the embedded files name tree so that it does not appear in
9477 /// the attachment list. This behavior may change in the future.
9478 ///
9479 /// `document` - handle to a document.
9480 ///
9481 /// `index` - the index of the embedded file to be deleted.
9482 ///
9483 /// Returns `true` on success.
9484 #[allow(non_snake_case)]
9485 fn FPDFDoc_DeleteAttachment(&self, document: FPDF_DOCUMENT, index: c_int) -> FPDF_BOOL;
9486
9487 /// Gets the name of the `attachment` file. `buffer` is only modified if `buflen`
9488 /// is longer than the length of the file name. On errors, `buffer` is unmodified
9489 /// and the returned length is 0.
9490 ///
9491 /// `attachment` - handle to an attachment.
9492 ///
9493 /// `buffer` - buffer for holding the file name, encoded in UTF-16LE.
9494 ///
9495 /// `buflen` - length of the buffer in bytes.
9496 ///
9497 /// Returns the length of the file name in bytes.
9498 #[allow(non_snake_case)]
9499 fn FPDFAttachment_GetName(
9500 &self,
9501 attachment: FPDF_ATTACHMENT,
9502 buffer: *mut FPDF_WCHAR,
9503 buflen: c_ulong,
9504 ) -> c_ulong;
9505
9506 /// Checks if the params dictionary of `attachment` has `key` as a key.
9507 ///
9508 /// `attachment` - handle to an attachment.
9509 ///
9510 /// `key` - the key to look for, encoded in UTF-8.
9511 ///
9512 /// Returns `true` if `key` exists.
9513 #[allow(non_snake_case)]
9514 fn FPDFAttachment_HasKey(&self, attachment: FPDF_ATTACHMENT, key: &str) -> FPDF_BOOL;
9515
9516 /// Gets the type of the value corresponding to `key` in the params dictionary of
9517 /// the embedded `attachment`.
9518 ///
9519 /// `attachment` - handle to an attachment.
9520 ///
9521 /// `key` - the key to look for, encoded in UTF-8.
9522 ///
9523 /// Returns the type of the dictionary value.
9524 #[allow(non_snake_case)]
9525 fn FPDFAttachment_GetValueType(
9526 &self,
9527 attachment: FPDF_ATTACHMENT,
9528 key: &str,
9529 ) -> FPDF_OBJECT_TYPE;
9530
9531 /// Sets the string value corresponding to `key` in the params dictionary of the
9532 /// embedded file `attachment`, overwriting the existing value if any. The value
9533 /// type should be FPDF_OBJECT_STRING after this function call succeeds.
9534 ///
9535 /// `attachment` - handle to an attachment.
9536 ///
9537 /// `key` - the key to the dictionary entry, encoded in UTF-8.
9538 ///
9539 /// `value` - the string value to be set, encoded in UTF-16LE.
9540 ///
9541 /// Returns `true` on success.
9542 ///
9543 /// A [&str]-friendly helper function is available for this function.
9544 /// See [PdfiumLibraryBindings::FPDFAttachment_SetStringValue_str].
9545 #[allow(non_snake_case)]
9546 fn FPDFAttachment_SetStringValue(
9547 &self,
9548 attachment: FPDF_ATTACHMENT,
9549 key: &str,
9550 value: FPDF_WIDESTRING,
9551 ) -> FPDF_BOOL;
9552
9553 /// A [&str]-friendly helper function for [PdfiumLibraryBindings::FPDFAttachment_SetStringValue].
9554 ///
9555 /// Sets the string value corresponding to `key` in the params dictionary of the
9556 /// embedded file `attachment`, overwriting the existing value if any. The value
9557 /// type should be FPDF_OBJECT_STRING after this function call succeeds.
9558 ///
9559 /// `attachment` - handle to an attachment.
9560 ///
9561 /// `key` - the key to the dictionary entry.
9562 ///
9563 /// `value` - the string value to be set.
9564 ///
9565 /// Returns `true` on success.
9566 #[inline]
9567 #[allow(non_snake_case)]
9568 fn FPDFAttachment_SetStringValue_str(
9569 &self,
9570 attachment: FPDF_ATTACHMENT,
9571 key: &str,
9572 value: &str,
9573 ) -> FPDF_BOOL {
9574 self.FPDFAttachment_SetStringValue(
9575 attachment,
9576 key,
9577 get_pdfium_utf16le_bytes_from_str(value).as_ptr() as FPDF_WIDESTRING,
9578 )
9579 }
9580
9581 /// Gets the string value corresponding to `key` in the params dictionary of the
9582 /// embedded file `attachment`. `buffer` is only modified if `buflen` is longer
9583 /// than the length of the string value. Note that if `key` does not exist in the
9584 /// dictionary or if `key`'s corresponding value in the dictionary is not a
9585 /// string (i.e. the value is not of type FPDF_OBJECT_STRING or
9586 /// FPDF_OBJECT_NAME), then an empty string would be copied to `buffer` and the
9587 /// return value would be 2. On other errors, nothing would be added to `buffer`
9588 /// and the return value would be 0.
9589 ///
9590 /// `attachment` - handle to an attachment.
9591 ///
9592 /// `key` - the key to the requested string value, encoded in UTF-8.
9593 ///
9594 /// `buffer` - buffer for holding the string value encoded in UTF-16LE.
9595 ///
9596 /// `buflen` - length of the buffer in bytes.
9597 ///
9598 /// Returns the length of the dictionary value string in bytes.
9599 #[allow(non_snake_case)]
9600 fn FPDFAttachment_GetStringValue(
9601 &self,
9602 attachment: FPDF_ATTACHMENT,
9603 key: &str,
9604 buffer: *mut FPDF_WCHAR,
9605 buflen: c_ulong,
9606 ) -> c_ulong;
9607
9608 /// Sets the file data of `attachment`, overwriting the existing file data if any.
9609 /// The creation date and checksum will be updated, while all other dictionary
9610 /// entries will be deleted. Note that only contents with `len` smaller than
9611 /// INT_MAX is supported.
9612 ///
9613 /// `attachment` - handle to an attachment.
9614 ///
9615 /// `contents` - buffer holding the file data to write to `attachment`.
9616 ///
9617 /// `len` - length of file data in bytes.
9618 ///
9619 /// Returns `true` on success.
9620 #[allow(non_snake_case)]
9621 fn FPDFAttachment_SetFile(
9622 &self,
9623 attachment: FPDF_ATTACHMENT,
9624 document: FPDF_DOCUMENT,
9625 contents: *const c_void,
9626 len: c_ulong,
9627 ) -> FPDF_BOOL;
9628
9629 /// Gets the file data of `attachment`.
9630 ///
9631 /// When the attachment file data is readable, true is returned, and `out_buflen`
9632 /// is updated to indicate the file data size. `buffer` is only modified if
9633 /// `buflen` is non-null and long enough to contain the entire file data. Callers
9634 /// must check both the return value and the input `buflen` is no less than the
9635 /// returned `out_buflen` before using the data.
9636 ///
9637 /// Otherwise, when the attachment file data is unreadable or when `out_buflen`
9638 /// is null, false is returned and `buffer` and `out_buflen` remain unmodified.
9639 ///
9640 /// `attachment` - handle to an attachment.
9641 ///
9642 /// `buffer` - buffer for holding the file data from `attachment`.
9643 ///
9644 /// `buflen` - length of the buffer in bytes.
9645 ///
9646 /// `out_buflen` - pointer to the variable that will receive the minimum buffer
9647 /// size to contain the file data of `attachment`.
9648 ///
9649 /// Returns `true` on success.
9650 #[allow(non_snake_case)]
9651 fn FPDFAttachment_GetFile(
9652 &self,
9653 attachment: FPDF_ATTACHMENT,
9654 buffer: *mut c_void,
9655 buflen: c_ulong,
9656 out_buflen: *mut c_ulong,
9657 ) -> FPDF_BOOL;
9658
9659 #[cfg(any(feature = "pdfium_future", feature = "pdfium_7350"))]
9660 /// Get the MIME type (Subtype) of the embedded file `attachment`. `buffer` is
9661 /// only modified if `buflen` is longer than the length of the MIME type string.
9662 /// If the Subtype is not found or if there is no file stream, an empty string
9663 /// would be copied to `buffer` and the return value would be 2. On other errors,
9664 /// nothing would be added to `buffer` and the return value would be 0.
9665 ///
9666 /// `attachment` - handle to an attachment.
9667 ///
9668 /// `buffer` - buffer for holding the MIME type string encoded in UTF-16LE.
9669 ///
9670 /// `buflen` - length of the buffer in bytes.
9671 ///
9672 /// Returns the length of the MIME type string in bytes.
9673 #[allow(non_snake_case)]
9674 fn FPDFAttachment_GetSubtype(
9675 &self,
9676 attachment: FPDF_ATTACHMENT,
9677 buffer: *mut FPDF_WCHAR,
9678 buflen: c_ulong,
9679 ) -> c_ulong;
9680
9681 /// Determines if `document` represents a tagged PDF.
9682 ///
9683 /// For the definition of tagged PDF, see 10.7 "Tagged PDF" in PDF Reference 1.7.
9684 ///
9685 /// `document` - handle to a document.
9686 ///
9687 /// Returns `true` if `document` is a tagged PDF.
9688 #[allow(non_snake_case)]
9689 fn FPDFCatalog_IsTagged(&self, document: FPDF_DOCUMENT) -> FPDF_BOOL;
9690
9691 #[cfg(any(
9692 feature = "pdfium_future",
9693 feature = "pdfium_7350",
9694 feature = "pdfium_7215",
9695 feature = "pdfium_7123",
9696 feature = "pdfium_6996",
9697 feature = "pdfium_6721",
9698 feature = "pdfium_6666"
9699 ))]
9700 /// Sets the language of `document` to `language`.
9701 ///
9702 /// `document` - handle to a document.
9703 ///
9704 /// `language` - the language to set to.
9705 ///
9706 /// Returns `true` on success.
9707 #[allow(non_snake_case)]
9708 fn FPDFCatalog_SetLanguage(&self, document: FPDF_DOCUMENT, language: &str) -> FPDF_BOOL;
9709}
9710
9711#[cfg(test)]
9712mod tests {
9713 use crate::prelude::*;
9714 use crate::utils::test::test_bind_to_pdfium;
9715
9716 #[test]
9717 fn test_is_true() -> Result<(), PdfiumError> {
9718 let pdfium = test_bind_to_pdfium();
9719
9720 assert!(!pdfium.bindings().is_true(0));
9721 assert!(pdfium.bindings().is_true(1));
9722 assert!(pdfium.bindings().is_true(-1));
9723
9724 Ok(())
9725 }
9726}