-
-
Save rgm/b3fb7c231ca41aad871eaf6115d7699f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require | |
'[clj-chrome-devtools.core :as chrome] | |
'[clj-chrome-devtools.commands.page :as page]) | |
(defn b64-decode | |
"https://stackoverflow.com/a/39188819/53790" | |
[to-decode] | |
(String. (.decode (Base64/getDecoder) to-decode))) | |
(def c (chrome/connect "localhost" 9222)) | |
(page/navigate c {:url "https://github.com"}) | |
(let [response (page/print-to-pdf c {:page-ranges "1-2"}) | |
pdf-data (b64-decode (:data response))] | |
(spit "test.pdf" pdf-data)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment