MVP for output code
This commit is contained in:
parent
f7133ea168
commit
bf768aa135
3 changed files with 13 additions and 0 deletions
|
@ -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
10
src/output/mod.rs
Normal 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");
|
||||
}
|
|
@ -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(());
|
||||
}
|
||||
|
|
Reference in a new issue