-
Notifications
You must be signed in to change notification settings - Fork 115
Open
Description
I may be misunderstanding how flatten() works, but doing something like this:
examples/form_flatten.rs
use image::ImageFormat;
use pdfium_render::prelude::*;
pub fn main() -> Result<(), PdfiumError> {
// For general comments about pdfium-render and binding to Pdfium, see export.rs.
let pdfium = Pdfium::default();
let document = pdfium.load_pdf_from_file("test/form-test.pdf", None)?; // Load the sample file...
document
.metadata()
.iter()
.enumerate()
.for_each(|(index, tag)| println!("{}: {:#?} = {}", index, tag.tag_type(), tag.value()));
match document.form() {
Some(form) => println!(
"PDF contains an embedded form of type {:#?}",
form.form_type()
),
None => println!("PDF does not contain an embedded form"),
};
let dpi = 200.0;
let render_config = PdfRenderConfig::new()
.scale_page_by_factor(dpi as f32 / 72.0)
.render_form_data(true) // Rendering of form data and annotations is the default...
.render_annotations(true) // ... but for the sake of demonstration we are explicit here.
.highlight_text_form_fields(PdfColor::YELLOW.with_alpha(128))
.highlight_checkbox_form_fields(PdfColor::BLUE.with_alpha(128));
let mut page = document.pages().first().expect("to get first page");
page.flatten()?;
page.render_with_config(&render_config)?
.as_image()
.as_rgba8()
.ok_or(PdfiumError::ImageError)?
.save_with_format("flattened-form-page.jpg", ImageFormat::Jpeg)
.map_err(|_| PdfiumError::ImageError)?;
Ok(())
}and running as
cargo run --example form_flatten
whereas I think i would have expected the form fields to be inlined and thus rendered (without any yellow bg)
something is happening because no yellow highlighted fields are rendered!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
