diff --git a/src/main.rs b/src/main.rs index 01cc9f2..d7a5a66 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,7 @@ mod process; mod input; mod utils; mod build; +mod output; #[cfg(test)] mod tests; diff --git a/src/output/mod.rs b/src/output/mod.rs new file mode 100644 index 0000000..51e0e81 --- /dev/null +++ b/src/output/mod.rs @@ -0,0 +1,10 @@ +use wkhtmltopdf::PdfApplication; + + +pub fn output(html: String) { + let mut pdf_app = PdfApplication::new().expect("Failed to init PDF application"); + let mut pdfout = pdf_app.builder().build_from_html(&html).expect("failed to build pdf"); + + pdfout.save("foo.pdf").expect("failed to save foo.pdf"); + println!("generated PDF saved as: foo.pdf"); +} diff --git a/src/process.rs b/src/process.rs index 1ab7f27..28e2b2d 100644 --- a/src/process.rs +++ b/src/process.rs @@ -1,11 +1,13 @@ use input::read_input_files; use config::Config; use build::build_input; +use output::output; pub fn build(config: Config) -> Result<(), String> { let input = try!(read_input_files(config.input.clone())); let raw_html = try!(build_input(config.clone(), input)); println!("{}", raw_html); + output(raw_html); return Ok(()); }