Hi. Thank you for your all works with genpdf. It looks great.
My problem is, i am using creating pdf for my wasm project. So, there is no filesystem. I can download the ttf's files from my server but i don't know how to use it with from_files() method. Is there any way to use fonts without filesystem?
Thank you.
On 2021-07-22 03:47:43, eribol@libredu.org wrote:
> My problem is, i am using creating pdf for my wasm project. So, there> is no filesystem. I can download the ttf's files from my server but i> don't know how to use it with from_files() method. Is there any way to> use fonts without filesystem?
Yes. The fonts::from_files function is just a shorthand for calling
FontData::load for all four font styles. Instead of FontData::load
(which takes a path), you can use FontData::new (which takes the raw
font data). So this gives you two options: Either you include the font
data in your binary using include_bytes!, or you download the font from
the network. You can then manually construct a FontFamily instance
using FontData::new.
wasm-card [0] is a project that already uses genpdf from WASM. It uses
the include_bytes! approach [1].
[0] https://codeberg.org/jelemux/wasm-card
[1] https://codeberg.org/jelemux/wasm-card/src/branch/main/src/model/vcard.rs#L301
Please let me know if anything is unclear or does not work properly.
Best,
Robin
Robin Krahl <robin.krahl@ireas.org> wrote:
> On 2021-07-22 03:47:43, eribol@libredu.org wrote:> > My problem is, i am using creating pdf for my wasm project. So, there> > is no filesystem. I can download the ttf's files from my server but i> > don't know how to use it with from_files() method. Is there any way to> > use fonts without filesystem?> > Yes. The fonts::from_files function is just a shorthand for calling> FontData::load for all four font styles. Instead of FontData::load> (which takes a path), you can use FontData::new (which takes the raw> font data). So this gives you two options: Either you include the font> data in your binary using include_bytes!, or you download the font from> the network. You can then manually construct a FontFamily instance> using FontData::new.> > wasm-card [0] is a project that already uses genpdf from WASM. It uses> the include_bytes! approach [1].> > [0] https://codeberg.org/jelemux/wasm-card> [1] https://codeberg.org/jelemux/wasm-card/src/branch/main/src/model/vcard.rs#L301> > Please let me know if anything is unclear or does not work properly.> > Best,> Robin
Thank you so much. It worked for now. Only thing i need, open pdf on Blob url whch its not about genpdf. Thank you again.