Skip to content

Commit

Permalink
Add printpdf1
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Dec 13, 2023
1 parent 745ea7c commit d436fb7
Show file tree
Hide file tree
Showing 4 changed files with 372 additions and 0 deletions.
2 changes: 2 additions & 0 deletions printpdf1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/*.pdf
/target/
346 changes: 346 additions & 0 deletions printpdf1/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions printpdf1/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "printpdf1"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.75"
printpdf = "0.6.0"
14 changes: 14 additions & 0 deletions printpdf1/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use printpdf::*;
use std::fs::File;
use std::io::BufWriter;

fn main() -> anyhow::Result<()> {
let (doc, _page1, _layer1) =
PdfDocument::new("PDF_Document_title", Mm(247.0), Mm(210.0), "Layer 1");
let (_page2, _layer1) = doc.add_page(Mm(10.0), Mm(250.0), "Page 2, Layer 1");

doc.save(&mut BufWriter::new(
File::create("test_working.pdf").unwrap(),
))?;
Ok(())
}

0 comments on commit d436fb7

Please sign in to comment.