combine_pdf 0.1.16 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/combine_pdf/combine_pdf_operations.rb +7 -7
- data/lib/combine_pdf/combine_pdf_page.rb +14 -12
- data/lib/combine_pdf/combine_pdf_pdf.rb +9 -0
- data/lib/combine_pdf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e47677b33c3ffe86a4925b1deb037548461129b4
|
4
|
+
data.tar.gz: 90a8ad24ec4a577591cbe3db7212361579c6cab6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3abdab8d627943a9183016b6dfcad5e661d6f1fb054538549714b18f45945c32fe6fd36e6c711b435db7bc1f534bf262cf321f0fb8c73d2fa9a0392910235c0
|
7
|
+
data.tar.gz: 93d3401a065522a276e22e5049e7b4c469e02de8fc3708f02783a0605d7f7ccc1bf1ac3e41e100951c384da809be04df41e259cadcd31dc52c2ef3c92b9d7509
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
***
|
4
4
|
|
5
|
+
Change log v.0.1.17
|
6
|
+
|
7
|
+
**feature**: Although it was possible to create and add empty PDF pages (at any location), it is now even easier with one method call to add empty pages at the end of a PDF object. It's also possible to add text to these empty pages or stamp them with different content.
|
8
|
+
|
9
|
+
**fix?**: a possible multi-threading issue might have existed where to threads saving PDF data at the same time might corrupt PDF data (although this theoretical issue was never reported and probably never encountered). The PDF streams should now be a bit more thread safe, as long as no two threads attempt to render the same PDF object at the same time.
|
10
|
+
|
11
|
+
**fix?**: Thank to Roma, who reported issue #14, we are now working on a fix of a mysterious issue with textboxes which could effect page numbering and textboxes on certain PDF files. It is unknown at this time if the issue is resolved and the fix is awaiting confirmation. The issue effected only some PDF files and not others.
|
12
|
+
|
13
|
+
***
|
14
|
+
|
5
15
|
Change log v.0.1.16
|
6
16
|
|
7
17
|
**fix?**: Compatability reports came in showing that some email servers convery new-line (\n) characters to CRLF (\r\n) - corrupting the binary code in the PDF files. This version attemps to fix this by adding more binary characters to the first comment line of the PDF file (right after the header). Most email programs and Antivirus programs should preserve the original EOL character once they recognize the file as binary.
|
@@ -82,16 +82,16 @@ module CombinePDF
|
|
82
82
|
|
83
83
|
if top # if this is a stamp (overlay)
|
84
84
|
page[:Contents] = original_contents
|
85
|
-
page[:Contents].unshift CONTENT_CONTAINER_START
|
86
|
-
page[:Contents].push CONTENT_CONTAINER_MIDDLE
|
85
|
+
page[:Contents].unshift create_deep_copy(CONTENT_CONTAINER_START)
|
86
|
+
page[:Contents].push create_deep_copy(CONTENT_CONTAINER_MIDDLE)
|
87
87
|
page[:Contents].push *stream_contents
|
88
|
-
page[:Contents].push CONTENT_CONTAINER_END
|
88
|
+
page[:Contents].push create_deep_copy(CONTENT_CONTAINER_END)
|
89
89
|
else #if this was a watermark (underlay? would be lost if the page was scanned, as white might not be transparent)
|
90
90
|
page[:Contents] = stream_contents
|
91
|
-
page[:Contents].unshift CONTENT_CONTAINER_START
|
92
|
-
page[:Contents].push CONTENT_CONTAINER_MIDDLE
|
91
|
+
page[:Contents].unshift create_deep_copy(CONTENT_CONTAINER_START)
|
92
|
+
page[:Contents].push create_deep_copy(CONTENT_CONTAINER_MIDDLE)
|
93
93
|
page[:Contents].push *original_contents
|
94
|
-
page[:Contents].push CONTENT_CONTAINER_END
|
94
|
+
page[:Contents].push create_deep_copy(CONTENT_CONTAINER_END)
|
95
95
|
end
|
96
96
|
|
97
97
|
page
|
@@ -198,7 +198,7 @@ module CombinePDF
|
|
198
198
|
elsif object.is_a?(String)
|
199
199
|
return object.dup
|
200
200
|
else
|
201
|
-
return object # objects that aren't Strings, Arrays or Hashes (such as Symbols and Fixnums)
|
201
|
+
return object # objects that aren't Strings, Arrays or Hashes (such as Symbols and Fixnums) won't be edited inplace.
|
202
202
|
end
|
203
203
|
end
|
204
204
|
# removes id and generation number values, for better comparrison
|
@@ -40,14 +40,16 @@ module CombinePDF
|
|
40
40
|
|
41
41
|
# accessor (getter) for the :MediaBox element of the page
|
42
42
|
def mediabox
|
43
|
-
self[:MediaBox]
|
43
|
+
self[:MediaBox].is_a?(Array) ? self[:MediaBox] : self[:MediaBox][:referenced_object]
|
44
44
|
end
|
45
|
-
|
46
|
-
#
|
47
|
-
def
|
48
|
-
self[:
|
45
|
+
|
46
|
+
# accessor (getter) for the :Resources element of the page
|
47
|
+
def resources
|
48
|
+
self[:Resources] ||= {}
|
49
|
+
self[:Resources][:referenced_object] || self[:Resources]
|
49
50
|
end
|
50
51
|
|
52
|
+
|
51
53
|
# This method adds a simple text box to the Page represented by the PDFWriter class.
|
52
54
|
# This function takes two values:
|
53
55
|
# text:: the text to potin the box.
|
@@ -194,7 +196,7 @@ module CombinePDF
|
|
194
196
|
# each unit (1) is 1/72 Inch
|
195
197
|
# create text stream
|
196
198
|
text_stream = ""
|
197
|
-
if text.to_s
|
199
|
+
if !text.to_s.empty? && options[:font_size] != 0 && (options[:font_color] || options[:stroke_color])
|
198
200
|
# compute x and y position for text
|
199
201
|
x = options[:x] + (options[:width]*options[:text_padding])
|
200
202
|
y = options[:y] + (options[:height]*options[:text_padding])
|
@@ -296,11 +298,6 @@ module CombinePDF
|
|
296
298
|
end
|
297
299
|
|
298
300
|
|
299
|
-
# accessor (getter) for the :Resources element of the page
|
300
|
-
def resources
|
301
|
-
self[:Resources]
|
302
|
-
end
|
303
|
-
|
304
301
|
# This method moves the Page[:Rotate] property into the page's data stream, so that
|
305
302
|
# "what you see is what you get".
|
306
303
|
#
|
@@ -324,7 +321,7 @@ module CombinePDF
|
|
324
321
|
# insert the rotation stream into the current content stream
|
325
322
|
insert_object "q\n#{ctm.join ' '} cm\n", 0
|
326
323
|
# close the rotation stream
|
327
|
-
insert_object CONTENT_CONTAINER_END
|
324
|
+
insert_object PDFOperations.create_deep_copy(CONTENT_CONTAINER_END)
|
328
325
|
# reset the mediabox and cropbox values - THIS IS ONLY FOR ORIENTATION CHANGE...
|
329
326
|
if ((self[:Rotate].to_f / 90)%2) != 0
|
330
327
|
self[:MediaBox] = self[:MediaBox].values_at(1,0,3,2)
|
@@ -390,6 +387,11 @@ module CombinePDF
|
|
390
387
|
end
|
391
388
|
#initializes the content stream in case it was not initialized before
|
392
389
|
def init_contents
|
390
|
+
# wrap content streams
|
391
|
+
insert_object 'q', 0
|
392
|
+
insert_object 'Q'
|
393
|
+
|
394
|
+
# Prep content
|
393
395
|
@contents = ''
|
394
396
|
insert_object @contents
|
395
397
|
@contents
|
@@ -314,6 +314,7 @@ module CombinePDF
|
|
314
314
|
return self
|
315
315
|
end
|
316
316
|
insert -1, data
|
317
|
+
self
|
317
318
|
end
|
318
319
|
|
319
320
|
# add the pages (or file) to the BEGINNING of the PDF (combine/merge) and RETURNS SELF for nesting operators.
|
@@ -357,6 +358,7 @@ module CombinePDF
|
|
357
358
|
location = page_count
|
358
359
|
end
|
359
360
|
pages_array.insert location, pages_to_add
|
361
|
+
pages_array.flatten!
|
360
362
|
pages_array
|
361
363
|
end
|
362
364
|
|
@@ -454,6 +456,13 @@ module CombinePDF
|
|
454
456
|
end
|
455
457
|
end
|
456
458
|
|
459
|
+
# adds a new page to the end of the PDF object.
|
460
|
+
#
|
461
|
+
# returns the new page object.
|
462
|
+
def new_page(mediabox = [0, 0, 595.3, 841.9])
|
463
|
+
insert(-1, PDFWriter.new(mediabox) ).last
|
464
|
+
end
|
465
|
+
|
457
466
|
# get the title for the pdf
|
458
467
|
# The title is stored in the information dictionary and isn't required
|
459
468
|
def title
|
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: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boaz Segev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-rc4
|