diff options
Diffstat (limited to 'src/view.rs')
-rw-r--r-- | src/view.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/view.rs b/src/view.rs index 9b95691..38cfa58 100644 --- a/src/view.rs +++ b/src/view.rs @@ -23,10 +23,10 @@ impl Component for Form { } fn view(&self) -> Html { - let pdf_raw = /*include_bytes!("../demo.pdf"); // this works */pdfgen::genpdf(); // this doesn't work - let pdf = std::str::from_utf8(&pdf_raw).expect("should be able to convert to string"); - let uri_component: String = js_sys::encode_uri_component(pdf).into(); - let href = format!{"data:application/pdf;charset=utf-8,{}", uri_component }; + let raw = pdfgen::genpdf(); + let data = base64::encode(&raw); + let uri_component: String = js_sys::encode_uri_component(&data).into(); + let href = format!{"data:application/pdf;base64,{}", uri_component }; html!{ <a href=href download="demo.pdf" > { "Download PDF" } |