html2pdf-rails 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81aa8cae824f6e905835a1c6a4b888c7fbd6be9a921b7f05afc16cabd5e1a97b
4
- data.tar.gz: 9bd80fd9c5fa427b9a63d82bfa12341b7de3ad382fecb32b86878c22abc4540d
3
+ metadata.gz: 5c933b1cfb11343837f0b30972a1062ffe7dc3e4d03e089a0734dfea617e320c
4
+ data.tar.gz: 20eb371e7da0b2795e2d9eea78487b5e7cad9e7e7f00317613b69fa2428ee660
5
5
  SHA512:
6
- metadata.gz: a73c0aea849dea12e74af2c772d6987429b44b8016fadca7fb6acf6ae407838212cd85c3785b147ec37c1384c16338ad72a20ceb12fddddb6b41073d9e6566d0
7
- data.tar.gz: 4029e1d519291d5787d2b95f2b780fdea2d42ed341727c10658182274b068a86bd5ed5522045c1304295dcc69aa1b7582ca7c069032e37320fd948406f3c91a1
6
+ metadata.gz: 121de0d8ceb2c4d40474ae991fa4c286794c67db29d477f7214ca923743afc86acda4fa02313b7b7d31ce81d4bc31694d12f8464a3e3332aafb7f0f6a860eb6f
7
+ data.tar.gz: 94b153953fbc58c413140555b499bf4e3967d9c7d857520adef5f85299b39708805f841b9a2744737471eeaaa0a4f4c3d407053c9d7b96614bb6e6a73c6b2bfa
data/README.md CHANGED
@@ -73,9 +73,9 @@ class ThingsController < ApplicationController
73
73
  template: 'things/show',
74
74
  layout: 'pdf', # for a pdf.pdf.erb file
75
75
  show_as_html: params.key?('debug'), # allow debugging based on url param
76
- pdf_options: { # SEE: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepdfoptions
76
+ pdf_options: { # SEE: https://pptr.dev/api/puppeteer.pdfoptions
77
77
  margin: {
78
- top: '30px'
78
+ top: '30px',
79
79
  bottom: '30px',
80
80
  }
81
81
  }
@@ -5,18 +5,20 @@ require 'html2pdf/rails/errors'
5
5
  module Html2Pdf
6
6
  module Rails
7
7
  class Client
8
- def self.post(*args)
9
- self.new(Html2Pdf.config.endpoint).post(*args)
8
+ def self.post(**options)
9
+ self.new(Html2Pdf.config.endpoint, Html2Pdf.config.app).post(**options)
10
10
  end
11
11
 
12
- def initialize(endpoint)
12
+ def initialize(endpoint, app)
13
13
  @uri = URI.parse(endpoint)
14
+ @app = app
14
15
  end
15
16
 
16
17
  def post(html:, put_to_storage: false, file_name: nil, disposition: nil, pdf_options: {})
17
18
  http = Net::HTTP.new(@uri.host, @uri.port).tap { |h| h.use_ssl = @uri.scheme == 'https' }
18
19
  request = Net::HTTP::Post.new(@uri.request_uri, headers)
19
20
  request.body = {
21
+ app: @app,
20
22
  html: html,
21
23
  putToStorage: put_to_storage,
22
24
  fileName: file_name,
@@ -14,10 +14,11 @@ module Html2Pdf
14
14
  ActionView::Base.include Helper
15
15
  end
16
16
 
17
- config.after_initialize do
17
+ config.after_initialize do |app|
18
18
  if Html2Pdf.config.endpoint.blank?
19
19
  raise 'Html2Pdf.config.endpoint is required'
20
20
  end
21
+ Html2Pdf.config.app ||= app.class.module_parent_name
21
22
  end
22
23
  end
23
24
  end
@@ -47,7 +47,7 @@ module Html2Pdf
47
47
 
48
48
  def _html2pdf_make_pdf(options = {})
49
49
  render_opts = options.slice(:template, :layout, :formats, :handlers)
50
- html = render_to_string(render_opts)
50
+ html = render_to_string(**render_opts)
51
51
 
52
52
  Retryable.retryable(tries: 3, on: Html2Pdf::Rails::ServiceUnavailableError) do
53
53
  Client.post(
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Html2Pdf
4
4
  module Rails
5
- VERSION = '0.3.1'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
@@ -6,6 +6,7 @@ module Html2Pdf
6
6
  class Config
7
7
  include ActiveSupport::Configurable
8
8
  config_accessor :endpoint
9
+ config_accessor :app
9
10
  end
10
11
 
11
12
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html2pdf-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - aki77
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-23 00:00:00.000000000 Z
11
+ date: 2025-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -110,7 +110,7 @@ homepage: https://github.com/SonicGarden/html2pdf-rails
110
110
  licenses:
111
111
  - MIT
112
112
  metadata: {}
113
- post_install_message:
113
+ post_install_message:
114
114
  rdoc_options: []
115
115
  require_paths:
116
116
  - lib
@@ -125,8 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.1.2
129
- signing_key:
128
+ rubygems_version: 3.5.16
129
+ signing_key:
130
130
  specification_version: 4
131
131
  summary: PDF generator (from HTML) gem for Ruby on Rails
132
132
  test_files: []