summaryrefslogtreecommitdiff
path: root/src/pdfgen.rs
diff options
context:
space:
mode:
authorjelemux <jeremias.weber@protonmail.com>2020-11-07 22:44:28 +0100
committerjelemux <jeremias.weber@protonmail.com>2020-11-07 22:44:28 +0100
commit7f12ce0f0374543fa03d9f7f332bb20d66d86837 (patch)
treeefa68ca3454de9feef2e0c3afe122cb8c002fd5a /src/pdfgen.rs
parent8cfb6b0b199586d45edf5abefbb8cf26f98cb829 (diff)
downloadwasm-card-7f12ce0f0374543fa03d9f7f332bb20d66d86837.tar.gz
wasm-card-7f12ce0f0374543fa03d9f7f332bb20d66d86837.tar.bz2
one button for everything
Diffstat (limited to 'src/pdfgen.rs')
-rw-r--r--src/pdfgen.rs52
1 files changed, 0 insertions, 52 deletions
diff --git a/src/pdfgen.rs b/src/pdfgen.rs
deleted file mode 100644
index 0bca467..0000000
--- a/src/pdfgen.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-use genpdf::Element as _;
-use genpdf::{elements, style, fonts};
-
-pub fn genpdf() -> Vec<u8> {
- let regular_bytes = include_bytes!("/usr/share/fonts/liberation/LiberationSans-Regular.ttf");
- let regular_font_data = fonts::FontData::new(regular_bytes.to_vec(), Some(printpdf::BuiltinFont::Helvetica)).expect("font data should be correct");
-
- let bold_bytes = include_bytes!("/usr/share/fonts/liberation/LiberationSans-Bold.ttf");
- let bold_font_data = fonts::FontData::new(bold_bytes.to_vec(), Some(printpdf::BuiltinFont::HelveticaBold)).expect("font data should be correct");
-
- let italic_bytes = include_bytes!("/usr/share/fonts/liberation/LiberationSans-Italic.ttf");
- let italic_font_data = fonts::FontData::new(italic_bytes.to_vec(), Some(printpdf::BuiltinFont::HelveticaOblique)).expect("font data should be correct");
-
- let bold_italic_bytes = include_bytes!("/usr/share/fonts/liberation/LiberationSans-BoldItalic.ttf");
- let bold_italic_font_data = fonts::FontData::new(bold_italic_bytes.to_vec(), Some(printpdf::BuiltinFont::HelveticaBoldOblique)).expect("font data should be correct");
-
- let font_family = fonts::FontFamily{
- regular: regular_font_data,
- bold: bold_font_data,
- italic: italic_font_data,
- bold_italic: bold_italic_font_data
- };
-
- let mut doc = genpdf::Document::new(font_family);
-
- doc.set_title("BCard test");
- doc.set_minimal_conformance();
- doc.set_margins(10);
- doc.set_line_spacing(1.25);
-
- #[cfg(feature = "hyphenation")]
- {
- use hyphenation::Load;
-
- doc.set_hyphenator(
- hyphenation::Standard::from_embedded(hyphenation::Language::EnglishUS)
- .expect("Failed to load hyphenation data"),
- );
- }
-
- doc.push(
- elements::Paragraph::new("genpdf Demo Document")
- .aligned(elements::Alignment::Center)
- .styled(style::Style::new().bold().with_font_size(20)),
- );
-
- // TODO fill doc with real data
-
- let mut buf: Vec<u8> = Vec::new();
- doc.render(&mut buf).expect("should render pdf");
- buf
-} \ No newline at end of file