Sha256: dc6980725e9f7a8ffdb9ad1d04cba668d7e8bb8a39abf97ee8efdb48dbfa6ef0
Contents?: true
Size: 759 Bytes
Versions: 8
Compression:
Stored size: 759 Bytes
Contents
require 'rest-client' module Quby module PdfRenderer class EmptyResponse < RuntimeError end def self.render_pdf(html_str) if ENV['GOTENBERG_URL'].present? RestClient.post(ENV['GOTENBERG_URL'], upload: { file: string_to_fileupload(html_str) }).body.tap do |response| raise EmptyResponse if response.empty? end else # deprecated fallback while testing. RestClient.post(ENV['HTML_TO_PDF_URL'], html_str).body.tap do |response| raise EmptyResponse if response.empty? end end end def self.string_to_fileupload(string) StringIO.new(string).tap do |file| def file.path "index.html" end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems