MVP for output code

This commit is contained in:
Jake Howard 2017-08-27 23:42:56 +01:00
parent f7133ea168
commit bf768aa135
Signed by: jake
GPG key ID: 57AFB45680EDD477
3 changed files with 13 additions and 0 deletions

View file

@ -16,6 +16,7 @@ mod process;
mod input;
mod utils;
mod build;
mod output;
#[cfg(test)]
mod tests;

10
src/output/mod.rs Normal file
View file

@ -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");
}

View file

@ -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(());
}