fschutt / printpdf

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

Bookmarks #86

Closed g-w1 closed 3 years ago

g-w1 commented 3 years ago

This pr implements bookmarks. Sorry about the big diff, my editor runs rustfmt on save. I tried git add -p but some of the content was in the same hunk as the formatted stuff. Right now the bookmark shows up in the chrome viewer in the top left, but there is no name associated with it, and it does not work. The reason I am doing this as a draft is I was wondering if you could take a look to see what is wrong?

To test it out, use the examples/bookmarks.rs

Thanks

Edit:

Feel free to not merge the formatting changes and just merge the content.

fschutt commented 3 years ago

Ok, I'll merge it just to get it into master, it doesn't seem to affect the rest of the PDF negatively.

There are some minor nits, for example when there are no bookmarks then there is no reason to even add an Outline dictionary, but that's just a small problem.

(I personally don't like rustfmt for exactly this reason, it often breaks perfectly readable code into multiple lines, I'll revert the formatting later)