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
Also Liked
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
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
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.
Popular in Questions
Other popular topics
Latest Phoenix Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









