-
Notifications
You must be signed in to change notification settings - Fork 115
Closed
Description
running these two programs seems to give a compile error on windows
use pdfium_render::prelude::*;
fn main() {
let pdfium = Pdfium::new(
Pdfium::bind_to_library(Pdfium::pdfium_platform_library_name_at_path("./"))
.or_else(|_| Pdfium::bind_to_system_library()).unwrap(),
);
// Create a new document containing a single page with the desired sample text.
let document = pdfium.create_new_pdf().unwrap();
let mut pages = document.pages();
let mut page = pages.create_page_at_start(PdfPagePaperSize::a4()).unwrap();
// Desired sample text:
let sample_text = vec!(
"TITLE HERE",
"",
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum",
"has been the industry's standard dummy text ever since the 1500s, when an unknown",
"printer took a galley of type and scrambled it to make a type specimen book. It has",
"survived not only five centuries, but also the leap into electronic typesetting, remaining",
"essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets",
"containing Lorem Ipsum passages, and more recently with desktop publishing software like",
"Aldus PageMaker including versions of Lorem Ipsum.",
);
// Add the sample text to the page. We create a separate text object
// for each line in the sample text.
let regular_font = PdfFont::helvetica(&document);
let bold_font = PdfFont::helvetica_bold(&document);
let font_size = PdfPoints::new(12.0);
let line_spacing = font_size * 1.5;
let line_left = PdfPoints::new(50.0);
let mut line_top = PdfPoints::new(700.0);
for (index, line) in sample_text.iter().enumerate() {
let font = {
// Make the first line bold, all other lines regular.
if index == 0 {
&bold_font
} else {
®ular_font
}
};
page.objects_mut()
.create_text_object(line_left, line_top, line, font, font_size).unwrap();
line_top -= line_spacing;
}
document.save_to_file("before.pdf").unwrap();
}// this just a part of the program I included only the part where the error seems to occur
let mut bold_word = PdfPageTextObject::new(
&document,
child_object.bold.clone(),
&object_txt.font(),
object_txt.font_size(),
)
.unwrap();
/* line 67 */ bold_part.translate(word_left, line_top).unwrap();
word_left += bold_part.width().unwrap();
//the error:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: PdfiumLibraryInternalError(Unknown)', src\place.rs:67:70 since create_text_object() use translate() method in its definition I'm assuming that both errors are in fact the same.
both programs compile fine on WSL
It is worth mentioning that opening a file, removing text objects from it and saving the edited version worked fine. probably because we didn't need to use translate() method.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels