SHARE
TWEET

Untitled

a guest Aug 18th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns rk-server.data-sending.pdf
  2.   (:require [unifn.core :as u]
  3.             [clj-htmltopdf.core :as htmltopdf]
  4.             [cheshire.core :as json]
  5.             [rk-server.email.core :as email]
  6.             [rk-server.data-sending.db :as db]
  7.             [rk-server.utils :as ut]
  8.             [rk-server.data-request :as data-request]
  9.             [rk-server.data-sending.crud :as crud]
  10.             [rk-server.data-sending.html :as html]
  11.             [rk-server.data-sending.common :as common]
  12.             [clojure.string :as str]
  13.             [rk-server.legal-documents :as legal-documents])
  14.   (:import [java.io ByteArrayOutputStream ByteArrayInputStream InputStream]
  15.            [java.util Base64]
  16.            [net.interfax.rest.client.impl DefaultInterFAXClient]
  17.            [org.apache.pdfbox.pdmodel PDDocument PDPage PDPageContentStream PDPageContentStream$AppendMode]))
  18.  
  19. (defn send-data-pdf [fax-number arg real-fax]
  20.   (binding [html/*manifest* arg]
  21.     (let [os (ByteArrayOutputStream.)
  22.           os (htmltopdf/->pdf (html/build-document (::data arg)
  23.                                                    (::user arg)
  24.                                                    (legal-documents/disclosure :server)
  25.                                                    real-fax
  26.                                                    nil)
  27.                               os common/pdf-options)
  28.           is (ByteArrayInputStream. (.toByteArray os))
  29.           fax (DefaultInterFAXClient.)
  30.           response (.sendFax fax fax-number
  31.                              (into-array InputStream [is])
  32.                              (into-array String ["application/pdf"]))]
  33.       {:state {:status-code (.getStatusCode response)}
  34.        :body (json/parse-string (.getResponseBody response))})))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top