use crate::pdfgen; use wasm_bindgen::prelude::*; use js_sys; use yew::prelude::*; struct Form { } impl Component for Form { type Message = (); type Properties = (); fn create(_props: Self::Properties, _link: ComponentLink) -> Self { Self { } } fn update(&mut self, _msg: Self::Message) -> ShouldRender { false } fn change(&mut self, _props: Self::Properties) -> ShouldRender { false } 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 }; html!{ { "Download PDF" } } } } #[wasm_bindgen(start)] pub fn run_app() { App::
::new().mount_to_body(); }