1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#![doc = include_str!("../README.md")]
mod bindgen {
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(dead_code)]
include!("bindgen.rs");
}
pub mod action;
pub mod action_destination;
pub mod bindings;
pub mod bitmap;
pub mod bitmap_config;
pub mod bookmark;
pub mod bookmarks;
pub mod color;
pub mod document;
pub mod error;
pub mod font;
pub mod form;
pub mod metadata;
pub mod page;
pub mod page_annotation;
pub mod page_annotation_circle;
pub mod page_annotation_free_text;
pub mod page_annotation_highlight;
pub mod page_annotation_ink;
pub mod page_annotation_link;
pub mod page_annotation_popup;
pub mod page_annotation_square;
pub mod page_annotation_squiggly;
pub mod page_annotation_stamp;
pub mod page_annotation_strikeout;
pub mod page_annotation_text;
pub mod page_annotation_underline;
pub mod page_annotation_unsupported;
pub mod page_annotations;
pub mod page_boundaries;
pub mod page_object;
pub mod page_object_form_fragment;
pub mod page_object_image;
pub mod page_object_path;
pub mod page_object_shading;
pub mod page_object_text;
pub mod page_object_unsupported;
pub mod page_objects;
pub mod page_size;
pub mod page_text;
pub mod pages;
pub mod pdfium;
mod utils;
pub mod prelude {
pub use super::{
action::*, action_destination::*, bindings::*, bitmap::*, bitmap_config::*, bookmark::*,
bookmarks::*, color::*, document::*, error::*, font::*, form::*, metadata::*, page::*,
page_annotation::*, page_annotation_circle::*, page_annotation_free_text::*,
page_annotation_highlight::*, page_annotation_ink::*, page_annotation_link::*,
page_annotation_popup::*, page_annotation_square::*, page_annotation_squiggly::*,
page_annotation_stamp::*, page_annotation_strikeout::*, page_annotation_text::*,
page_annotation_underline::*, page_annotation_unsupported::*, page_annotations::*,
page_boundaries::*, page_object::*, page_object_form_fragment::*, page_object_image::*,
page_object_path::*, page_object_shading::*, page_object_text::*,
page_object_unsupported::*, page_objects::*, page_size::*, page_text::*, pages::*,
pdfium::*,
};
}
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(feature = "static"))]
mod native;
#[cfg(not(target_arch = "wasm32"))]
#[cfg(feature = "static")]
mod linked;
#[cfg(target_arch = "wasm32")]
mod wasm;
#[cfg(test)]
pub mod tests {
use crate::prelude::*;
use image::ImageFormat;
#[test]
fn test() {
let bindings = Pdfium::bind_to_library(Pdfium::pdfium_platform_library_name_at_path("./"))
.or_else(|_| Pdfium::bind_to_system_library());
assert!(bindings.is_ok());
let render_config = PdfBitmapConfig::new()
.set_target_width(2000)
.set_maximum_height(2000)
.rotate_if_landscape(PdfBitmapRotation::Degrees90, true)
.render_form_data(true)
.render_annotations(true);
Pdfium::new(bindings.unwrap())
.load_pdf_from_file("./test/form-test.pdf", None)
.unwrap()
.pages()
.iter()
.for_each(|page| {
let result = page
.get_bitmap_with_config(&render_config)
.unwrap()
.as_image()
.as_rgba8()
.unwrap()
.save_with_format(
format!("form-test-page-{}.jpg", page.index()),
ImageFormat::Jpeg,
);
assert!(result.is_ok());
});
}
}