fschutt / printpdf

An easy-to-use library for writing PDF in Rust
https://docs.rs/printpdf/
MIT License
802 stars 96 forks source link

[Documentation] Comparison of printpdf to other pdf-writers? #105

Open rubyFeedback opened 2 years ago

rubyFeedback commented 2 years ago

Hey there Felix,

If you ever have some spare time, would you consider adding a short subsection comparing printpdf to a very few other pdf-writers? Does not have to be a long paragraph or a super-detailed comparison, just, say, pick at max 3 different ones and showcase a little bit where printpdf may be better or more convenient or something to use. (Of course the comparison should be objective, if possible, but it's perfectly fine to focus on aspects where printpdf is better.)

And a rust-GUI via azul would be interesting to show too, just a mini-GUI example for adding a "hello world" string and then a paragraph via the simplest minimal GUI possible. To showcase azul too. (I know you have the large excel application on-going, but just a quick example to showcase what is possible via printpdf). :)

As always please feel free to ignore/close this issue request at any moment in time!

fschutt commented 2 years ago

There isn't much to compare. Right now printpdf is more or less the only high-level PDF library for Rust, others are only very low-level. There are not that many other PDF abstractions.

lopdf is just a core library, providing the bare basics, and then printpdf builds on top of that. There is pdf-writer, but that is effectively the same thing as lopdf, but with a different API. Then you have wkhtmltopdf, but that's a well-known library less focused on quality and more focused on rendering HTML to PDF. The resulting quality of the PDF might not be very high.

As for azul I'm almost done for my purpose:

image

I've written this application in order to automatically apply styles, edit the texts manually and then I use printpdf to export the result to Illustrator, seperated by layers:

image

All the icons in the map are SVG files, showcasing how azul can render SVG files (via resvg) and printpdf can export the same SVG (via svg2pdf - placing one symbol many times in the map, without impacting file size).

For examples, just see the examples folder: https://github.com/fschutt/printpdf/tree/master/examples

I started printpdf in 2017 because I already used Rust because of the required performance for writing a GIS application - and other PDF libraries for C++ either didn't compile, refused to work or there were no examples so I couldn't figure out how to use them. So I used Rust because otherwise I'd never been able to get to the point where I am now. The output from QtPdf was simply horrible when importing the result to Adobe Illustrator, so I couldn't use that.

There is a hello-world example right on the front page of https://azul.rs/ and there's also lots of documentation about the how and why:

https://azul.rs/guide/1.0.0-alpha1/GettingStarted https://azul.rs/guide/1.0.0-alpha1/ApplicationArchitecture

However, azul is not finished right now, there are lots of bugs still remaining. Despite being originally cross-platform, I only focus on Windows right now, because that's the platform I use MapEdit on, so that I can sell my maps (to fund azuls development) and quit my 9-to-5. Once I have that up and running, I'll have more time and money to finish azul.

The examples for azul all work with the exception of udp-chat - images and code are here: https://github.com/fschutt/azul/tree/master/examples/rust#readme