combine_pdf 1.0.18 → 1.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +38 -1
- data/lib/combine_pdf/api.rb +5 -5
- data/lib/combine_pdf/fonts.rb +12 -3
- data/lib/combine_pdf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acb1b817f13695dc04d7e0a3575ef90a9cc93408400c7aa3aab58a6bb42495b5
|
4
|
+
data.tar.gz: 18a65db68ae2f75e9778ddfdd4ca9fbb6ad0f606420bac9632dc492e5310ccc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c54f717182c8d1403be7e2019bc2a97b491b08a08c45e0e9cb2c66d334495cff6c15c78916654ea776469d8d2d764b20ab5c9074d313b62eaa0d41dcc1d21dd1
|
7
|
+
data.tar.gz: a9b4989550754718a2799547484e20b94a4515631bdab15e67002a574b2f33b9b32485f11c273bde0321d8f314e9b57620f0b48fdf41bc4694fc6b8098dc7b92
|
data/CHANGELOG.md
CHANGED
@@ -2,12 +2,20 @@
|
|
2
2
|
|
3
3
|
***
|
4
4
|
|
5
|
+
#### Change log v.1.0.19
|
6
|
+
|
7
|
+
**Fix**: fixes font height and width detection issue. Issue #179. Credit to @5anchezzz for opening the issue.
|
8
|
+
|
9
|
+
**Fix**: fixes an indentation warning. Issue #173. Credit to @rubyFeedback for exposing this issue.
|
10
|
+
|
5
11
|
#### Change log v.1.0.18
|
6
12
|
|
7
13
|
**Fix**: fixed issue with the 1.0.17 release where `ProcSet` PDF Arrays should have been expected but where ignored and a PDF Object was assumed instead (issue #171) - credit to @chuchiperriman (Jesús Barbero Rodríguez).
|
8
14
|
|
9
15
|
#### Change log v.1.0.17
|
10
16
|
|
17
|
+
NB: yanked from RubyGems.org.
|
18
|
+
|
11
19
|
**Fix**: fixed issue where nested structure equality tests might provide false positives, resulting in lost data (issue #166) - credit to @cschilbe (Conrad Schilbe).
|
12
20
|
|
13
21
|
#### Change log v.1.0.16
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# CombinePDF - the ruby way for merging PDF files
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/combine_pdf.svg)](http://badge.fury.io/rb/combine_pdf)
|
3
3
|
[![GitHub](https://img.shields.io/badge/GitHub-Open%20Source-blue.svg)](https://github.com/boazsegev/combine_pdf)
|
4
|
+
[![Documentation](http://inch-ci.org/github/boazsegev/combine_pdf.svg?branch=master)](https://www.rubydoc.info/github/boazsegev/combine_pdf)
|
4
5
|
[![Maintainers Wanted](https://img.shields.io/badge/maintainers-wanted-red.svg)](https://github.com/pickhardt/maintainers-wanted)
|
5
6
|
|
7
|
+
|
6
8
|
CombinePDF is a nifty model, written in pure Ruby, to parse PDF files and combine (merge) them with other PDF files, watermark them or stamp them (all using the PDF file format and pure Ruby code).
|
7
9
|
|
8
10
|
## Install
|
@@ -114,7 +116,42 @@ pdf.number_pages
|
|
114
116
|
pdf.save "file_with_numbering.pdf"
|
115
117
|
```
|
116
118
|
|
117
|
-
Numbering can be done with many different options, with different formating, with or without a box object, and even with opacity values - see documentation.
|
119
|
+
Numbering can be done with many different options, with different formating, with or without a box object, and even with opacity values - [see documentation](https://www.rubydoc.info/github/boazsegev/combine_pdf/CombinePDF/PDF#number_pages-instance_method).
|
120
|
+
|
121
|
+
For example, should you prefer to place the page number on the bottom right side of all PDF pages, do:
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
pdf.number_pages(location: [:bottom_right])
|
125
|
+
```
|
126
|
+
|
127
|
+
As another example, the dashes around the number are removed and a box is placed around it. The numbering is semi-transparent and the first 3 pages are numbered using letters (a,b,c) rather than numbers:
|
128
|
+
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
# number first 3 pages as "a", "b", "c"
|
132
|
+
pdf.number_pages(number_format: " %s ",
|
133
|
+
location: [:top, :bottom, :top_left, :top_right, :bottom_left, :bottom_right],
|
134
|
+
start_at: "a",
|
135
|
+
page_range: (0..2),
|
136
|
+
box_color: [0.8,0.8,0.8],
|
137
|
+
border_color: [0.4, 0.4, 0.4],
|
138
|
+
border_width: 1,
|
139
|
+
box_radius: 6,
|
140
|
+
opacity: 0.75)
|
141
|
+
# number the rest of the pages as 4, 5, ... etc'
|
142
|
+
pdf.number_pages(number_format: " %s ",
|
143
|
+
location: [:top, :bottom, :top_left, :top_right, :bottom_left, :bottom_right],
|
144
|
+
start_at: 4,
|
145
|
+
page_range: (3..-1),
|
146
|
+
box_color: [0.8,0.8,0.8],
|
147
|
+
border_color: [0.4, 0.4, 0.4],
|
148
|
+
border_width: 1,
|
149
|
+
box_radius: 6,
|
150
|
+
opacity: 0.75)
|
151
|
+
```
|
152
|
+
|
153
|
+
pdf.number_pages(number_format: " %s ", location: :bottom_right, font_size: 44)
|
154
|
+
|
118
155
|
|
119
156
|
## Loading and Parsing PDF data
|
120
157
|
|
data/lib/combine_pdf/api.rb
CHANGED
@@ -24,11 +24,11 @@ module CombinePDF
|
|
24
24
|
raise TypeError, "couldn't create PDF object, expecting type String" unless string.is_a?(String) || string.is_a?(Pathname)
|
25
25
|
begin
|
26
26
|
(begin
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
File.file? string
|
28
|
+
rescue
|
29
|
+
false
|
30
|
+
end) ? load(string) : parse(string)
|
31
|
+
rescue => _e
|
32
32
|
raise 'General PDF error - Use CombinePDF.load or CombinePDF.parse for a non-general error message (the requested file was not found OR the string received is not a valid PDF stream OR the file was found but not valid).'
|
33
33
|
end
|
34
34
|
end
|
data/lib/combine_pdf/fonts.rb
CHANGED
@@ -138,12 +138,21 @@ module CombinePDF
|
|
138
138
|
text.each_char do |c|
|
139
139
|
metrics_array << (merged_metrics[c] || { wx: 0, boundingbox: [0, 0, 0, 0] })
|
140
140
|
end
|
141
|
-
|
142
|
-
|
141
|
+
metrics_array_mapped_top = [].dup
|
142
|
+
metrics_array_mapped_bottom = [].dup
|
143
143
|
width = 0.0
|
144
144
|
metrics_array.each do |m|
|
145
|
-
|
145
|
+
if (m && m[:boundingbox])
|
146
|
+
metrics_array_mapped_top << m[:boundingbox][3]
|
147
|
+
metrics_array_mapped_bottom << m[:boundingbox][1]
|
148
|
+
else
|
149
|
+
metrics_array_mapped_top << 0
|
150
|
+
metrics_array_mapped_bottom << 0
|
151
|
+
end
|
152
|
+
width += (m[:wx] || m[:wy] || 0) if m
|
146
153
|
end
|
154
|
+
height = metrics_array_mapped_top.max
|
155
|
+
height -=metrics_array_mapped_bottom.min
|
147
156
|
return [height.to_f / 1000 * size, width.to_f / 1000 * size] if metrics_array[0][:wy]
|
148
157
|
[width.to_f / 1000 * size, height.to_f / 1000 * size]
|
149
158
|
end
|
data/lib/combine_pdf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: combine_pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boaz Segev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-rc4
|