This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-06
Channels
- # announcements (13)
- # aws (3)
- # beginners (10)
- # calva (3)
- # clj-kondo (1)
- # clojure (63)
- # clojure-spec (15)
- # clojure-sweden (1)
- # clojure-uk (6)
- # community-development (2)
- # cursive (32)
- # datomic (20)
- # duct (1)
- # emacs (11)
- # events (1)
- # fulcro (32)
- # keechma (23)
- # luminus (2)
- # reagent (1)
- # ring (1)
- # shadow-cljs (23)
- # spacemacs (5)
- # specter (4)
- # sql (13)
- # tools-deps (16)
- # vim (1)
- # yada (2)
does anyone have any experience with pdfboxing
? in my example i'm trying to save the first page of a PDF as a file, but i get the following exception (and corrupt pdf file output):
(-> (pdf/split-pdf :input "/tmp/example.pdf")
first
(.save "/tmp/page-1.pdf"))
Execution error (IOException) at org.apache.pdfbox.cos.COSStream/checkClosed (COSStream.java:82).
COSStream has been closed and cannot be read. Perhaps its enclosing PDDocument has been closed?
where the first page's type
is org.apache.pdfbox.pdmodel.PDDocument
Is it considered bad practice to keep atoms (or other mutable state) as values within immutable data structures? I tried this little experiment so that I could see what was going on:
client> (def t {:atom (atom nil)})
#'client/t
client> (update-in t [:atom] #(reset! % true))
{:atom true}
client> t
{:atom #atom[true 0x63a9848e]}
Not uncommon, totally fine
You get to choose the granularity of your state - a map with several atoms or an atom holding a map
More atoms gives you more granular state and smaller updates (with the caveat that they can’t be coordinated transactionally)
In general with Clojure, people tend to make things pretty coarse as atom updates are usually very fast
cgrand (as usual) had a pretty advanced take on this with refs in https://github.com/cgrand/megaref
That’s an oldie but should still work just fine today afaik