Kurisu

Kurisu

How to create printable web page by rendering text on svg image with Phoenix?

I do not know if my question makes sense, but I will try to develop it.

Let’s say I have a classic Phoenix web application and want to add some cards printing feature. This is will be done by retrieving some data from the database and rendering them precisely on an existing svg image. Then user can print the resulted page.

This is really my first time for such a feature, not only with Elixir but all languages included. So I have really no idea where to start from.

Please, which tools, libraries, resources should I use for this?

Tutorials or open source projects also will be greatly welcome.

Thanks

Marked As Solved

Kurisu

Kurisu

As a summary for people who come across this topic:

Also Liked

LostKobrakai

LostKobrakai

Imho the best way currently to create a pdf from html in elixir is rambo+weasyprint. I had many problems with wkhtmltopdf and more complex options. Weasyprint on the other hand does what it suggests and handles css quite well.

kokolegorille

kokolegorille

I have done this previously with PDF generator to build printable receipt, with background image… but it was in Ruby, with prawn.

I guess I would use pdf_generator w/ Elixir, but I have not done this yet.

For simple card printing, You could use a special stylesheet for printing purpose and include it like this.

<link rel="stylesheet" type="text/css" href="print.css" media="print">

This allows to define what, and what not to print.

stefanchrobot

stefanchrobot

Note that prawn is very lightweight as it directly writes raw PDFs (you can think of PDF as a textual format). On the other hand pdf_generator uses wkhtmltopdf which might be quite heavy. There are some libraries similar to prawn for Elixir/Erlang (one even started by Joe Armstrong), but none of them have support for proper custom fonts (it’s a hard task) so that was a showstopper for me to do PDF generation in Elixir.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement