combine_pdf 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54fe3a4a2dc8031d7903927a20cd8ab2698915b9
4
- data.tar.gz: 7e01b142f7ab89fad68ecbff4b8035da2b1c3226
3
+ metadata.gz: 0cdaac783f68294ad27e5b4debc724f56190fc02
4
+ data.tar.gz: c31baf6a9e9fc4076b1d28abafde4e383d797b1f
5
5
  SHA512:
6
- metadata.gz: d7696ec1f7222fc3ee6e4bd27736bd9ad6115b9ae1ee44eba333f1ce6494a5d864cabc9e8d76897d7fe0d651e4cec8fef0ef6d6ea84e5ab2036c1996fa820207
7
- data.tar.gz: 59c72be7a53302ff6516227ce1b1837a9f23881871a372f616c965f0b450e971be52201a521d3e94b968c709d3f51682472414ff47647bdf45e4f7475038e2b4
6
+ metadata.gz: 10ec2ba8ab2885d7f99cab5c7bcd7feaf22408d8e4da66e0ab3fc2f57ab0c5ba52e9325e3c110642b03a2309561d0494bfaab7b37126c949937f55e66a22ef29
7
+ data.tar.gz: 3650485fcdbafbd255912365bc6ffee8acd86b16cf07e71653388972ed2fb78f27305ca5b8c4f51303e45b3f59f6d468c8dbdaa180e084aff1045bc5e01c8659
data/CHANGELOG.md CHANGED
@@ -2,10 +2,17 @@
2
2
 
3
3
  ***
4
4
 
5
+ Change log v.0.1.10
6
+
7
+ **fix**: fixed a typo that prevented access to the CombinePDF::VERSION constant.
8
+
9
+ ***
10
+
5
11
  Change log v.0.1.9
6
12
 
7
13
  **fix**: possible fix for bug reported by lamphuongha, regarding PDF 1.5 streams. I await confirmation that the fix actually works, as I cannot seem to reproduce the whole spectrum of the bug on my system...
8
14
 
15
+ ***
9
16
 
10
17
  Change log v.0.1.8
11
18
 
data/README.md CHANGED
@@ -4,23 +4,30 @@ CombinePDF is a nifty model, written in pure Ruby, to parse PDF files and combin
4
4
  # Install
5
5
 
6
6
  Install with ruby gems:
7
- ```
7
+
8
+ ```ruby
8
9
  gem install combine_pdf
9
10
  ```
10
11
 
11
12
  ## Combine/Merge PDF files or Pages
13
+
12
14
  To combine PDF files (or data):
15
+
13
16
  ```ruby
14
17
  pdf = CombinePDF.new
15
18
  pdf << CombinePDF.new("file1.pdf") # one way to combine, very fast.
16
19
  pdf << CombinePDF.new("file2.pdf")
17
20
  pdf.save "combined.pdf"
18
21
  ```
22
+
19
23
  Or even a one liner:
24
+
20
25
  ```ruby
21
26
  (CombinePDF.new("file1.pdf") << CombinePDF.new("file2.pdf") << CombinePDF.new("file3.pdf")).save("combined.pdf")
22
27
  ```
28
+
23
29
  you can also add just odd or even pages:
30
+
24
31
  ```ruby
25
32
  pdf = CombinePDF.new
26
33
  i = 0
@@ -37,39 +44,51 @@ notice that adding all the pages one by one is slower then adding the whole file
37
44
  To add content to existing PDF pages, first import the new content from an existing PDF file. After that, add the content to each of the pages in your existing PDF.
38
45
 
39
46
  In this example, we will add a company logo to each page:
47
+
40
48
  ```ruby
41
49
  company_logo = CombinePDF.new("company_logo.pdf").pages[0]
42
50
  pdf = CombinePDF.new "content_file.pdf"
43
51
  pdf.pages.each {|page| page << company_logo} # notice the << operator is on a page and not a PDF object.
44
52
  pdf.save "content_with_logo.pdf"
45
53
  ```
54
+
46
55
  Notice the << operator is on a page and not a PDF object. The << operator acts differently on PDF objects and on Pages.
47
56
 
48
57
  The << operator defaults to secure injection by renaming references to avoid conflics. For overlaying pages using compressed data that might not be editable (due to limited filter support), you can use:
58
+
49
59
  ```ruby
50
60
  pdf.pages(nil, false).each {|page| page << stamp_page}
51
61
  ```
62
+
52
63
  ## Page Numbering
64
+
53
65
  adding page numbers to a PDF object or file is as simple as can be:
66
+
54
67
  ```ruby
55
68
  pdf = CombinePDF.new "file_to_number.pdf"
56
69
  pdf.number_pages
57
70
  pdf.save "file_with_numbering.pdf"
58
71
  ```
72
+
59
73
  Numbering can be done with many different options, with different formating, with or without a box object, and even with opacity values - see documentation.
60
74
 
61
75
  ## Loading PDF data
76
+
62
77
  Loading PDF data can be done from file system or directly from the memory.
63
78
 
64
79
  Loading data from a file is easy:
80
+
65
81
  ```ruby
66
82
  pdf = CombinePDF.new("file.pdf")
67
83
  ```
84
+
68
85
  you can also parse PDF files from memory:
86
+
69
87
  ```ruby
70
88
  pdf_data = IO.read 'file.pdf' # for this demo, load a file to memory
71
89
  pdf = CombinePDF.parse(pdf_data)
72
90
  ```
91
+
73
92
  Loading from the memory is especially effective for importing PDF data recieved through the internet or from a different authoring library such as Prawn.
74
93
 
75
94
  Demo
@@ -107,11 +126,3 @@ Credit to his wonderful is given here. Please respect his license and copyright.
107
126
  License
108
127
  =======
109
128
  MIT
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
data/combine_pdf.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'combine_pdf/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "combine_pdf"
8
- spec.version = CombinePdf::VERSION
8
+ spec.version = CombinePDF::VERSION
9
9
  spec.authors = ["Boaz Segev"]
10
10
  spec.email = ["We try, we fail, we do, we are"]
11
11
  spec.summary = %q{Combine, stamp and watermark PDF files in pure Ruby.}
@@ -199,13 +199,13 @@ module CombinePDF
199
199
  when ')'
200
200
  count -= 1 unless seperator_count.odd?
201
201
  else
202
- warn "Unknown error parsing string at #{@scanner.pos}!"
203
- cout = 0 # error
202
+ warn "Unknown error parsing string at #{@scanner.pos} for string: #{str}!"
203
+ count = 0 # error
204
204
  end
205
205
  end
206
206
  # The PDF formatted string is: str[0..-2]
207
207
  # now staring to convert to regular string
208
- str_bytes = str[0..-2].bytes
208
+ str_bytes = str[0..-2].bytes.to_a
209
209
  str = []
210
210
  until str_bytes.empty?
211
211
  case str_bytes[0]
@@ -1,3 +1,3 @@
1
- module CombinePdf
2
- VERSION = "0.1.9"
1
+ module CombinePDF
2
+ VERSION = "0.1.10"
3
3
  end
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.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boaz Segev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-20 00:00:00.000000000 Z
11
+ date: 2015-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-rc4