This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (5)
- # babashka (5)
- # beginners (39)
- # calva (1)
- # chlorine-clover (22)
- # circleci (4)
- # clara (5)
- # clj-kondo (1)
- # cljs-dev (2)
- # cljsrn (8)
- # clojure (46)
- # clojure-canada (15)
- # clojure-norway (3)
- # clojure-uk (6)
- # clojurescript (39)
- # conjure (10)
- # core-async (9)
- # datomic (2)
- # figwheel-main (26)
- # fulcro (33)
- # ghostwheel (9)
- # jobs (6)
- # leiningen (1)
- # malli (7)
- # music (1)
- # off-topic (48)
- # re-frame (11)
- # reagent (1)
- # shadow-cljs (86)
- # spacemacs (8)
Yes, sometimes I wonder if I had to nominate a single feature from Clojure as a selling point then perhaps I would choose...
Clojure's equality semantics are an understatement. You only appreciate it a long time after the fact
How would I pass args to enlive’s
at macro if I have them as a map, can’t use
apply because it’s macro:
I what to pass a seq of transformations, e.g.
(at a-node [:a :selector] a-transformation)
[[:a :selector] a-transformation]
What is currently the best option to generate PDFs in Clojure? I was thinking about
wkhtmltopdf, but I found this project is abandoned. There are other projects but looks abandoned too. I need PDFs with precision to each
mm. Generating PDFs using
wkthmltopdf (html->pdf) works fine and using
js is very customizable. I also found using Java libraries to make PDFs is a nightmare when want to be precise to each
mm and do things like fit words into size of block, so this font size should be counted and do other magic. So after all I am looking something where I can use html + js -> PDF. Do you recommend something? I can also run conversion from command line, so it doesn’t have to be Java library.
PS I am looking free tool.
clj-pdf, it is not abandoned, and works pretty well for my (limited) use cases: invoices, reports with tables, etc. https://github.com/clj-pdf/clj-pdf
Thanks. I think I was looking on this a few years ago but I need generate PDFs precise to each
mm and text needs to fit into box, so font has to be lowered if needed but there is a minimum value and some other custom things. Does it work with this things today?
I wrote a library for just that, which as far as I know is still used in production at my previous employer. The docs are not awesome, and there have not been changes in a while, but I would consider it stable. https://github.com/mdiin/pdf-stamper
I haven't heard of anything better than
wkhtmltopdf -- funnily enough it was [and still is] very popular with CFML (ColdFusion) developers who often seem to need to produce and manipulate very specific PDF documents.
hmm I am reading this is also possible to use things like puppeter etc. in Google Cloud Functions - just an interesting alternative
Looks like it is still getting commits https://github.com/wkhtmltopdf/wkhtmltopdf/commits/master
What makes you say it’s abandoned? IME old Clojure code usually continues to function perfectly on new versions of Clojure, so there’s just generally less need to roll new releases unless new functionality has been added.
C++ code also doesn’t change much IME, but mostly because it’s rare to get anything working for very long, so it’s scary to touch something that (seems to) work…. /s
Last real PDF generation I did was using OpenOffice / LibreOffice in daemon mode from Java, which is horrendous. And this was mostly document conversion (e.g. .docx -> .pdf), which sounds like a different use case to yours.
google cloud functions (solutions based on node.js) looks very cheap for this purpose. I have to back to this topic tomorrow. Goodnight.
I was going to say, using a web driver that lets you print to PDF or export to PDF might work
If you do find good alternatives @kwladyka please report back here with them. I'd be very interested, since I still have a lot of contacts in the CFML community who would also be interested in that information.
sure, I will let you know. I know from my own experience generating precise PDFs is a hard thing.
We're using browserless https://www.browserless.io with Puppeteer and PDF printing to generate PDF exports of various things that users can create in our product - you can use their hosted version or run the browserless container yourself. It's a bit crazy that the best way we found to generate a PDF is to spin up a headless browser
yes me too, I think the best one is to use web browser (chrome) to generate PDF and make templates in html + js
This is still in progress, but google functions or amazon lambdas with node.js looks as a good alternative. First I will finish this with wkhtmltopdf and later will work on try this solutions.
But maybe you have any idea how to compare 2 PDFs if they are the same. So I can write tests and be sure PDFs looks like before. I was trying to make
hash on them, but this doesn’t work good. PDF binary “string” is so different depends on local settings even using the same version of wkthmltopdf. This is too crazy. Any idea how to compare PDFs visual aspect?
I found this https://github.com/red6/pdfcompare but maybe you know something battle tested
No idea. I've always managed to avoid PDF work (because I hate dealing with exactly this sort of annoying thing). Most CFML shops don't do CI/CD and many of them don't even automate testing very much so I suspect they just check PDFs manually / visually.
Same, we generate our PDFs out of content authored in our app, and because it's based on user supplied content there's no real automated way of testing the generator. Since we're using Chrome as the layout engine, that task is somewhat easier as the print-optimized views can be tested just like any other part of a web application. But in the end visual inspection is still required at the end of the day
Low value at this point, as we have the PDF generated as we need them. Also, the machinery required to produce a PDF is surprisingly complicated so costs outweigh benefits at this point
There's too many combinations of assets that can be used to produce a PDF so an inspection would probably be a) slow b) still wouldn't catch all the cases. But YMMV, all I wrote is based on our constraints, features etc etc etc
I wrote a library for just that some years ago, which as far as I know is still used in production at my previous employer. The docs are not awesome, and there have not been changes in a while, but I would consider it stable. The general idea is to describe the layout as an EDN template and fuse it with a PDF document, thus separating data logic from layout logic. Maybe someone finds it useful. https://github.com/mdiin/pdf-stamper
Really cool - I wish we could use it (our PDFs are effectively print-outs of pages built by our React app)
So far I stay with wkthmltopdf, because I already have something what work, but I will change this later. After first version on production will be released and first client will start to use this. I think I will change this to cloud functions (google) / labmda (AWS) with node.js. Much more updated solutions which from what I can read are battle tested.