├── .github └── workflows │ └── rust.yml ├── .gitignore ├── .gitmodules ├── Cargo.toml ├── README.md ├── ci ├── build.bash ├── common.bash ├── set_rust_version.bash └── test.bash ├── qpdf-rs ├── Cargo.toml ├── README.md ├── src │ ├── array.rs │ ├── dict.rs │ ├── error.rs │ ├── lib.rs │ ├── object.rs │ ├── scalar.rs │ ├── stream.rs │ └── writer.rs └── tests │ ├── data │ ├── encrypted.pdf │ └── test.pdf │ └── test_qpdf.rs ├── qpdf-sys ├── Cargo.toml ├── README.md ├── bindings │ ├── aarch64-apple-darwin.rs │ ├── aarch64-pc-windows-msvc.rs │ ├── aarch64-unknown-linux-gnu.rs │ ├── armv7-unknown-linux-gnueabihf.rs │ ├── x86_64-apple-darwin.rs │ ├── x86_64-pc-windows-gnu.rs │ ├── x86_64-pc-windows-msvc.rs │ └── x86_64-unknown-linux-gnu.rs ├── build.rs ├── include │ ├── jconfig.h │ └── qpdf │ │ └── qpdf-config.h └── src │ └── lib.rs └── rustfmt.toml /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | windows: 7 | runs-on: windows-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | with: 11 | persist-credentials: false 12 | - run: git submodule update --init 13 | shell: bash 14 | - run: ci/set_rust_version.bash ${{ matrix.channel }} ${{ matrix.target }} 15 | shell: bash 16 | - run: ci/build.bash cargo ${{ matrix.target }} vendor 17 | shell: bash 18 | - run: ci/test.bash cargo ${{ matrix.target }} vendor 19 | shell: bash 20 | 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | channel: [stable] 25 | target: 26 | - x86_64-pc-windows-msvc 27 | - x86_64-pc-windows-gnu 28 | 29 | macos: 30 | runs-on: macos-latest 31 | steps: 32 | - uses: actions/checkout@v2 33 | with: 34 | persist-credentials: false 35 | - run: git submodule update --init 36 | - run: ci/set_rust_version.bash ${{ matrix.channel }} ${{ matrix.target }} 37 | - run: ci/build.bash cargo ${{ matrix.target }} vendor 38 | - run: ci/test.bash cargo ${{ matrix.target }} vendor 39 | 40 | strategy: 41 | fail-fast: false 42 | matrix: 43 | channel: [stable] 44 | target: 45 | - x86_64-apple-darwin 46 | 47 | linux: 48 | runs-on: ubuntu-latest 49 | steps: 50 | - uses: actions/checkout@v2 51 | with: 52 | persist-credentials: false 53 | - run: git submodule update --init 54 | - run: sudo apt-get update && sudo apt-get install -yqq libqpdf-dev 55 | - run: ci/set_rust_version.bash ${{ matrix.channel }} ${{ matrix.target }} 56 | - run: ci/build.bash cargo ${{ matrix.target }} 57 | - run: ci/test.bash cargo ${{ matrix.target }} 58 | 59 | strategy: 60 | fail-fast: false 61 | matrix: 62 | channel: [stable] 63 | target: 64 | - x86_64-unknown-linux-gnu 65 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /.idea 3 | /.vscode 4 | Cargo.lock 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "qpdf-sys/qpdf"] 2 | path = qpdf-sys/qpdf 3 | url = https://github.com/qpdf/qpdf 4 | [submodule "qpdf-sys/zlib"] 5 | path = qpdf-sys/zlib 6 | url = https://github.com/madler/zlib.git 7 | [submodule "qpdf-sys/jpeg"] 8 | path = qpdf-sys/jpeg 9 | url = https://github.com/libjpeg-turbo/ijg.git 10 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = ["qpdf-sys", "qpdf-rs"] 4 | 5 | [workspace.package] 6 | version = "0.3.4" 7 | authors = ["Dmitry Pankratov "] 8 | edition = "2021" 9 | repository = "https://github.com/ancwrd1/qpdf-rs" 10 | documentation = "https://docs.rs/qpdf" 11 | readme = "README.md" 12 | keywords = ["PDF", "QPDF"] 13 | license = "MIT/Apache-2.0" 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # qpdf-rs 2 | 3 | [![github actions](https://github.com/ancwrd1/qpdf-rs/workflows/CI/badge.svg)](https://github.com/ancwrd1/qpdf-rs/actions) 4 | [![crates](https://img.shields.io/crates/v/qpdf.svg)](https://crates.io/crates/qpdf) 5 | [![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) 6 | [![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 7 | [![docs.rs](https://docs.rs/qpdf/badge.svg)](https://docs.rs/qpdf) 8 | 9 | ## Overview 10 | 11 | This project contains Rust safe bindings to a popular [QPDF C++ library](https://github.com/qpdf/qpdf). 12 | It uses the QPDF C API exposed via `qpdf-c.h` header. 13 | 14 | Tested on the following targets: 15 | 16 | * x86_64-unknown-linux-gnu 17 | * aarch64-unknown-linux-gnu 18 | * x86_64-pc-windows-gnu 19 | * x86_64-pc-windows-msvc 20 | * x86_64-apple-darwin 21 | * aarch64-apple-darwin 22 | 23 | The prebuilt bindings for those targets are included in the source tree. 24 | 25 | By default, `pkg-config` will be used to link against the system library `libqpdf`. 26 | 27 | If the `vendored` feature is enabled, a vendored source tree of qpdf is built and linked statically. 28 | 29 | The `legacy` feature enables bindings to the r2/3/4 encryption options which are available in qpdf 10.x but not 11.x. 30 | 31 | ## Usage example 32 | 33 | ```rust,no_run 34 | use qpdf::*; 35 | 36 | fn make_pdf_from_scratch() -> qpdf::Result> { 37 | let qpdf = QPdf::empty(); 38 | 39 | let font = qpdf 40 | .parse_object( 41 | r#"<< 42 | /Type /Font 43 | /Subtype /Type1 44 | /Name /F1 45 | /BaseFont /Helvetica 46 | /Encoding /WinAnsiEncoding 47 | >>"#, 48 | )?; 49 | 50 | let procset = qpdf.parse_object("[/PDF /Text]")?; 51 | let contents = qpdf.new_stream(b"BT /F1 15 Tf 72 720 Td (First Page) Tj ET\n"); 52 | let mediabox = qpdf.parse_object("[0 0 612 792]")?; 53 | let rfont = qpdf.new_dictionary_from([("/F1", font.into_indirect())]); 54 | let resources = qpdf.new_dictionary_from([ 55 | ("/ProcSet", procset.into_indirect()), 56 | ("/Font", rfont.into()) 57 | ]); 58 | let page = qpdf.new_dictionary_from([ 59 | ("/Type", qpdf.new_name("/Page")), 60 | ("/MediaBox", mediabox), 61 | ("/Contents", contents.into()), 62 | ("/Resources", resources.into()), 63 | ]); 64 | 65 | qpdf.add_page(&page.into_indirect(), true)?; 66 | 67 | let mem = qpdf 68 | .writer() 69 | .static_id(true) 70 | .force_pdf_version("1.7") 71 | .normalize_content(true) 72 | .preserve_unreferenced_objects(false) 73 | .object_stream_mode(ObjectStreamMode::Preserve) 74 | .compress_streams(false) 75 | .stream_data_mode(StreamDataMode::Preserve) 76 | .write_to_memory()?; 77 | 78 | Ok(mem) 79 | } 80 | ``` 81 | 82 | ## Additional build requirements 83 | 84 | * C/C++ compiler 85 | * For the targets which do not have prebuilt bindgen bindings: 86 | * Installed clang/llvm (with `libclang` shared library) for bindgen build-time invocation 87 | * For cross-compilation a custom sysroot must be passed to clang via `BINDGEN_EXTRA_CLANG_ARGS` 88 | environment variable, for example: `BINDGEN_EXTRA_CLANG_ARGS="--sysroot=/usr/x86_64-w64-mingw32/sys-root"` 89 | 90 | ## License 91 | 92 | Licensed under [Apache 2.0](https://opensource.org/licenses/Apache-2.0) license. 93 | -------------------------------------------------------------------------------- /ci/build.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Script for building your rust projects. 3 | set -e 4 | 5 | source ci/common.bash 6 | 7 | # $1 {path} = Path to cross/cargo executable 8 | CROSS=$1 9 | # $2 {string} = 10 | TARGET_TRIPLE=$2 11 | # $3 {boolean} = Whether to use vendored sources. 12 | VENDOR=$3 13 | # $4 {boolean} = Whether or not building for release or not. 14 | RELEASE_BUILD=$4 15 | 16 | required_arg $CROSS 'CROSS' 17 | required_arg $TARGET_TRIPLE '' 18 | 19 | if [ -n "$VENDOR" ]; then 20 | VENDOR="--features vendored" 21 | fi 22 | 23 | if [ -z "$RELEASE_BUILD" ]; then 24 | $CROSS build --target $TARGET_TRIPLE $VENDOR --workspace 25 | $CROSS build --target $TARGET_TRIPLE --all-features --workspace 26 | else 27 | $CROSS build --target $TARGET_TRIPLE --all-features --release --workspace 28 | fi 29 | 30 | -------------------------------------------------------------------------------- /ci/common.bash: -------------------------------------------------------------------------------- 1 | required_arg() { 2 | if [ -z "$1" ]; then 3 | echo "Required argument $2 missing" 4 | exit 1 5 | fi 6 | } 7 | -------------------------------------------------------------------------------- /ci/set_rust_version.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | rustup update 4 | rustup default $1 5 | rustup target add $2 6 | -------------------------------------------------------------------------------- /ci/test.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Script for building your rust projects. 3 | set -e 4 | 5 | source ci/common.bash 6 | 7 | # $1 {path} = Path to cross/cargo executable 8 | CROSS=$1 9 | # $2 {string} = 10 | TARGET_TRIPLE=$2 11 | # $3 {boolean} = Whether to use vendored sources. 12 | VENDOR=$3 13 | 14 | required_arg $CROSS 'CROSS' 15 | required_arg $TARGET_TRIPLE '' 16 | 17 | if [ -n "$VENDOR" ]; then 18 | VENDOR="--features vendored" 19 | fi 20 | 21 | $CROSS test --target $TARGET_TRIPLE $VENDOR --workspace 22 | $CROSS build --target $TARGET_TRIPLE --all-features --workspace 23 | -------------------------------------------------------------------------------- /qpdf-rs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "qpdf" 3 | description = "Rust bindings to QPDF C++ library" 4 | version.workspace = true 5 | authors.workspace = true 6 | edition.workspace = true 7 | repository.workspace = true 8 | documentation.workspace = true 9 | readme.workspace = true 10 | keywords.workspace = true 11 | license.workspace = true 12 | 13 | [dependencies] 14 | qpdf-sys = { path = "../qpdf-sys", version = "0.3" } 15 | libc = "0.2" 16 | 17 | [features] 18 | vendored = ["qpdf-sys/vendored"] 19 | legacy = [] 20 | 21 | [package.metadata.docs.rs] 22 | features = ["vendored"] 23 | -------------------------------------------------------------------------------- /qpdf-rs/README.md: -------------------------------------------------------------------------------- 1 | ../README.md -------------------------------------------------------------------------------- /qpdf-rs/src/array.rs: -------------------------------------------------------------------------------- 1 | use std::fmt; 2 | 3 | use crate::{QPdfObject, QPdfObjectLike}; 4 | 5 | /// QPdfArray wraps a QPdfObject for array-specific operations 6 | pub struct QPdfArray { 7 | inner: QPdfObject, 8 | } 9 | 10 | impl QPdfArray { 11 | fn new(inner: QPdfObject) -> Self { 12 | QPdfArray { inner } 13 | } 14 | 15 | /// Get array length 16 | pub fn len(&self) -> usize { 17 | unsafe { qpdf_sys::qpdf_oh_get_array_n_items(self.inner.owner.inner(), self.inner.inner) as _ } 18 | } 19 | 20 | /// Return true if array is empty 21 | pub fn is_empty(&self) -> bool { 22 | self.len() == 0 23 | } 24 | 25 | /// Return array iterator 26 | pub fn iter(&self) -> QPdfArrayIterator { 27 | QPdfArrayIterator { index: 0, inner: self } 28 | } 29 | 30 | /// Get array item 31 | pub fn get(&self, index: usize) -> Option { 32 | if index < self.len() { 33 | Some(unsafe { 34 | QPdfObject::new( 35 | self.inner.owner.clone(), 36 | qpdf_sys::qpdf_oh_get_array_item(self.inner.owner.inner(), self.inner.inner, index as _), 37 | ) 38 | }) 39 | } else { 40 | None 41 | } 42 | } 43 | 44 | /// Set array item 45 | pub fn set>(&mut self, index: usize, item: I) { 46 | unsafe { 47 | qpdf_sys::qpdf_oh_set_array_item( 48 | self.inner.owner.inner(), 49 | self.inner.inner, 50 | index as _, 51 | item.as_ref().inner, 52 | ); 53 | } 54 | } 55 | 56 | /// Append an item to the array 57 | pub fn push>(&self, item: I) { 58 | unsafe { 59 | qpdf_sys::qpdf_oh_append_item(self.inner.owner.inner(), self.inner.inner, item.as_ref().inner); 60 | } 61 | } 62 | 63 | /// Insert an item into array 64 | pub fn insert>(&mut self, index: usize, item: I) { 65 | unsafe { 66 | qpdf_sys::qpdf_oh_insert_item( 67 | self.inner.owner.inner(), 68 | self.inner.inner, 69 | index as _, 70 | item.as_ref().inner, 71 | ); 72 | } 73 | } 74 | 75 | /// Remove array item 76 | pub fn remove(&mut self, index: usize) { 77 | unsafe { 78 | qpdf_sys::qpdf_oh_erase_item(self.inner.owner.inner(), self.inner.inner, index as _); 79 | } 80 | } 81 | } 82 | 83 | impl QPdfObjectLike for QPdfArray { 84 | fn as_object(&self) -> &QPdfObject { 85 | &self.inner 86 | } 87 | } 88 | 89 | impl From for QPdfArray { 90 | fn from(obj: QPdfObject) -> Self { 91 | QPdfArray::new(obj) 92 | } 93 | } 94 | 95 | impl From for QPdfObject { 96 | fn from(dict: QPdfArray) -> Self { 97 | dict.inner 98 | } 99 | } 100 | 101 | impl AsRef for QPdfArray { 102 | fn as_ref(&self) -> &QPdfObject { 103 | &self.inner 104 | } 105 | } 106 | 107 | /// QPdfArray iterator 108 | pub struct QPdfArrayIterator<'a> { 109 | index: usize, 110 | inner: &'a QPdfArray, 111 | } 112 | 113 | impl Iterator for QPdfArrayIterator<'_> { 114 | type Item = QPdfObject; 115 | 116 | fn next(&mut self) -> Option { 117 | let item = self.inner.get(self.index); 118 | self.index += 1; 119 | item 120 | } 121 | } 122 | 123 | impl fmt::Display for QPdfArray { 124 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 125 | self.inner.fmt(f) 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /qpdf-rs/src/dict.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | ffi::{CStr, CString}, 3 | fmt, ptr, 4 | }; 5 | 6 | use crate::{QPdfObject, QPdfObjectLike, QPdfObjectType, QPdfStreamData, Result}; 7 | 8 | /// QPdfDictionary wraps a QPdfObject for dictionary-related operations 9 | pub struct QPdfDictionary { 10 | inner: QPdfObject, 11 | } 12 | 13 | impl QPdfDictionary { 14 | pub(crate) fn new(inner: QPdfObject) -> Self { 15 | QPdfDictionary { inner } 16 | } 17 | 18 | /// Get contents from the page object 19 | pub fn get_page_content_data(&self) -> Result { 20 | unsafe { 21 | let mut len = 0; 22 | let mut buffer = ptr::null_mut(); 23 | qpdf_sys::qpdf_oh_get_page_content_data(self.inner.owner.inner(), self.inner.inner, &mut buffer, &mut len); 24 | self.inner 25 | .owner 26 | .last_error_or_then(|| QPdfStreamData::new(buffer, len as _)) 27 | } 28 | } 29 | 30 | /// Check whether there is a key in the dictionary 31 | pub fn has(&self, key: &str) -> bool { 32 | unsafe { 33 | let key_str = CString::new(key).unwrap(); 34 | qpdf_sys::qpdf_oh_has_key(self.inner.owner.inner(), self.inner.inner, key_str.as_ptr()) != 0 35 | } 36 | } 37 | 38 | /// Get dictionary element for the specified key 39 | pub fn get(&self, key: &str) -> Option { 40 | unsafe { 41 | let key_str = CString::new(key).unwrap(); 42 | let oh = qpdf_sys::qpdf_oh_get_key(self.inner.owner.inner(), self.inner.inner, key_str.as_ptr()); 43 | let obj = QPdfObject::new(self.inner.owner.clone(), oh); 44 | if obj.get_type() != QPdfObjectType::Null { 45 | Some(obj) 46 | } else { 47 | None 48 | } 49 | } 50 | } 51 | 52 | /// Set dictionary element for the specified key 53 | pub fn set>(&self, key: &str, value: V) { 54 | unsafe { 55 | let key_str = CString::new(key).unwrap(); 56 | qpdf_sys::qpdf_oh_replace_key( 57 | self.inner.owner.inner(), 58 | self.inner.inner, 59 | key_str.as_ptr(), 60 | value.as_ref().inner, 61 | ); 62 | } 63 | } 64 | 65 | /// Remove dictionary element 66 | pub fn remove(&self, key: &str) { 67 | unsafe { 68 | let key_str = CString::new(key).unwrap(); 69 | qpdf_sys::qpdf_oh_remove_key(self.inner.owner.inner(), self.inner.inner, key_str.as_ptr()); 70 | } 71 | } 72 | 73 | /// Return all keys from the dictionary 74 | pub fn keys(&self) -> Vec { 75 | let mut keys = Vec::new(); 76 | unsafe { 77 | qpdf_sys::qpdf_oh_begin_dict_key_iter(self.inner.owner.inner(), self.inner.inner); 78 | while qpdf_sys::qpdf_oh_dict_more_keys(self.inner.owner.inner()) != 0 { 79 | keys.push( 80 | CStr::from_ptr(qpdf_sys::qpdf_oh_dict_next_key(self.inner.owner.inner())) 81 | .to_string_lossy() 82 | .into_owned(), 83 | ); 84 | } 85 | } 86 | keys 87 | } 88 | } 89 | 90 | impl QPdfObjectLike for QPdfDictionary { 91 | fn as_object(&self) -> &QPdfObject { 92 | &self.inner 93 | } 94 | } 95 | 96 | impl From for QPdfDictionary { 97 | fn from(obj: QPdfObject) -> Self { 98 | QPdfDictionary::new(obj) 99 | } 100 | } 101 | 102 | impl From for QPdfObject { 103 | fn from(dict: QPdfDictionary) -> Self { 104 | dict.inner 105 | } 106 | } 107 | 108 | impl AsRef for QPdfDictionary { 109 | fn as_ref(&self) -> &QPdfObject { 110 | &self.inner 111 | } 112 | } 113 | 114 | impl fmt::Display for QPdfDictionary { 115 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 116 | self.inner.fmt(f) 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /qpdf-rs/src/error.rs: -------------------------------------------------------------------------------- 1 | use std::ffi::NulError; 2 | use std::fmt; 3 | 4 | use crate::Result; 5 | 6 | /// Error codes returned by QPDF library calls 7 | #[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Hash, Default)] 8 | pub enum QPdfErrorCode { 9 | #[default] 10 | Unknown, 11 | InvalidParameter, 12 | InternalError, 13 | SystemError, 14 | Unsupported, 15 | InvalidPassword, 16 | DamagedPdf, 17 | PagesError, 18 | ObjectError, 19 | } 20 | 21 | pub(crate) fn error_or_ok(error: qpdf_sys::qpdf_error_code_e) -> Result<()> { 22 | let code = match error as qpdf_sys::qpdf_error_code_e { 23 | qpdf_sys::qpdf_error_code_e_qpdf_e_success => return Ok(()), 24 | qpdf_sys::qpdf_error_code_e_qpdf_e_internal => QPdfErrorCode::InternalError, 25 | qpdf_sys::qpdf_error_code_e_qpdf_e_system => QPdfErrorCode::SystemError, 26 | qpdf_sys::qpdf_error_code_e_qpdf_e_unsupported => QPdfErrorCode::Unsupported, 27 | qpdf_sys::qpdf_error_code_e_qpdf_e_password => QPdfErrorCode::InvalidPassword, 28 | qpdf_sys::qpdf_error_code_e_qpdf_e_damaged_pdf => QPdfErrorCode::DamagedPdf, 29 | qpdf_sys::qpdf_error_code_e_qpdf_e_pages => QPdfErrorCode::PagesError, 30 | qpdf_sys::qpdf_error_code_e_qpdf_e_object => QPdfErrorCode::ObjectError, 31 | _ => QPdfErrorCode::Unknown, 32 | }; 33 | Err(QPdfError { 34 | error_code: code, 35 | description: None, 36 | position: None, 37 | }) 38 | } 39 | 40 | /// QPdfError holds an error code and an optional extra information 41 | #[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Default)] 42 | pub struct QPdfError { 43 | pub(crate) error_code: QPdfErrorCode, 44 | pub(crate) description: Option, 45 | pub(crate) position: Option, 46 | } 47 | 48 | impl fmt::Display for QPdfError { 49 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 50 | write!( 51 | f, 52 | "{:?}: {}", 53 | self.error_code, 54 | self.description.as_deref().unwrap_or_default() 55 | ) 56 | } 57 | } 58 | 59 | impl std::error::Error for QPdfError {} 60 | 61 | impl QPdfError { 62 | pub fn error_code(&self) -> QPdfErrorCode { 63 | self.error_code 64 | } 65 | 66 | pub fn description(&self) -> Option<&str> { 67 | self.description.as_deref() 68 | } 69 | 70 | pub fn position(&self) -> Option { 71 | self.position 72 | } 73 | } 74 | 75 | impl From for QPdfError { 76 | fn from(_: NulError) -> Self { 77 | QPdfError { 78 | error_code: QPdfErrorCode::InvalidParameter, 79 | description: Some("Unexpected null code in the string parameter".to_owned()), 80 | position: None, 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /qpdf-rs/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::manual_c_str_literals)] 2 | #![doc = include_str!("../README.md")] 3 | 4 | use std::{ 5 | cell::RefCell, 6 | collections::HashSet, 7 | ffi::{CStr, CString}, 8 | fmt, 9 | hash::{self, Hasher}, 10 | path::Path, 11 | ptr, 12 | rc::Rc, 13 | }; 14 | 15 | pub use array::*; 16 | pub use dict::*; 17 | pub use error::*; 18 | pub use object::*; 19 | pub use scalar::*; 20 | pub use stream::*; 21 | pub use writer::*; 22 | 23 | pub mod array; 24 | pub mod dict; 25 | pub mod error; 26 | pub mod object; 27 | pub mod scalar; 28 | pub mod stream; 29 | pub mod writer; 30 | 31 | pub type Result = std::result::Result; 32 | 33 | struct Handle { 34 | handle: qpdf_sys::qpdf_data, 35 | buffer: Vec, 36 | } 37 | 38 | impl Drop for Handle { 39 | fn drop(&mut self) { 40 | unsafe { 41 | qpdf_sys::qpdf_cleanup(&mut self.handle); 42 | } 43 | } 44 | } 45 | 46 | /// QPdf is a data structure which represents a PDF file 47 | #[derive(Clone)] 48 | pub struct QPdf { 49 | inner: Rc, 50 | foreign: Rc>>, 51 | } 52 | 53 | impl hash::Hash for QPdf { 54 | fn hash(&self, state: &mut H) { 55 | self.inner.handle.hash(state) 56 | } 57 | } 58 | 59 | impl PartialEq for QPdf { 60 | fn eq(&self, other: &Self) -> bool { 61 | self.inner.handle.eq(&other.inner.handle) 62 | } 63 | } 64 | 65 | impl Eq for QPdf {} 66 | 67 | impl fmt::Debug for QPdf { 68 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 69 | write!(f, "QPDF version {}", QPdf::library_version()) 70 | } 71 | } 72 | 73 | impl QPdf { 74 | pub(crate) fn inner(&self) -> qpdf_sys::qpdf_data { 75 | self.inner.handle 76 | } 77 | 78 | fn wrap_ffi_call(self: &QPdf, f: F) -> Result<()> 79 | where 80 | F: FnOnce() -> R, 81 | { 82 | f(); 83 | self.last_error_or_then(|| ()) 84 | } 85 | 86 | fn last_error_or_then(self: &QPdf, f: F) -> Result 87 | where 88 | F: FnOnce() -> T, 89 | { 90 | unsafe { 91 | if qpdf_sys::qpdf_has_error(self.inner()) == 0 { 92 | return Ok(f()); 93 | } 94 | 95 | let qpdf_error = qpdf_sys::qpdf_get_error(self.inner()); 96 | let code = qpdf_sys::qpdf_get_error_code(self.inner(), qpdf_error); 97 | 98 | match error_or_ok(code) { 99 | Ok(_) => Ok(f()), 100 | Err(e) => { 101 | let error_detail = qpdf_sys::qpdf_get_error_message_detail(self.inner(), qpdf_error); 102 | 103 | let description = if !error_detail.is_null() { 104 | Some(CStr::from_ptr(error_detail).to_string_lossy().into_owned()) 105 | } else { 106 | None 107 | }; 108 | 109 | let position = qpdf_sys::qpdf_get_error_file_position(self.inner(), qpdf_error); 110 | 111 | Err(QPdfError { 112 | description, 113 | position: Some(position), 114 | ..e 115 | }) 116 | } 117 | } 118 | } 119 | } 120 | 121 | /// Get QPDF library version 122 | pub fn library_version() -> String { 123 | unsafe { 124 | CStr::from_ptr(qpdf_sys::qpdf_get_qpdf_version()) 125 | .to_string_lossy() 126 | .into_owned() 127 | } 128 | } 129 | 130 | fn new() -> QPdf { 131 | Self::new_with_buffer(Vec::new()) 132 | } 133 | 134 | fn new_with_buffer(buffer: Vec) -> QPdf { 135 | unsafe { 136 | let inner = qpdf_sys::qpdf_init(); 137 | qpdf_sys::qpdf_set_suppress_warnings(inner, true.into()); 138 | qpdf_sys::qpdf_silence_errors(inner); 139 | QPdf { 140 | inner: Rc::new(Handle { handle: inner, buffer }), 141 | foreign: Rc::new(RefCell::new(HashSet::new())), 142 | } 143 | } 144 | } 145 | 146 | /// Create an empty PDF 147 | pub fn empty() -> QPdf { 148 | let qpdf = QPdf::new(); 149 | unsafe { 150 | qpdf_sys::qpdf_empty_pdf(qpdf.inner()); 151 | } 152 | qpdf 153 | } 154 | 155 | fn do_read_file(self: &QPdf, path: &Path, password: Option<&str>) -> Result<()> { 156 | let filename = CString::new(path.to_string_lossy().as_ref())?; 157 | let password = password.and_then(|p| CString::new(p).ok()); 158 | 159 | let raw_password = password.as_ref().map(|p| p.as_ptr()).unwrap_or_else(ptr::null); 160 | 161 | self.wrap_ffi_call(|| unsafe { qpdf_sys::qpdf_read(self.inner(), filename.as_ptr(), raw_password) }) 162 | } 163 | 164 | fn do_read_from_memory(self: &QPdf, password: Option<&str>) -> Result<()> { 165 | let password = password.and_then(|p| CString::new(p).ok()); 166 | 167 | let raw_password = password.as_ref().map(|p| p.as_ptr()).unwrap_or_else(ptr::null); 168 | 169 | self.wrap_ffi_call(|| unsafe { 170 | qpdf_sys::qpdf_read_memory( 171 | self.inner(), 172 | b"memory\0".as_ptr() as _, 173 | self.inner.buffer.as_ptr() as _, 174 | self.inner.buffer.len() as _, 175 | raw_password, 176 | ); 177 | }) 178 | } 179 | 180 | /// Read PDF from the file 181 | pub fn read>(path: P) -> Result { 182 | let qpdf = QPdf::new(); 183 | qpdf.do_read_file(path.as_ref(), None)?; 184 | Ok(qpdf) 185 | } 186 | 187 | /// Load encrypted PDF from the file 188 | pub fn read_encrypted>(path: P, password: &str) -> Result { 189 | let qpdf = QPdf::new(); 190 | qpdf.do_read_file(path.as_ref(), Some(password))?; 191 | Ok(qpdf) 192 | } 193 | 194 | /// Read PDF from memory 195 | pub fn read_from_memory>(buffer: T) -> Result { 196 | let qpdf = QPdf::new_with_buffer(buffer.as_ref().into()); 197 | qpdf.do_read_from_memory(None)?; 198 | Ok(qpdf) 199 | } 200 | 201 | /// Read encrypted PDF from memory 202 | pub fn read_from_memory_encrypted>(buffer: T, password: &str) -> Result { 203 | let qpdf = QPdf::new_with_buffer(buffer.as_ref().into()); 204 | qpdf.do_read_from_memory(Some(password))?; 205 | Ok(qpdf) 206 | } 207 | 208 | /// Return QPdfWriter used to write PDF to file or memory 209 | pub fn writer(self: &QPdf) -> QPdfWriter { 210 | QPdfWriter::new(self.clone()) 211 | } 212 | 213 | /// Check PDF for errors 214 | pub fn check_pdf(self: &QPdf) -> Result<()> { 215 | self.wrap_ffi_call(|| unsafe { qpdf_sys::qpdf_check_pdf(self.inner()) }) 216 | } 217 | 218 | /// Enable or disable automatic PDF recovery 219 | pub fn enable_recovery(self: &QPdf, flag: bool) { 220 | unsafe { qpdf_sys::qpdf_set_attempt_recovery(self.inner(), flag.into()) } 221 | } 222 | 223 | /// Enable or disable xref streams ignorance 224 | pub fn ignore_xref_streams(self: &QPdf, flag: bool) { 225 | unsafe { qpdf_sys::qpdf_set_ignore_xref_streams(self.inner(), flag.into()) } 226 | } 227 | 228 | /// Get PDF version as a string 229 | pub fn get_pdf_version(self: &QPdf) -> String { 230 | unsafe { 231 | let version = qpdf_sys::qpdf_get_pdf_version(self.inner()); 232 | if version.is_null() { 233 | String::new() 234 | } else { 235 | CStr::from_ptr(version).to_string_lossy().into_owned() 236 | } 237 | } 238 | } 239 | 240 | /// Get PDF extension level 241 | pub fn get_pdf_extension_level(self: &QPdf) -> u32 { 242 | unsafe { qpdf_sys::qpdf_get_pdf_extension_level(self.inner()) as _ } 243 | } 244 | 245 | /// Return true if PDF is linearized 246 | pub fn is_linearized(self: &QPdf) -> bool { 247 | unsafe { qpdf_sys::qpdf_is_linearized(self.inner()) != 0 } 248 | } 249 | 250 | /// Return true if PDF is encrypted 251 | pub fn is_encrypted(self: &QPdf) -> bool { 252 | unsafe { qpdf_sys::qpdf_is_encrypted(self.inner()) != 0 } 253 | } 254 | 255 | /// Add a page object to PDF. The `first` parameter indicates whether to prepend or append it. 256 | pub fn add_page>(self: &QPdf, new_page: T, first: bool) -> Result<()> { 257 | if new_page.as_ref().owner.inner() != self.inner() { 258 | self.foreign.borrow_mut().insert(new_page.as_ref().owner.clone()); 259 | } 260 | self.wrap_ffi_call(|| unsafe { 261 | qpdf_sys::qpdf_add_page( 262 | self.inner(), 263 | new_page.as_ref().owner.inner(), 264 | new_page.as_ref().inner, 265 | first.into(), 266 | ) 267 | }) 268 | } 269 | 270 | /// Add a page object to PDF before or after a specified `ref_page`. A page may belong to another PDF. 271 | pub fn add_page_at(self: &QPdf, new_page: N, before: bool, ref_page: R) -> Result<()> 272 | where 273 | N: AsRef, 274 | R: AsRef, 275 | { 276 | if new_page.as_ref().owner.inner() != self.inner() { 277 | self.foreign.borrow_mut().insert(new_page.as_ref().owner.clone()); 278 | } 279 | self.wrap_ffi_call(|| unsafe { 280 | qpdf_sys::qpdf_add_page_at( 281 | self.inner(), 282 | new_page.as_ref().owner.inner(), 283 | new_page.as_ref().inner, 284 | before.into(), 285 | ref_page.as_ref().inner, 286 | ) 287 | }) 288 | } 289 | 290 | /// Get number of page objects in the PDF. 291 | pub fn get_num_pages(self: &QPdf) -> Result { 292 | unsafe { 293 | let n = qpdf_sys::qpdf_get_num_pages(self.inner()); 294 | self.last_error_or_then(|| n as _) 295 | } 296 | } 297 | 298 | /// Get a page object from the PDF with a given zero-based index 299 | pub fn get_page(self: &QPdf, zero_based_index: u32) -> Option { 300 | unsafe { 301 | let oh = qpdf_sys::qpdf_get_page_n(self.inner(), zero_based_index as _); 302 | self.last_error_or_then(|| ()).ok()?; 303 | if oh != 0 { 304 | Some(QPdfObject::new(self.clone(), oh).into()) 305 | } else { 306 | None 307 | } 308 | } 309 | } 310 | 311 | /// Get all pages from the PDF. 312 | pub fn get_pages(self: &QPdf) -> Result> { 313 | Ok((0..self.get_num_pages()?).filter_map(|i| self.get_page(i)).collect()) 314 | } 315 | 316 | /// Remove page object from the PDF. 317 | pub fn remove_page>(self: &QPdf, page: P) -> Result<()> { 318 | self.foreign.borrow_mut().remove(&page.as_ref().owner); 319 | self.wrap_ffi_call(|| unsafe { qpdf_sys::qpdf_remove_page(self.inner(), page.as_ref().inner) }) 320 | } 321 | 322 | /// Parse textual representation of PDF object. 323 | pub fn parse_object(self: &QPdf, object: &str) -> Result { 324 | unsafe { 325 | let s = CString::new(object)?; 326 | let oh = qpdf_sys::qpdf_oh_parse(self.inner(), s.as_ptr()); 327 | self.last_error_or_then(|| QPdfObject::new(self.clone(), oh)) 328 | } 329 | } 330 | 331 | /// Get trailer object. 332 | pub fn get_trailer(self: &QPdf) -> Option { 333 | let oh = unsafe { qpdf_sys::qpdf_get_trailer(self.inner()) }; 334 | self.last_error_or_then(|| ()).ok()?; 335 | let obj = QPdfObject::new(self.clone(), oh); 336 | if obj.get_type() != QPdfObjectType::Uninitialized && obj.get_type() != QPdfObjectType::Null { 337 | Some(obj.into()) 338 | } else { 339 | None 340 | } 341 | } 342 | 343 | /// Get root object. 344 | pub fn get_root(self: &QPdf) -> Option { 345 | let oh = unsafe { qpdf_sys::qpdf_get_root(self.inner()) }; 346 | self.last_error_or_then(|| ()).ok()?; 347 | let obj = QPdfObject::new(self.clone(), oh); 348 | if obj.get_type() != QPdfObjectType::Uninitialized && obj.get_type() != QPdfObjectType::Null { 349 | Some(obj.into()) 350 | } else { 351 | None 352 | } 353 | } 354 | 355 | /// Find indirect object by object id and generation 356 | pub fn get_object_by_id(self: &QPdf, obj_id: u32, gen: u32) -> Option { 357 | let oh = unsafe { qpdf_sys::qpdf_get_object_by_id(self.inner(), obj_id as _, gen as _) }; 358 | self.last_error_or_then(|| ()).ok()?; 359 | let obj = QPdfObject::new(self.clone(), oh); 360 | if obj.get_type() != QPdfObjectType::Uninitialized && obj.get_type() != QPdfObjectType::Null { 361 | Some(obj) 362 | } else { 363 | None 364 | } 365 | } 366 | 367 | /// Replace indirect object by object id and generation 368 | pub fn replace_object>(self: &QPdf, obj_id: u32, gen: u32, object: O) -> Result<()> { 369 | self.wrap_ffi_call(|| unsafe { 370 | qpdf_sys::qpdf_replace_object(self.inner(), obj_id as _, gen as _, object.as_ref().inner) 371 | }) 372 | } 373 | 374 | /// Create a bool object 375 | pub fn new_bool(self: &QPdf, value: bool) -> QPdfObject { 376 | let oh = unsafe { qpdf_sys::qpdf_oh_new_bool(self.inner(), value.into()) }; 377 | QPdfObject::new(self.clone(), oh) 378 | } 379 | 380 | /// Create a null object 381 | pub fn new_null(self: &QPdf) -> QPdfObject { 382 | let oh = unsafe { qpdf_sys::qpdf_oh_new_null(self.inner()) }; 383 | QPdfObject::new(self.clone(), oh) 384 | } 385 | 386 | /// Create an integer object 387 | pub fn new_integer(self: &QPdf, value: i64) -> QPdfScalar { 388 | let oh = unsafe { qpdf_sys::qpdf_oh_new_integer(self.inner(), value) }; 389 | QPdfObject::new(self.clone(), oh).into() 390 | } 391 | 392 | /// Create a real object from the textual representation 393 | pub fn new_real_from_string(self: &QPdf, value: &str) -> QPdfScalar { 394 | let oh = unsafe { 395 | let value_str = CString::new(value).unwrap(); 396 | qpdf_sys::qpdf_oh_new_real_from_string(self.inner(), value_str.as_ptr()) 397 | }; 398 | QPdfObject::new(self.clone(), oh).into() 399 | } 400 | 401 | /// Create a real object from the double value 402 | pub fn new_real(self: &QPdf, value: f64, decimal_places: u32) -> QPdfScalar { 403 | let oh = unsafe { qpdf_sys::qpdf_oh_new_real_from_double(self.inner(), value, decimal_places as _) }; 404 | QPdfObject::new(self.clone(), oh).into() 405 | } 406 | 407 | /// Create an empty array object 408 | pub fn new_array(self: &QPdf) -> QPdfArray { 409 | let oh = unsafe { qpdf_sys::qpdf_oh_new_array(self.inner()) }; 410 | QPdfObject::new(self.clone(), oh).into() 411 | } 412 | 413 | /// Create an array object from the iterator 414 | pub fn new_array_from(self: &QPdf, iter: I) -> QPdfArray 415 | where 416 | I: IntoIterator, 417 | { 418 | let oh = unsafe { qpdf_sys::qpdf_oh_new_array(self.inner()) }; 419 | let array: QPdfArray = QPdfObject::new(self.clone(), oh).into(); 420 | for item in iter.into_iter() { 421 | array.push(&item); 422 | } 423 | array 424 | } 425 | 426 | /// Create a name object 427 | pub fn new_name(self: &QPdf, value: &str) -> QPdfObject { 428 | let oh = unsafe { 429 | let value_str = CString::new(value).unwrap(); 430 | qpdf_sys::qpdf_oh_new_name(self.inner(), value_str.as_ptr()) 431 | }; 432 | QPdfObject::new(self.clone(), oh) 433 | } 434 | 435 | /// Create a string object encoded as a PDF string or binary string 436 | pub fn new_utf8_string(self: &QPdf, value: &str) -> QPdfObject { 437 | let oh = unsafe { 438 | let value_str = CString::new(value).unwrap(); 439 | qpdf_sys::qpdf_oh_new_unicode_string(self.inner(), value_str.as_ptr()) 440 | }; 441 | QPdfObject::new(self.clone(), oh) 442 | } 443 | 444 | /// Create a PDF string object enclosed in parentheses 445 | pub fn new_string(self: &QPdf, value: &str) -> QPdfObject { 446 | let oh = unsafe { 447 | let value_str = CString::new(value).unwrap(); 448 | qpdf_sys::qpdf_oh_new_string(self.inner(), value_str.as_ptr()) 449 | }; 450 | QPdfObject::new(self.clone(), oh) 451 | } 452 | 453 | /// Create a binary string object enclosed in angle brackets 454 | pub fn new_binary_string>(self: &QPdf, value: V) -> QPdfObject { 455 | let oh = unsafe { 456 | qpdf_sys::qpdf_oh_new_binary_string(self.inner(), value.as_ref().as_ptr() as _, value.as_ref().len() as _) 457 | }; 458 | QPdfObject::new(self.clone(), oh) 459 | } 460 | 461 | /// Create an empty dictionary object 462 | pub fn new_dictionary(self: &QPdf) -> QPdfDictionary { 463 | let oh = unsafe { qpdf_sys::qpdf_oh_new_dictionary(self.inner()) }; 464 | QPdfDictionary::new(QPdfObject::new(self.clone(), oh)) 465 | } 466 | 467 | /// Create a dictionary object from the iterator 468 | pub fn new_dictionary_from(self: &QPdf, iter: I) -> QPdfDictionary 469 | where 470 | I: IntoIterator, 471 | S: AsRef, 472 | O: Into, 473 | { 474 | let oh = unsafe { qpdf_sys::qpdf_oh_new_dictionary(self.inner()) }; 475 | let dict = QPdfDictionary::new(QPdfObject::new(self.clone(), oh)); 476 | for item in iter.into_iter() { 477 | dict.set(item.0.as_ref(), item.1.into()); 478 | } 479 | dict 480 | } 481 | 482 | /// Create a stream object with the specified contents. The filter and params are not set. 483 | pub fn new_stream>(self: &QPdf, data: D) -> QPdfStream { 484 | let oh = unsafe { qpdf_sys::qpdf_oh_new_stream(self.inner()) }; 485 | let obj: QPdfStream = QPdfObject::new(self.clone(), oh).into(); 486 | obj.replace_data(data, self.new_null(), self.new_null()); 487 | obj 488 | } 489 | 490 | /// Create a stream object with specified dictionary and contents. The filter and params are not set. 491 | pub fn new_stream_with_dictionary(self: &QPdf, iter: I, data: T) -> QPdfStream 492 | where 493 | I: IntoIterator, 494 | S: AsRef, 495 | O: Into, 496 | T: AsRef<[u8]>, 497 | { 498 | let stream = self.new_stream(data.as_ref()); 499 | let dict = stream.get_dictionary(); 500 | for item in iter.into_iter() { 501 | dict.set(item.0.as_ref(), item.1.into()); 502 | } 503 | drop(dict); 504 | stream 505 | } 506 | 507 | /// Copy object from the foreign PDF 508 | pub fn copy_from_foreign>(self: &QPdf, foreign: F) -> QPdfObject { 509 | let oh = unsafe { 510 | qpdf_sys::qpdf_oh_copy_foreign_object(self.inner(), foreign.as_ref().owner.inner(), foreign.as_ref().inner) 511 | }; 512 | self.foreign.borrow_mut().insert(foreign.as_ref().owner.clone()); 513 | QPdfObject::new(self.clone(), oh) 514 | } 515 | 516 | /// Return true if PDF has warnings 517 | pub fn more_warnings(self: &QPdf) -> bool { 518 | unsafe { qpdf_sys::qpdf_more_warnings(self.inner()) != 0 } 519 | } 520 | } 521 | -------------------------------------------------------------------------------- /qpdf-rs/src/object.rs: -------------------------------------------------------------------------------- 1 | use std::{cmp::Ordering, ffi::CStr, fmt, slice}; 2 | 3 | use crate::QPdf; 4 | 5 | /// Types of the QPDF objects 6 | #[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Hash)] 7 | pub enum QPdfObjectType { 8 | Uninitialized, 9 | Reserved, 10 | Null, 11 | Boolean, 12 | Integer, 13 | Real, 14 | String, 15 | Name, 16 | Array, 17 | Dictionary, 18 | Stream, 19 | Operator, 20 | InlineImage, 21 | } 22 | 23 | impl QPdfObjectType { 24 | fn from_qpdf_enum(obj_t: qpdf_sys::qpdf_object_type_e) -> Self { 25 | match obj_t { 26 | qpdf_sys::qpdf_object_type_e_ot_uninitialized => QPdfObjectType::Uninitialized, 27 | qpdf_sys::qpdf_object_type_e_ot_reserved => QPdfObjectType::Reserved, 28 | qpdf_sys::qpdf_object_type_e_ot_null => QPdfObjectType::Null, 29 | qpdf_sys::qpdf_object_type_e_ot_boolean => QPdfObjectType::Boolean, 30 | qpdf_sys::qpdf_object_type_e_ot_integer => QPdfObjectType::Integer, 31 | qpdf_sys::qpdf_object_type_e_ot_real => QPdfObjectType::Real, 32 | qpdf_sys::qpdf_object_type_e_ot_string => QPdfObjectType::String, 33 | qpdf_sys::qpdf_object_type_e_ot_name => QPdfObjectType::Name, 34 | qpdf_sys::qpdf_object_type_e_ot_array => QPdfObjectType::Array, 35 | qpdf_sys::qpdf_object_type_e_ot_dictionary => QPdfObjectType::Dictionary, 36 | qpdf_sys::qpdf_object_type_e_ot_stream => QPdfObjectType::Stream, 37 | qpdf_sys::qpdf_object_type_e_ot_operator => QPdfObjectType::Operator, 38 | qpdf_sys::qpdf_object_type_e_ot_inlineimage => QPdfObjectType::InlineImage, 39 | _ => panic!("Unexpected object type!"), 40 | } 41 | } 42 | } 43 | 44 | pub trait QPdfObjectLike { 45 | /// Return inner object 46 | fn as_object(&self) -> &QPdfObject; 47 | 48 | fn owner(&self) -> QPdf { 49 | self.as_object().owner.clone() 50 | } 51 | 52 | /// Get this object type 53 | fn get_type(&self) -> QPdfObjectType { 54 | self.as_object().get_type() 55 | } 56 | 57 | /// 'Unparse' the object converting it to a binary representation 58 | fn to_binary(&self) -> String { 59 | self.as_object().to_binary() 60 | } 61 | 62 | /// Return true if this is an operator object 63 | fn is_operator(&self) -> bool { 64 | self.as_object().is_operator() 65 | } 66 | 67 | /// Return true if this is a scalar object 68 | fn is_scalar(&self) -> bool { 69 | self.as_object().is_scalar() 70 | } 71 | 72 | /// Return true if this is an indirect object 73 | fn is_indirect(&self) -> bool { 74 | self.as_object().is_indirect() 75 | } 76 | 77 | /// Get boolean value 78 | fn as_bool(&self) -> bool { 79 | self.as_object().as_bool() 80 | } 81 | 82 | /// Get name value 83 | fn as_name(&self) -> String { 84 | self.as_object().as_name() 85 | } 86 | 87 | /// Get string value 88 | fn as_string(&self) -> String { 89 | self.as_object().as_string() 90 | } 91 | 92 | /// Get binary string value 93 | fn as_binary_string(&self) -> Vec { 94 | self.as_object().as_binary_string() 95 | } 96 | 97 | /// Get ID of the indirect object 98 | fn get_id(&self) -> u32 { 99 | self.as_object().get_id() 100 | } 101 | 102 | /// Get generation of the indirect object 103 | fn get_generation(&self) -> u32 { 104 | self.as_object().get_generation() 105 | } 106 | 107 | fn into_indirect(self) -> QPdfObject 108 | where 109 | Self: Sized + Into, 110 | { 111 | let obj: QPdfObject = self.into(); 112 | obj.into_indirect() 113 | } 114 | } 115 | 116 | /// This structure represents a single PDF object bound to the owning `QPdf`. 117 | pub struct QPdfObject { 118 | pub(crate) owner: QPdf, 119 | pub(crate) inner: qpdf_sys::qpdf_oh, 120 | } 121 | 122 | impl QPdfObject { 123 | pub(crate) fn new(owner: QPdf, inner: qpdf_sys::qpdf_oh) -> Self { 124 | QPdfObject { owner, inner } 125 | } 126 | } 127 | 128 | impl QPdfObjectLike for QPdfObject { 129 | fn as_object(&self) -> &QPdfObject { 130 | self 131 | } 132 | 133 | fn get_type(&self) -> QPdfObjectType { 134 | unsafe { QPdfObjectType::from_qpdf_enum(qpdf_sys::qpdf_oh_get_type_code(self.owner.inner(), self.inner)) } 135 | } 136 | 137 | fn to_binary(&self) -> String { 138 | unsafe { 139 | CStr::from_ptr(qpdf_sys::qpdf_oh_unparse_binary(self.owner.inner(), self.inner)) 140 | .to_string_lossy() 141 | .into_owned() 142 | } 143 | } 144 | 145 | fn is_operator(&self) -> bool { 146 | unsafe { qpdf_sys::qpdf_oh_is_operator(self.owner.inner(), self.inner) != 0 } 147 | } 148 | 149 | fn is_scalar(&self) -> bool { 150 | unsafe { qpdf_sys::qpdf_oh_is_scalar(self.owner.inner(), self.inner) != 0 } 151 | } 152 | 153 | fn is_indirect(&self) -> bool { 154 | unsafe { qpdf_sys::qpdf_oh_is_indirect(self.owner.inner(), self.inner) != 0 } 155 | } 156 | 157 | fn as_bool(&self) -> bool { 158 | unsafe { qpdf_sys::qpdf_oh_get_bool_value(self.owner.inner(), self.inner) != 0 } 159 | } 160 | 161 | fn as_name(&self) -> String { 162 | unsafe { 163 | CStr::from_ptr(qpdf_sys::qpdf_oh_get_name(self.owner.inner(), self.inner)) 164 | .to_string_lossy() 165 | .into_owned() 166 | } 167 | } 168 | 169 | fn as_string(&self) -> String { 170 | unsafe { 171 | CStr::from_ptr(qpdf_sys::qpdf_oh_get_utf8_value(self.owner.inner(), self.inner)) 172 | .to_string_lossy() 173 | .into_owned() 174 | } 175 | } 176 | 177 | fn as_binary_string(&self) -> Vec { 178 | unsafe { 179 | let mut length = 0; 180 | let data = qpdf_sys::qpdf_oh_get_binary_string_value(self.owner.inner(), self.inner, &mut length); 181 | slice::from_raw_parts(data as *const u8, length as _).to_vec() 182 | } 183 | } 184 | 185 | fn get_id(&self) -> u32 { 186 | unsafe { qpdf_sys::qpdf_oh_get_object_id(self.owner.inner(), self.inner) as _ } 187 | } 188 | 189 | fn get_generation(&self) -> u32 { 190 | unsafe { qpdf_sys::qpdf_oh_get_generation(self.owner.inner(), self.inner) as _ } 191 | } 192 | 193 | /// convert to indirect object 194 | fn into_indirect(self) -> QPdfObject { 195 | unsafe { 196 | QPdfObject::new( 197 | self.owner.clone(), 198 | qpdf_sys::qpdf_make_indirect_object(self.owner.inner(), self.inner), 199 | ) 200 | } 201 | } 202 | } 203 | 204 | impl AsRef for QPdfObject { 205 | fn as_ref(&self) -> &QPdfObject { 206 | self 207 | } 208 | } 209 | 210 | impl fmt::Debug for QPdfObject { 211 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 212 | write!(f, "QpdfObject {{ {self} }}") 213 | } 214 | } 215 | impl Clone for QPdfObject { 216 | fn clone(&self) -> Self { 217 | unsafe { 218 | QPdfObject { 219 | owner: self.owner.clone(), 220 | inner: qpdf_sys::qpdf_oh_new_object(self.owner.inner(), self.inner), 221 | } 222 | } 223 | } 224 | } 225 | 226 | impl PartialEq for QPdfObject { 227 | fn eq(&self, other: &Self) -> bool { 228 | self.inner == other.inner 229 | } 230 | } 231 | 232 | impl PartialOrd for QPdfObject { 233 | fn partial_cmp(&self, other: &Self) -> Option { 234 | self.inner.partial_cmp(&other.inner) 235 | } 236 | } 237 | 238 | impl Drop for QPdfObject { 239 | fn drop(&mut self) { 240 | unsafe { 241 | qpdf_sys::qpdf_oh_release(self.owner.inner(), self.inner); 242 | } 243 | } 244 | } 245 | 246 | impl fmt::Display for QPdfObject { 247 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 248 | unsafe { 249 | write!( 250 | f, 251 | "{}", 252 | CStr::from_ptr(qpdf_sys::qpdf_oh_unparse(self.owner.inner(), self.inner)).to_string_lossy() 253 | ) 254 | } 255 | } 256 | } 257 | -------------------------------------------------------------------------------- /qpdf-rs/src/scalar.rs: -------------------------------------------------------------------------------- 1 | use std::{ffi::CStr, fmt}; 2 | 3 | use crate::{QPdfObject, QPdfObjectLike}; 4 | 5 | /// QPdfScalar represents scalar objects such as integer and real 6 | pub struct QPdfScalar { 7 | inner: QPdfObject, 8 | } 9 | 10 | impl QPdfScalar { 11 | pub(crate) fn new(inner: QPdfObject) -> Self { 12 | Self { inner } 13 | } 14 | 15 | /// Get i64 value 16 | pub fn as_i64(&self) -> i64 { 17 | unsafe { qpdf_sys::qpdf_oh_get_int_value(self.inner.owner.inner(), self.inner.inner) } 18 | } 19 | 20 | /// Get u64 value 21 | pub fn as_u64(&self) -> u64 { 22 | unsafe { qpdf_sys::qpdf_oh_get_uint_value(self.inner.owner.inner(), self.inner.inner) } 23 | } 24 | 25 | /// Get i32 value 26 | pub fn as_i32(&self) -> i32 { 27 | unsafe { qpdf_sys::qpdf_oh_get_int_value_as_int(self.inner.owner.inner(), self.inner.inner) } 28 | } 29 | 30 | /// Get u32 value 31 | pub fn as_u32(&self) -> u32 { 32 | unsafe { qpdf_sys::qpdf_oh_get_uint_value_as_uint(self.inner.owner.inner(), self.inner.inner) } 33 | } 34 | 35 | /// Get numeric value 36 | pub fn as_f64(&self) -> f64 { 37 | unsafe { qpdf_sys::qpdf_oh_get_numeric_value(self.inner.owner.inner(), self.inner.inner) } 38 | } 39 | 40 | /// Get real value in string format 41 | pub fn as_real(&self) -> String { 42 | unsafe { 43 | CStr::from_ptr(qpdf_sys::qpdf_oh_get_real_value( 44 | self.inner.owner.inner(), 45 | self.inner.inner, 46 | )) 47 | .to_string_lossy() 48 | .into_owned() 49 | } 50 | } 51 | } 52 | 53 | impl QPdfObjectLike for QPdfScalar { 54 | fn as_object(&self) -> &QPdfObject { 55 | &self.inner 56 | } 57 | } 58 | 59 | impl From for QPdfScalar { 60 | fn from(obj: QPdfObject) -> Self { 61 | QPdfScalar::new(obj) 62 | } 63 | } 64 | 65 | impl From for QPdfObject { 66 | fn from(dict: QPdfScalar) -> Self { 67 | dict.inner 68 | } 69 | } 70 | 71 | impl AsRef for QPdfScalar { 72 | fn as_ref(&self) -> &QPdfObject { 73 | &self.inner 74 | } 75 | } 76 | 77 | impl fmt::Display for QPdfScalar { 78 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 79 | self.inner.fmt(f) 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /qpdf-rs/src/stream.rs: -------------------------------------------------------------------------------- 1 | use std::{fmt, ops::Deref, ptr, slice}; 2 | 3 | use crate::{QPdfDictionary, QPdfObject, QPdfObjectLike, Result}; 4 | 5 | /// Stream decoding level 6 | #[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Hash)] 7 | pub enum StreamDecodeLevel { 8 | None, 9 | Generalized, 10 | Specialized, 11 | All, 12 | } 13 | 14 | impl StreamDecodeLevel { 15 | pub(crate) fn as_qpdf_enum(&self) -> qpdf_sys::qpdf_stream_decode_level_e { 16 | match self { 17 | StreamDecodeLevel::None => qpdf_sys::qpdf_stream_decode_level_e_qpdf_dl_none, 18 | StreamDecodeLevel::Generalized => qpdf_sys::qpdf_stream_decode_level_e_qpdf_dl_generalized, 19 | StreamDecodeLevel::Specialized => qpdf_sys::qpdf_stream_decode_level_e_qpdf_dl_specialized, 20 | StreamDecodeLevel::All => qpdf_sys::qpdf_stream_decode_level_e_qpdf_dl_all, 21 | } 22 | } 23 | } 24 | 25 | /// Object stream mode 26 | #[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Hash)] 27 | pub enum ObjectStreamMode { 28 | Disable, 29 | Preserve, 30 | Generate, 31 | } 32 | 33 | impl ObjectStreamMode { 34 | pub(crate) fn as_qpdf_enum(&self) -> qpdf_sys::qpdf_object_stream_e { 35 | match self { 36 | ObjectStreamMode::Disable => qpdf_sys::qpdf_object_stream_e_qpdf_o_disable, 37 | ObjectStreamMode::Preserve => qpdf_sys::qpdf_object_stream_e_qpdf_o_preserve, 38 | ObjectStreamMode::Generate => qpdf_sys::qpdf_object_stream_e_qpdf_o_generate, 39 | } 40 | } 41 | } 42 | 43 | /// Object stream mode 44 | #[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Hash)] 45 | pub enum StreamDataMode { 46 | Uncompress, 47 | Preserve, 48 | Compress, 49 | } 50 | 51 | impl StreamDataMode { 52 | pub(crate) fn as_qpdf_enum(&self) -> qpdf_sys::qpdf_stream_data_e { 53 | match self { 54 | StreamDataMode::Uncompress => qpdf_sys::qpdf_stream_data_e_qpdf_s_uncompress, 55 | StreamDataMode::Preserve => qpdf_sys::qpdf_stream_data_e_qpdf_s_preserve, 56 | StreamDataMode::Compress => qpdf_sys::qpdf_stream_data_e_qpdf_s_compress, 57 | } 58 | } 59 | } 60 | 61 | /// QPdfStream represents a stream object 62 | pub struct QPdfStream { 63 | inner: QPdfObject, 64 | } 65 | 66 | impl QPdfStream { 67 | pub(crate) fn new(inner: QPdfObject) -> Self { 68 | QPdfStream { inner } 69 | } 70 | 71 | /// Replace stream data 72 | pub fn replace_data(&self, data: D, filter: F, params: P) 73 | where 74 | F: AsRef, 75 | P: AsRef, 76 | D: AsRef<[u8]>, 77 | { 78 | unsafe { 79 | qpdf_sys::qpdf_oh_replace_stream_data( 80 | self.inner.owner.inner(), 81 | self.inner.inner, 82 | data.as_ref().as_ptr() as _, 83 | data.as_ref().len() as _, 84 | filter.as_ref().inner, 85 | params.as_ref().inner, 86 | ); 87 | } 88 | } 89 | 90 | /// Get stream data 91 | pub fn get_data(&self, decode_level: StreamDecodeLevel) -> Result { 92 | unsafe { 93 | let mut filtered = 0; 94 | let mut len = 0; 95 | let mut buffer = ptr::null_mut(); 96 | qpdf_sys::qpdf_oh_get_stream_data( 97 | self.inner.owner.inner(), 98 | self.inner.inner, 99 | decode_level.as_qpdf_enum(), 100 | &mut filtered, 101 | &mut buffer, 102 | &mut len, 103 | ); 104 | self.inner 105 | .owner 106 | .last_error_or_then(|| QPdfStreamData::new(buffer, len as _)) 107 | } 108 | } 109 | 110 | /// Return a dictionary associated with the stream 111 | pub fn get_dictionary(&self) -> QPdfDictionary { 112 | unsafe { 113 | QPdfObject::new( 114 | self.inner.owner.clone(), 115 | qpdf_sys::qpdf_oh_get_dict(self.inner.owner.inner(), self.inner.inner), 116 | ) 117 | .into() 118 | } 119 | } 120 | } 121 | 122 | impl QPdfObjectLike for QPdfStream { 123 | fn as_object(&self) -> &QPdfObject { 124 | &self.inner 125 | } 126 | } 127 | 128 | impl From for QPdfStream { 129 | fn from(obj: QPdfObject) -> Self { 130 | QPdfStream::new(obj) 131 | } 132 | } 133 | 134 | impl From for QPdfObject { 135 | fn from(dict: QPdfStream) -> Self { 136 | dict.inner 137 | } 138 | } 139 | 140 | impl AsRef for QPdfStream { 141 | fn as_ref(&self) -> &QPdfObject { 142 | &self.inner 143 | } 144 | } 145 | 146 | impl fmt::Display for QPdfStream { 147 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 148 | self.inner.fmt(f) 149 | } 150 | } 151 | 152 | /// This structure holds an owned stream data. 153 | pub struct QPdfStreamData { 154 | data: *const u8, 155 | len: usize, 156 | } 157 | 158 | impl QPdfStreamData { 159 | pub(crate) fn new(data: *const u8, len: usize) -> Self { 160 | QPdfStreamData { data, len } 161 | } 162 | 163 | /// Get data length 164 | pub fn len(&self) -> usize { 165 | self.len 166 | } 167 | 168 | /// Return true if data has zero length 169 | pub fn is_empty(&self) -> bool { 170 | self.len() == 0 171 | } 172 | } 173 | 174 | impl AsRef<[u8]> for QPdfStreamData { 175 | fn as_ref(&self) -> &[u8] { 176 | unsafe { slice::from_raw_parts(self.data, self.len) } 177 | } 178 | } 179 | 180 | impl Deref for QPdfStreamData { 181 | type Target = [u8]; 182 | 183 | fn deref(&self) -> &Self::Target { 184 | self.as_ref() 185 | } 186 | } 187 | 188 | impl Drop for QPdfStreamData { 189 | fn drop(&mut self) { 190 | unsafe { 191 | libc::free(self.data as _); 192 | } 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /qpdf-rs/src/writer.rs: -------------------------------------------------------------------------------- 1 | use std::{ffi::CString, path::Path, slice}; 2 | 3 | use crate::{ObjectStreamMode, QPdf, Result, StreamDataMode, StreamDecodeLevel}; 4 | 5 | /// Print permissions 6 | #[derive(Debug, Default, Clone, Copy, Eq, PartialEq, PartialOrd)] 7 | pub enum PrintPermission { 8 | #[default] 9 | Full, 10 | Low, 11 | None, 12 | } 13 | 14 | impl From for qpdf_sys::qpdf_r3_print_e { 15 | fn from(value: PrintPermission) -> Self { 16 | match value { 17 | PrintPermission::Full => qpdf_sys::qpdf_r3_print_e_qpdf_r3p_full, 18 | PrintPermission::Low => qpdf_sys::qpdf_r3_print_e_qpdf_r3p_low, 19 | PrintPermission::None => qpdf_sys::qpdf_r3_print_e_qpdf_r3p_none, 20 | } 21 | } 22 | } 23 | 24 | /// Encryption using RC4 with key length of 40 bits 25 | #[derive(Debug, Default, Clone, Eq, PartialEq)] 26 | pub struct EncryptionParamsR2 { 27 | pub user_password: String, 28 | pub owner_password: String, 29 | pub allow_print: bool, 30 | pub allow_modify: bool, 31 | pub allow_extract: bool, 32 | pub allow_annotate: bool, 33 | } 34 | 35 | /// Encryption using RC4 with key length of 128 bits. 36 | /// Minimal PDF version: 1.4. 37 | #[derive(Debug, Default, Clone, Eq, PartialEq)] 38 | pub struct EncryptionParamsR3 { 39 | pub user_password: String, 40 | pub owner_password: String, 41 | pub allow_accessibility: bool, 42 | pub allow_extract: bool, 43 | pub allow_assemble: bool, 44 | pub allow_annotate_and_form: bool, 45 | pub allow_form_filling: bool, 46 | pub allow_modify_other: bool, 47 | pub allow_print: PrintPermission, 48 | } 49 | 50 | /// Encryption using RC4-128 or AES-256 algorithm and additional flag to encrypt metadata. 51 | /// Minimal PDF version: 1.5. 52 | #[derive(Debug, Default, Clone, Eq, PartialEq)] 53 | pub struct EncryptionParamsR4 { 54 | pub user_password: String, 55 | pub owner_password: String, 56 | pub allow_accessibility: bool, 57 | pub allow_extract: bool, 58 | pub allow_assemble: bool, 59 | pub allow_annotate_and_form: bool, 60 | pub allow_form_filling: bool, 61 | pub allow_modify_other: bool, 62 | pub allow_print: PrintPermission, 63 | pub encrypt_metadata: bool, 64 | pub use_aes: bool, 65 | } 66 | 67 | /// Encryption using AES-256 algorithm and additional flag to encrypt metadata 68 | /// Minimal PDF version: 1.7. Is required for PDF 2.0. 69 | #[derive(Debug, Default, Clone, Eq, PartialEq)] 70 | pub struct EncryptionParamsR6 { 71 | pub user_password: String, 72 | pub owner_password: String, 73 | pub allow_accessibility: bool, 74 | pub allow_extract: bool, 75 | pub allow_assemble: bool, 76 | pub allow_annotate_and_form: bool, 77 | pub allow_form_filling: bool, 78 | pub allow_modify_other: bool, 79 | pub allow_print: PrintPermission, 80 | pub encrypt_metadata: bool, 81 | } 82 | 83 | /// Encryption parameters selector 84 | #[derive(Debug, Clone, Eq, PartialEq)] 85 | pub enum EncryptionParams { 86 | /// R2 level, any PDF version 87 | #[cfg(feature = "legacy")] 88 | R2(EncryptionParamsR2), 89 | /// R3 level, PDF version >= 1.4 90 | #[cfg(feature = "legacy")] 91 | R3(EncryptionParamsR3), 92 | /// R4 level, PDF version >= 1.5 93 | #[cfg(feature = "legacy")] 94 | R4(EncryptionParamsR4), 95 | /// R6 level, PDF version >= 1.7 96 | R6(EncryptionParamsR6), 97 | } 98 | 99 | /// PDF writer with several customizable parameters 100 | pub struct QPdfWriter { 101 | owner: QPdf, 102 | compress_streams: Option, 103 | preserve_unreferenced_objects: Option, 104 | normalize_content: Option, 105 | preserve_encryption: Option, 106 | linearize: Option, 107 | static_id: Option, 108 | deterministic_id: Option, 109 | min_pdf_version: Option, 110 | force_pdf_version: Option, 111 | stream_decode_level: Option, 112 | object_stream_mode: Option, 113 | stream_data_mode: Option, 114 | encryption_params: Option, 115 | } 116 | 117 | impl QPdfWriter { 118 | pub(crate) fn new(owner: QPdf) -> Self { 119 | QPdfWriter { 120 | owner, 121 | compress_streams: None, 122 | preserve_unreferenced_objects: None, 123 | normalize_content: None, 124 | preserve_encryption: None, 125 | linearize: None, 126 | static_id: None, 127 | deterministic_id: None, 128 | min_pdf_version: None, 129 | force_pdf_version: None, 130 | stream_decode_level: None, 131 | object_stream_mode: None, 132 | stream_data_mode: None, 133 | encryption_params: None, 134 | } 135 | } 136 | 137 | fn process_params(&self) -> Result<()> { 138 | unsafe { 139 | if let Some(compress_streams) = self.compress_streams { 140 | qpdf_sys::qpdf_set_compress_streams(self.owner.inner(), compress_streams.into()); 141 | } 142 | 143 | if let Some(preserve_unreferenced_objects) = self.preserve_unreferenced_objects { 144 | qpdf_sys::qpdf_set_preserve_unreferenced_objects( 145 | self.owner.inner(), 146 | preserve_unreferenced_objects.into(), 147 | ); 148 | } 149 | 150 | if let Some(normalize_content) = self.normalize_content { 151 | qpdf_sys::qpdf_set_content_normalization(self.owner.inner(), normalize_content.into()); 152 | } 153 | 154 | if let Some(preserve_encryption) = self.preserve_encryption { 155 | qpdf_sys::qpdf_set_preserve_encryption(self.owner.inner(), preserve_encryption.into()); 156 | } 157 | 158 | if let Some(linearize) = self.linearize { 159 | qpdf_sys::qpdf_set_linearization(self.owner.inner(), linearize.into()); 160 | } 161 | 162 | if let Some(static_id) = self.static_id { 163 | qpdf_sys::qpdf_set_static_ID(self.owner.inner(), static_id.into()); 164 | } 165 | 166 | if let Some(deterministic_id) = self.deterministic_id { 167 | qpdf_sys::qpdf_set_deterministic_ID(self.owner.inner(), deterministic_id.into()); 168 | } 169 | 170 | if let Some(stream_decode_level) = self.stream_decode_level { 171 | qpdf_sys::qpdf_set_decode_level(self.owner.inner(), stream_decode_level.as_qpdf_enum()); 172 | } 173 | 174 | if let Some(object_stream_mode) = self.object_stream_mode { 175 | qpdf_sys::qpdf_set_object_stream_mode(self.owner.inner(), object_stream_mode.as_qpdf_enum()); 176 | } 177 | 178 | if let Some(stream_data_mode) = self.stream_data_mode { 179 | qpdf_sys::qpdf_set_stream_data_mode(self.owner.inner(), stream_data_mode.as_qpdf_enum()); 180 | } 181 | 182 | if let Some(ref version) = self.min_pdf_version { 183 | let version = CString::new(version.as_str())?; 184 | self.owner 185 | .wrap_ffi_call(|| qpdf_sys::qpdf_set_minimum_pdf_version(self.owner.inner(), version.as_ptr()))?; 186 | } 187 | if let Some(ref version) = self.force_pdf_version { 188 | let version = CString::new(version.as_str())?; 189 | self.owner 190 | .wrap_ffi_call(|| qpdf_sys::qpdf_force_pdf_version(self.owner.inner(), version.as_ptr()))?; 191 | } 192 | if let Some(ref params) = self.encryption_params { 193 | self.set_encryption_params(params)?; 194 | } 195 | } 196 | Ok(()) 197 | } 198 | 199 | fn set_encryption_params(&self, params: &EncryptionParams) -> Result<()> { 200 | match params { 201 | #[cfg(feature = "legacy")] 202 | EncryptionParams::R2(r2) => { 203 | let user_password = CString::new(r2.user_password.as_str())?; 204 | let owner_password = CString::new(r2.owner_password.as_str())?; 205 | unsafe { 206 | self.owner.wrap_ffi_call(|| { 207 | qpdf_sys::qpdf_set_r2_encryption_parameters_insecure( 208 | self.owner.inner(), 209 | user_password.as_ptr(), 210 | owner_password.as_ptr(), 211 | r2.allow_print.into(), 212 | r2.allow_modify.into(), 213 | r2.allow_extract.into(), 214 | r2.allow_annotate.into(), 215 | ) 216 | })?; 217 | } 218 | } 219 | #[cfg(feature = "legacy")] 220 | EncryptionParams::R3(r3) => { 221 | let user_password = CString::new(r3.user_password.as_str())?; 222 | let owner_password = CString::new(r3.owner_password.as_str())?; 223 | unsafe { 224 | self.owner.wrap_ffi_call(|| { 225 | qpdf_sys::qpdf_set_r3_encryption_parameters_insecure( 226 | self.owner.inner(), 227 | user_password.as_ptr(), 228 | owner_password.as_ptr(), 229 | r3.allow_accessibility.into(), 230 | r3.allow_extract.into(), 231 | r3.allow_assemble.into(), 232 | r3.allow_annotate_and_form.into(), 233 | r3.allow_form_filling.into(), 234 | r3.allow_modify_other.into(), 235 | r3.allow_print.into(), 236 | ) 237 | })?; 238 | } 239 | } 240 | #[cfg(feature = "legacy")] 241 | EncryptionParams::R4(r4) => { 242 | let user_password = CString::new(r4.user_password.as_str())?; 243 | let owner_password = CString::new(r4.owner_password.as_str())?; 244 | unsafe { 245 | self.owner.wrap_ffi_call(|| { 246 | qpdf_sys::qpdf_set_r4_encryption_parameters_insecure( 247 | self.owner.inner(), 248 | user_password.as_ptr(), 249 | owner_password.as_ptr(), 250 | r4.allow_accessibility.into(), 251 | r4.allow_extract.into(), 252 | r4.allow_assemble.into(), 253 | r4.allow_annotate_and_form.into(), 254 | r4.allow_form_filling.into(), 255 | r4.allow_modify_other.into(), 256 | r4.allow_print.into(), 257 | r4.encrypt_metadata.into(), 258 | r4.use_aes.into(), 259 | ) 260 | })?; 261 | } 262 | } 263 | EncryptionParams::R6(r6) => { 264 | let user_password = CString::new(r6.user_password.as_str())?; 265 | let owner_password = CString::new(r6.owner_password.as_str())?; 266 | unsafe { 267 | self.owner.wrap_ffi_call(|| { 268 | qpdf_sys::qpdf_set_r6_encryption_parameters2( 269 | self.owner.inner(), 270 | user_password.as_ptr(), 271 | owner_password.as_ptr(), 272 | r6.allow_accessibility.into(), 273 | r6.allow_extract.into(), 274 | r6.allow_assemble.into(), 275 | r6.allow_annotate_and_form.into(), 276 | r6.allow_form_filling.into(), 277 | r6.allow_modify_other.into(), 278 | r6.allow_print.into(), 279 | r6.encrypt_metadata.into(), 280 | ) 281 | })?; 282 | } 283 | } 284 | } 285 | Ok(()) 286 | } 287 | 288 | /// Write PDF to a file 289 | pub fn write

(&self, path: P) -> Result<()> 290 | where 291 | P: AsRef, 292 | { 293 | let filename = CString::new(path.as_ref().to_string_lossy().as_ref())?; 294 | 295 | let inner = self.owner.inner(); 296 | 297 | self.owner 298 | .wrap_ffi_call(|| unsafe { qpdf_sys::qpdf_init_write(inner, filename.as_ptr()) })?; 299 | 300 | self.process_params()?; 301 | 302 | self.owner.wrap_ffi_call(|| unsafe { qpdf_sys::qpdf_write(inner) }) 303 | } 304 | 305 | /// Write PDF to a memory and return it in a Vec 306 | pub fn write_to_memory(&self) -> Result> { 307 | let inner = self.owner.inner(); 308 | self.owner 309 | .wrap_ffi_call(|| unsafe { qpdf_sys::qpdf_init_write_memory(inner) })?; 310 | 311 | self.process_params()?; 312 | 313 | self.owner.wrap_ffi_call(|| unsafe { qpdf_sys::qpdf_write(inner) })?; 314 | 315 | let buffer = unsafe { qpdf_sys::qpdf_get_buffer(inner) }; 316 | let buffer_len = unsafe { qpdf_sys::qpdf_get_buffer_length(inner) }; 317 | 318 | unsafe { Ok(slice::from_raw_parts(buffer, buffer_len as _).to_vec()) } 319 | } 320 | 321 | /// Enable or disable stream compression 322 | pub fn compress_streams(&mut self, flag: bool) -> &mut Self { 323 | self.compress_streams = Some(flag); 324 | self 325 | } 326 | 327 | /// Set minimum PDF version 328 | pub fn minimum_pdf_version(&mut self, version: &str) -> &mut Self { 329 | self.min_pdf_version = Some(version.to_owned()); 330 | self 331 | } 332 | 333 | /// Force a specific PDF version 334 | pub fn force_pdf_version(&mut self, version: &str) -> &mut Self { 335 | self.force_pdf_version = Some(version.to_owned()); 336 | self 337 | } 338 | 339 | /// Set stream decode level 340 | pub fn stream_decode_level(&mut self, level: StreamDecodeLevel) -> &mut Self { 341 | self.stream_decode_level = Some(level); 342 | self 343 | } 344 | 345 | /// Set object stream mode 346 | pub fn object_stream_mode(&mut self, mode: ObjectStreamMode) -> &mut Self { 347 | self.object_stream_mode = Some(mode); 348 | self 349 | } 350 | 351 | /// Set stream data mode 352 | pub fn stream_data_mode(&mut self, mode: StreamDataMode) -> &mut Self { 353 | self.stream_data_mode = Some(mode); 354 | self 355 | } 356 | 357 | /// Set a flag indicating whether to preserve the unreferenced objects 358 | pub fn preserve_unreferenced_objects(&mut self, flag: bool) -> &mut Self { 359 | self.preserve_unreferenced_objects = Some(flag); 360 | self 361 | } 362 | 363 | /// Set a flag indicating whether to normalized contents 364 | pub fn normalize_content(&mut self, flag: bool) -> &mut Self { 365 | self.normalize_content = Some(flag); 366 | self 367 | } 368 | 369 | /// Preserve or remove encryption 370 | pub fn preserve_encryption(&mut self, flag: bool) -> &mut Self { 371 | self.preserve_encryption = Some(flag); 372 | self 373 | } 374 | 375 | /// Enable or disable linearization 376 | pub fn linearize(&mut self, flag: bool) -> &mut Self { 377 | self.linearize = Some(flag); 378 | self 379 | } 380 | 381 | // Enable or disable static ID 382 | pub fn static_id(&mut self, flag: bool) -> &mut Self { 383 | self.static_id = Some(flag); 384 | self 385 | } 386 | 387 | // Enable or disable deterministic ID 388 | pub fn deterministic_id(&mut self, flag: bool) -> &mut Self { 389 | self.deterministic_id = Some(flag); 390 | self 391 | } 392 | 393 | // Set encryption parameters 394 | pub fn encryption_params(&mut self, params: EncryptionParams) -> &mut Self { 395 | self.encryption_params = Some(params); 396 | self 397 | } 398 | } 399 | -------------------------------------------------------------------------------- /qpdf-rs/tests/data/encrypted.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ancwrd1/qpdf-rs/1f1340460271364753f862678db8efa39f4038cd/qpdf-rs/tests/data/encrypted.pdf -------------------------------------------------------------------------------- /qpdf-rs/tests/data/test.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ancwrd1/qpdf-rs/1f1340460271364753f862678db8efa39f4038cd/qpdf-rs/tests/data/test.pdf -------------------------------------------------------------------------------- /qpdf-rs/tests/test_qpdf.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashSet; 2 | 3 | use qpdf::*; 4 | 5 | fn load_pdf() -> QPdf { 6 | QPdf::read("tests/data/test.pdf").unwrap() 7 | } 8 | 9 | fn load_pdf_from_memory() -> QPdf { 10 | let data = std::fs::read("tests/data/test.pdf").unwrap(); 11 | QPdf::read_from_memory(data).unwrap() 12 | } 13 | 14 | #[test] 15 | fn test_qpdf_version() { 16 | let version = dbg!(QPdf::library_version()); 17 | assert!(!version.is_empty()); 18 | } 19 | 20 | #[test] 21 | fn test_writer() { 22 | let qpdf = load_pdf(); 23 | let mut writer = qpdf.writer(); 24 | writer 25 | .force_pdf_version("1.7") 26 | .normalize_content(true) 27 | .preserve_unreferenced_objects(true) 28 | .object_stream_mode(ObjectStreamMode::Disable) 29 | .linearize(true) 30 | .compress_streams(true) 31 | .stream_data_mode(StreamDataMode::Compress); 32 | 33 | let mem = writer.write_to_memory().unwrap(); 34 | 35 | let mem_pdf = QPdf::read_from_memory(mem).unwrap(); 36 | assert_eq!(mem_pdf.get_pdf_version(), "1.7"); 37 | assert!(mem_pdf.is_linearized()); 38 | } 39 | 40 | #[test] 41 | fn test_pdf_from_scratch() { 42 | let qpdf = QPdf::empty(); 43 | 44 | let font = qpdf 45 | .parse_object( 46 | r#"<< 47 | /Type /Font 48 | /Subtype /Type1 49 | /Name /F1 50 | /BaseFont /Helvetica 51 | /Encoding /WinAnsiEncoding 52 | >>"#, 53 | ) 54 | .unwrap(); 55 | 56 | let procset = qpdf.parse_object("[/PDF /Text]").unwrap(); 57 | let contents = qpdf.new_stream(b"BT /F1 15 Tf 72 720 Td (First Page) Tj ET\n"); 58 | let mediabox = qpdf.parse_object("[0 0 612 792]").unwrap(); 59 | let rfont = qpdf.new_dictionary_from([("/F1", font.into_indirect())]); 60 | let resources = qpdf.new_dictionary_from([("/ProcSet", procset.into_indirect()), ("/Font", rfont.into())]); 61 | let page = qpdf.new_dictionary_from([ 62 | ("/Type", qpdf.new_name("/Page")), 63 | ("/MediaBox", mediabox), 64 | ("/Contents", contents.into()), 65 | ("/Resources", resources.into()), 66 | ]); 67 | 68 | qpdf.add_page(page.into_indirect(), true).unwrap(); 69 | 70 | let mem = qpdf 71 | .writer() 72 | .static_id(true) 73 | .force_pdf_version("1.7") 74 | .normalize_content(true) 75 | .preserve_unreferenced_objects(true) 76 | .object_stream_mode(ObjectStreamMode::Preserve) 77 | .linearize(true) 78 | .compress_streams(true) 79 | .stream_data_mode(StreamDataMode::Preserve) 80 | .write_to_memory() 81 | .unwrap(); 82 | 83 | let mem_pdf = QPdf::read_from_memory(mem).unwrap(); 84 | assert_eq!(mem_pdf.get_pdf_version(), "1.7"); 85 | assert!(mem_pdf.is_linearized()); 86 | } 87 | 88 | #[test] 89 | fn test_qpdf_basic_objects() { 90 | let qpdf = QPdf::empty(); 91 | let obj = qpdf.new_bool(true); 92 | assert!(obj.get_type() == QPdfObjectType::Boolean && obj.as_bool()); 93 | assert_eq!(obj.to_string(), "true"); 94 | 95 | let obj = qpdf.new_name("foo"); 96 | assert!(obj.get_type() == QPdfObjectType::Name && obj.as_name() == "foo"); 97 | assert_eq!(obj.to_string(), "foo"); 98 | 99 | let obj = qpdf.new_integer(12_3456_7890); 100 | assert!(obj.is_scalar() && obj.as_i64() == 12_3456_7890); 101 | assert_eq!(obj.to_string(), "1234567890"); 102 | 103 | let obj = qpdf.new_null(); 104 | assert_eq!(obj.get_type(), QPdfObjectType::Null); 105 | assert_eq!(obj.to_string(), "null"); 106 | 107 | let obj = qpdf.new_real(1.2345, 3); 108 | assert_eq!(obj.as_real(), "1.234"); 109 | assert_eq!(obj.to_string(), "1.234"); 110 | 111 | let obj = qpdf.new_stream([]); 112 | assert_eq!(obj.get_type(), QPdfObjectType::Stream); 113 | assert_eq!(obj.to_string(), "3 0 R"); 114 | 115 | obj.get_dictionary().set("/Type", qpdf.new_name("/Stream")); 116 | 117 | let obj_id = obj.get_id(); 118 | assert_ne!(obj.into_indirect().get_id(), obj_id); 119 | } 120 | 121 | #[test] 122 | fn test_qpdf_streams() { 123 | let qpdf = QPdf::empty(); 124 | 125 | let obj = qpdf.get_object_by_id(1234, 1); 126 | assert!(obj.is_none()); 127 | 128 | let obj = qpdf.new_stream_with_dictionary([("/Type", qpdf.new_name("/Test"))], [1, 2, 3, 4]); 129 | assert_eq!(obj.get_type(), QPdfObjectType::Stream); 130 | 131 | let by_id: QPdfStream = qpdf 132 | .get_object_by_id(obj.get_id(), obj.get_generation()) 133 | .unwrap() 134 | .into(); 135 | println!("{by_id}"); 136 | 137 | let data = by_id.get_data(StreamDecodeLevel::None).unwrap(); 138 | assert_eq!(data.as_ref(), &[1, 2, 3, 4]); 139 | 140 | assert_eq!(obj.get_dictionary().get("/Type").unwrap().as_name(), "/Test"); 141 | 142 | let indirect = obj.into_indirect(); 143 | assert!(indirect.is_indirect()); 144 | assert_ne!(indirect.get_id(), 0); 145 | assert_eq!(indirect.get_generation(), 0); 146 | } 147 | 148 | #[test] 149 | fn test_parse_object() { 150 | let text = "<< /Type /Page /Resources << /XObject null >> /MediaBox null /Contents null >>"; 151 | let qpdf = QPdf::empty(); 152 | let obj = qpdf.parse_object(text).unwrap(); 153 | assert_eq!(obj.get_type(), QPdfObjectType::Dictionary); 154 | println!("{obj}"); 155 | println!("version: {}", qpdf.get_pdf_version()); 156 | } 157 | 158 | #[test] 159 | fn test_error() { 160 | let qpdf = QPdf::empty(); 161 | assert!(qpdf.get_page(0).is_none()); 162 | let result = qpdf.parse_object("<<--< /Type -- null >>"); 163 | assert!(result.is_err()); 164 | println!("{result:?}"); 165 | } 166 | 167 | #[test] 168 | fn test_array() { 169 | let qpdf = QPdf::empty(); 170 | let mut arr = qpdf.new_array(); 171 | arr.push(qpdf.new_integer(1)); 172 | arr.push(qpdf.new_integer(2)); 173 | arr.push(qpdf.new_integer(3)); 174 | assert_eq!(arr.to_string(), "[ 1 2 3 ]"); 175 | 176 | assert!(arr.get(10).is_none()); 177 | 178 | assert_eq!( 179 | arr.iter().map(|v| QPdfScalar::from(v).as_i32()).collect::>(), 180 | vec![1, 2, 3] 181 | ); 182 | 183 | arr.set(1, qpdf.new_integer(5)); 184 | assert_eq!(arr.to_string(), "[ 1 5 3 ]"); 185 | } 186 | 187 | #[test] 188 | fn test_dictionary() { 189 | let qpdf = QPdf::empty(); 190 | let dict: QPdfDictionary = qpdf 191 | .parse_object("<< /Type /Page /Resources << /XObject null >> /MediaBox [1 2 3 4] /Contents (hello) >>") 192 | .unwrap() 193 | .into(); 194 | 195 | let keys = dict.keys().into_iter().collect::>(); 196 | assert_eq!( 197 | keys, 198 | ["/Type", "/Resources", "/MediaBox", "/Contents"] 199 | .into_iter() 200 | .map(|s| s.to_owned()) 201 | .collect::>() 202 | ); 203 | 204 | assert_eq!(dict.get("/Type").unwrap().get_type(), QPdfObjectType::Name); 205 | assert_eq!(dict.get("/Contents").unwrap().as_string(), "hello"); 206 | 207 | let bval = qpdf.new_bool(true); 208 | dict.set("/MyKey", &bval); 209 | 210 | let setval = dict.get("/MyKey").unwrap(); 211 | assert!(setval.as_bool()); 212 | assert_ne!(bval, setval); 213 | 214 | dict.remove("/MyKey"); 215 | assert!(dict.get("/MyKey").is_none()); 216 | } 217 | 218 | #[test] 219 | fn test_strings() { 220 | let qpdf = QPdf::empty(); 221 | let bin_str = qpdf.new_binary_string([1, 2, 3, 4]); 222 | assert_eq!(bin_str.to_string(), "<01020304>"); 223 | 224 | let utf8_str = qpdf.new_utf8_string("привет"); 225 | assert_eq!(utf8_str.to_string(), ""); 226 | 227 | let plain_str = qpdf.new_string("hello"); 228 | assert_eq!(plain_str.to_string(), "(hello)"); 229 | assert_eq!(plain_str.to_binary(), "<68656c6c6f>"); 230 | } 231 | 232 | #[test] 233 | fn test_pdf_ops() { 234 | let qpdf = load_pdf_from_memory(); 235 | println!("{:?}", qpdf.get_pdf_version()); 236 | 237 | let trailer = qpdf.get_trailer().unwrap(); 238 | println!("trailer: {trailer}"); 239 | 240 | let root = qpdf.get_root().unwrap(); 241 | println!("root: {root}"); 242 | assert_eq!(root.get("/Type").unwrap().as_name(), "/Catalog"); 243 | assert!(root.has("/Pages")); 244 | 245 | let pages = qpdf.get_pages().unwrap(); 246 | assert_eq!(pages.len(), 2); 247 | 248 | for page in pages { 249 | let keys = page.keys(); 250 | assert!(!keys.is_empty()); 251 | println!("{keys:?}"); 252 | 253 | let data = page.get_page_content_data().unwrap(); 254 | println!("{}", String::from_utf8_lossy(data.as_ref())); 255 | 256 | qpdf.add_page(&page, false).unwrap(); 257 | } 258 | 259 | let buffer = qpdf.writer().write_to_memory().unwrap(); 260 | let saved_pdf = QPdf::read_from_memory(&buffer).unwrap(); 261 | assert_eq!(saved_pdf.get_num_pages().unwrap(), 4); 262 | 263 | let pages = saved_pdf.get_pages().unwrap(); 264 | for page in pages { 265 | saved_pdf.remove_page(&page).unwrap(); 266 | } 267 | assert_eq!(saved_pdf.get_num_pages().unwrap(), 0); 268 | } 269 | 270 | #[test] 271 | fn test_pdf_encrypted_read() { 272 | let qpdf = QPdf::read("tests/data/encrypted.pdf"); 273 | assert!(qpdf.is_err()); 274 | println!("{qpdf:?}"); 275 | 276 | let qpdf = QPdf::read_encrypted("tests/data/encrypted.pdf", "test"); 277 | assert!(qpdf.is_ok()); 278 | 279 | let data = std::fs::read("tests/data/encrypted.pdf").unwrap(); 280 | let qpdf = QPdf::read_from_memory_encrypted(data, "test"); 281 | assert!(qpdf.is_ok()); 282 | } 283 | 284 | fn test_pdf_encrypted_write(params: EncryptionParams) { 285 | let qpdf = QPdf::read("tests/data/test.pdf").unwrap(); 286 | 287 | let data = qpdf.writer().encryption_params(params).write_to_memory().unwrap(); 288 | 289 | let qpdf = QPdf::read_from_memory_encrypted(&data, "foo"); 290 | assert!(qpdf.is_ok()); 291 | 292 | let qpdf = QPdf::read_from_memory_encrypted(&data, "foo2"); 293 | assert!(qpdf.is_err()); 294 | } 295 | 296 | #[cfg(feature = "legacy")] 297 | #[test] 298 | fn test_pdf_encrypted_r2_write() { 299 | test_pdf_encrypted_write(EncryptionParams::R2(EncryptionParamsR2 { 300 | user_password: "foo".to_string(), 301 | owner_password: "foo".to_string(), 302 | allow_print: true, 303 | allow_modify: true, 304 | allow_extract: true, 305 | allow_annotate: true, 306 | })) 307 | } 308 | 309 | #[cfg(feature = "legacy")] 310 | #[test] 311 | fn test_pdf_encrypted_r3_write() { 312 | test_pdf_encrypted_write(EncryptionParams::R3(EncryptionParamsR3 { 313 | user_password: "foo".to_string(), 314 | owner_password: "foo".to_string(), 315 | allow_accessibility: true, 316 | allow_extract: true, 317 | allow_assemble: true, 318 | allow_annotate_and_form: true, 319 | allow_form_filling: true, 320 | allow_modify_other: true, 321 | allow_print: Default::default(), 322 | })) 323 | } 324 | 325 | #[cfg(feature = "legacy")] 326 | #[test] 327 | fn test_pdf_encrypted_r4_write() { 328 | test_pdf_encrypted_write(EncryptionParams::R4(EncryptionParamsR4 { 329 | user_password: "foo".to_string(), 330 | owner_password: "foo".to_string(), 331 | allow_accessibility: true, 332 | allow_extract: true, 333 | allow_assemble: true, 334 | allow_annotate_and_form: true, 335 | allow_form_filling: true, 336 | allow_modify_other: true, 337 | allow_print: Default::default(), 338 | encrypt_metadata: true, 339 | use_aes: true, 340 | })) 341 | } 342 | 343 | #[test] 344 | fn test_pdf_encrypted_r6_write() { 345 | test_pdf_encrypted_write(EncryptionParams::R6(EncryptionParamsR6 { 346 | user_password: "foo".to_string(), 347 | owner_password: "foo".to_string(), 348 | allow_accessibility: true, 349 | allow_extract: true, 350 | allow_assemble: true, 351 | allow_annotate_and_form: true, 352 | allow_form_filling: true, 353 | allow_modify_other: true, 354 | allow_print: Default::default(), 355 | encrypt_metadata: true, 356 | })) 357 | } 358 | 359 | #[test] 360 | fn test_foreign_objects() { 361 | let source = load_pdf_from_memory(); 362 | let sink = QPdf::empty(); 363 | 364 | let page = sink.copy_from_foreign(&source.get_pages().unwrap()[0]); 365 | drop(source); 366 | 367 | sink.add_page(page, false).unwrap(); 368 | 369 | // shouldn't crash 370 | sink.writer() 371 | .static_id(true) 372 | .force_pdf_version("1.7") 373 | .normalize_content(true) 374 | .preserve_unreferenced_objects(false) 375 | .object_stream_mode(ObjectStreamMode::Preserve) 376 | .compress_streams(false) 377 | .stream_data_mode(StreamDataMode::Preserve) 378 | .write_to_memory() 379 | .unwrap(); 380 | } 381 | 382 | #[test] 383 | fn test_foreign_pages() { 384 | let sink = QPdf::empty(); 385 | 386 | for source in [load_pdf_from_memory(), load_pdf_from_memory(), load_pdf_from_memory()] { 387 | source.get_pages().unwrap().iter().for_each(|p| { 388 | sink.add_page(p, false).unwrap(); 389 | }); 390 | } 391 | 392 | // shouldn't crash 393 | sink.writer().write_to_memory().unwrap(); 394 | } 395 | -------------------------------------------------------------------------------- /qpdf-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "qpdf-sys" 3 | description = "Rust bindings to QPDF C++ library via FFI and bindgen" 4 | version.workspace = true 5 | authors.workspace = true 6 | edition.workspace = true 7 | repository.workspace = true 8 | documentation.workspace = true 9 | readme.workspace = true 10 | keywords.workspace = true 11 | license.workspace = true 12 | exclude = [ 13 | 'qpdf/qpdf/*', 14 | 'qpdf/appimage/*', 15 | 'qpdf/examples/*', 16 | 'qpdf/fuzz/*', 17 | 'qpdf/libtests/*' 18 | ] 19 | 20 | [build-dependencies] 21 | cc = { version = "1", features = ["parallel"], optional = true } 22 | bindgen = "0.71" 23 | pkg-config = "0.3" 24 | 25 | [features] 26 | vendored = ["dep:cc"] 27 | 28 | [package.metadata.docs.rs] 29 | features = ["vendored"] 30 | -------------------------------------------------------------------------------- /qpdf-sys/README.md: -------------------------------------------------------------------------------- 1 | ../README.md -------------------------------------------------------------------------------- /qpdf-sys/bindings/armv7-unknown-linux-gnueabihf.rs: -------------------------------------------------------------------------------- 1 | /* automatically generated by rust-bindgen 0.70.1 */ 2 | 3 | pub const QPDF_MAJOR_VERSION: u32 = 12; 4 | pub const QPDF_MINOR_VERSION: u32 = 0; 5 | pub const QPDF_PATCH_VERSION: u32 = 0; 6 | pub const QPDF_VERSION: &[u8; 7] = b"12.0.0\0"; 7 | pub const _STRING_H: u32 = 1; 8 | pub const _FEATURES_H: u32 = 1; 9 | pub const _DEFAULT_SOURCE: u32 = 1; 10 | pub const __GLIBC_USE_ISOC2Y: u32 = 0; 11 | pub const __GLIBC_USE_ISOC23: u32 = 0; 12 | pub const __USE_ISOC11: u32 = 1; 13 | pub const __USE_ISOC99: u32 = 1; 14 | pub const __USE_ISOC95: u32 = 1; 15 | pub const __USE_POSIX_IMPLICITLY: u32 = 1; 16 | pub const _POSIX_SOURCE: u32 = 1; 17 | pub const _POSIX_C_SOURCE: u32 = 200809; 18 | pub const __USE_POSIX: u32 = 1; 19 | pub const __USE_POSIX2: u32 = 1; 20 | pub const __USE_POSIX199309: u32 = 1; 21 | pub const __USE_POSIX199506: u32 = 1; 22 | pub const __USE_XOPEN2K: u32 = 1; 23 | pub const __USE_XOPEN2K8: u32 = 1; 24 | pub const _ATFILE_SOURCE: u32 = 1; 25 | pub const __WORDSIZE: u32 = 32; 26 | pub const __WORDSIZE32_SIZE_ULONG: u32 = 0; 27 | pub const __WORDSIZE32_PTRDIFF_LONG: u32 = 0; 28 | pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1; 29 | pub const __TIMESIZE: u32 = 32; 30 | pub const __USE_MISC: u32 = 1; 31 | pub const __USE_ATFILE: u32 = 1; 32 | pub const __USE_FORTIFY_LEVEL: u32 = 0; 33 | pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0; 34 | pub const __GLIBC_USE_DEPRECATED_SCANF: u32 = 0; 35 | pub const __GLIBC_USE_C23_STRTOL: u32 = 0; 36 | pub const _STDC_PREDEF_H: u32 = 1; 37 | pub const __STDC_IEC_559__: u32 = 1; 38 | pub const __STDC_IEC_60559_BFP__: u32 = 201404; 39 | pub const __STDC_IEC_559_COMPLEX__: u32 = 1; 40 | pub const __STDC_IEC_60559_COMPLEX__: u32 = 201404; 41 | pub const __STDC_ISO_10646__: u32 = 201706; 42 | pub const __GNU_LIBRARY__: u32 = 6; 43 | pub const __GLIBC__: u32 = 2; 44 | pub const __GLIBC_MINOR__: u32 = 41; 45 | pub const _SYS_CDEFS_H: u32 = 1; 46 | pub const __glibc_c99_flexarr_available: u32 = 1; 47 | pub const __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI: u32 = 0; 48 | pub const __HAVE_GENERIC_SELECTION: u32 = 1; 49 | pub const __GLIBC_USE_LIB_EXT2: u32 = 0; 50 | pub const __GLIBC_USE_IEC_60559_BFP_EXT: u32 = 0; 51 | pub const __GLIBC_USE_IEC_60559_BFP_EXT_C23: u32 = 0; 52 | pub const __GLIBC_USE_IEC_60559_EXT: u32 = 0; 53 | pub const __GLIBC_USE_IEC_60559_FUNCS_EXT: u32 = 0; 54 | pub const __GLIBC_USE_IEC_60559_FUNCS_EXT_C23: u32 = 0; 55 | pub const __GLIBC_USE_IEC_60559_TYPES_EXT: u32 = 0; 56 | pub const _BITS_TYPES_LOCALE_T_H: u32 = 1; 57 | pub const _BITS_TYPES___LOCALE_T_H: u32 = 1; 58 | pub const _STRINGS_H: u32 = 1; 59 | pub const QPDF_SUCCESS: u32 = 0; 60 | pub const QPDF_WARNINGS: u32 = 1; 61 | pub const QPDF_ERRORS: u32 = 2; 62 | pub const QPDF_TRUE: u32 = 1; 63 | pub const QPDF_FALSE: u32 = 0; 64 | pub const qpdf_exit_code_e_qpdf_exit_success: qpdf_exit_code_e = 0; 65 | pub const qpdf_exit_code_e_qpdf_exit_error: qpdf_exit_code_e = 2; 66 | pub const qpdf_exit_code_e_qpdf_exit_warning: qpdf_exit_code_e = 3; 67 | pub const qpdf_exit_code_e_qpdf_exit_is_not_encrypted: qpdf_exit_code_e = 2; 68 | pub const qpdf_exit_code_e_qpdf_exit_correct_password: qpdf_exit_code_e = 3; 69 | pub type qpdf_exit_code_e = ::std::os::raw::c_uint; 70 | pub const qpdf_error_code_e_qpdf_e_success: qpdf_error_code_e = 0; 71 | pub const qpdf_error_code_e_qpdf_e_internal: qpdf_error_code_e = 1; 72 | pub const qpdf_error_code_e_qpdf_e_system: qpdf_error_code_e = 2; 73 | pub const qpdf_error_code_e_qpdf_e_unsupported: qpdf_error_code_e = 3; 74 | pub const qpdf_error_code_e_qpdf_e_password: qpdf_error_code_e = 4; 75 | pub const qpdf_error_code_e_qpdf_e_damaged_pdf: qpdf_error_code_e = 5; 76 | pub const qpdf_error_code_e_qpdf_e_pages: qpdf_error_code_e = 6; 77 | pub const qpdf_error_code_e_qpdf_e_object: qpdf_error_code_e = 7; 78 | pub const qpdf_error_code_e_qpdf_e_json: qpdf_error_code_e = 8; 79 | pub const qpdf_error_code_e_qpdf_e_linearization: qpdf_error_code_e = 9; 80 | pub type qpdf_error_code_e = ::std::os::raw::c_uint; 81 | pub const qpdf_object_type_e_ot_uninitialized: qpdf_object_type_e = 0; 82 | pub const qpdf_object_type_e_ot_reserved: qpdf_object_type_e = 1; 83 | pub const qpdf_object_type_e_ot_null: qpdf_object_type_e = 2; 84 | pub const qpdf_object_type_e_ot_boolean: qpdf_object_type_e = 3; 85 | pub const qpdf_object_type_e_ot_integer: qpdf_object_type_e = 4; 86 | pub const qpdf_object_type_e_ot_real: qpdf_object_type_e = 5; 87 | pub const qpdf_object_type_e_ot_string: qpdf_object_type_e = 6; 88 | pub const qpdf_object_type_e_ot_name: qpdf_object_type_e = 7; 89 | pub const qpdf_object_type_e_ot_array: qpdf_object_type_e = 8; 90 | pub const qpdf_object_type_e_ot_dictionary: qpdf_object_type_e = 9; 91 | pub const qpdf_object_type_e_ot_stream: qpdf_object_type_e = 10; 92 | pub const qpdf_object_type_e_ot_operator: qpdf_object_type_e = 11; 93 | pub const qpdf_object_type_e_ot_inlineimage: qpdf_object_type_e = 12; 94 | pub const qpdf_object_type_e_ot_unresolved: qpdf_object_type_e = 13; 95 | pub const qpdf_object_type_e_ot_destroyed: qpdf_object_type_e = 14; 96 | pub const qpdf_object_type_e_ot_reference: qpdf_object_type_e = 15; 97 | pub type qpdf_object_type_e = ::std::os::raw::c_uint; 98 | pub const qpdf_object_stream_e_qpdf_o_disable: qpdf_object_stream_e = 0; 99 | pub const qpdf_object_stream_e_qpdf_o_preserve: qpdf_object_stream_e = 1; 100 | pub const qpdf_object_stream_e_qpdf_o_generate: qpdf_object_stream_e = 2; 101 | pub type qpdf_object_stream_e = ::std::os::raw::c_uint; 102 | pub const qpdf_stream_data_e_qpdf_s_uncompress: qpdf_stream_data_e = 0; 103 | pub const qpdf_stream_data_e_qpdf_s_preserve: qpdf_stream_data_e = 1; 104 | pub const qpdf_stream_data_e_qpdf_s_compress: qpdf_stream_data_e = 2; 105 | pub type qpdf_stream_data_e = ::std::os::raw::c_uint; 106 | pub const qpdf_stream_encode_flags_e_qpdf_ef_compress: qpdf_stream_encode_flags_e = 1; 107 | pub const qpdf_stream_encode_flags_e_qpdf_ef_normalize: qpdf_stream_encode_flags_e = 2; 108 | pub type qpdf_stream_encode_flags_e = ::std::os::raw::c_uint; 109 | pub const qpdf_stream_decode_level_e_qpdf_dl_none: qpdf_stream_decode_level_e = 0; 110 | pub const qpdf_stream_decode_level_e_qpdf_dl_generalized: qpdf_stream_decode_level_e = 1; 111 | pub const qpdf_stream_decode_level_e_qpdf_dl_specialized: qpdf_stream_decode_level_e = 2; 112 | pub const qpdf_stream_decode_level_e_qpdf_dl_all: qpdf_stream_decode_level_e = 3; 113 | pub type qpdf_stream_decode_level_e = ::std::os::raw::c_uint; 114 | pub const qpdf_json_stream_data_e_qpdf_sj_none: qpdf_json_stream_data_e = 0; 115 | pub const qpdf_json_stream_data_e_qpdf_sj_inline: qpdf_json_stream_data_e = 1; 116 | pub const qpdf_json_stream_data_e_qpdf_sj_file: qpdf_json_stream_data_e = 2; 117 | pub type qpdf_json_stream_data_e = ::std::os::raw::c_uint; 118 | pub const qpdf_r3_print_e_qpdf_r3p_full: qpdf_r3_print_e = 0; 119 | pub const qpdf_r3_print_e_qpdf_r3p_low: qpdf_r3_print_e = 1; 120 | pub const qpdf_r3_print_e_qpdf_r3p_none: qpdf_r3_print_e = 2; 121 | pub type qpdf_r3_print_e = ::std::os::raw::c_uint; 122 | pub const qpdf_r3_modify_e_qpdf_r3m_all: qpdf_r3_modify_e = 0; 123 | pub const qpdf_r3_modify_e_qpdf_r3m_annotate: qpdf_r3_modify_e = 1; 124 | pub const qpdf_r3_modify_e_qpdf_r3m_form: qpdf_r3_modify_e = 2; 125 | pub const qpdf_r3_modify_e_qpdf_r3m_assembly: qpdf_r3_modify_e = 3; 126 | pub const qpdf_r3_modify_e_qpdf_r3m_none: qpdf_r3_modify_e = 4; 127 | pub type qpdf_r3_modify_e = ::std::os::raw::c_uint; 128 | pub const pdf_form_field_flag_e_ff_all_read_only: pdf_form_field_flag_e = 1; 129 | pub const pdf_form_field_flag_e_ff_all_required: pdf_form_field_flag_e = 2; 130 | pub const pdf_form_field_flag_e_ff_all_no_export: pdf_form_field_flag_e = 4; 131 | pub const pdf_form_field_flag_e_ff_btn_no_toggle_off: pdf_form_field_flag_e = 16384; 132 | pub const pdf_form_field_flag_e_ff_btn_radio: pdf_form_field_flag_e = 32768; 133 | pub const pdf_form_field_flag_e_ff_btn_pushbutton: pdf_form_field_flag_e = 65536; 134 | pub const pdf_form_field_flag_e_ff_btn_radios_in_unison: pdf_form_field_flag_e = 131072; 135 | pub const pdf_form_field_flag_e_ff_tx_multiline: pdf_form_field_flag_e = 4096; 136 | pub const pdf_form_field_flag_e_ff_tx_password: pdf_form_field_flag_e = 8192; 137 | pub const pdf_form_field_flag_e_ff_tx_file_select: pdf_form_field_flag_e = 1048576; 138 | pub const pdf_form_field_flag_e_ff_tx_do_not_spell_check: pdf_form_field_flag_e = 4194304; 139 | pub const pdf_form_field_flag_e_ff_tx_do_not_scroll: pdf_form_field_flag_e = 8388608; 140 | pub const pdf_form_field_flag_e_ff_tx_comb: pdf_form_field_flag_e = 16777216; 141 | pub const pdf_form_field_flag_e_ff_tx_rich_text: pdf_form_field_flag_e = 33554432; 142 | pub const pdf_form_field_flag_e_ff_ch_combo: pdf_form_field_flag_e = 131072; 143 | pub const pdf_form_field_flag_e_ff_ch_edit: pdf_form_field_flag_e = 262144; 144 | pub const pdf_form_field_flag_e_ff_ch_sort: pdf_form_field_flag_e = 524288; 145 | pub const pdf_form_field_flag_e_ff_ch_multi_select: pdf_form_field_flag_e = 2097152; 146 | pub const pdf_form_field_flag_e_ff_ch_do_not_spell_check: pdf_form_field_flag_e = 4194304; 147 | pub const pdf_form_field_flag_e_ff_ch_commit_on_sel_change: pdf_form_field_flag_e = 67108864; 148 | pub type pdf_form_field_flag_e = ::std::os::raw::c_uint; 149 | pub const pdf_annotation_flag_e_an_invisible: pdf_annotation_flag_e = 1; 150 | pub const pdf_annotation_flag_e_an_hidden: pdf_annotation_flag_e = 2; 151 | pub const pdf_annotation_flag_e_an_print: pdf_annotation_flag_e = 4; 152 | pub const pdf_annotation_flag_e_an_no_zoom: pdf_annotation_flag_e = 8; 153 | pub const pdf_annotation_flag_e_an_no_rotate: pdf_annotation_flag_e = 16; 154 | pub const pdf_annotation_flag_e_an_no_view: pdf_annotation_flag_e = 32; 155 | pub const pdf_annotation_flag_e_an_read_only: pdf_annotation_flag_e = 64; 156 | pub const pdf_annotation_flag_e_an_locked: pdf_annotation_flag_e = 128; 157 | pub const pdf_annotation_flag_e_an_toggle_no_view: pdf_annotation_flag_e = 256; 158 | pub const pdf_annotation_flag_e_an_locked_contents: pdf_annotation_flag_e = 512; 159 | pub type pdf_annotation_flag_e = ::std::os::raw::c_uint; 160 | pub const qpdf_encryption_status_e_qpdf_es_encrypted: qpdf_encryption_status_e = 1; 161 | pub const qpdf_encryption_status_e_qpdf_es_password_incorrect: qpdf_encryption_status_e = 2; 162 | pub type qpdf_encryption_status_e = ::std::os::raw::c_uint; 163 | pub const qpdf_page_label_e_pl_none: qpdf_page_label_e = 0; 164 | pub const qpdf_page_label_e_pl_digits: qpdf_page_label_e = 1; 165 | pub const qpdf_page_label_e_pl_alpha_lower: qpdf_page_label_e = 2; 166 | pub const qpdf_page_label_e_pl_alpha_upper: qpdf_page_label_e = 3; 167 | pub const qpdf_page_label_e_pl_roman_lower: qpdf_page_label_e = 4; 168 | pub const qpdf_page_label_e_pl_roman_upper: qpdf_page_label_e = 5; 169 | pub type qpdf_page_label_e = ::std::os::raw::c_uint; 170 | pub type qpdf_offset_t = ::std::os::raw::c_longlong; 171 | pub type wchar_t = ::std::os::raw::c_uint; 172 | #[repr(C)] 173 | #[derive(Debug, Copy, Clone)] 174 | pub struct max_align_t { 175 | pub __clang_max_align_nonce1: ::std::os::raw::c_longlong, 176 | pub __clang_max_align_nonce2: f64, 177 | } 178 | #[allow(clippy::unnecessary_operation, clippy::identity_op)] 179 | const _: () = { 180 | ["Size of max_align_t"][::std::mem::size_of::() - 16usize]; 181 | ["Alignment of max_align_t"][::std::mem::align_of::() - 8usize]; 182 | ["Offset of field: max_align_t::__clang_max_align_nonce1"] 183 | [::std::mem::offset_of!(max_align_t, __clang_max_align_nonce1) - 0usize]; 184 | ["Offset of field: max_align_t::__clang_max_align_nonce2"] 185 | [::std::mem::offset_of!(max_align_t, __clang_max_align_nonce2) - 8usize]; 186 | }; 187 | #[repr(C)] 188 | #[derive(Debug, Copy, Clone)] 189 | pub struct _qpdflogger_handle { 190 | _unused: [u8; 0], 191 | } 192 | pub type qpdflogger_handle = *mut _qpdflogger_handle; 193 | extern "C" { 194 | pub fn qpdflogger_default_logger() -> qpdflogger_handle; 195 | } 196 | extern "C" { 197 | pub fn qpdflogger_create() -> qpdflogger_handle; 198 | } 199 | extern "C" { 200 | pub fn qpdflogger_cleanup(l: *mut qpdflogger_handle); 201 | } 202 | pub const qpdf_log_dest_e_qpdf_log_dest_default: qpdf_log_dest_e = 0; 203 | pub const qpdf_log_dest_e_qpdf_log_dest_stdout: qpdf_log_dest_e = 1; 204 | pub const qpdf_log_dest_e_qpdf_log_dest_stderr: qpdf_log_dest_e = 2; 205 | pub const qpdf_log_dest_e_qpdf_log_dest_discard: qpdf_log_dest_e = 3; 206 | pub const qpdf_log_dest_e_qpdf_log_dest_custom: qpdf_log_dest_e = 4; 207 | pub type qpdf_log_dest_e = ::std::os::raw::c_uint; 208 | pub type qpdf_log_fn_t = ::std::option::Option< 209 | unsafe extern "C" fn( 210 | data: *const ::std::os::raw::c_char, 211 | len: usize, 212 | udata: *mut ::std::os::raw::c_void, 213 | ) -> ::std::os::raw::c_int, 214 | >; 215 | extern "C" { 216 | pub fn qpdflogger_set_info( 217 | l: qpdflogger_handle, 218 | dest: qpdf_log_dest_e, 219 | fn_: qpdf_log_fn_t, 220 | udata: *mut ::std::os::raw::c_void, 221 | ); 222 | } 223 | extern "C" { 224 | pub fn qpdflogger_set_warn( 225 | l: qpdflogger_handle, 226 | dest: qpdf_log_dest_e, 227 | fn_: qpdf_log_fn_t, 228 | udata: *mut ::std::os::raw::c_void, 229 | ); 230 | } 231 | extern "C" { 232 | pub fn qpdflogger_set_error( 233 | l: qpdflogger_handle, 234 | dest: qpdf_log_dest_e, 235 | fn_: qpdf_log_fn_t, 236 | udata: *mut ::std::os::raw::c_void, 237 | ); 238 | } 239 | extern "C" { 240 | pub fn qpdflogger_set_save( 241 | l: qpdflogger_handle, 242 | dest: qpdf_log_dest_e, 243 | fn_: qpdf_log_fn_t, 244 | udata: *mut ::std::os::raw::c_void, 245 | only_if_not_set: ::std::os::raw::c_int, 246 | ); 247 | } 248 | extern "C" { 249 | pub fn qpdflogger_save_to_standard_output(l: qpdflogger_handle, only_if_not_set: ::std::os::raw::c_int); 250 | } 251 | extern "C" { 252 | pub fn qpdflogger_equal(l1: qpdflogger_handle, l2: qpdflogger_handle) -> ::std::os::raw::c_int; 253 | } 254 | extern "C" { 255 | pub fn memcpy( 256 | __dest: *mut ::std::os::raw::c_void, 257 | __src: *const ::std::os::raw::c_void, 258 | __n: ::std::os::raw::c_uint, 259 | ) -> *mut ::std::os::raw::c_void; 260 | } 261 | extern "C" { 262 | pub fn memmove( 263 | __dest: *mut ::std::os::raw::c_void, 264 | __src: *const ::std::os::raw::c_void, 265 | __n: ::std::os::raw::c_uint, 266 | ) -> *mut ::std::os::raw::c_void; 267 | } 268 | extern "C" { 269 | pub fn memccpy( 270 | __dest: *mut ::std::os::raw::c_void, 271 | __src: *const ::std::os::raw::c_void, 272 | __c: ::std::os::raw::c_int, 273 | __n: ::std::os::raw::c_uint, 274 | ) -> *mut ::std::os::raw::c_void; 275 | } 276 | extern "C" { 277 | pub fn memset( 278 | __s: *mut ::std::os::raw::c_void, 279 | __c: ::std::os::raw::c_int, 280 | __n: ::std::os::raw::c_uint, 281 | ) -> *mut ::std::os::raw::c_void; 282 | } 283 | extern "C" { 284 | pub fn memcmp( 285 | __s1: *const ::std::os::raw::c_void, 286 | __s2: *const ::std::os::raw::c_void, 287 | __n: ::std::os::raw::c_uint, 288 | ) -> ::std::os::raw::c_int; 289 | } 290 | extern "C" { 291 | pub fn __memcmpeq( 292 | __s1: *const ::std::os::raw::c_void, 293 | __s2: *const ::std::os::raw::c_void, 294 | __n: usize, 295 | ) -> ::std::os::raw::c_int; 296 | } 297 | extern "C" { 298 | pub fn memchr( 299 | __s: *const ::std::os::raw::c_void, 300 | __c: ::std::os::raw::c_int, 301 | __n: ::std::os::raw::c_uint, 302 | ) -> *mut ::std::os::raw::c_void; 303 | } 304 | extern "C" { 305 | pub fn strcpy( 306 | __dest: *mut ::std::os::raw::c_char, 307 | __src: *const ::std::os::raw::c_char, 308 | ) -> *mut ::std::os::raw::c_char; 309 | } 310 | extern "C" { 311 | pub fn strncpy( 312 | __dest: *mut ::std::os::raw::c_char, 313 | __src: *const ::std::os::raw::c_char, 314 | __n: ::std::os::raw::c_uint, 315 | ) -> *mut ::std::os::raw::c_char; 316 | } 317 | extern "C" { 318 | pub fn strcat( 319 | __dest: *mut ::std::os::raw::c_char, 320 | __src: *const ::std::os::raw::c_char, 321 | ) -> *mut ::std::os::raw::c_char; 322 | } 323 | extern "C" { 324 | pub fn strncat( 325 | __dest: *mut ::std::os::raw::c_char, 326 | __src: *const ::std::os::raw::c_char, 327 | __n: ::std::os::raw::c_uint, 328 | ) -> *mut ::std::os::raw::c_char; 329 | } 330 | extern "C" { 331 | pub fn strcmp(__s1: *const ::std::os::raw::c_char, __s2: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; 332 | } 333 | extern "C" { 334 | pub fn strncmp( 335 | __s1: *const ::std::os::raw::c_char, 336 | __s2: *const ::std::os::raw::c_char, 337 | __n: ::std::os::raw::c_uint, 338 | ) -> ::std::os::raw::c_int; 339 | } 340 | extern "C" { 341 | pub fn strcoll(__s1: *const ::std::os::raw::c_char, __s2: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; 342 | } 343 | extern "C" { 344 | pub fn strxfrm( 345 | __dest: *mut ::std::os::raw::c_char, 346 | __src: *const ::std::os::raw::c_char, 347 | __n: ::std::os::raw::c_uint, 348 | ) -> ::std::os::raw::c_uint; 349 | } 350 | #[repr(C)] 351 | #[derive(Debug, Copy, Clone)] 352 | pub struct __locale_struct { 353 | pub __locales: [*mut __locale_data; 13usize], 354 | pub __ctype_b: *const ::std::os::raw::c_ushort, 355 | pub __ctype_tolower: *const ::std::os::raw::c_int, 356 | pub __ctype_toupper: *const ::std::os::raw::c_int, 357 | pub __names: [*const ::std::os::raw::c_char; 13usize], 358 | } 359 | #[allow(clippy::unnecessary_operation, clippy::identity_op)] 360 | const _: () = { 361 | ["Size of __locale_struct"][::std::mem::size_of::<__locale_struct>() - 116usize]; 362 | ["Alignment of __locale_struct"][::std::mem::align_of::<__locale_struct>() - 4usize]; 363 | ["Offset of field: __locale_struct::__locales"][::std::mem::offset_of!(__locale_struct, __locales) - 0usize]; 364 | ["Offset of field: __locale_struct::__ctype_b"][::std::mem::offset_of!(__locale_struct, __ctype_b) - 52usize]; 365 | ["Offset of field: __locale_struct::__ctype_tolower"] 366 | [::std::mem::offset_of!(__locale_struct, __ctype_tolower) - 56usize]; 367 | ["Offset of field: __locale_struct::__ctype_toupper"] 368 | [::std::mem::offset_of!(__locale_struct, __ctype_toupper) - 60usize]; 369 | ["Offset of field: __locale_struct::__names"][::std::mem::offset_of!(__locale_struct, __names) - 64usize]; 370 | }; 371 | pub type __locale_t = *mut __locale_struct; 372 | pub type locale_t = __locale_t; 373 | extern "C" { 374 | pub fn strcoll_l( 375 | __s1: *const ::std::os::raw::c_char, 376 | __s2: *const ::std::os::raw::c_char, 377 | __l: locale_t, 378 | ) -> ::std::os::raw::c_int; 379 | } 380 | extern "C" { 381 | pub fn strxfrm_l( 382 | __dest: *mut ::std::os::raw::c_char, 383 | __src: *const ::std::os::raw::c_char, 384 | __n: usize, 385 | __l: locale_t, 386 | ) -> usize; 387 | } 388 | extern "C" { 389 | pub fn strdup(__s: *const ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char; 390 | } 391 | extern "C" { 392 | pub fn strndup(__string: *const ::std::os::raw::c_char, __n: ::std::os::raw::c_uint) 393 | -> *mut ::std::os::raw::c_char; 394 | } 395 | extern "C" { 396 | pub fn strchr(__s: *const ::std::os::raw::c_char, __c: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; 397 | } 398 | extern "C" { 399 | pub fn strrchr(__s: *const ::std::os::raw::c_char, __c: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; 400 | } 401 | extern "C" { 402 | pub fn strchrnul(__s: *const ::std::os::raw::c_char, __c: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; 403 | } 404 | extern "C" { 405 | pub fn strcspn( 406 | __s: *const ::std::os::raw::c_char, 407 | __reject: *const ::std::os::raw::c_char, 408 | ) -> ::std::os::raw::c_uint; 409 | } 410 | extern "C" { 411 | pub fn strspn( 412 | __s: *const ::std::os::raw::c_char, 413 | __accept: *const ::std::os::raw::c_char, 414 | ) -> ::std::os::raw::c_uint; 415 | } 416 | extern "C" { 417 | pub fn strpbrk( 418 | __s: *const ::std::os::raw::c_char, 419 | __accept: *const ::std::os::raw::c_char, 420 | ) -> *mut ::std::os::raw::c_char; 421 | } 422 | extern "C" { 423 | pub fn strstr( 424 | __haystack: *const ::std::os::raw::c_char, 425 | __needle: *const ::std::os::raw::c_char, 426 | ) -> *mut ::std::os::raw::c_char; 427 | } 428 | extern "C" { 429 | pub fn strtok( 430 | __s: *mut ::std::os::raw::c_char, 431 | __delim: *const ::std::os::raw::c_char, 432 | ) -> *mut ::std::os::raw::c_char; 433 | } 434 | extern "C" { 435 | pub fn __strtok_r( 436 | __s: *mut ::std::os::raw::c_char, 437 | __delim: *const ::std::os::raw::c_char, 438 | __save_ptr: *mut *mut ::std::os::raw::c_char, 439 | ) -> *mut ::std::os::raw::c_char; 440 | } 441 | extern "C" { 442 | pub fn strtok_r( 443 | __s: *mut ::std::os::raw::c_char, 444 | __delim: *const ::std::os::raw::c_char, 445 | __save_ptr: *mut *mut ::std::os::raw::c_char, 446 | ) -> *mut ::std::os::raw::c_char; 447 | } 448 | extern "C" { 449 | pub fn strcasestr( 450 | __haystack: *const ::std::os::raw::c_char, 451 | __needle: *const ::std::os::raw::c_char, 452 | ) -> *mut ::std::os::raw::c_char; 453 | } 454 | extern "C" { 455 | pub fn memmem( 456 | __haystack: *const ::std::os::raw::c_void, 457 | __haystacklen: usize, 458 | __needle: *const ::std::os::raw::c_void, 459 | __needlelen: usize, 460 | ) -> *mut ::std::os::raw::c_void; 461 | } 462 | extern "C" { 463 | pub fn __mempcpy( 464 | __dest: *mut ::std::os::raw::c_void, 465 | __src: *const ::std::os::raw::c_void, 466 | __n: usize, 467 | ) -> *mut ::std::os::raw::c_void; 468 | } 469 | extern "C" { 470 | pub fn mempcpy( 471 | __dest: *mut ::std::os::raw::c_void, 472 | __src: *const ::std::os::raw::c_void, 473 | __n: ::std::os::raw::c_uint, 474 | ) -> *mut ::std::os::raw::c_void; 475 | } 476 | extern "C" { 477 | pub fn strlen(__s: *const ::std::os::raw::c_char) -> ::std::os::raw::c_uint; 478 | } 479 | extern "C" { 480 | pub fn strnlen(__string: *const ::std::os::raw::c_char, __maxlen: usize) -> usize; 481 | } 482 | extern "C" { 483 | pub fn strerror(__errnum: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; 484 | } 485 | extern "C" { 486 | #[link_name = "\u{1}__xpg_strerror_r"] 487 | pub fn strerror_r( 488 | __errnum: ::std::os::raw::c_int, 489 | __buf: *mut ::std::os::raw::c_char, 490 | __buflen: usize, 491 | ) -> ::std::os::raw::c_int; 492 | } 493 | extern "C" { 494 | pub fn strerror_l(__errnum: ::std::os::raw::c_int, __l: locale_t) -> *mut ::std::os::raw::c_char; 495 | } 496 | extern "C" { 497 | pub fn bcmp( 498 | __s1: *const ::std::os::raw::c_void, 499 | __s2: *const ::std::os::raw::c_void, 500 | __n: ::std::os::raw::c_uint, 501 | ) -> ::std::os::raw::c_int; 502 | } 503 | extern "C" { 504 | pub fn bcopy( 505 | __src: *const ::std::os::raw::c_void, 506 | __dest: *mut ::std::os::raw::c_void, 507 | __n: ::std::os::raw::c_uint, 508 | ); 509 | } 510 | extern "C" { 511 | pub fn bzero(__s: *mut ::std::os::raw::c_void, __n: ::std::os::raw::c_uint); 512 | } 513 | extern "C" { 514 | pub fn index(__s: *const ::std::os::raw::c_char, __c: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; 515 | } 516 | extern "C" { 517 | pub fn rindex(__s: *const ::std::os::raw::c_char, __c: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; 518 | } 519 | extern "C" { 520 | pub fn ffs(__i: ::std::os::raw::c_int) -> ::std::os::raw::c_int; 521 | } 522 | extern "C" { 523 | pub fn ffsl(__l: ::std::os::raw::c_long) -> ::std::os::raw::c_int; 524 | } 525 | extern "C" { 526 | pub fn ffsll(__ll: ::std::os::raw::c_longlong) -> ::std::os::raw::c_int; 527 | } 528 | extern "C" { 529 | pub fn strcasecmp( 530 | __s1: *const ::std::os::raw::c_char, 531 | __s2: *const ::std::os::raw::c_char, 532 | ) -> ::std::os::raw::c_int; 533 | } 534 | extern "C" { 535 | pub fn strncasecmp( 536 | __s1: *const ::std::os::raw::c_char, 537 | __s2: *const ::std::os::raw::c_char, 538 | __n: ::std::os::raw::c_uint, 539 | ) -> ::std::os::raw::c_int; 540 | } 541 | extern "C" { 542 | pub fn strcasecmp_l( 543 | __s1: *const ::std::os::raw::c_char, 544 | __s2: *const ::std::os::raw::c_char, 545 | __loc: locale_t, 546 | ) -> ::std::os::raw::c_int; 547 | } 548 | extern "C" { 549 | pub fn strncasecmp_l( 550 | __s1: *const ::std::os::raw::c_char, 551 | __s2: *const ::std::os::raw::c_char, 552 | __n: usize, 553 | __loc: locale_t, 554 | ) -> ::std::os::raw::c_int; 555 | } 556 | extern "C" { 557 | pub fn explicit_bzero(__s: *mut ::std::os::raw::c_void, __n: usize); 558 | } 559 | extern "C" { 560 | pub fn strsep( 561 | __stringp: *mut *mut ::std::os::raw::c_char, 562 | __delim: *const ::std::os::raw::c_char, 563 | ) -> *mut ::std::os::raw::c_char; 564 | } 565 | extern "C" { 566 | pub fn strsignal(__sig: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; 567 | } 568 | extern "C" { 569 | pub fn __stpcpy( 570 | __dest: *mut ::std::os::raw::c_char, 571 | __src: *const ::std::os::raw::c_char, 572 | ) -> *mut ::std::os::raw::c_char; 573 | } 574 | extern "C" { 575 | pub fn stpcpy( 576 | __dest: *mut ::std::os::raw::c_char, 577 | __src: *const ::std::os::raw::c_char, 578 | ) -> *mut ::std::os::raw::c_char; 579 | } 580 | extern "C" { 581 | pub fn __stpncpy( 582 | __dest: *mut ::std::os::raw::c_char, 583 | __src: *const ::std::os::raw::c_char, 584 | __n: usize, 585 | ) -> *mut ::std::os::raw::c_char; 586 | } 587 | extern "C" { 588 | pub fn stpncpy( 589 | __dest: *mut ::std::os::raw::c_char, 590 | __src: *const ::std::os::raw::c_char, 591 | __n: ::std::os::raw::c_uint, 592 | ) -> *mut ::std::os::raw::c_char; 593 | } 594 | extern "C" { 595 | pub fn strlcpy( 596 | __dest: *mut ::std::os::raw::c_char, 597 | __src: *const ::std::os::raw::c_char, 598 | __n: ::std::os::raw::c_uint, 599 | ) -> ::std::os::raw::c_uint; 600 | } 601 | extern "C" { 602 | pub fn strlcat( 603 | __dest: *mut ::std::os::raw::c_char, 604 | __src: *const ::std::os::raw::c_char, 605 | __n: ::std::os::raw::c_uint, 606 | ) -> ::std::os::raw::c_uint; 607 | } 608 | #[repr(C)] 609 | #[derive(Debug, Copy, Clone)] 610 | pub struct _qpdf_data { 611 | _unused: [u8; 0], 612 | } 613 | pub type qpdf_data = *mut _qpdf_data; 614 | #[repr(C)] 615 | #[derive(Debug, Copy, Clone)] 616 | pub struct _qpdf_error { 617 | _unused: [u8; 0], 618 | } 619 | pub type qpdf_error = *mut _qpdf_error; 620 | pub type QPDF_ERROR_CODE = ::std::os::raw::c_int; 621 | pub type QPDF_BOOL = ::std::os::raw::c_int; 622 | extern "C" { 623 | pub fn qpdf_silence_errors(qpdf: qpdf_data); 624 | } 625 | extern "C" { 626 | pub fn qpdf_get_qpdf_version() -> *const ::std::os::raw::c_char; 627 | } 628 | extern "C" { 629 | pub fn qpdf_init() -> qpdf_data; 630 | } 631 | extern "C" { 632 | pub fn qpdf_cleanup(qpdf: *mut qpdf_data); 633 | } 634 | extern "C" { 635 | pub fn qpdf_has_error(qpdf: qpdf_data) -> QPDF_BOOL; 636 | } 637 | extern "C" { 638 | pub fn qpdf_get_error(qpdf: qpdf_data) -> qpdf_error; 639 | } 640 | extern "C" { 641 | pub fn qpdf_more_warnings(qpdf: qpdf_data) -> QPDF_BOOL; 642 | } 643 | extern "C" { 644 | pub fn qpdf_next_warning(qpdf: qpdf_data) -> qpdf_error; 645 | } 646 | extern "C" { 647 | pub fn qpdf_get_error_full_text(q: qpdf_data, e: qpdf_error) -> *const ::std::os::raw::c_char; 648 | } 649 | extern "C" { 650 | pub fn qpdf_get_error_code(q: qpdf_data, e: qpdf_error) -> qpdf_error_code_e; 651 | } 652 | extern "C" { 653 | pub fn qpdf_get_error_filename(q: qpdf_data, e: qpdf_error) -> *const ::std::os::raw::c_char; 654 | } 655 | extern "C" { 656 | pub fn qpdf_get_error_file_position(q: qpdf_data, e: qpdf_error) -> ::std::os::raw::c_ulonglong; 657 | } 658 | extern "C" { 659 | pub fn qpdf_get_error_message_detail(q: qpdf_data, e: qpdf_error) -> *const ::std::os::raw::c_char; 660 | } 661 | extern "C" { 662 | pub fn qpdf_set_suppress_warnings(qpdf: qpdf_data, value: QPDF_BOOL); 663 | } 664 | extern "C" { 665 | pub fn qpdf_set_logger(qpdf: qpdf_data, logger: qpdflogger_handle); 666 | } 667 | extern "C" { 668 | pub fn qpdf_get_logger(qpdf: qpdf_data) -> qpdflogger_handle; 669 | } 670 | extern "C" { 671 | pub fn qpdf_check_pdf(qpdf: qpdf_data) -> QPDF_ERROR_CODE; 672 | } 673 | extern "C" { 674 | pub fn qpdf_set_ignore_xref_streams(qpdf: qpdf_data, value: QPDF_BOOL); 675 | } 676 | extern "C" { 677 | pub fn qpdf_set_attempt_recovery(qpdf: qpdf_data, value: QPDF_BOOL); 678 | } 679 | extern "C" { 680 | pub fn qpdf_read( 681 | qpdf: qpdf_data, 682 | filename: *const ::std::os::raw::c_char, 683 | password: *const ::std::os::raw::c_char, 684 | ) -> QPDF_ERROR_CODE; 685 | } 686 | extern "C" { 687 | pub fn qpdf_read_memory( 688 | qpdf: qpdf_data, 689 | description: *const ::std::os::raw::c_char, 690 | buffer: *const ::std::os::raw::c_char, 691 | size: ::std::os::raw::c_ulonglong, 692 | password: *const ::std::os::raw::c_char, 693 | ) -> QPDF_ERROR_CODE; 694 | } 695 | extern "C" { 696 | pub fn qpdf_empty_pdf(qpdf: qpdf_data) -> QPDF_ERROR_CODE; 697 | } 698 | extern "C" { 699 | pub fn qpdf_create_from_json_file(qpdf: qpdf_data, filename: *const ::std::os::raw::c_char) -> QPDF_ERROR_CODE; 700 | } 701 | extern "C" { 702 | pub fn qpdf_create_from_json_data( 703 | qpdf: qpdf_data, 704 | buffer: *const ::std::os::raw::c_char, 705 | size: ::std::os::raw::c_ulonglong, 706 | ) -> QPDF_ERROR_CODE; 707 | } 708 | extern "C" { 709 | pub fn qpdf_update_from_json_file(qpdf: qpdf_data, filename: *const ::std::os::raw::c_char) -> QPDF_ERROR_CODE; 710 | } 711 | extern "C" { 712 | pub fn qpdf_update_from_json_data( 713 | qpdf: qpdf_data, 714 | buffer: *const ::std::os::raw::c_char, 715 | size: ::std::os::raw::c_ulonglong, 716 | ) -> QPDF_ERROR_CODE; 717 | } 718 | extern "C" { 719 | pub fn qpdf_get_pdf_version(qpdf: qpdf_data) -> *const ::std::os::raw::c_char; 720 | } 721 | extern "C" { 722 | pub fn qpdf_get_pdf_extension_level(qpdf: qpdf_data) -> ::std::os::raw::c_int; 723 | } 724 | extern "C" { 725 | pub fn qpdf_get_user_password(qpdf: qpdf_data) -> *const ::std::os::raw::c_char; 726 | } 727 | extern "C" { 728 | pub fn qpdf_get_info_key(qpdf: qpdf_data, key: *const ::std::os::raw::c_char) -> *const ::std::os::raw::c_char; 729 | } 730 | extern "C" { 731 | pub fn qpdf_set_info_key(qpdf: qpdf_data, key: *const ::std::os::raw::c_char, value: *const ::std::os::raw::c_char); 732 | } 733 | extern "C" { 734 | pub fn qpdf_is_linearized(qpdf: qpdf_data) -> QPDF_BOOL; 735 | } 736 | extern "C" { 737 | pub fn qpdf_is_encrypted(qpdf: qpdf_data) -> QPDF_BOOL; 738 | } 739 | extern "C" { 740 | pub fn qpdf_allow_accessibility(qpdf: qpdf_data) -> QPDF_BOOL; 741 | } 742 | extern "C" { 743 | pub fn qpdf_allow_extract_all(qpdf: qpdf_data) -> QPDF_BOOL; 744 | } 745 | extern "C" { 746 | pub fn qpdf_allow_print_low_res(qpdf: qpdf_data) -> QPDF_BOOL; 747 | } 748 | extern "C" { 749 | pub fn qpdf_allow_print_high_res(qpdf: qpdf_data) -> QPDF_BOOL; 750 | } 751 | extern "C" { 752 | pub fn qpdf_allow_modify_assembly(qpdf: qpdf_data) -> QPDF_BOOL; 753 | } 754 | extern "C" { 755 | pub fn qpdf_allow_modify_form(qpdf: qpdf_data) -> QPDF_BOOL; 756 | } 757 | extern "C" { 758 | pub fn qpdf_allow_modify_annotation(qpdf: qpdf_data) -> QPDF_BOOL; 759 | } 760 | extern "C" { 761 | pub fn qpdf_allow_modify_other(qpdf: qpdf_data) -> QPDF_BOOL; 762 | } 763 | extern "C" { 764 | pub fn qpdf_allow_modify_all(qpdf: qpdf_data) -> QPDF_BOOL; 765 | } 766 | pub type qpdf_write_fn_t = ::std::option::Option< 767 | unsafe extern "C" fn( 768 | data: *const ::std::os::raw::c_char, 769 | len: usize, 770 | udata: *mut ::std::os::raw::c_void, 771 | ) -> ::std::os::raw::c_int, 772 | >; 773 | extern "C" { 774 | pub fn qpdf_write_json( 775 | qpdf: qpdf_data, 776 | version: ::std::os::raw::c_int, 777 | fn_: qpdf_write_fn_t, 778 | udata: *mut ::std::os::raw::c_void, 779 | decode_level: qpdf_stream_decode_level_e, 780 | json_stream_data: qpdf_json_stream_data_e, 781 | file_prefix: *const ::std::os::raw::c_char, 782 | wanted_objects: *const *const ::std::os::raw::c_char, 783 | ) -> QPDF_ERROR_CODE; 784 | } 785 | extern "C" { 786 | pub fn qpdf_init_write(qpdf: qpdf_data, filename: *const ::std::os::raw::c_char) -> QPDF_ERROR_CODE; 787 | } 788 | extern "C" { 789 | pub fn qpdf_init_write_memory(qpdf: qpdf_data) -> QPDF_ERROR_CODE; 790 | } 791 | extern "C" { 792 | pub fn qpdf_get_buffer_length(qpdf: qpdf_data) -> usize; 793 | } 794 | extern "C" { 795 | pub fn qpdf_get_buffer(qpdf: qpdf_data) -> *const ::std::os::raw::c_uchar; 796 | } 797 | extern "C" { 798 | pub fn qpdf_set_object_stream_mode(qpdf: qpdf_data, mode: qpdf_object_stream_e); 799 | } 800 | extern "C" { 801 | pub fn qpdf_set_stream_data_mode(qpdf: qpdf_data, mode: qpdf_stream_data_e); 802 | } 803 | extern "C" { 804 | pub fn qpdf_set_compress_streams(qpdf: qpdf_data, value: QPDF_BOOL); 805 | } 806 | extern "C" { 807 | pub fn qpdf_set_decode_level(qpdf: qpdf_data, level: qpdf_stream_decode_level_e); 808 | } 809 | extern "C" { 810 | pub fn qpdf_set_preserve_unreferenced_objects(qpdf: qpdf_data, value: QPDF_BOOL); 811 | } 812 | extern "C" { 813 | pub fn qpdf_set_newline_before_endstream(qpdf: qpdf_data, value: QPDF_BOOL); 814 | } 815 | extern "C" { 816 | pub fn qpdf_set_content_normalization(qpdf: qpdf_data, value: QPDF_BOOL); 817 | } 818 | extern "C" { 819 | pub fn qpdf_set_qdf_mode(qpdf: qpdf_data, value: QPDF_BOOL); 820 | } 821 | extern "C" { 822 | pub fn qpdf_set_deterministic_ID(qpdf: qpdf_data, value: QPDF_BOOL); 823 | } 824 | extern "C" { 825 | pub fn qpdf_set_static_ID(qpdf: qpdf_data, value: QPDF_BOOL); 826 | } 827 | extern "C" { 828 | pub fn qpdf_set_static_aes_IV(qpdf: qpdf_data, value: QPDF_BOOL); 829 | } 830 | extern "C" { 831 | pub fn qpdf_set_suppress_original_object_IDs(qpdf: qpdf_data, value: QPDF_BOOL); 832 | } 833 | extern "C" { 834 | pub fn qpdf_set_preserve_encryption(qpdf: qpdf_data, value: QPDF_BOOL); 835 | } 836 | extern "C" { 837 | pub fn qpdf_set_r2_encryption_parameters_insecure( 838 | qpdf: qpdf_data, 839 | user_password: *const ::std::os::raw::c_char, 840 | owner_password: *const ::std::os::raw::c_char, 841 | allow_print: QPDF_BOOL, 842 | allow_modify: QPDF_BOOL, 843 | allow_extract: QPDF_BOOL, 844 | allow_annotate: QPDF_BOOL, 845 | ); 846 | } 847 | extern "C" { 848 | pub fn qpdf_set_r3_encryption_parameters_insecure( 849 | qpdf: qpdf_data, 850 | user_password: *const ::std::os::raw::c_char, 851 | owner_password: *const ::std::os::raw::c_char, 852 | allow_accessibility: QPDF_BOOL, 853 | allow_extract: QPDF_BOOL, 854 | allow_assemble: QPDF_BOOL, 855 | allow_annotate_and_form: QPDF_BOOL, 856 | allow_form_filling: QPDF_BOOL, 857 | allow_modify_other: QPDF_BOOL, 858 | print: qpdf_r3_print_e, 859 | ); 860 | } 861 | extern "C" { 862 | pub fn qpdf_set_r4_encryption_parameters_insecure( 863 | qpdf: qpdf_data, 864 | user_password: *const ::std::os::raw::c_char, 865 | owner_password: *const ::std::os::raw::c_char, 866 | allow_accessibility: QPDF_BOOL, 867 | allow_extract: QPDF_BOOL, 868 | allow_assemble: QPDF_BOOL, 869 | allow_annotate_and_form: QPDF_BOOL, 870 | allow_form_filling: QPDF_BOOL, 871 | allow_modify_other: QPDF_BOOL, 872 | print: qpdf_r3_print_e, 873 | encrypt_metadata: QPDF_BOOL, 874 | use_aes: QPDF_BOOL, 875 | ); 876 | } 877 | extern "C" { 878 | pub fn qpdf_set_r5_encryption_parameters2( 879 | qpdf: qpdf_data, 880 | user_password: *const ::std::os::raw::c_char, 881 | owner_password: *const ::std::os::raw::c_char, 882 | allow_accessibility: QPDF_BOOL, 883 | allow_extract: QPDF_BOOL, 884 | allow_assemble: QPDF_BOOL, 885 | allow_annotate_and_form: QPDF_BOOL, 886 | allow_form_filling: QPDF_BOOL, 887 | allow_modify_other: QPDF_BOOL, 888 | print: qpdf_r3_print_e, 889 | encrypt_metadata: QPDF_BOOL, 890 | ); 891 | } 892 | extern "C" { 893 | pub fn qpdf_set_r6_encryption_parameters2( 894 | qpdf: qpdf_data, 895 | user_password: *const ::std::os::raw::c_char, 896 | owner_password: *const ::std::os::raw::c_char, 897 | allow_accessibility: QPDF_BOOL, 898 | allow_extract: QPDF_BOOL, 899 | allow_assemble: QPDF_BOOL, 900 | allow_annotate_and_form: QPDF_BOOL, 901 | allow_form_filling: QPDF_BOOL, 902 | allow_modify_other: QPDF_BOOL, 903 | print: qpdf_r3_print_e, 904 | encrypt_metadata: QPDF_BOOL, 905 | ); 906 | } 907 | extern "C" { 908 | pub fn qpdf_set_linearization(qpdf: qpdf_data, value: QPDF_BOOL); 909 | } 910 | extern "C" { 911 | pub fn qpdf_set_minimum_pdf_version(qpdf: qpdf_data, version: *const ::std::os::raw::c_char); 912 | } 913 | extern "C" { 914 | pub fn qpdf_set_minimum_pdf_version_and_extension( 915 | qpdf: qpdf_data, 916 | version: *const ::std::os::raw::c_char, 917 | extension_level: ::std::os::raw::c_int, 918 | ); 919 | } 920 | extern "C" { 921 | pub fn qpdf_force_pdf_version(qpdf: qpdf_data, version: *const ::std::os::raw::c_char); 922 | } 923 | extern "C" { 924 | pub fn qpdf_force_pdf_version_and_extension( 925 | qpdf: qpdf_data, 926 | version: *const ::std::os::raw::c_char, 927 | extension_level: ::std::os::raw::c_int, 928 | ); 929 | } 930 | extern "C" { 931 | pub fn qpdf_register_progress_reporter( 932 | qpdf: qpdf_data, 933 | report_progress: ::std::option::Option< 934 | unsafe extern "C" fn(percent: ::std::os::raw::c_int, data: *mut ::std::os::raw::c_void), 935 | >, 936 | data: *mut ::std::os::raw::c_void, 937 | ); 938 | } 939 | extern "C" { 940 | pub fn qpdf_write(qpdf: qpdf_data) -> QPDF_ERROR_CODE; 941 | } 942 | pub type qpdf_oh = ::std::os::raw::c_uint; 943 | extern "C" { 944 | pub fn qpdf_oh_release(qpdf: qpdf_data, oh: qpdf_oh); 945 | } 946 | extern "C" { 947 | pub fn qpdf_oh_release_all(qpdf: qpdf_data); 948 | } 949 | extern "C" { 950 | pub fn qpdf_oh_new_object(qpdf: qpdf_data, oh: qpdf_oh) -> qpdf_oh; 951 | } 952 | extern "C" { 953 | pub fn qpdf_get_trailer(qpdf: qpdf_data) -> qpdf_oh; 954 | } 955 | extern "C" { 956 | pub fn qpdf_get_root(qpdf: qpdf_data) -> qpdf_oh; 957 | } 958 | extern "C" { 959 | pub fn qpdf_get_object_by_id( 960 | qpdf: qpdf_data, 961 | objid: ::std::os::raw::c_int, 962 | generation: ::std::os::raw::c_int, 963 | ) -> qpdf_oh; 964 | } 965 | extern "C" { 966 | pub fn qpdf_make_indirect_object(qpdf: qpdf_data, oh: qpdf_oh) -> qpdf_oh; 967 | } 968 | extern "C" { 969 | pub fn qpdf_replace_object( 970 | qpdf: qpdf_data, 971 | objid: ::std::os::raw::c_int, 972 | generation: ::std::os::raw::c_int, 973 | oh: qpdf_oh, 974 | ); 975 | } 976 | extern "C" { 977 | pub fn qpdf_oh_is_initialized(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 978 | } 979 | extern "C" { 980 | pub fn qpdf_oh_is_bool(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 981 | } 982 | extern "C" { 983 | pub fn qpdf_oh_is_null(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 984 | } 985 | extern "C" { 986 | pub fn qpdf_oh_is_integer(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 987 | } 988 | extern "C" { 989 | pub fn qpdf_oh_is_real(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 990 | } 991 | extern "C" { 992 | pub fn qpdf_oh_is_name(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 993 | } 994 | extern "C" { 995 | pub fn qpdf_oh_is_string(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 996 | } 997 | extern "C" { 998 | pub fn qpdf_oh_is_operator(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 999 | } 1000 | extern "C" { 1001 | pub fn qpdf_oh_is_inline_image(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1002 | } 1003 | extern "C" { 1004 | pub fn qpdf_oh_is_array(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1005 | } 1006 | extern "C" { 1007 | pub fn qpdf_oh_is_dictionary(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1008 | } 1009 | extern "C" { 1010 | pub fn qpdf_oh_is_stream(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1011 | } 1012 | extern "C" { 1013 | pub fn qpdf_oh_is_indirect(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1014 | } 1015 | extern "C" { 1016 | pub fn qpdf_oh_is_scalar(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1017 | } 1018 | extern "C" { 1019 | pub fn qpdf_oh_is_name_and_equals(qpdf: qpdf_data, oh: qpdf_oh, name: *const ::std::os::raw::c_char) -> QPDF_BOOL; 1020 | } 1021 | extern "C" { 1022 | pub fn qpdf_oh_is_dictionary_of_type( 1023 | qpdf: qpdf_data, 1024 | oh: qpdf_oh, 1025 | type_: *const ::std::os::raw::c_char, 1026 | subtype: *const ::std::os::raw::c_char, 1027 | ) -> QPDF_BOOL; 1028 | } 1029 | extern "C" { 1030 | pub fn qpdf_oh_get_type_code(qpdf: qpdf_data, oh: qpdf_oh) -> qpdf_object_type_e; 1031 | } 1032 | extern "C" { 1033 | pub fn qpdf_oh_get_type_name(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1034 | } 1035 | extern "C" { 1036 | pub fn qpdf_oh_wrap_in_array(qpdf: qpdf_data, oh: qpdf_oh) -> qpdf_oh; 1037 | } 1038 | extern "C" { 1039 | pub fn qpdf_oh_parse(qpdf: qpdf_data, object_str: *const ::std::os::raw::c_char) -> qpdf_oh; 1040 | } 1041 | extern "C" { 1042 | pub fn qpdf_oh_get_bool_value(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1043 | } 1044 | extern "C" { 1045 | pub fn qpdf_oh_get_value_as_bool(qpdf: qpdf_data, oh: qpdf_oh, value: *mut QPDF_BOOL) -> QPDF_BOOL; 1046 | } 1047 | extern "C" { 1048 | pub fn qpdf_oh_get_int_value(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_longlong; 1049 | } 1050 | extern "C" { 1051 | pub fn qpdf_oh_get_value_as_longlong( 1052 | qpdf: qpdf_data, 1053 | oh: qpdf_oh, 1054 | value: *mut ::std::os::raw::c_longlong, 1055 | ) -> QPDF_BOOL; 1056 | } 1057 | extern "C" { 1058 | pub fn qpdf_oh_get_int_value_as_int(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_int; 1059 | } 1060 | extern "C" { 1061 | pub fn qpdf_oh_get_value_as_int(qpdf: qpdf_data, oh: qpdf_oh, value: *mut ::std::os::raw::c_int) -> QPDF_BOOL; 1062 | } 1063 | extern "C" { 1064 | pub fn qpdf_oh_get_uint_value(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_ulonglong; 1065 | } 1066 | extern "C" { 1067 | pub fn qpdf_oh_get_value_as_ulonglong( 1068 | qpdf: qpdf_data, 1069 | oh: qpdf_oh, 1070 | value: *mut ::std::os::raw::c_ulonglong, 1071 | ) -> QPDF_BOOL; 1072 | } 1073 | extern "C" { 1074 | pub fn qpdf_oh_get_uint_value_as_uint(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_uint; 1075 | } 1076 | extern "C" { 1077 | pub fn qpdf_oh_get_value_as_uint(qpdf: qpdf_data, oh: qpdf_oh, value: *mut ::std::os::raw::c_uint) -> QPDF_BOOL; 1078 | } 1079 | extern "C" { 1080 | pub fn qpdf_oh_get_real_value(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1081 | } 1082 | extern "C" { 1083 | pub fn qpdf_oh_get_value_as_real( 1084 | qpdf: qpdf_data, 1085 | oh: qpdf_oh, 1086 | value: *mut *const ::std::os::raw::c_char, 1087 | length: *mut usize, 1088 | ) -> QPDF_BOOL; 1089 | } 1090 | extern "C" { 1091 | pub fn qpdf_oh_is_number(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1092 | } 1093 | extern "C" { 1094 | pub fn qpdf_oh_get_numeric_value(qpdf: qpdf_data, oh: qpdf_oh) -> f64; 1095 | } 1096 | extern "C" { 1097 | pub fn qpdf_oh_get_value_as_number(qpdf: qpdf_data, oh: qpdf_oh, value: *mut f64) -> QPDF_BOOL; 1098 | } 1099 | extern "C" { 1100 | pub fn qpdf_oh_get_name(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1101 | } 1102 | extern "C" { 1103 | pub fn qpdf_oh_get_value_as_name( 1104 | qpdf: qpdf_data, 1105 | oh: qpdf_oh, 1106 | value: *mut *const ::std::os::raw::c_char, 1107 | length: *mut usize, 1108 | ) -> QPDF_BOOL; 1109 | } 1110 | extern "C" { 1111 | pub fn qpdf_get_last_string_length(qpdf: qpdf_data) -> usize; 1112 | } 1113 | extern "C" { 1114 | pub fn qpdf_oh_get_string_value(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1115 | } 1116 | extern "C" { 1117 | pub fn qpdf_oh_get_value_as_string( 1118 | qpdf: qpdf_data, 1119 | oh: qpdf_oh, 1120 | value: *mut *const ::std::os::raw::c_char, 1121 | length: *mut usize, 1122 | ) -> QPDF_BOOL; 1123 | } 1124 | extern "C" { 1125 | pub fn qpdf_oh_get_utf8_value(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1126 | } 1127 | extern "C" { 1128 | pub fn qpdf_oh_get_value_as_utf8( 1129 | qpdf: qpdf_data, 1130 | oh: qpdf_oh, 1131 | value: *mut *const ::std::os::raw::c_char, 1132 | length: *mut usize, 1133 | ) -> QPDF_BOOL; 1134 | } 1135 | extern "C" { 1136 | pub fn qpdf_oh_get_binary_string_value( 1137 | qpdf: qpdf_data, 1138 | oh: qpdf_oh, 1139 | length: *mut usize, 1140 | ) -> *const ::std::os::raw::c_char; 1141 | } 1142 | extern "C" { 1143 | pub fn qpdf_oh_get_binary_utf8_value( 1144 | qpdf: qpdf_data, 1145 | oh: qpdf_oh, 1146 | length: *mut usize, 1147 | ) -> *const ::std::os::raw::c_char; 1148 | } 1149 | extern "C" { 1150 | pub fn qpdf_oh_get_array_n_items(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_int; 1151 | } 1152 | extern "C" { 1153 | pub fn qpdf_oh_get_array_item(qpdf: qpdf_data, oh: qpdf_oh, n: ::std::os::raw::c_int) -> qpdf_oh; 1154 | } 1155 | extern "C" { 1156 | pub fn qpdf_oh_begin_dict_key_iter(qpdf: qpdf_data, dict: qpdf_oh); 1157 | } 1158 | extern "C" { 1159 | pub fn qpdf_oh_dict_more_keys(qpdf: qpdf_data) -> QPDF_BOOL; 1160 | } 1161 | extern "C" { 1162 | pub fn qpdf_oh_dict_next_key(qpdf: qpdf_data) -> *const ::std::os::raw::c_char; 1163 | } 1164 | extern "C" { 1165 | pub fn qpdf_oh_has_key(qpdf: qpdf_data, oh: qpdf_oh, key: *const ::std::os::raw::c_char) -> QPDF_BOOL; 1166 | } 1167 | extern "C" { 1168 | pub fn qpdf_oh_get_key(qpdf: qpdf_data, oh: qpdf_oh, key: *const ::std::os::raw::c_char) -> qpdf_oh; 1169 | } 1170 | extern "C" { 1171 | pub fn qpdf_oh_get_key_if_dict(qpdf: qpdf_data, oh: qpdf_oh, key: *const ::std::os::raw::c_char) -> qpdf_oh; 1172 | } 1173 | extern "C" { 1174 | pub fn qpdf_oh_is_or_has_name(qpdf: qpdf_data, oh: qpdf_oh, key: *const ::std::os::raw::c_char) -> QPDF_BOOL; 1175 | } 1176 | extern "C" { 1177 | pub fn qpdf_oh_new_uninitialized(qpdf: qpdf_data) -> qpdf_oh; 1178 | } 1179 | extern "C" { 1180 | pub fn qpdf_oh_new_null(qpdf: qpdf_data) -> qpdf_oh; 1181 | } 1182 | extern "C" { 1183 | pub fn qpdf_oh_new_bool(qpdf: qpdf_data, value: QPDF_BOOL) -> qpdf_oh; 1184 | } 1185 | extern "C" { 1186 | pub fn qpdf_oh_new_integer(qpdf: qpdf_data, value: ::std::os::raw::c_longlong) -> qpdf_oh; 1187 | } 1188 | extern "C" { 1189 | pub fn qpdf_oh_new_real_from_string(qpdf: qpdf_data, value: *const ::std::os::raw::c_char) -> qpdf_oh; 1190 | } 1191 | extern "C" { 1192 | pub fn qpdf_oh_new_real_from_double(qpdf: qpdf_data, value: f64, decimal_places: ::std::os::raw::c_int) -> qpdf_oh; 1193 | } 1194 | extern "C" { 1195 | pub fn qpdf_oh_new_name(qpdf: qpdf_data, name: *const ::std::os::raw::c_char) -> qpdf_oh; 1196 | } 1197 | extern "C" { 1198 | pub fn qpdf_oh_new_string(qpdf: qpdf_data, str_: *const ::std::os::raw::c_char) -> qpdf_oh; 1199 | } 1200 | extern "C" { 1201 | pub fn qpdf_oh_new_unicode_string(qpdf: qpdf_data, utf8_str: *const ::std::os::raw::c_char) -> qpdf_oh; 1202 | } 1203 | extern "C" { 1204 | pub fn qpdf_oh_new_binary_string(qpdf: qpdf_data, str_: *const ::std::os::raw::c_char, length: usize) -> qpdf_oh; 1205 | } 1206 | extern "C" { 1207 | pub fn qpdf_oh_new_binary_unicode_string( 1208 | qpdf: qpdf_data, 1209 | str_: *const ::std::os::raw::c_char, 1210 | length: usize, 1211 | ) -> qpdf_oh; 1212 | } 1213 | extern "C" { 1214 | pub fn qpdf_oh_new_array(qpdf: qpdf_data) -> qpdf_oh; 1215 | } 1216 | extern "C" { 1217 | pub fn qpdf_oh_new_dictionary(qpdf: qpdf_data) -> qpdf_oh; 1218 | } 1219 | extern "C" { 1220 | pub fn qpdf_oh_new_stream(qpdf: qpdf_data) -> qpdf_oh; 1221 | } 1222 | extern "C" { 1223 | pub fn qpdf_oh_make_direct(qpdf: qpdf_data, oh: qpdf_oh); 1224 | } 1225 | extern "C" { 1226 | pub fn qpdf_oh_set_array_item(qpdf: qpdf_data, oh: qpdf_oh, at: ::std::os::raw::c_int, item: qpdf_oh); 1227 | } 1228 | extern "C" { 1229 | pub fn qpdf_oh_insert_item(qpdf: qpdf_data, oh: qpdf_oh, at: ::std::os::raw::c_int, item: qpdf_oh); 1230 | } 1231 | extern "C" { 1232 | pub fn qpdf_oh_append_item(qpdf: qpdf_data, oh: qpdf_oh, item: qpdf_oh); 1233 | } 1234 | extern "C" { 1235 | pub fn qpdf_oh_erase_item(qpdf: qpdf_data, oh: qpdf_oh, at: ::std::os::raw::c_int); 1236 | } 1237 | extern "C" { 1238 | pub fn qpdf_oh_replace_key(qpdf: qpdf_data, oh: qpdf_oh, key: *const ::std::os::raw::c_char, item: qpdf_oh); 1239 | } 1240 | extern "C" { 1241 | pub fn qpdf_oh_remove_key(qpdf: qpdf_data, oh: qpdf_oh, key: *const ::std::os::raw::c_char); 1242 | } 1243 | extern "C" { 1244 | pub fn qpdf_oh_replace_or_remove_key( 1245 | qpdf: qpdf_data, 1246 | oh: qpdf_oh, 1247 | key: *const ::std::os::raw::c_char, 1248 | item: qpdf_oh, 1249 | ); 1250 | } 1251 | extern "C" { 1252 | pub fn qpdf_oh_get_dict(qpdf: qpdf_data, oh: qpdf_oh) -> qpdf_oh; 1253 | } 1254 | extern "C" { 1255 | pub fn qpdf_oh_get_object_id(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_int; 1256 | } 1257 | extern "C" { 1258 | pub fn qpdf_oh_get_generation(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_int; 1259 | } 1260 | extern "C" { 1261 | pub fn qpdf_oh_unparse(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1262 | } 1263 | extern "C" { 1264 | pub fn qpdf_oh_unparse_resolved(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1265 | } 1266 | extern "C" { 1267 | pub fn qpdf_oh_unparse_binary(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1268 | } 1269 | extern "C" { 1270 | pub fn qpdf_oh_copy_foreign_object(qpdf: qpdf_data, other_qpdf: qpdf_data, foreign_oh: qpdf_oh) -> qpdf_oh; 1271 | } 1272 | extern "C" { 1273 | pub fn qpdf_oh_get_stream_data( 1274 | qpdf: qpdf_data, 1275 | stream_oh: qpdf_oh, 1276 | decode_level: qpdf_stream_decode_level_e, 1277 | filtered: *mut QPDF_BOOL, 1278 | bufp: *mut *mut ::std::os::raw::c_uchar, 1279 | len: *mut usize, 1280 | ) -> QPDF_ERROR_CODE; 1281 | } 1282 | extern "C" { 1283 | pub fn qpdf_oh_get_page_content_data( 1284 | qpdf: qpdf_data, 1285 | page_oh: qpdf_oh, 1286 | bufp: *mut *mut ::std::os::raw::c_uchar, 1287 | len: *mut usize, 1288 | ) -> QPDF_ERROR_CODE; 1289 | } 1290 | extern "C" { 1291 | pub fn qpdf_oh_free_buffer(bufp: *mut *mut ::std::os::raw::c_uchar); 1292 | } 1293 | extern "C" { 1294 | pub fn qpdf_oh_replace_stream_data( 1295 | qpdf: qpdf_data, 1296 | stream_oh: qpdf_oh, 1297 | buf: *const ::std::os::raw::c_uchar, 1298 | len: usize, 1299 | filter: qpdf_oh, 1300 | decode_parms: qpdf_oh, 1301 | ); 1302 | } 1303 | extern "C" { 1304 | pub fn qpdf_get_num_pages(qpdf: qpdf_data) -> ::std::os::raw::c_int; 1305 | } 1306 | extern "C" { 1307 | pub fn qpdf_get_page_n(qpdf: qpdf_data, zero_based_index: usize) -> qpdf_oh; 1308 | } 1309 | extern "C" { 1310 | pub fn qpdf_update_all_pages_cache(qpdf: qpdf_data) -> QPDF_ERROR_CODE; 1311 | } 1312 | extern "C" { 1313 | pub fn qpdf_find_page_by_id( 1314 | qpdf: qpdf_data, 1315 | objid: ::std::os::raw::c_int, 1316 | generation: ::std::os::raw::c_int, 1317 | ) -> ::std::os::raw::c_int; 1318 | } 1319 | extern "C" { 1320 | pub fn qpdf_find_page_by_oh(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_int; 1321 | } 1322 | extern "C" { 1323 | pub fn qpdf_push_inherited_attributes_to_page(qpdf: qpdf_data) -> QPDF_ERROR_CODE; 1324 | } 1325 | extern "C" { 1326 | pub fn qpdf_add_page( 1327 | qpdf: qpdf_data, 1328 | newpage_qpdf: qpdf_data, 1329 | newpage: qpdf_oh, 1330 | first: QPDF_BOOL, 1331 | ) -> QPDF_ERROR_CODE; 1332 | } 1333 | extern "C" { 1334 | pub fn qpdf_add_page_at( 1335 | qpdf: qpdf_data, 1336 | newpage_qpdf: qpdf_data, 1337 | newpage: qpdf_oh, 1338 | before: QPDF_BOOL, 1339 | refpage: qpdf_oh, 1340 | ) -> QPDF_ERROR_CODE; 1341 | } 1342 | extern "C" { 1343 | pub fn qpdf_remove_page(qpdf: qpdf_data, page: qpdf_oh) -> QPDF_ERROR_CODE; 1344 | } 1345 | #[repr(C)] 1346 | #[derive(Debug, Copy, Clone)] 1347 | pub struct __locale_data { 1348 | pub _address: u8, 1349 | } 1350 | -------------------------------------------------------------------------------- /qpdf-sys/bindings/x86_64-unknown-linux-gnu.rs: -------------------------------------------------------------------------------- 1 | /* automatically generated by rust-bindgen 0.70.1 */ 2 | 3 | pub const QPDF_MAJOR_VERSION: u32 = 12; 4 | pub const QPDF_MINOR_VERSION: u32 = 0; 5 | pub const QPDF_PATCH_VERSION: u32 = 0; 6 | pub const QPDF_VERSION: &[u8; 7] = b"12.0.0\0"; 7 | pub const _STRING_H: u32 = 1; 8 | pub const _FEATURES_H: u32 = 1; 9 | pub const _DEFAULT_SOURCE: u32 = 1; 10 | pub const __GLIBC_USE_ISOC2Y: u32 = 0; 11 | pub const __GLIBC_USE_ISOC23: u32 = 0; 12 | pub const __USE_ISOC11: u32 = 1; 13 | pub const __USE_ISOC99: u32 = 1; 14 | pub const __USE_ISOC95: u32 = 1; 15 | pub const __USE_POSIX_IMPLICITLY: u32 = 1; 16 | pub const _POSIX_SOURCE: u32 = 1; 17 | pub const _POSIX_C_SOURCE: u32 = 200809; 18 | pub const __USE_POSIX: u32 = 1; 19 | pub const __USE_POSIX2: u32 = 1; 20 | pub const __USE_POSIX199309: u32 = 1; 21 | pub const __USE_POSIX199506: u32 = 1; 22 | pub const __USE_XOPEN2K: u32 = 1; 23 | pub const __USE_XOPEN2K8: u32 = 1; 24 | pub const _ATFILE_SOURCE: u32 = 1; 25 | pub const __WORDSIZE: u32 = 64; 26 | pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1; 27 | pub const __SYSCALL_WORDSIZE: u32 = 64; 28 | pub const __TIMESIZE: u32 = 64; 29 | pub const __USE_TIME_BITS64: u32 = 1; 30 | pub const __USE_MISC: u32 = 1; 31 | pub const __USE_ATFILE: u32 = 1; 32 | pub const __USE_FORTIFY_LEVEL: u32 = 0; 33 | pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0; 34 | pub const __GLIBC_USE_DEPRECATED_SCANF: u32 = 0; 35 | pub const __GLIBC_USE_C23_STRTOL: u32 = 0; 36 | pub const _STDC_PREDEF_H: u32 = 1; 37 | pub const __STDC_IEC_559__: u32 = 1; 38 | pub const __STDC_IEC_60559_BFP__: u32 = 201404; 39 | pub const __STDC_IEC_559_COMPLEX__: u32 = 1; 40 | pub const __STDC_IEC_60559_COMPLEX__: u32 = 201404; 41 | pub const __STDC_ISO_10646__: u32 = 201706; 42 | pub const __GNU_LIBRARY__: u32 = 6; 43 | pub const __GLIBC__: u32 = 2; 44 | pub const __GLIBC_MINOR__: u32 = 41; 45 | pub const _SYS_CDEFS_H: u32 = 1; 46 | pub const __glibc_c99_flexarr_available: u32 = 1; 47 | pub const __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI: u32 = 0; 48 | pub const __HAVE_GENERIC_SELECTION: u32 = 1; 49 | pub const __GLIBC_USE_LIB_EXT2: u32 = 0; 50 | pub const __GLIBC_USE_IEC_60559_BFP_EXT: u32 = 0; 51 | pub const __GLIBC_USE_IEC_60559_BFP_EXT_C23: u32 = 0; 52 | pub const __GLIBC_USE_IEC_60559_EXT: u32 = 0; 53 | pub const __GLIBC_USE_IEC_60559_FUNCS_EXT: u32 = 0; 54 | pub const __GLIBC_USE_IEC_60559_FUNCS_EXT_C23: u32 = 0; 55 | pub const __GLIBC_USE_IEC_60559_TYPES_EXT: u32 = 0; 56 | pub const _BITS_TYPES_LOCALE_T_H: u32 = 1; 57 | pub const _BITS_TYPES___LOCALE_T_H: u32 = 1; 58 | pub const _STRINGS_H: u32 = 1; 59 | pub const QPDF_SUCCESS: u32 = 0; 60 | pub const QPDF_WARNINGS: u32 = 1; 61 | pub const QPDF_ERRORS: u32 = 2; 62 | pub const QPDF_TRUE: u32 = 1; 63 | pub const QPDF_FALSE: u32 = 0; 64 | pub const qpdf_exit_code_e_qpdf_exit_success: qpdf_exit_code_e = 0; 65 | pub const qpdf_exit_code_e_qpdf_exit_error: qpdf_exit_code_e = 2; 66 | pub const qpdf_exit_code_e_qpdf_exit_warning: qpdf_exit_code_e = 3; 67 | pub const qpdf_exit_code_e_qpdf_exit_is_not_encrypted: qpdf_exit_code_e = 2; 68 | pub const qpdf_exit_code_e_qpdf_exit_correct_password: qpdf_exit_code_e = 3; 69 | pub type qpdf_exit_code_e = ::std::os::raw::c_uint; 70 | pub const qpdf_error_code_e_qpdf_e_success: qpdf_error_code_e = 0; 71 | pub const qpdf_error_code_e_qpdf_e_internal: qpdf_error_code_e = 1; 72 | pub const qpdf_error_code_e_qpdf_e_system: qpdf_error_code_e = 2; 73 | pub const qpdf_error_code_e_qpdf_e_unsupported: qpdf_error_code_e = 3; 74 | pub const qpdf_error_code_e_qpdf_e_password: qpdf_error_code_e = 4; 75 | pub const qpdf_error_code_e_qpdf_e_damaged_pdf: qpdf_error_code_e = 5; 76 | pub const qpdf_error_code_e_qpdf_e_pages: qpdf_error_code_e = 6; 77 | pub const qpdf_error_code_e_qpdf_e_object: qpdf_error_code_e = 7; 78 | pub const qpdf_error_code_e_qpdf_e_json: qpdf_error_code_e = 8; 79 | pub const qpdf_error_code_e_qpdf_e_linearization: qpdf_error_code_e = 9; 80 | pub type qpdf_error_code_e = ::std::os::raw::c_uint; 81 | pub const qpdf_object_type_e_ot_uninitialized: qpdf_object_type_e = 0; 82 | pub const qpdf_object_type_e_ot_reserved: qpdf_object_type_e = 1; 83 | pub const qpdf_object_type_e_ot_null: qpdf_object_type_e = 2; 84 | pub const qpdf_object_type_e_ot_boolean: qpdf_object_type_e = 3; 85 | pub const qpdf_object_type_e_ot_integer: qpdf_object_type_e = 4; 86 | pub const qpdf_object_type_e_ot_real: qpdf_object_type_e = 5; 87 | pub const qpdf_object_type_e_ot_string: qpdf_object_type_e = 6; 88 | pub const qpdf_object_type_e_ot_name: qpdf_object_type_e = 7; 89 | pub const qpdf_object_type_e_ot_array: qpdf_object_type_e = 8; 90 | pub const qpdf_object_type_e_ot_dictionary: qpdf_object_type_e = 9; 91 | pub const qpdf_object_type_e_ot_stream: qpdf_object_type_e = 10; 92 | pub const qpdf_object_type_e_ot_operator: qpdf_object_type_e = 11; 93 | pub const qpdf_object_type_e_ot_inlineimage: qpdf_object_type_e = 12; 94 | pub const qpdf_object_type_e_ot_unresolved: qpdf_object_type_e = 13; 95 | pub const qpdf_object_type_e_ot_destroyed: qpdf_object_type_e = 14; 96 | pub const qpdf_object_type_e_ot_reference: qpdf_object_type_e = 15; 97 | pub type qpdf_object_type_e = ::std::os::raw::c_uint; 98 | pub const qpdf_object_stream_e_qpdf_o_disable: qpdf_object_stream_e = 0; 99 | pub const qpdf_object_stream_e_qpdf_o_preserve: qpdf_object_stream_e = 1; 100 | pub const qpdf_object_stream_e_qpdf_o_generate: qpdf_object_stream_e = 2; 101 | pub type qpdf_object_stream_e = ::std::os::raw::c_uint; 102 | pub const qpdf_stream_data_e_qpdf_s_uncompress: qpdf_stream_data_e = 0; 103 | pub const qpdf_stream_data_e_qpdf_s_preserve: qpdf_stream_data_e = 1; 104 | pub const qpdf_stream_data_e_qpdf_s_compress: qpdf_stream_data_e = 2; 105 | pub type qpdf_stream_data_e = ::std::os::raw::c_uint; 106 | pub const qpdf_stream_encode_flags_e_qpdf_ef_compress: qpdf_stream_encode_flags_e = 1; 107 | pub const qpdf_stream_encode_flags_e_qpdf_ef_normalize: qpdf_stream_encode_flags_e = 2; 108 | pub type qpdf_stream_encode_flags_e = ::std::os::raw::c_uint; 109 | pub const qpdf_stream_decode_level_e_qpdf_dl_none: qpdf_stream_decode_level_e = 0; 110 | pub const qpdf_stream_decode_level_e_qpdf_dl_generalized: qpdf_stream_decode_level_e = 1; 111 | pub const qpdf_stream_decode_level_e_qpdf_dl_specialized: qpdf_stream_decode_level_e = 2; 112 | pub const qpdf_stream_decode_level_e_qpdf_dl_all: qpdf_stream_decode_level_e = 3; 113 | pub type qpdf_stream_decode_level_e = ::std::os::raw::c_uint; 114 | pub const qpdf_json_stream_data_e_qpdf_sj_none: qpdf_json_stream_data_e = 0; 115 | pub const qpdf_json_stream_data_e_qpdf_sj_inline: qpdf_json_stream_data_e = 1; 116 | pub const qpdf_json_stream_data_e_qpdf_sj_file: qpdf_json_stream_data_e = 2; 117 | pub type qpdf_json_stream_data_e = ::std::os::raw::c_uint; 118 | pub const qpdf_r3_print_e_qpdf_r3p_full: qpdf_r3_print_e = 0; 119 | pub const qpdf_r3_print_e_qpdf_r3p_low: qpdf_r3_print_e = 1; 120 | pub const qpdf_r3_print_e_qpdf_r3p_none: qpdf_r3_print_e = 2; 121 | pub type qpdf_r3_print_e = ::std::os::raw::c_uint; 122 | pub const qpdf_r3_modify_e_qpdf_r3m_all: qpdf_r3_modify_e = 0; 123 | pub const qpdf_r3_modify_e_qpdf_r3m_annotate: qpdf_r3_modify_e = 1; 124 | pub const qpdf_r3_modify_e_qpdf_r3m_form: qpdf_r3_modify_e = 2; 125 | pub const qpdf_r3_modify_e_qpdf_r3m_assembly: qpdf_r3_modify_e = 3; 126 | pub const qpdf_r3_modify_e_qpdf_r3m_none: qpdf_r3_modify_e = 4; 127 | pub type qpdf_r3_modify_e = ::std::os::raw::c_uint; 128 | pub const pdf_form_field_flag_e_ff_all_read_only: pdf_form_field_flag_e = 1; 129 | pub const pdf_form_field_flag_e_ff_all_required: pdf_form_field_flag_e = 2; 130 | pub const pdf_form_field_flag_e_ff_all_no_export: pdf_form_field_flag_e = 4; 131 | pub const pdf_form_field_flag_e_ff_btn_no_toggle_off: pdf_form_field_flag_e = 16384; 132 | pub const pdf_form_field_flag_e_ff_btn_radio: pdf_form_field_flag_e = 32768; 133 | pub const pdf_form_field_flag_e_ff_btn_pushbutton: pdf_form_field_flag_e = 65536; 134 | pub const pdf_form_field_flag_e_ff_btn_radios_in_unison: pdf_form_field_flag_e = 131072; 135 | pub const pdf_form_field_flag_e_ff_tx_multiline: pdf_form_field_flag_e = 4096; 136 | pub const pdf_form_field_flag_e_ff_tx_password: pdf_form_field_flag_e = 8192; 137 | pub const pdf_form_field_flag_e_ff_tx_file_select: pdf_form_field_flag_e = 1048576; 138 | pub const pdf_form_field_flag_e_ff_tx_do_not_spell_check: pdf_form_field_flag_e = 4194304; 139 | pub const pdf_form_field_flag_e_ff_tx_do_not_scroll: pdf_form_field_flag_e = 8388608; 140 | pub const pdf_form_field_flag_e_ff_tx_comb: pdf_form_field_flag_e = 16777216; 141 | pub const pdf_form_field_flag_e_ff_tx_rich_text: pdf_form_field_flag_e = 33554432; 142 | pub const pdf_form_field_flag_e_ff_ch_combo: pdf_form_field_flag_e = 131072; 143 | pub const pdf_form_field_flag_e_ff_ch_edit: pdf_form_field_flag_e = 262144; 144 | pub const pdf_form_field_flag_e_ff_ch_sort: pdf_form_field_flag_e = 524288; 145 | pub const pdf_form_field_flag_e_ff_ch_multi_select: pdf_form_field_flag_e = 2097152; 146 | pub const pdf_form_field_flag_e_ff_ch_do_not_spell_check: pdf_form_field_flag_e = 4194304; 147 | pub const pdf_form_field_flag_e_ff_ch_commit_on_sel_change: pdf_form_field_flag_e = 67108864; 148 | pub type pdf_form_field_flag_e = ::std::os::raw::c_uint; 149 | pub const pdf_annotation_flag_e_an_invisible: pdf_annotation_flag_e = 1; 150 | pub const pdf_annotation_flag_e_an_hidden: pdf_annotation_flag_e = 2; 151 | pub const pdf_annotation_flag_e_an_print: pdf_annotation_flag_e = 4; 152 | pub const pdf_annotation_flag_e_an_no_zoom: pdf_annotation_flag_e = 8; 153 | pub const pdf_annotation_flag_e_an_no_rotate: pdf_annotation_flag_e = 16; 154 | pub const pdf_annotation_flag_e_an_no_view: pdf_annotation_flag_e = 32; 155 | pub const pdf_annotation_flag_e_an_read_only: pdf_annotation_flag_e = 64; 156 | pub const pdf_annotation_flag_e_an_locked: pdf_annotation_flag_e = 128; 157 | pub const pdf_annotation_flag_e_an_toggle_no_view: pdf_annotation_flag_e = 256; 158 | pub const pdf_annotation_flag_e_an_locked_contents: pdf_annotation_flag_e = 512; 159 | pub type pdf_annotation_flag_e = ::std::os::raw::c_uint; 160 | pub const qpdf_encryption_status_e_qpdf_es_encrypted: qpdf_encryption_status_e = 1; 161 | pub const qpdf_encryption_status_e_qpdf_es_password_incorrect: qpdf_encryption_status_e = 2; 162 | pub type qpdf_encryption_status_e = ::std::os::raw::c_uint; 163 | pub const qpdf_page_label_e_pl_none: qpdf_page_label_e = 0; 164 | pub const qpdf_page_label_e_pl_digits: qpdf_page_label_e = 1; 165 | pub const qpdf_page_label_e_pl_alpha_lower: qpdf_page_label_e = 2; 166 | pub const qpdf_page_label_e_pl_alpha_upper: qpdf_page_label_e = 3; 167 | pub const qpdf_page_label_e_pl_roman_lower: qpdf_page_label_e = 4; 168 | pub const qpdf_page_label_e_pl_roman_upper: qpdf_page_label_e = 5; 169 | pub type qpdf_page_label_e = ::std::os::raw::c_uint; 170 | pub type qpdf_offset_t = ::std::os::raw::c_longlong; 171 | pub type wchar_t = ::std::os::raw::c_int; 172 | #[repr(C)] 173 | #[repr(align(16))] 174 | #[derive(Debug, Copy, Clone)] 175 | pub struct max_align_t { 176 | pub __clang_max_align_nonce1: ::std::os::raw::c_longlong, 177 | pub __bindgen_padding_0: u64, 178 | pub __clang_max_align_nonce2: u128, 179 | } 180 | #[allow(clippy::unnecessary_operation, clippy::identity_op)] 181 | const _: () = { 182 | ["Size of max_align_t"][::std::mem::size_of::() - 32usize]; 183 | ["Alignment of max_align_t"][::std::mem::align_of::() - 16usize]; 184 | ["Offset of field: max_align_t::__clang_max_align_nonce1"] 185 | [::std::mem::offset_of!(max_align_t, __clang_max_align_nonce1) - 0usize]; 186 | ["Offset of field: max_align_t::__clang_max_align_nonce2"] 187 | [::std::mem::offset_of!(max_align_t, __clang_max_align_nonce2) - 16usize]; 188 | }; 189 | #[repr(C)] 190 | #[derive(Debug, Copy, Clone)] 191 | pub struct _qpdflogger_handle { 192 | _unused: [u8; 0], 193 | } 194 | pub type qpdflogger_handle = *mut _qpdflogger_handle; 195 | extern "C" { 196 | pub fn qpdflogger_default_logger() -> qpdflogger_handle; 197 | } 198 | extern "C" { 199 | pub fn qpdflogger_create() -> qpdflogger_handle; 200 | } 201 | extern "C" { 202 | pub fn qpdflogger_cleanup(l: *mut qpdflogger_handle); 203 | } 204 | pub const qpdf_log_dest_e_qpdf_log_dest_default: qpdf_log_dest_e = 0; 205 | pub const qpdf_log_dest_e_qpdf_log_dest_stdout: qpdf_log_dest_e = 1; 206 | pub const qpdf_log_dest_e_qpdf_log_dest_stderr: qpdf_log_dest_e = 2; 207 | pub const qpdf_log_dest_e_qpdf_log_dest_discard: qpdf_log_dest_e = 3; 208 | pub const qpdf_log_dest_e_qpdf_log_dest_custom: qpdf_log_dest_e = 4; 209 | pub type qpdf_log_dest_e = ::std::os::raw::c_uint; 210 | pub type qpdf_log_fn_t = ::std::option::Option< 211 | unsafe extern "C" fn( 212 | data: *const ::std::os::raw::c_char, 213 | len: usize, 214 | udata: *mut ::std::os::raw::c_void, 215 | ) -> ::std::os::raw::c_int, 216 | >; 217 | extern "C" { 218 | pub fn qpdflogger_set_info( 219 | l: qpdflogger_handle, 220 | dest: qpdf_log_dest_e, 221 | fn_: qpdf_log_fn_t, 222 | udata: *mut ::std::os::raw::c_void, 223 | ); 224 | } 225 | extern "C" { 226 | pub fn qpdflogger_set_warn( 227 | l: qpdflogger_handle, 228 | dest: qpdf_log_dest_e, 229 | fn_: qpdf_log_fn_t, 230 | udata: *mut ::std::os::raw::c_void, 231 | ); 232 | } 233 | extern "C" { 234 | pub fn qpdflogger_set_error( 235 | l: qpdflogger_handle, 236 | dest: qpdf_log_dest_e, 237 | fn_: qpdf_log_fn_t, 238 | udata: *mut ::std::os::raw::c_void, 239 | ); 240 | } 241 | extern "C" { 242 | pub fn qpdflogger_set_save( 243 | l: qpdflogger_handle, 244 | dest: qpdf_log_dest_e, 245 | fn_: qpdf_log_fn_t, 246 | udata: *mut ::std::os::raw::c_void, 247 | only_if_not_set: ::std::os::raw::c_int, 248 | ); 249 | } 250 | extern "C" { 251 | pub fn qpdflogger_save_to_standard_output(l: qpdflogger_handle, only_if_not_set: ::std::os::raw::c_int); 252 | } 253 | extern "C" { 254 | pub fn qpdflogger_equal(l1: qpdflogger_handle, l2: qpdflogger_handle) -> ::std::os::raw::c_int; 255 | } 256 | extern "C" { 257 | pub fn memcpy( 258 | __dest: *mut ::std::os::raw::c_void, 259 | __src: *const ::std::os::raw::c_void, 260 | __n: ::std::os::raw::c_ulong, 261 | ) -> *mut ::std::os::raw::c_void; 262 | } 263 | extern "C" { 264 | pub fn memmove( 265 | __dest: *mut ::std::os::raw::c_void, 266 | __src: *const ::std::os::raw::c_void, 267 | __n: ::std::os::raw::c_ulong, 268 | ) -> *mut ::std::os::raw::c_void; 269 | } 270 | extern "C" { 271 | pub fn memccpy( 272 | __dest: *mut ::std::os::raw::c_void, 273 | __src: *const ::std::os::raw::c_void, 274 | __c: ::std::os::raw::c_int, 275 | __n: ::std::os::raw::c_ulong, 276 | ) -> *mut ::std::os::raw::c_void; 277 | } 278 | extern "C" { 279 | pub fn memset( 280 | __s: *mut ::std::os::raw::c_void, 281 | __c: ::std::os::raw::c_int, 282 | __n: ::std::os::raw::c_ulong, 283 | ) -> *mut ::std::os::raw::c_void; 284 | } 285 | extern "C" { 286 | pub fn memcmp( 287 | __s1: *const ::std::os::raw::c_void, 288 | __s2: *const ::std::os::raw::c_void, 289 | __n: ::std::os::raw::c_ulong, 290 | ) -> ::std::os::raw::c_int; 291 | } 292 | extern "C" { 293 | pub fn __memcmpeq( 294 | __s1: *const ::std::os::raw::c_void, 295 | __s2: *const ::std::os::raw::c_void, 296 | __n: usize, 297 | ) -> ::std::os::raw::c_int; 298 | } 299 | extern "C" { 300 | pub fn memchr( 301 | __s: *const ::std::os::raw::c_void, 302 | __c: ::std::os::raw::c_int, 303 | __n: ::std::os::raw::c_ulong, 304 | ) -> *mut ::std::os::raw::c_void; 305 | } 306 | extern "C" { 307 | pub fn strcpy( 308 | __dest: *mut ::std::os::raw::c_char, 309 | __src: *const ::std::os::raw::c_char, 310 | ) -> *mut ::std::os::raw::c_char; 311 | } 312 | extern "C" { 313 | pub fn strncpy( 314 | __dest: *mut ::std::os::raw::c_char, 315 | __src: *const ::std::os::raw::c_char, 316 | __n: ::std::os::raw::c_ulong, 317 | ) -> *mut ::std::os::raw::c_char; 318 | } 319 | extern "C" { 320 | pub fn strcat( 321 | __dest: *mut ::std::os::raw::c_char, 322 | __src: *const ::std::os::raw::c_char, 323 | ) -> *mut ::std::os::raw::c_char; 324 | } 325 | extern "C" { 326 | pub fn strncat( 327 | __dest: *mut ::std::os::raw::c_char, 328 | __src: *const ::std::os::raw::c_char, 329 | __n: ::std::os::raw::c_ulong, 330 | ) -> *mut ::std::os::raw::c_char; 331 | } 332 | extern "C" { 333 | pub fn strcmp(__s1: *const ::std::os::raw::c_char, __s2: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; 334 | } 335 | extern "C" { 336 | pub fn strncmp( 337 | __s1: *const ::std::os::raw::c_char, 338 | __s2: *const ::std::os::raw::c_char, 339 | __n: ::std::os::raw::c_ulong, 340 | ) -> ::std::os::raw::c_int; 341 | } 342 | extern "C" { 343 | pub fn strcoll(__s1: *const ::std::os::raw::c_char, __s2: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; 344 | } 345 | extern "C" { 346 | pub fn strxfrm( 347 | __dest: *mut ::std::os::raw::c_char, 348 | __src: *const ::std::os::raw::c_char, 349 | __n: ::std::os::raw::c_ulong, 350 | ) -> ::std::os::raw::c_ulong; 351 | } 352 | #[repr(C)] 353 | #[derive(Debug, Copy, Clone)] 354 | pub struct __locale_struct { 355 | pub __locales: [*mut __locale_data; 13usize], 356 | pub __ctype_b: *const ::std::os::raw::c_ushort, 357 | pub __ctype_tolower: *const ::std::os::raw::c_int, 358 | pub __ctype_toupper: *const ::std::os::raw::c_int, 359 | pub __names: [*const ::std::os::raw::c_char; 13usize], 360 | } 361 | #[allow(clippy::unnecessary_operation, clippy::identity_op)] 362 | const _: () = { 363 | ["Size of __locale_struct"][::std::mem::size_of::<__locale_struct>() - 232usize]; 364 | ["Alignment of __locale_struct"][::std::mem::align_of::<__locale_struct>() - 8usize]; 365 | ["Offset of field: __locale_struct::__locales"][::std::mem::offset_of!(__locale_struct, __locales) - 0usize]; 366 | ["Offset of field: __locale_struct::__ctype_b"][::std::mem::offset_of!(__locale_struct, __ctype_b) - 104usize]; 367 | ["Offset of field: __locale_struct::__ctype_tolower"] 368 | [::std::mem::offset_of!(__locale_struct, __ctype_tolower) - 112usize]; 369 | ["Offset of field: __locale_struct::__ctype_toupper"] 370 | [::std::mem::offset_of!(__locale_struct, __ctype_toupper) - 120usize]; 371 | ["Offset of field: __locale_struct::__names"][::std::mem::offset_of!(__locale_struct, __names) - 128usize]; 372 | }; 373 | pub type __locale_t = *mut __locale_struct; 374 | pub type locale_t = __locale_t; 375 | extern "C" { 376 | pub fn strcoll_l( 377 | __s1: *const ::std::os::raw::c_char, 378 | __s2: *const ::std::os::raw::c_char, 379 | __l: locale_t, 380 | ) -> ::std::os::raw::c_int; 381 | } 382 | extern "C" { 383 | pub fn strxfrm_l( 384 | __dest: *mut ::std::os::raw::c_char, 385 | __src: *const ::std::os::raw::c_char, 386 | __n: usize, 387 | __l: locale_t, 388 | ) -> usize; 389 | } 390 | extern "C" { 391 | pub fn strdup(__s: *const ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char; 392 | } 393 | extern "C" { 394 | pub fn strndup( 395 | __string: *const ::std::os::raw::c_char, 396 | __n: ::std::os::raw::c_ulong, 397 | ) -> *mut ::std::os::raw::c_char; 398 | } 399 | extern "C" { 400 | pub fn strchr(__s: *const ::std::os::raw::c_char, __c: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; 401 | } 402 | extern "C" { 403 | pub fn strrchr(__s: *const ::std::os::raw::c_char, __c: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; 404 | } 405 | extern "C" { 406 | pub fn strchrnul(__s: *const ::std::os::raw::c_char, __c: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; 407 | } 408 | extern "C" { 409 | pub fn strcspn( 410 | __s: *const ::std::os::raw::c_char, 411 | __reject: *const ::std::os::raw::c_char, 412 | ) -> ::std::os::raw::c_ulong; 413 | } 414 | extern "C" { 415 | pub fn strspn( 416 | __s: *const ::std::os::raw::c_char, 417 | __accept: *const ::std::os::raw::c_char, 418 | ) -> ::std::os::raw::c_ulong; 419 | } 420 | extern "C" { 421 | pub fn strpbrk( 422 | __s: *const ::std::os::raw::c_char, 423 | __accept: *const ::std::os::raw::c_char, 424 | ) -> *mut ::std::os::raw::c_char; 425 | } 426 | extern "C" { 427 | pub fn strstr( 428 | __haystack: *const ::std::os::raw::c_char, 429 | __needle: *const ::std::os::raw::c_char, 430 | ) -> *mut ::std::os::raw::c_char; 431 | } 432 | extern "C" { 433 | pub fn strtok( 434 | __s: *mut ::std::os::raw::c_char, 435 | __delim: *const ::std::os::raw::c_char, 436 | ) -> *mut ::std::os::raw::c_char; 437 | } 438 | extern "C" { 439 | pub fn __strtok_r( 440 | __s: *mut ::std::os::raw::c_char, 441 | __delim: *const ::std::os::raw::c_char, 442 | __save_ptr: *mut *mut ::std::os::raw::c_char, 443 | ) -> *mut ::std::os::raw::c_char; 444 | } 445 | extern "C" { 446 | pub fn strtok_r( 447 | __s: *mut ::std::os::raw::c_char, 448 | __delim: *const ::std::os::raw::c_char, 449 | __save_ptr: *mut *mut ::std::os::raw::c_char, 450 | ) -> *mut ::std::os::raw::c_char; 451 | } 452 | extern "C" { 453 | pub fn strcasestr( 454 | __haystack: *const ::std::os::raw::c_char, 455 | __needle: *const ::std::os::raw::c_char, 456 | ) -> *mut ::std::os::raw::c_char; 457 | } 458 | extern "C" { 459 | pub fn memmem( 460 | __haystack: *const ::std::os::raw::c_void, 461 | __haystacklen: usize, 462 | __needle: *const ::std::os::raw::c_void, 463 | __needlelen: usize, 464 | ) -> *mut ::std::os::raw::c_void; 465 | } 466 | extern "C" { 467 | pub fn __mempcpy( 468 | __dest: *mut ::std::os::raw::c_void, 469 | __src: *const ::std::os::raw::c_void, 470 | __n: usize, 471 | ) -> *mut ::std::os::raw::c_void; 472 | } 473 | extern "C" { 474 | pub fn mempcpy( 475 | __dest: *mut ::std::os::raw::c_void, 476 | __src: *const ::std::os::raw::c_void, 477 | __n: ::std::os::raw::c_ulong, 478 | ) -> *mut ::std::os::raw::c_void; 479 | } 480 | extern "C" { 481 | pub fn strlen(__s: *const ::std::os::raw::c_char) -> ::std::os::raw::c_ulong; 482 | } 483 | extern "C" { 484 | pub fn strnlen(__string: *const ::std::os::raw::c_char, __maxlen: usize) -> usize; 485 | } 486 | extern "C" { 487 | pub fn strerror(__errnum: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; 488 | } 489 | extern "C" { 490 | #[link_name = "\u{1}__xpg_strerror_r"] 491 | pub fn strerror_r( 492 | __errnum: ::std::os::raw::c_int, 493 | __buf: *mut ::std::os::raw::c_char, 494 | __buflen: usize, 495 | ) -> ::std::os::raw::c_int; 496 | } 497 | extern "C" { 498 | pub fn strerror_l(__errnum: ::std::os::raw::c_int, __l: locale_t) -> *mut ::std::os::raw::c_char; 499 | } 500 | extern "C" { 501 | pub fn bcmp( 502 | __s1: *const ::std::os::raw::c_void, 503 | __s2: *const ::std::os::raw::c_void, 504 | __n: ::std::os::raw::c_ulong, 505 | ) -> ::std::os::raw::c_int; 506 | } 507 | extern "C" { 508 | pub fn bcopy( 509 | __src: *const ::std::os::raw::c_void, 510 | __dest: *mut ::std::os::raw::c_void, 511 | __n: ::std::os::raw::c_ulong, 512 | ); 513 | } 514 | extern "C" { 515 | pub fn bzero(__s: *mut ::std::os::raw::c_void, __n: ::std::os::raw::c_ulong); 516 | } 517 | extern "C" { 518 | pub fn index(__s: *const ::std::os::raw::c_char, __c: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; 519 | } 520 | extern "C" { 521 | pub fn rindex(__s: *const ::std::os::raw::c_char, __c: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; 522 | } 523 | extern "C" { 524 | pub fn ffs(__i: ::std::os::raw::c_int) -> ::std::os::raw::c_int; 525 | } 526 | extern "C" { 527 | pub fn ffsl(__l: ::std::os::raw::c_long) -> ::std::os::raw::c_int; 528 | } 529 | extern "C" { 530 | pub fn ffsll(__ll: ::std::os::raw::c_longlong) -> ::std::os::raw::c_int; 531 | } 532 | extern "C" { 533 | pub fn strcasecmp( 534 | __s1: *const ::std::os::raw::c_char, 535 | __s2: *const ::std::os::raw::c_char, 536 | ) -> ::std::os::raw::c_int; 537 | } 538 | extern "C" { 539 | pub fn strncasecmp( 540 | __s1: *const ::std::os::raw::c_char, 541 | __s2: *const ::std::os::raw::c_char, 542 | __n: ::std::os::raw::c_ulong, 543 | ) -> ::std::os::raw::c_int; 544 | } 545 | extern "C" { 546 | pub fn strcasecmp_l( 547 | __s1: *const ::std::os::raw::c_char, 548 | __s2: *const ::std::os::raw::c_char, 549 | __loc: locale_t, 550 | ) -> ::std::os::raw::c_int; 551 | } 552 | extern "C" { 553 | pub fn strncasecmp_l( 554 | __s1: *const ::std::os::raw::c_char, 555 | __s2: *const ::std::os::raw::c_char, 556 | __n: usize, 557 | __loc: locale_t, 558 | ) -> ::std::os::raw::c_int; 559 | } 560 | extern "C" { 561 | pub fn explicit_bzero(__s: *mut ::std::os::raw::c_void, __n: usize); 562 | } 563 | extern "C" { 564 | pub fn strsep( 565 | __stringp: *mut *mut ::std::os::raw::c_char, 566 | __delim: *const ::std::os::raw::c_char, 567 | ) -> *mut ::std::os::raw::c_char; 568 | } 569 | extern "C" { 570 | pub fn strsignal(__sig: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; 571 | } 572 | extern "C" { 573 | pub fn __stpcpy( 574 | __dest: *mut ::std::os::raw::c_char, 575 | __src: *const ::std::os::raw::c_char, 576 | ) -> *mut ::std::os::raw::c_char; 577 | } 578 | extern "C" { 579 | pub fn stpcpy( 580 | __dest: *mut ::std::os::raw::c_char, 581 | __src: *const ::std::os::raw::c_char, 582 | ) -> *mut ::std::os::raw::c_char; 583 | } 584 | extern "C" { 585 | pub fn __stpncpy( 586 | __dest: *mut ::std::os::raw::c_char, 587 | __src: *const ::std::os::raw::c_char, 588 | __n: usize, 589 | ) -> *mut ::std::os::raw::c_char; 590 | } 591 | extern "C" { 592 | pub fn stpncpy( 593 | __dest: *mut ::std::os::raw::c_char, 594 | __src: *const ::std::os::raw::c_char, 595 | __n: ::std::os::raw::c_ulong, 596 | ) -> *mut ::std::os::raw::c_char; 597 | } 598 | extern "C" { 599 | pub fn strlcpy( 600 | __dest: *mut ::std::os::raw::c_char, 601 | __src: *const ::std::os::raw::c_char, 602 | __n: ::std::os::raw::c_ulong, 603 | ) -> ::std::os::raw::c_ulong; 604 | } 605 | extern "C" { 606 | pub fn strlcat( 607 | __dest: *mut ::std::os::raw::c_char, 608 | __src: *const ::std::os::raw::c_char, 609 | __n: ::std::os::raw::c_ulong, 610 | ) -> ::std::os::raw::c_ulong; 611 | } 612 | #[repr(C)] 613 | #[derive(Debug, Copy, Clone)] 614 | pub struct _qpdf_data { 615 | _unused: [u8; 0], 616 | } 617 | pub type qpdf_data = *mut _qpdf_data; 618 | #[repr(C)] 619 | #[derive(Debug, Copy, Clone)] 620 | pub struct _qpdf_error { 621 | _unused: [u8; 0], 622 | } 623 | pub type qpdf_error = *mut _qpdf_error; 624 | pub type QPDF_ERROR_CODE = ::std::os::raw::c_int; 625 | pub type QPDF_BOOL = ::std::os::raw::c_int; 626 | extern "C" { 627 | pub fn qpdf_silence_errors(qpdf: qpdf_data); 628 | } 629 | extern "C" { 630 | pub fn qpdf_get_qpdf_version() -> *const ::std::os::raw::c_char; 631 | } 632 | extern "C" { 633 | pub fn qpdf_init() -> qpdf_data; 634 | } 635 | extern "C" { 636 | pub fn qpdf_cleanup(qpdf: *mut qpdf_data); 637 | } 638 | extern "C" { 639 | pub fn qpdf_has_error(qpdf: qpdf_data) -> QPDF_BOOL; 640 | } 641 | extern "C" { 642 | pub fn qpdf_get_error(qpdf: qpdf_data) -> qpdf_error; 643 | } 644 | extern "C" { 645 | pub fn qpdf_more_warnings(qpdf: qpdf_data) -> QPDF_BOOL; 646 | } 647 | extern "C" { 648 | pub fn qpdf_next_warning(qpdf: qpdf_data) -> qpdf_error; 649 | } 650 | extern "C" { 651 | pub fn qpdf_get_error_full_text(q: qpdf_data, e: qpdf_error) -> *const ::std::os::raw::c_char; 652 | } 653 | extern "C" { 654 | pub fn qpdf_get_error_code(q: qpdf_data, e: qpdf_error) -> qpdf_error_code_e; 655 | } 656 | extern "C" { 657 | pub fn qpdf_get_error_filename(q: qpdf_data, e: qpdf_error) -> *const ::std::os::raw::c_char; 658 | } 659 | extern "C" { 660 | pub fn qpdf_get_error_file_position(q: qpdf_data, e: qpdf_error) -> ::std::os::raw::c_ulonglong; 661 | } 662 | extern "C" { 663 | pub fn qpdf_get_error_message_detail(q: qpdf_data, e: qpdf_error) -> *const ::std::os::raw::c_char; 664 | } 665 | extern "C" { 666 | pub fn qpdf_set_suppress_warnings(qpdf: qpdf_data, value: QPDF_BOOL); 667 | } 668 | extern "C" { 669 | pub fn qpdf_set_logger(qpdf: qpdf_data, logger: qpdflogger_handle); 670 | } 671 | extern "C" { 672 | pub fn qpdf_get_logger(qpdf: qpdf_data) -> qpdflogger_handle; 673 | } 674 | extern "C" { 675 | pub fn qpdf_check_pdf(qpdf: qpdf_data) -> QPDF_ERROR_CODE; 676 | } 677 | extern "C" { 678 | pub fn qpdf_set_ignore_xref_streams(qpdf: qpdf_data, value: QPDF_BOOL); 679 | } 680 | extern "C" { 681 | pub fn qpdf_set_attempt_recovery(qpdf: qpdf_data, value: QPDF_BOOL); 682 | } 683 | extern "C" { 684 | pub fn qpdf_read( 685 | qpdf: qpdf_data, 686 | filename: *const ::std::os::raw::c_char, 687 | password: *const ::std::os::raw::c_char, 688 | ) -> QPDF_ERROR_CODE; 689 | } 690 | extern "C" { 691 | pub fn qpdf_read_memory( 692 | qpdf: qpdf_data, 693 | description: *const ::std::os::raw::c_char, 694 | buffer: *const ::std::os::raw::c_char, 695 | size: ::std::os::raw::c_ulonglong, 696 | password: *const ::std::os::raw::c_char, 697 | ) -> QPDF_ERROR_CODE; 698 | } 699 | extern "C" { 700 | pub fn qpdf_empty_pdf(qpdf: qpdf_data) -> QPDF_ERROR_CODE; 701 | } 702 | extern "C" { 703 | pub fn qpdf_create_from_json_file(qpdf: qpdf_data, filename: *const ::std::os::raw::c_char) -> QPDF_ERROR_CODE; 704 | } 705 | extern "C" { 706 | pub fn qpdf_create_from_json_data( 707 | qpdf: qpdf_data, 708 | buffer: *const ::std::os::raw::c_char, 709 | size: ::std::os::raw::c_ulonglong, 710 | ) -> QPDF_ERROR_CODE; 711 | } 712 | extern "C" { 713 | pub fn qpdf_update_from_json_file(qpdf: qpdf_data, filename: *const ::std::os::raw::c_char) -> QPDF_ERROR_CODE; 714 | } 715 | extern "C" { 716 | pub fn qpdf_update_from_json_data( 717 | qpdf: qpdf_data, 718 | buffer: *const ::std::os::raw::c_char, 719 | size: ::std::os::raw::c_ulonglong, 720 | ) -> QPDF_ERROR_CODE; 721 | } 722 | extern "C" { 723 | pub fn qpdf_get_pdf_version(qpdf: qpdf_data) -> *const ::std::os::raw::c_char; 724 | } 725 | extern "C" { 726 | pub fn qpdf_get_pdf_extension_level(qpdf: qpdf_data) -> ::std::os::raw::c_int; 727 | } 728 | extern "C" { 729 | pub fn qpdf_get_user_password(qpdf: qpdf_data) -> *const ::std::os::raw::c_char; 730 | } 731 | extern "C" { 732 | pub fn qpdf_get_info_key(qpdf: qpdf_data, key: *const ::std::os::raw::c_char) -> *const ::std::os::raw::c_char; 733 | } 734 | extern "C" { 735 | pub fn qpdf_set_info_key(qpdf: qpdf_data, key: *const ::std::os::raw::c_char, value: *const ::std::os::raw::c_char); 736 | } 737 | extern "C" { 738 | pub fn qpdf_is_linearized(qpdf: qpdf_data) -> QPDF_BOOL; 739 | } 740 | extern "C" { 741 | pub fn qpdf_is_encrypted(qpdf: qpdf_data) -> QPDF_BOOL; 742 | } 743 | extern "C" { 744 | pub fn qpdf_allow_accessibility(qpdf: qpdf_data) -> QPDF_BOOL; 745 | } 746 | extern "C" { 747 | pub fn qpdf_allow_extract_all(qpdf: qpdf_data) -> QPDF_BOOL; 748 | } 749 | extern "C" { 750 | pub fn qpdf_allow_print_low_res(qpdf: qpdf_data) -> QPDF_BOOL; 751 | } 752 | extern "C" { 753 | pub fn qpdf_allow_print_high_res(qpdf: qpdf_data) -> QPDF_BOOL; 754 | } 755 | extern "C" { 756 | pub fn qpdf_allow_modify_assembly(qpdf: qpdf_data) -> QPDF_BOOL; 757 | } 758 | extern "C" { 759 | pub fn qpdf_allow_modify_form(qpdf: qpdf_data) -> QPDF_BOOL; 760 | } 761 | extern "C" { 762 | pub fn qpdf_allow_modify_annotation(qpdf: qpdf_data) -> QPDF_BOOL; 763 | } 764 | extern "C" { 765 | pub fn qpdf_allow_modify_other(qpdf: qpdf_data) -> QPDF_BOOL; 766 | } 767 | extern "C" { 768 | pub fn qpdf_allow_modify_all(qpdf: qpdf_data) -> QPDF_BOOL; 769 | } 770 | pub type qpdf_write_fn_t = ::std::option::Option< 771 | unsafe extern "C" fn( 772 | data: *const ::std::os::raw::c_char, 773 | len: usize, 774 | udata: *mut ::std::os::raw::c_void, 775 | ) -> ::std::os::raw::c_int, 776 | >; 777 | extern "C" { 778 | pub fn qpdf_write_json( 779 | qpdf: qpdf_data, 780 | version: ::std::os::raw::c_int, 781 | fn_: qpdf_write_fn_t, 782 | udata: *mut ::std::os::raw::c_void, 783 | decode_level: qpdf_stream_decode_level_e, 784 | json_stream_data: qpdf_json_stream_data_e, 785 | file_prefix: *const ::std::os::raw::c_char, 786 | wanted_objects: *const *const ::std::os::raw::c_char, 787 | ) -> QPDF_ERROR_CODE; 788 | } 789 | extern "C" { 790 | pub fn qpdf_init_write(qpdf: qpdf_data, filename: *const ::std::os::raw::c_char) -> QPDF_ERROR_CODE; 791 | } 792 | extern "C" { 793 | pub fn qpdf_init_write_memory(qpdf: qpdf_data) -> QPDF_ERROR_CODE; 794 | } 795 | extern "C" { 796 | pub fn qpdf_get_buffer_length(qpdf: qpdf_data) -> usize; 797 | } 798 | extern "C" { 799 | pub fn qpdf_get_buffer(qpdf: qpdf_data) -> *const ::std::os::raw::c_uchar; 800 | } 801 | extern "C" { 802 | pub fn qpdf_set_object_stream_mode(qpdf: qpdf_data, mode: qpdf_object_stream_e); 803 | } 804 | extern "C" { 805 | pub fn qpdf_set_stream_data_mode(qpdf: qpdf_data, mode: qpdf_stream_data_e); 806 | } 807 | extern "C" { 808 | pub fn qpdf_set_compress_streams(qpdf: qpdf_data, value: QPDF_BOOL); 809 | } 810 | extern "C" { 811 | pub fn qpdf_set_decode_level(qpdf: qpdf_data, level: qpdf_stream_decode_level_e); 812 | } 813 | extern "C" { 814 | pub fn qpdf_set_preserve_unreferenced_objects(qpdf: qpdf_data, value: QPDF_BOOL); 815 | } 816 | extern "C" { 817 | pub fn qpdf_set_newline_before_endstream(qpdf: qpdf_data, value: QPDF_BOOL); 818 | } 819 | extern "C" { 820 | pub fn qpdf_set_content_normalization(qpdf: qpdf_data, value: QPDF_BOOL); 821 | } 822 | extern "C" { 823 | pub fn qpdf_set_qdf_mode(qpdf: qpdf_data, value: QPDF_BOOL); 824 | } 825 | extern "C" { 826 | pub fn qpdf_set_deterministic_ID(qpdf: qpdf_data, value: QPDF_BOOL); 827 | } 828 | extern "C" { 829 | pub fn qpdf_set_static_ID(qpdf: qpdf_data, value: QPDF_BOOL); 830 | } 831 | extern "C" { 832 | pub fn qpdf_set_static_aes_IV(qpdf: qpdf_data, value: QPDF_BOOL); 833 | } 834 | extern "C" { 835 | pub fn qpdf_set_suppress_original_object_IDs(qpdf: qpdf_data, value: QPDF_BOOL); 836 | } 837 | extern "C" { 838 | pub fn qpdf_set_preserve_encryption(qpdf: qpdf_data, value: QPDF_BOOL); 839 | } 840 | extern "C" { 841 | pub fn qpdf_set_r2_encryption_parameters_insecure( 842 | qpdf: qpdf_data, 843 | user_password: *const ::std::os::raw::c_char, 844 | owner_password: *const ::std::os::raw::c_char, 845 | allow_print: QPDF_BOOL, 846 | allow_modify: QPDF_BOOL, 847 | allow_extract: QPDF_BOOL, 848 | allow_annotate: QPDF_BOOL, 849 | ); 850 | } 851 | extern "C" { 852 | pub fn qpdf_set_r3_encryption_parameters_insecure( 853 | qpdf: qpdf_data, 854 | user_password: *const ::std::os::raw::c_char, 855 | owner_password: *const ::std::os::raw::c_char, 856 | allow_accessibility: QPDF_BOOL, 857 | allow_extract: QPDF_BOOL, 858 | allow_assemble: QPDF_BOOL, 859 | allow_annotate_and_form: QPDF_BOOL, 860 | allow_form_filling: QPDF_BOOL, 861 | allow_modify_other: QPDF_BOOL, 862 | print: qpdf_r3_print_e, 863 | ); 864 | } 865 | extern "C" { 866 | pub fn qpdf_set_r4_encryption_parameters_insecure( 867 | qpdf: qpdf_data, 868 | user_password: *const ::std::os::raw::c_char, 869 | owner_password: *const ::std::os::raw::c_char, 870 | allow_accessibility: QPDF_BOOL, 871 | allow_extract: QPDF_BOOL, 872 | allow_assemble: QPDF_BOOL, 873 | allow_annotate_and_form: QPDF_BOOL, 874 | allow_form_filling: QPDF_BOOL, 875 | allow_modify_other: QPDF_BOOL, 876 | print: qpdf_r3_print_e, 877 | encrypt_metadata: QPDF_BOOL, 878 | use_aes: QPDF_BOOL, 879 | ); 880 | } 881 | extern "C" { 882 | pub fn qpdf_set_r5_encryption_parameters2( 883 | qpdf: qpdf_data, 884 | user_password: *const ::std::os::raw::c_char, 885 | owner_password: *const ::std::os::raw::c_char, 886 | allow_accessibility: QPDF_BOOL, 887 | allow_extract: QPDF_BOOL, 888 | allow_assemble: QPDF_BOOL, 889 | allow_annotate_and_form: QPDF_BOOL, 890 | allow_form_filling: QPDF_BOOL, 891 | allow_modify_other: QPDF_BOOL, 892 | print: qpdf_r3_print_e, 893 | encrypt_metadata: QPDF_BOOL, 894 | ); 895 | } 896 | extern "C" { 897 | pub fn qpdf_set_r6_encryption_parameters2( 898 | qpdf: qpdf_data, 899 | user_password: *const ::std::os::raw::c_char, 900 | owner_password: *const ::std::os::raw::c_char, 901 | allow_accessibility: QPDF_BOOL, 902 | allow_extract: QPDF_BOOL, 903 | allow_assemble: QPDF_BOOL, 904 | allow_annotate_and_form: QPDF_BOOL, 905 | allow_form_filling: QPDF_BOOL, 906 | allow_modify_other: QPDF_BOOL, 907 | print: qpdf_r3_print_e, 908 | encrypt_metadata: QPDF_BOOL, 909 | ); 910 | } 911 | extern "C" { 912 | pub fn qpdf_set_linearization(qpdf: qpdf_data, value: QPDF_BOOL); 913 | } 914 | extern "C" { 915 | pub fn qpdf_set_minimum_pdf_version(qpdf: qpdf_data, version: *const ::std::os::raw::c_char); 916 | } 917 | extern "C" { 918 | pub fn qpdf_set_minimum_pdf_version_and_extension( 919 | qpdf: qpdf_data, 920 | version: *const ::std::os::raw::c_char, 921 | extension_level: ::std::os::raw::c_int, 922 | ); 923 | } 924 | extern "C" { 925 | pub fn qpdf_force_pdf_version(qpdf: qpdf_data, version: *const ::std::os::raw::c_char); 926 | } 927 | extern "C" { 928 | pub fn qpdf_force_pdf_version_and_extension( 929 | qpdf: qpdf_data, 930 | version: *const ::std::os::raw::c_char, 931 | extension_level: ::std::os::raw::c_int, 932 | ); 933 | } 934 | extern "C" { 935 | pub fn qpdf_register_progress_reporter( 936 | qpdf: qpdf_data, 937 | report_progress: ::std::option::Option< 938 | unsafe extern "C" fn(percent: ::std::os::raw::c_int, data: *mut ::std::os::raw::c_void), 939 | >, 940 | data: *mut ::std::os::raw::c_void, 941 | ); 942 | } 943 | extern "C" { 944 | pub fn qpdf_write(qpdf: qpdf_data) -> QPDF_ERROR_CODE; 945 | } 946 | pub type qpdf_oh = ::std::os::raw::c_uint; 947 | extern "C" { 948 | pub fn qpdf_oh_release(qpdf: qpdf_data, oh: qpdf_oh); 949 | } 950 | extern "C" { 951 | pub fn qpdf_oh_release_all(qpdf: qpdf_data); 952 | } 953 | extern "C" { 954 | pub fn qpdf_oh_new_object(qpdf: qpdf_data, oh: qpdf_oh) -> qpdf_oh; 955 | } 956 | extern "C" { 957 | pub fn qpdf_get_trailer(qpdf: qpdf_data) -> qpdf_oh; 958 | } 959 | extern "C" { 960 | pub fn qpdf_get_root(qpdf: qpdf_data) -> qpdf_oh; 961 | } 962 | extern "C" { 963 | pub fn qpdf_get_object_by_id( 964 | qpdf: qpdf_data, 965 | objid: ::std::os::raw::c_int, 966 | generation: ::std::os::raw::c_int, 967 | ) -> qpdf_oh; 968 | } 969 | extern "C" { 970 | pub fn qpdf_make_indirect_object(qpdf: qpdf_data, oh: qpdf_oh) -> qpdf_oh; 971 | } 972 | extern "C" { 973 | pub fn qpdf_replace_object( 974 | qpdf: qpdf_data, 975 | objid: ::std::os::raw::c_int, 976 | generation: ::std::os::raw::c_int, 977 | oh: qpdf_oh, 978 | ); 979 | } 980 | extern "C" { 981 | pub fn qpdf_oh_is_initialized(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 982 | } 983 | extern "C" { 984 | pub fn qpdf_oh_is_bool(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 985 | } 986 | extern "C" { 987 | pub fn qpdf_oh_is_null(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 988 | } 989 | extern "C" { 990 | pub fn qpdf_oh_is_integer(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 991 | } 992 | extern "C" { 993 | pub fn qpdf_oh_is_real(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 994 | } 995 | extern "C" { 996 | pub fn qpdf_oh_is_name(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 997 | } 998 | extern "C" { 999 | pub fn qpdf_oh_is_string(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1000 | } 1001 | extern "C" { 1002 | pub fn qpdf_oh_is_operator(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1003 | } 1004 | extern "C" { 1005 | pub fn qpdf_oh_is_inline_image(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1006 | } 1007 | extern "C" { 1008 | pub fn qpdf_oh_is_array(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1009 | } 1010 | extern "C" { 1011 | pub fn qpdf_oh_is_dictionary(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1012 | } 1013 | extern "C" { 1014 | pub fn qpdf_oh_is_stream(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1015 | } 1016 | extern "C" { 1017 | pub fn qpdf_oh_is_indirect(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1018 | } 1019 | extern "C" { 1020 | pub fn qpdf_oh_is_scalar(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1021 | } 1022 | extern "C" { 1023 | pub fn qpdf_oh_is_name_and_equals(qpdf: qpdf_data, oh: qpdf_oh, name: *const ::std::os::raw::c_char) -> QPDF_BOOL; 1024 | } 1025 | extern "C" { 1026 | pub fn qpdf_oh_is_dictionary_of_type( 1027 | qpdf: qpdf_data, 1028 | oh: qpdf_oh, 1029 | type_: *const ::std::os::raw::c_char, 1030 | subtype: *const ::std::os::raw::c_char, 1031 | ) -> QPDF_BOOL; 1032 | } 1033 | extern "C" { 1034 | pub fn qpdf_oh_get_type_code(qpdf: qpdf_data, oh: qpdf_oh) -> qpdf_object_type_e; 1035 | } 1036 | extern "C" { 1037 | pub fn qpdf_oh_get_type_name(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1038 | } 1039 | extern "C" { 1040 | pub fn qpdf_oh_wrap_in_array(qpdf: qpdf_data, oh: qpdf_oh) -> qpdf_oh; 1041 | } 1042 | extern "C" { 1043 | pub fn qpdf_oh_parse(qpdf: qpdf_data, object_str: *const ::std::os::raw::c_char) -> qpdf_oh; 1044 | } 1045 | extern "C" { 1046 | pub fn qpdf_oh_get_bool_value(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1047 | } 1048 | extern "C" { 1049 | pub fn qpdf_oh_get_value_as_bool(qpdf: qpdf_data, oh: qpdf_oh, value: *mut QPDF_BOOL) -> QPDF_BOOL; 1050 | } 1051 | extern "C" { 1052 | pub fn qpdf_oh_get_int_value(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_longlong; 1053 | } 1054 | extern "C" { 1055 | pub fn qpdf_oh_get_value_as_longlong( 1056 | qpdf: qpdf_data, 1057 | oh: qpdf_oh, 1058 | value: *mut ::std::os::raw::c_longlong, 1059 | ) -> QPDF_BOOL; 1060 | } 1061 | extern "C" { 1062 | pub fn qpdf_oh_get_int_value_as_int(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_int; 1063 | } 1064 | extern "C" { 1065 | pub fn qpdf_oh_get_value_as_int(qpdf: qpdf_data, oh: qpdf_oh, value: *mut ::std::os::raw::c_int) -> QPDF_BOOL; 1066 | } 1067 | extern "C" { 1068 | pub fn qpdf_oh_get_uint_value(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_ulonglong; 1069 | } 1070 | extern "C" { 1071 | pub fn qpdf_oh_get_value_as_ulonglong( 1072 | qpdf: qpdf_data, 1073 | oh: qpdf_oh, 1074 | value: *mut ::std::os::raw::c_ulonglong, 1075 | ) -> QPDF_BOOL; 1076 | } 1077 | extern "C" { 1078 | pub fn qpdf_oh_get_uint_value_as_uint(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_uint; 1079 | } 1080 | extern "C" { 1081 | pub fn qpdf_oh_get_value_as_uint(qpdf: qpdf_data, oh: qpdf_oh, value: *mut ::std::os::raw::c_uint) -> QPDF_BOOL; 1082 | } 1083 | extern "C" { 1084 | pub fn qpdf_oh_get_real_value(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1085 | } 1086 | extern "C" { 1087 | pub fn qpdf_oh_get_value_as_real( 1088 | qpdf: qpdf_data, 1089 | oh: qpdf_oh, 1090 | value: *mut *const ::std::os::raw::c_char, 1091 | length: *mut usize, 1092 | ) -> QPDF_BOOL; 1093 | } 1094 | extern "C" { 1095 | pub fn qpdf_oh_is_number(qpdf: qpdf_data, oh: qpdf_oh) -> QPDF_BOOL; 1096 | } 1097 | extern "C" { 1098 | pub fn qpdf_oh_get_numeric_value(qpdf: qpdf_data, oh: qpdf_oh) -> f64; 1099 | } 1100 | extern "C" { 1101 | pub fn qpdf_oh_get_value_as_number(qpdf: qpdf_data, oh: qpdf_oh, value: *mut f64) -> QPDF_BOOL; 1102 | } 1103 | extern "C" { 1104 | pub fn qpdf_oh_get_name(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1105 | } 1106 | extern "C" { 1107 | pub fn qpdf_oh_get_value_as_name( 1108 | qpdf: qpdf_data, 1109 | oh: qpdf_oh, 1110 | value: *mut *const ::std::os::raw::c_char, 1111 | length: *mut usize, 1112 | ) -> QPDF_BOOL; 1113 | } 1114 | extern "C" { 1115 | pub fn qpdf_get_last_string_length(qpdf: qpdf_data) -> usize; 1116 | } 1117 | extern "C" { 1118 | pub fn qpdf_oh_get_string_value(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1119 | } 1120 | extern "C" { 1121 | pub fn qpdf_oh_get_value_as_string( 1122 | qpdf: qpdf_data, 1123 | oh: qpdf_oh, 1124 | value: *mut *const ::std::os::raw::c_char, 1125 | length: *mut usize, 1126 | ) -> QPDF_BOOL; 1127 | } 1128 | extern "C" { 1129 | pub fn qpdf_oh_get_utf8_value(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1130 | } 1131 | extern "C" { 1132 | pub fn qpdf_oh_get_value_as_utf8( 1133 | qpdf: qpdf_data, 1134 | oh: qpdf_oh, 1135 | value: *mut *const ::std::os::raw::c_char, 1136 | length: *mut usize, 1137 | ) -> QPDF_BOOL; 1138 | } 1139 | extern "C" { 1140 | pub fn qpdf_oh_get_binary_string_value( 1141 | qpdf: qpdf_data, 1142 | oh: qpdf_oh, 1143 | length: *mut usize, 1144 | ) -> *const ::std::os::raw::c_char; 1145 | } 1146 | extern "C" { 1147 | pub fn qpdf_oh_get_binary_utf8_value( 1148 | qpdf: qpdf_data, 1149 | oh: qpdf_oh, 1150 | length: *mut usize, 1151 | ) -> *const ::std::os::raw::c_char; 1152 | } 1153 | extern "C" { 1154 | pub fn qpdf_oh_get_array_n_items(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_int; 1155 | } 1156 | extern "C" { 1157 | pub fn qpdf_oh_get_array_item(qpdf: qpdf_data, oh: qpdf_oh, n: ::std::os::raw::c_int) -> qpdf_oh; 1158 | } 1159 | extern "C" { 1160 | pub fn qpdf_oh_begin_dict_key_iter(qpdf: qpdf_data, dict: qpdf_oh); 1161 | } 1162 | extern "C" { 1163 | pub fn qpdf_oh_dict_more_keys(qpdf: qpdf_data) -> QPDF_BOOL; 1164 | } 1165 | extern "C" { 1166 | pub fn qpdf_oh_dict_next_key(qpdf: qpdf_data) -> *const ::std::os::raw::c_char; 1167 | } 1168 | extern "C" { 1169 | pub fn qpdf_oh_has_key(qpdf: qpdf_data, oh: qpdf_oh, key: *const ::std::os::raw::c_char) -> QPDF_BOOL; 1170 | } 1171 | extern "C" { 1172 | pub fn qpdf_oh_get_key(qpdf: qpdf_data, oh: qpdf_oh, key: *const ::std::os::raw::c_char) -> qpdf_oh; 1173 | } 1174 | extern "C" { 1175 | pub fn qpdf_oh_get_key_if_dict(qpdf: qpdf_data, oh: qpdf_oh, key: *const ::std::os::raw::c_char) -> qpdf_oh; 1176 | } 1177 | extern "C" { 1178 | pub fn qpdf_oh_is_or_has_name(qpdf: qpdf_data, oh: qpdf_oh, key: *const ::std::os::raw::c_char) -> QPDF_BOOL; 1179 | } 1180 | extern "C" { 1181 | pub fn qpdf_oh_new_uninitialized(qpdf: qpdf_data) -> qpdf_oh; 1182 | } 1183 | extern "C" { 1184 | pub fn qpdf_oh_new_null(qpdf: qpdf_data) -> qpdf_oh; 1185 | } 1186 | extern "C" { 1187 | pub fn qpdf_oh_new_bool(qpdf: qpdf_data, value: QPDF_BOOL) -> qpdf_oh; 1188 | } 1189 | extern "C" { 1190 | pub fn qpdf_oh_new_integer(qpdf: qpdf_data, value: ::std::os::raw::c_longlong) -> qpdf_oh; 1191 | } 1192 | extern "C" { 1193 | pub fn qpdf_oh_new_real_from_string(qpdf: qpdf_data, value: *const ::std::os::raw::c_char) -> qpdf_oh; 1194 | } 1195 | extern "C" { 1196 | pub fn qpdf_oh_new_real_from_double(qpdf: qpdf_data, value: f64, decimal_places: ::std::os::raw::c_int) -> qpdf_oh; 1197 | } 1198 | extern "C" { 1199 | pub fn qpdf_oh_new_name(qpdf: qpdf_data, name: *const ::std::os::raw::c_char) -> qpdf_oh; 1200 | } 1201 | extern "C" { 1202 | pub fn qpdf_oh_new_string(qpdf: qpdf_data, str_: *const ::std::os::raw::c_char) -> qpdf_oh; 1203 | } 1204 | extern "C" { 1205 | pub fn qpdf_oh_new_unicode_string(qpdf: qpdf_data, utf8_str: *const ::std::os::raw::c_char) -> qpdf_oh; 1206 | } 1207 | extern "C" { 1208 | pub fn qpdf_oh_new_binary_string(qpdf: qpdf_data, str_: *const ::std::os::raw::c_char, length: usize) -> qpdf_oh; 1209 | } 1210 | extern "C" { 1211 | pub fn qpdf_oh_new_binary_unicode_string( 1212 | qpdf: qpdf_data, 1213 | str_: *const ::std::os::raw::c_char, 1214 | length: usize, 1215 | ) -> qpdf_oh; 1216 | } 1217 | extern "C" { 1218 | pub fn qpdf_oh_new_array(qpdf: qpdf_data) -> qpdf_oh; 1219 | } 1220 | extern "C" { 1221 | pub fn qpdf_oh_new_dictionary(qpdf: qpdf_data) -> qpdf_oh; 1222 | } 1223 | extern "C" { 1224 | pub fn qpdf_oh_new_stream(qpdf: qpdf_data) -> qpdf_oh; 1225 | } 1226 | extern "C" { 1227 | pub fn qpdf_oh_make_direct(qpdf: qpdf_data, oh: qpdf_oh); 1228 | } 1229 | extern "C" { 1230 | pub fn qpdf_oh_set_array_item(qpdf: qpdf_data, oh: qpdf_oh, at: ::std::os::raw::c_int, item: qpdf_oh); 1231 | } 1232 | extern "C" { 1233 | pub fn qpdf_oh_insert_item(qpdf: qpdf_data, oh: qpdf_oh, at: ::std::os::raw::c_int, item: qpdf_oh); 1234 | } 1235 | extern "C" { 1236 | pub fn qpdf_oh_append_item(qpdf: qpdf_data, oh: qpdf_oh, item: qpdf_oh); 1237 | } 1238 | extern "C" { 1239 | pub fn qpdf_oh_erase_item(qpdf: qpdf_data, oh: qpdf_oh, at: ::std::os::raw::c_int); 1240 | } 1241 | extern "C" { 1242 | pub fn qpdf_oh_replace_key(qpdf: qpdf_data, oh: qpdf_oh, key: *const ::std::os::raw::c_char, item: qpdf_oh); 1243 | } 1244 | extern "C" { 1245 | pub fn qpdf_oh_remove_key(qpdf: qpdf_data, oh: qpdf_oh, key: *const ::std::os::raw::c_char); 1246 | } 1247 | extern "C" { 1248 | pub fn qpdf_oh_replace_or_remove_key( 1249 | qpdf: qpdf_data, 1250 | oh: qpdf_oh, 1251 | key: *const ::std::os::raw::c_char, 1252 | item: qpdf_oh, 1253 | ); 1254 | } 1255 | extern "C" { 1256 | pub fn qpdf_oh_get_dict(qpdf: qpdf_data, oh: qpdf_oh) -> qpdf_oh; 1257 | } 1258 | extern "C" { 1259 | pub fn qpdf_oh_get_object_id(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_int; 1260 | } 1261 | extern "C" { 1262 | pub fn qpdf_oh_get_generation(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_int; 1263 | } 1264 | extern "C" { 1265 | pub fn qpdf_oh_unparse(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1266 | } 1267 | extern "C" { 1268 | pub fn qpdf_oh_unparse_resolved(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1269 | } 1270 | extern "C" { 1271 | pub fn qpdf_oh_unparse_binary(qpdf: qpdf_data, oh: qpdf_oh) -> *const ::std::os::raw::c_char; 1272 | } 1273 | extern "C" { 1274 | pub fn qpdf_oh_copy_foreign_object(qpdf: qpdf_data, other_qpdf: qpdf_data, foreign_oh: qpdf_oh) -> qpdf_oh; 1275 | } 1276 | extern "C" { 1277 | pub fn qpdf_oh_get_stream_data( 1278 | qpdf: qpdf_data, 1279 | stream_oh: qpdf_oh, 1280 | decode_level: qpdf_stream_decode_level_e, 1281 | filtered: *mut QPDF_BOOL, 1282 | bufp: *mut *mut ::std::os::raw::c_uchar, 1283 | len: *mut usize, 1284 | ) -> QPDF_ERROR_CODE; 1285 | } 1286 | extern "C" { 1287 | pub fn qpdf_oh_get_page_content_data( 1288 | qpdf: qpdf_data, 1289 | page_oh: qpdf_oh, 1290 | bufp: *mut *mut ::std::os::raw::c_uchar, 1291 | len: *mut usize, 1292 | ) -> QPDF_ERROR_CODE; 1293 | } 1294 | extern "C" { 1295 | pub fn qpdf_oh_free_buffer(bufp: *mut *mut ::std::os::raw::c_uchar); 1296 | } 1297 | extern "C" { 1298 | pub fn qpdf_oh_replace_stream_data( 1299 | qpdf: qpdf_data, 1300 | stream_oh: qpdf_oh, 1301 | buf: *const ::std::os::raw::c_uchar, 1302 | len: usize, 1303 | filter: qpdf_oh, 1304 | decode_parms: qpdf_oh, 1305 | ); 1306 | } 1307 | extern "C" { 1308 | pub fn qpdf_get_num_pages(qpdf: qpdf_data) -> ::std::os::raw::c_int; 1309 | } 1310 | extern "C" { 1311 | pub fn qpdf_get_page_n(qpdf: qpdf_data, zero_based_index: usize) -> qpdf_oh; 1312 | } 1313 | extern "C" { 1314 | pub fn qpdf_update_all_pages_cache(qpdf: qpdf_data) -> QPDF_ERROR_CODE; 1315 | } 1316 | extern "C" { 1317 | pub fn qpdf_find_page_by_id( 1318 | qpdf: qpdf_data, 1319 | objid: ::std::os::raw::c_int, 1320 | generation: ::std::os::raw::c_int, 1321 | ) -> ::std::os::raw::c_int; 1322 | } 1323 | extern "C" { 1324 | pub fn qpdf_find_page_by_oh(qpdf: qpdf_data, oh: qpdf_oh) -> ::std::os::raw::c_int; 1325 | } 1326 | extern "C" { 1327 | pub fn qpdf_push_inherited_attributes_to_page(qpdf: qpdf_data) -> QPDF_ERROR_CODE; 1328 | } 1329 | extern "C" { 1330 | pub fn qpdf_add_page( 1331 | qpdf: qpdf_data, 1332 | newpage_qpdf: qpdf_data, 1333 | newpage: qpdf_oh, 1334 | first: QPDF_BOOL, 1335 | ) -> QPDF_ERROR_CODE; 1336 | } 1337 | extern "C" { 1338 | pub fn qpdf_add_page_at( 1339 | qpdf: qpdf_data, 1340 | newpage_qpdf: qpdf_data, 1341 | newpage: qpdf_oh, 1342 | before: QPDF_BOOL, 1343 | refpage: qpdf_oh, 1344 | ) -> QPDF_ERROR_CODE; 1345 | } 1346 | extern "C" { 1347 | pub fn qpdf_remove_page(qpdf: qpdf_data, page: qpdf_oh) -> QPDF_ERROR_CODE; 1348 | } 1349 | #[repr(C)] 1350 | #[derive(Debug, Copy, Clone)] 1351 | pub struct __locale_data { 1352 | pub _address: u8, 1353 | } 1354 | -------------------------------------------------------------------------------- /qpdf-sys/build.rs: -------------------------------------------------------------------------------- 1 | use std::{env, path::PathBuf}; 2 | 3 | #[cfg(feature = "vendored")] 4 | const ZLIB_SRC: &[&str] = &[ 5 | "adler32.c", 6 | "compress.c", 7 | "crc32.c", 8 | "deflate.c", 9 | "infback.c", 10 | "inffast.c", 11 | "inflate.c", 12 | "inftrees.c", 13 | "trees.c", 14 | "uncompr.c", 15 | "zutil.c", 16 | ]; 17 | 18 | #[cfg(feature = "vendored")] 19 | const JPEG_SRC: &[&str] = &[ 20 | "jaricom.c", 21 | "jcapimin.c", 22 | "jcapistd.c", 23 | "jcarith.c", 24 | "jccoefct.c", 25 | "jccolor.c", 26 | "jcdctmgr.c", 27 | "jchuff.c", 28 | "jcinit.c", 29 | "jcmainct.c", 30 | "jcmarker.c", 31 | "jcmaster.c", 32 | "jcomapi.c", 33 | "jcparam.c", 34 | "jcprepct.c", 35 | "jcsample.c", 36 | "jctrans.c", 37 | "jdapimin.c", 38 | "jdapistd.c", 39 | "jdarith.c", 40 | "jdatadst.c", 41 | "jdatasrc.c", 42 | "jdcoefct.c", 43 | "jdcolor.c", 44 | "jddctmgr.c", 45 | "jdhuff.c", 46 | "jdinput.c", 47 | "jdmainct.c", 48 | "jdmarker.c", 49 | "jdmaster.c", 50 | "jdmerge.c", 51 | "jdpostct.c", 52 | "jdsample.c", 53 | "jdtrans.c", 54 | "jerror.c", 55 | "jfdctflt.c", 56 | "jfdctfst.c", 57 | "jfdctint.c", 58 | "jidctflt.c", 59 | "jidctfst.c", 60 | "jidctint.c", 61 | "jmemmgr.c", 62 | "jmemnobs.c", 63 | "jquant1.c", 64 | "jquant2.c", 65 | "jutils.c", 66 | ]; 67 | 68 | #[cfg(feature = "vendored")] 69 | const QPDF_SRC: &[&str] = &[ 70 | "AES_PDF_native.cc", 71 | "MD5_native.cc", 72 | "QPDFCrypto_native.cc", 73 | "RC4_native.cc", 74 | "SHA2_native.cc", 75 | "rijndael.cc", 76 | "BitStream.cc", 77 | "BitWriter.cc", 78 | "Buffer.cc", 79 | "BufferInputSource.cc", 80 | "ClosedFileInputSource.cc", 81 | "ContentNormalizer.cc", 82 | "CryptoRandomDataProvider.cc", 83 | "FileInputSource.cc", 84 | "InputSource.cc", 85 | "InsecureRandomDataProvider.cc", 86 | "JSON.cc", 87 | "JSONHandler.cc", 88 | "MD5.cc", 89 | "NNTree.cc", 90 | "OffsetInputSource.cc", 91 | "PDFVersion.cc", 92 | "Pipeline.cc", 93 | "Pl_AES_PDF.cc", 94 | "Pl_ASCII85Decoder.cc", 95 | "Pl_ASCIIHexDecoder.cc", 96 | "Pl_Base64.cc", 97 | "Pl_Buffer.cc", 98 | "Pl_Concatenate.cc", 99 | "Pl_Count.cc", 100 | "Pl_DCT.cc", 101 | "Pl_Discard.cc", 102 | "Pl_Flate.cc", 103 | "Pl_Function.cc", 104 | "Pl_LZWDecoder.cc", 105 | "Pl_MD5.cc", 106 | "Pl_OStream.cc", 107 | "Pl_PNGFilter.cc", 108 | "Pl_QPDFTokenizer.cc", 109 | "Pl_RC4.cc", 110 | "Pl_RunLength.cc", 111 | "Pl_SHA2.cc", 112 | "Pl_StdioFile.cc", 113 | "Pl_String.cc", 114 | "Pl_TIFFPredictor.cc", 115 | "QPDF.cc", 116 | "QPDFAcroFormDocumentHelper.cc", 117 | "QPDFAnnotationObjectHelper.cc", 118 | "QPDFArgParser.cc", 119 | "QPDFCryptoProvider.cc", 120 | "QPDFDocumentHelper.cc", 121 | "QPDFEFStreamObjectHelper.cc", 122 | "QPDFEmbeddedFileDocumentHelper.cc", 123 | "QPDFExc.cc", 124 | "QPDFFileSpecObjectHelper.cc", 125 | "QPDFFormFieldObjectHelper.cc", 126 | "QPDFJob.cc", 127 | "QPDFJob_argv.cc", 128 | "QPDFJob_config.cc", 129 | "QPDFJob_json.cc", 130 | "QPDFLogger.cc", 131 | "QPDFMatrix.cc", 132 | "QPDFNameTreeObjectHelper.cc", 133 | "QPDFNumberTreeObjectHelper.cc", 134 | "QPDFObject.cc", 135 | "QPDFObjectHandle.cc", 136 | "QPDFObjectHelper.cc", 137 | "QPDFOutlineDocumentHelper.cc", 138 | "QPDFOutlineObjectHelper.cc", 139 | "QPDFPageDocumentHelper.cc", 140 | "QPDFPageLabelDocumentHelper.cc", 141 | "QPDFPageObjectHelper.cc", 142 | "QPDFParser.cc", 143 | "QPDFStreamFilter.cc", 144 | "QPDFSystemError.cc", 145 | "QPDFTokenizer.cc", 146 | "QPDFUsage.cc", 147 | "QPDFWriter.cc", 148 | "QPDFXRefEntry.cc", 149 | "QPDF_Array.cc", 150 | "QPDF_Dictionary.cc", 151 | "QPDF_Name.cc", 152 | "QPDF_Stream.cc", 153 | "QPDF_String.cc", 154 | "QPDF_encryption.cc", 155 | "QPDF_json.cc", 156 | "QPDF_linearization.cc", 157 | "QPDF_optimization.cc", 158 | "QPDF_pages.cc", 159 | "QTC.cc", 160 | "QUtil.cc", 161 | "RC4.cc", 162 | "ResourceFinder.cc", 163 | "SecureRandomDataProvider.cc", 164 | "SF_FlateLzwDecode.cc", 165 | "qpdf-c.cc", 166 | "qpdfjob-c.cc", 167 | "qpdflogger-c.cc", 168 | ]; 169 | 170 | #[cfg(feature = "vendored")] 171 | fn base_build() -> cc::Build { 172 | let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); 173 | let mut build = cc::Build::new(); 174 | 175 | build 176 | .warnings(false) 177 | .extra_warnings(false) 178 | .define("POINTERHOLDER_TRANSITION", "4") 179 | .define("QPDF_DISABLE_QTC", "1") 180 | .include(root.join("include")); 181 | 182 | build 183 | } 184 | 185 | #[cfg(feature = "vendored")] 186 | fn is_msvc() -> bool { 187 | env::var("TARGET").unwrap().ends_with("-msvc") 188 | } 189 | 190 | #[cfg(feature = "vendored")] 191 | fn is_windows() -> bool { 192 | env::var("TARGET").unwrap().contains("-pc-windows-") 193 | } 194 | 195 | #[cfg(feature = "vendored")] 196 | fn build_cc(name: &str, dir: &str, files: &[&str]) { 197 | let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); 198 | let path = root.join(dir); 199 | 200 | let cpp_flags: &[&str] = if is_msvc() { &["/D_CRT_SECURE_NO_WARNINGS"] } else { &[] }; 201 | 202 | let mut build = base_build(); 203 | for flag in cpp_flags { 204 | build.flag(flag); 205 | } 206 | 207 | build 208 | .include(&path) 209 | .files(files.iter().map(|f| path.join(f)).collect::>()) 210 | .compile(name); 211 | } 212 | 213 | #[cfg(feature = "vendored")] 214 | fn build_qpdf() { 215 | let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); 216 | let cpp_flags: &[&str] = if is_msvc() { 217 | &["/std:c++17", "/EHsc"] 218 | } else { 219 | &["-std=c++17"] 220 | }; 221 | 222 | let mut build = base_build(); 223 | for flag in cpp_flags { 224 | build.flag(flag); 225 | } 226 | 227 | build 228 | .cpp(true) 229 | .include(root.join("zlib")) 230 | .include(root.join("jpeg")) 231 | .include(root.join("qpdf").join("include")) 232 | .include(root.join("qpdf").join("libqpdf")) 233 | .files( 234 | QPDF_SRC 235 | .iter() 236 | .map(|f| root.join("qpdf").join("libqpdf").join(f)) 237 | .collect::>(), 238 | ) 239 | .compile("qpdf"); 240 | 241 | build_cc("sha2", "qpdf/libqpdf", &["sha2.c", "sha2big.c"]); 242 | } 243 | 244 | #[cfg(feature = "vendored")] 245 | fn build_bindings() { 246 | let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); 247 | let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("bindings.rs"); 248 | let existing = root 249 | .join("bindings") 250 | .join(format!("{}.rs", env::var("TARGET").unwrap())); 251 | 252 | if existing.exists() { 253 | std::fs::copy(&existing, &out_path).unwrap(); 254 | } else { 255 | let path = root.join("qpdf").join("include"); 256 | let bindings = bindgen::builder() 257 | .clang_arg(format!("-I{}", path.display())) 258 | .header(format!("{}/qpdf/qpdf-c.h", path.display())) 259 | .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) 260 | .generate() 261 | .unwrap(); 262 | 263 | bindings.write_to_file(&out_path).expect("Couldn't write bindings!"); 264 | } 265 | } 266 | 267 | #[cfg(feature = "vendored")] 268 | fn main() { 269 | build_bindings(); 270 | build_cc("zlib", "zlib", ZLIB_SRC); 271 | build_cc("jpeg", "jpeg", JPEG_SRC); 272 | build_qpdf(); 273 | 274 | if is_windows() { 275 | println!("cargo:rustc-link-lib=advapi32"); 276 | } 277 | } 278 | 279 | #[cfg(not(feature = "vendored"))] 280 | fn main() { 281 | let lib = pkg_config::Config::new() 282 | .atleast_version("10.6.3") 283 | .probe("libqpdf") 284 | .unwrap(); 285 | 286 | let mut builder = bindgen::builder(); 287 | 288 | for path in lib.include_paths { 289 | builder = builder.clang_arg(format!("-I{}", path.to_str().unwrap())); 290 | 291 | let header_path = path.join("qpdf/qpdf-c.h"); 292 | if header_path.exists() { 293 | builder = builder.header(header_path.into_os_string().into_string().unwrap()); 294 | } 295 | } 296 | 297 | for (key, val) in lib.defines { 298 | builder = builder.clang_arg(match val { 299 | Some(val) => format!("-D{}={}", key, val), 300 | None => format!("-D{}", key), 301 | }); 302 | } 303 | 304 | let bindings = builder 305 | .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) 306 | .generate() 307 | .unwrap(); 308 | 309 | let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("bindings.rs"); 310 | 311 | bindings.write_to_file(out_path).unwrap(); 312 | } 313 | -------------------------------------------------------------------------------- /qpdf-sys/include/jconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef JCONFIG_H 2 | #define JCONFIG_H 3 | 4 | #define HAVE_PROTOTYPES 5 | #define HAVE_UNSIGNED_CHAR 6 | #define HAVE_UNSIGNED_SHORT 7 | #define HAVE_STDDEF_H 8 | #define HAVE_STDLIB_H 9 | #define HAVE_LOCALE_H 10 | 11 | /* Define "boolean" as unsigned char, not enum, on Windows systems. */ 12 | #ifdef _WIN32 13 | #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ 14 | typedef unsigned char boolean; 15 | #endif 16 | #ifndef FALSE /* in case these macros already exist */ 17 | #define FALSE 0 /* values of boolean */ 18 | #endif 19 | #ifndef TRUE 20 | #define TRUE 1 21 | #endif 22 | #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ 23 | #endif 24 | 25 | #ifdef JPEG_INTERNALS 26 | 27 | #undef RIGHT_SHIFT_IS_UNSIGNED 28 | #undef INLINE 29 | /* These are for configuring the JPEG memory manager. */ 30 | #undef DEFAULT_MAX_MEM 31 | #undef NO_MKTEMP 32 | 33 | #endif /* JPEG_INTERNALS */ 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /qpdf-sys/include/qpdf/qpdf-config.h: -------------------------------------------------------------------------------- 1 | #define DEFAULT_CRYPTO "native" 2 | #define USE_CRYPTO_NATIVE 1 3 | #define HAVE_EXTERN_LONG_TIMEZONE 1 4 | #define HAVE_INTTYPES_H 1 5 | #define HAVE_LOCALTIME_R 1 6 | #define HAVE_STDINT_H 1 7 | #define HAVE_TM_GMTOFF 1 8 | #define RANDOM_DEVICE "/dev/urandom" 9 | -------------------------------------------------------------------------------- /qpdf-sys/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_upper_case_globals)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_snake_case)] 4 | #![allow(deref_nullptr)] 5 | 6 | include!(concat!(env!("OUT_DIR"), "/bindings.rs")); 7 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | edition = "2021" 2 | max_width = 120 3 | --------------------------------------------------------------------------------