From f267433455dbc69e771b06dd7c433c90ad978d33 Mon Sep 17 00:00:00 2001 From: jelemux Date: Tue, 20 Oct 2020 01:09:47 +0200 Subject: made it work --- src/view.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/view.rs') 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!{ { "Download PDF" } -- cgit v1.2.3