summaryrefslogtreecommitdiff
path: root/src/view.rs
diff options
context:
space:
mode:
authorjelemux <jeremias.weber@protonmail.com>2020-10-20 01:09:47 +0200
committerjelemux <jeremias.weber@protonmail.com>2020-10-20 01:09:47 +0200
commitf267433455dbc69e771b06dd7c433c90ad978d33 (patch)
tree1ff4a90bec2dd80f7115ce2317d093efad404db4 /src/view.rs
parent3a0a55362fd98c74bfb14df320bcacafd0c57835 (diff)
downloadwasm-card-f267433455dbc69e771b06dd7c433c90ad978d33.tar.gz
wasm-card-f267433455dbc69e771b06dd7c433c90ad978d33.tar.bz2
made it work
Diffstat (limited to 'src/view.rs')
-rw-r--r--src/view.rs8
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" }