TaserudConsulting / jsonresume-nix

Reproducible résumé using Nix ❄️ and jsonresume
ISC License
50 stars 5 forks source link

build pdf #13

Closed i-am-logger closed 1 month ago

frogamic commented 11 months ago

This is something I would like as well, I might try tackle it

ShaddyDC commented 1 month ago

It looks like the blessed way to build a pdf using resumed is to use puppeteer? Seems kind of annoying. https://github.com/rbardini/resumed/tree/main/examples/with-pdf-export

etu commented 1 month ago

It looks like the blessed way to build a pdf using resumed is to use puppeteer? Seems kind of annoying. https://github.com/rbardini/resumed/tree/main/examples/with-pdf-export

There were a long time since I've had a look at running puppeteer for any form of local or personal use.

However, I just had a look in nixpkgs and found https://search.nixos.org/packages?channel=24.05&show=puppeteer-cli in there, which is this following package: https://github.com/JarvusInnovations/puppeteer-cli

I've tried it locally by just pulling it in with nix-shell and running:

nix-shell -p puppeteer-cli

# For making a PDF
puppeteer print resume.html resume.pdf

# For making a screenshot
puppeteer screenshot resume.html resume.png

It's a bit weird for me because the screenshot comes out pretty decent, but still missing icons and such. The PDF sometimes comes out worse, sometimes I didn't get any visible text at all but not always.

However, this seems like a good way.

Update: Interesting find!

If I run:

puppeteer print <link-to-public-resume> resume.pdf --format A4

it does come out perfect, so it's probably something with environment or paths and not loaded correctly.

etu commented 1 month ago

I've just pushed: https://github.com/TaserudConsulting/jsonresume-nix/commit/b0d4ac3516f2a537f49bdfd76508e5feff91e960

It seems to work fairly well with the fullmoon theme, with the elegant theme it's more flakey.

It's not a very pretty implementation since it pulls in the dependencies and runs it as a process as the current user and I would rather have it inside the sandbox and output it to $out as it would be an isolated nix build. But hey! It's something and things can always be improved :slightly_smiling_face:

ShaddyDC commented 1 month ago

Well that was fast, thanks a bunch! :)