prawndown-ext 0.1.11 → 0.1.12

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: cde2a748cc80534bf28bcb5540cd5788eb3d2690b64fec3c0357f72edfaa25bf
4
- data.tar.gz: dfcc6a5c1d475d660e3c8502e5351c91907bb5872a637f0a229e9f828c530945
3
+ metadata.gz: 6abd3d5ad775ed05ac8dfbe1fc68283104e63bd64aeadb6254bf31759db1b959
4
+ data.tar.gz: 555e53c35fbd8380eaaa434d024f0d084efdd222e1a7f1376f50bffbe162abc9
5
5
  SHA512:
6
- metadata.gz: 756968bf80dfc61824d0a6825aaf966132b0a25fc4c62879cc32dfdba3454ab2e0f900b55f8c7658e4588d8631f9bcfa13cf065f1d117157f5bb41c0d6ed25ae
7
- data.tar.gz: 443c379f6e4d49bcbaea754a6775d5099a74c1d0ccdba2a5e762c7923252f7716e4a1bb722e4f688ee3a16b41fb22e402664cbfec1ed95fde5ebc8e9e5c1dd3f
6
+ metadata.gz: c7e6004fe66a36371094bd33532664f17250ad7a877f09fa4b1ed1ec12b810987e79738d1179e50db014c010637d07deb1aba0edcce11ef32cf72887993c6a04
7
+ data.tar.gz: bf13a1d81efc3d6239d93b37bf002558cbe7fd5d24571dc3b1691fbf2ed23eb69e1511283131adee052ce6507231f98e59d569738d2f35612c02081d80ff3277
@@ -2,6 +2,6 @@
2
2
 
3
3
  module PrawndownExt
4
4
  module Ext
5
- VERSION = "0.1.11"
5
+ VERSION = "0.1.12"
6
6
  end
7
7
  end
data/lib/prawndown-ext.rb CHANGED
@@ -37,7 +37,9 @@ module PrawndownExt
37
37
  args["margin"] = 0
38
38
  end
39
39
 
40
- pdf.pad args["margin"] do
40
+ half_margin = (args["margin"] * 0.5).floor
41
+
42
+ pdf.pad half_margin do
41
43
  pdf.indent args["margin"], args["margin"] do
42
44
  pdf.text args["text"], inline_format: true, leading: options[args["command"] + "_line_spacing"].to_f
43
45
  end
@@ -52,6 +54,25 @@ module PrawndownExt
52
54
  end
53
55
  end
54
56
 
57
+ width = nil
58
+ height = nil
59
+
60
+ if options.key?("image_width")
61
+ width = options["image_width"].to_i
62
+ end
63
+
64
+ if options.key?("image_height")
65
+ height = options["image_height"].to_i
66
+ end
67
+
68
+ if width.nil? && height.nil?
69
+ width = pdf.bounds.width
70
+ end
71
+
72
+ if !width.nil?
73
+ width = [pdf.bounds.width, width].min
74
+ end
75
+
55
76
  if args["path"][0] == "/"
56
77
  args["path"] = args["path"][1..-1]
57
78
  end
@@ -63,14 +84,32 @@ module PrawndownExt
63
84
  end
64
85
 
65
86
  if File.extname(file) != ".gif"
66
- pdf.image(file,
67
- width: pdf.bounds.width,
68
- position: :center)
87
+ if !(height.nil? && width.nil?)
88
+
89
+ if height.nil? && !width.nil?
90
+ pdf.image(file,
91
+ width: [pdf.bounds.width, width].min,
92
+ position: :center)
93
+ elsif !height.nil? && width.nil?
94
+ pdf.image(file,
95
+ height: height,
96
+ position: :center)
97
+ else
98
+ pdf.image(file,
99
+ width: [pdf.bounds.width, width].min,
100
+ height: height,
101
+ position: :center)
102
+ end
103
+ end
69
104
  end
70
105
  end
71
106
 
72
107
  def self.cl_newline args, pdf, options
73
- pdf.start_new_page()
108
+ if pdf.bounds.instance_of? Prawn::Document::ColumnBox
109
+ pdf.bounds.move_past_bottom
110
+ else
111
+ pdf.start_new_page
112
+ end
74
113
  end
75
114
 
76
115
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawndown-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - PunishedFelix