rghost 0.9.4 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MTA2ZGRmNDM2NTVhZmViYmJmNmM5M2IwM2I4ZTIzY2I2ODliYmE3NA==
5
- data.tar.gz: !binary |-
6
- MTE1ZTk0YTkwZmM3YzBlYjY5YjFlMmJlOWQ3YTVjYTE2NzFlMGU4Mw==
2
+ SHA256:
3
+ metadata.gz: 4a13b5e2e99e0b48b7beec30296c2e578f23991bf3de4b2ac0cd87afe87fac10
4
+ data.tar.gz: 65db7916b2a0dc94383fdefbc8c6555fe40e0f38f4f983c8b8afd1d6c6497b50
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZGRkNzM3MDgzY2I0YzI5ODkzNTFkMTJlMmYwMjFmY2VhNDEyMmJkMmVkNGU0
10
- MmVmMzA1MjA0NTM4ZTgzN2E4YjA5NzQ3Mjk3Y2YwNjcyYjMzYWM1ZTFmZTc4
11
- NGFmZjBmYTM4OTNiNWZjOTZkNGZhZWI2Y2NmZmJhYmZhZmM4YTc=
12
- data.tar.gz: !binary |-
13
- Njk5NjE0NTVmODU0NzFlM2NlYmRlNmZiMmM4MDI4YmFlMjljNDBkMTFmNDYx
14
- NDI5ZGU5NTNjYjExOTY3MDBjMjc2MGZjMjJkNjI1OGNlMTc3MmQzNzIyMWI0
15
- ZWE2YzdlNzEwYTFkMmM0ODk5NDg2NDQyYjU0Zjc3ZDRhNGNiNzg=
6
+ metadata.gz: bb42950761acc59d41f8cfc6e0e65528c1ff020d1fc871283fe8300594495056b25241caf4200b2c22ff5144966a1ad1b0188efc913b7b5432be8ffddbaa9aa1
7
+ data.tar.gz: b6c37359954906b8486680fce4222c1ee3baeaac8349549c0b0d9e94dd52fc2c078d5b741538ffd68a3445906cd28543f066059222e3c2c3ffa5114a979c034f
data/lib/rghost.rb CHANGED
@@ -12,7 +12,8 @@ require 'rghost/variable'
12
12
  require 'rghost/ps_facade'
13
13
  require 'rghost/function'
14
14
  require 'rghost/document'
15
- require 'rghost/grid/grid'
15
+ require 'rghost/merge_pdfs'
16
+ require 'rghost/grid/grid'
16
17
  RGhost::Config::GS[:PATH]="/opt/local/bin/gs"
17
18
 
18
19
 
@@ -3,7 +3,7 @@ require "rghost/helpers"
3
3
  module RGhost::Constants
4
4
  module HashKeyMethod #:nodoc:
5
5
  def method_missing(method, *args)
6
- self[method.to_sym]
6
+ self[method.to_sym]
7
7
  end
8
8
  end
9
9
  class HashKeyMethodClass < Hash #:nodoc:
@@ -11,7 +11,7 @@ module RGhost::Constants
11
11
  end
12
12
  module Devices
13
13
  #Standard Devices
14
- STANDARD=RGhost::Constants::HashKeyMethodClass[
14
+ STANDARD=RGhost::Constants::HashKeyMethodClass[
15
15
  #-- MS-DOS displays",
16
16
  :ega => "EGA (640x350, 16-color)",
17
17
  :vga => "VGA (640x480, 16-color)",
@@ -65,8 +65,6 @@ module RGhost::Constants
65
65
  :lj5gray => "H-P LaserJet 5 & 6 family, gray-scale bitmap;",
66
66
  :lp2563 => "H-P 2563B line printer",
67
67
  :oce9050 => "OCE 9050 printe",
68
- :pxlmono => "H-P black-and-white PCL XL printers (LaserJet 5 and 6 family)",
69
- :pxlcolor => "H-P color PCL XL printers (e.g. Color LaserJet 4500)",
70
68
  #-- Fax file format",
71
69
  :faxg3 => "Group 3 fax, with EOLs but no header or EOD",
72
70
  :faxg32d => "Group 3 2-D fax, with EOLs but no header or EOD",
@@ -76,7 +74,7 @@ module RGhost::Constants
76
74
  :tiffg32d => "TIFF Group 3 2-D fax",
77
75
  :tiffg4 => "TIFF Group 4 fax",
78
76
  #-- High-level (vector) file formats",
79
- :epswrite => "EPS output (like PostScript Distillery)",
77
+ :eps2write => "EPS output (like PostScript Distillery)",
80
78
  :pdfwrite => "PDF output (like Adobe Acrobat Distiller)",
81
79
  :pswrite => "PostScript output (like PostScript Distillery)",
82
80
  :pxlmono => "Black-and-white PCL XL",
@@ -132,13 +130,13 @@ module RGhost::Constants
132
130
  :tiff24nc => "TIFF 24-bit RGB, no compression (NeXT standard format)",
133
131
  :tifflzw => "TIFF LZW (tag = 5) (monochrome)",
134
132
  :tiffpack => "TIFF PackBits (tag = 32773) (monochrome)"
135
-
136
-
133
+
134
+
137
135
  ]
138
136
  DEVICES_ALIAS={
139
- :eps => :epswrite,
137
+ :eps => :eps2write,
140
138
  :pdf => :pdfwrite,
141
- :ps => :pswrite,
139
+ :ps => :ps2write,
142
140
  :pcl => :pxlmono,
143
141
  :tif => :tiffcrle,
144
142
  :tiff => :tiffcrle,
@@ -147,15 +145,15 @@ module RGhost::Constants
147
145
  }
148
146
  #Load device by alias
149
147
  def device_for(dev)
150
-
151
-
148
+
149
+
152
150
  return DEVICES_ALIAS[dev] if DEVICES_ALIAS.key? dev
153
151
  return dev if STANDARD.key? dev
154
152
  raise "Undefined device: #{dev}"
155
153
  end
156
-
154
+
157
155
  end
158
-
156
+
159
157
  module Fonts
160
158
  #Standard Encodings
161
159
  ENCODINGS=['ISOLatin1Encoding', 'StandardEncoding ']
@@ -261,7 +259,7 @@ module RGhost::Constants
261
259
  'ZapfDingbats' => "-itc-zapfdingbats-medium-r-normal--",
262
260
  'Symbol' => "--symbol-medium-r-normal--"
263
261
  }
264
-
262
+
265
263
  end
266
264
  #Color map
267
265
  module Colors
@@ -564,7 +562,7 @@ module RGhost::Constants
564
562
  :Yellow => [0.0,0.0,1.0,0.0],
565
563
  :YellowGreen => [0.248780487804878,0.0,0.75609756097561,0.196078431372549]
566
564
  ]
567
-
565
+
568
566
  end
569
567
  #Standard papers
570
568
  module Papers
@@ -619,8 +617,8 @@ module RGhost::Constants
619
617
  :flse => [612,936],
620
618
  :halfletter => [396,612]
621
619
  }
622
-
620
+
623
621
  end
624
622
  end
625
623
 
626
-
624
+
@@ -0,0 +1,12 @@
1
+ class RGhost::MergePdfs
2
+ attr_reader :error, :errors
3
+ DEFAULT_OPTIONS = { :convert => true }
4
+
5
+ def self.merge(pdfs, options={})
6
+ rge = RGhost::Engine.new(pdfs,DEFAULT_OPTIONS.merge(options))
7
+ out = rge.render(:pdf)
8
+ @error = rge.error
9
+ @errors = rge.errors
10
+ out
11
+ end
12
+ end
@@ -70,15 +70,8 @@ module RGhost::Config
70
70
  :default_params=> %w(gs -dNOPAUSE -dBATCH -dQUIET -dNOPAGEPROMPT),
71
71
  :stack_elements => 5000,
72
72
  :font_encoding => :IsoLatin,
73
- :charset_convert => begin
74
- if RUBY_VERSION =~ /^1.8/
75
- require 'iconv'
76
- lambda { |text| Iconv::iconv('latin1','utf-8', text).join }
77
- else
78
- lambda { |text| text.encode('ISO-8859-1', 'UTF-8') }
79
- end
80
- end,
81
- :external_encoding => nil,
73
+ :external_encoding => 'ascii-8bit',
74
+ :charset_convert => nil,
82
75
  :fontsize => 8,
83
76
  :unit => RGhost::Units::Cm
84
77
  }
@@ -120,10 +113,28 @@ module RGhost::Config
120
113
  d.benchmark(:stop)
121
114
  d.done
122
115
  d
116
+ end
123
117
 
118
+ #Generate the UTF-8 encoding mapping
119
+ #
120
+ # RGhost::Config.utf8_encodings.render :pdf, :filename => "/tmp/encoding_map.pdf"
121
+ #
122
+ def self.utf8_encodings
123
+ doc = RGhost::Document.new :paper => [20,10], :margin_left => 2.3, :margin_bottom => 2.3
124
124
 
125
+ doc.virtual_pages do
126
+ 7.times do
127
+ new_page :width => 2, :margin_left => 1
128
+ end
129
+ end
125
130
 
131
+ RGhost::RubyToPs::UTF8_ENCODINGS.each do |k,v|
132
+ doc.show "#{k} = #{v}"
133
+ doc.next_row
134
+ end
135
+ doc
126
136
  end
137
+
127
138
  #This method is a helper to gets the best encoding.
128
139
  #
129
140
  #link:images/encode_test.png
@@ -52,11 +52,9 @@ class RGhost::Engine
52
52
  params << "-sstdout=#{shellescape(file_err)}"
53
53
  params << "-sOutputFile=#{shellescape(file_out)}"
54
54
  params << @options[:raw] if @options[:raw]
55
-
56
-
57
55
  case @document
58
56
  when RGhost::Document
59
- file_in="#{tmp_filename}.rgin"
57
+ file_in = shellescape("#{tmp_filename}.rgin")
60
58
  params.concat @document.gs_paper
61
59
  mode=external_encoding.nil? ? 'w' : "w:#{external_encoding}"
62
60
  fi=File.open(file_in,mode)
@@ -66,10 +64,14 @@ class RGhost::Engine
66
64
  file_in=@document.path
67
65
  #@delete_input=false unless @options[:debug]
68
66
  when String
69
- file_in=@document
67
+ file_in = shellescape(@document)
68
+ when Array
69
+ file_in = @document.map{|d| shellescape(d) }.join(' ')
70
+ else
71
+ raise RuntimeError.new("Cannot convert #{@document.class}. Supported classes are RGhost::Document or File or String.")
70
72
  end
71
73
 
72
- params << shellescape(file_in)
74
+ params << file_in
73
75
 
74
76
  if RGhost::Config::GS[:mode] == :gslib
75
77
  require "rghost/rgengine"
@@ -1,8 +1,8 @@
1
1
  module RGhost::VERSION #:nodoc:
2
2
  MAJOR = 0
3
- MINOR = 8
3
+ MINOR = 9
4
4
  TINY = 7
5
5
  DATE=1244286414
6
6
  STRING = [MAJOR, MINOR, TINY].join('.')
7
-
7
+
8
8
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  #Converts Ruby types to Postscript types
2
3
  module RGhost::RubyToPs
3
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rghost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shairon Toledo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-26 00:00:00.000000000 Z
11
+ date: 2019-09-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby Ghostscript Engine is a document creation and conversion API, support(PDF,PS,GIF,TIF,PNG,JPG...).
14
14
  It uses the GhostScript framework for the format conversion, utilizes EPS templates
@@ -61,6 +61,7 @@ files:
61
61
  - lib/rghost/line.rb
62
62
  - lib/rghost/line_width.rb
63
63
  - lib/rghost/load.rb
64
+ - lib/rghost/merge_pdfs.rb
64
65
  - lib/rghost/newpath.rb
65
66
  - lib/rghost/paper.rb
66
67
  - lib/rghost/parse_text.rb
@@ -157,19 +158,16 @@ require_paths:
157
158
  - lib
158
159
  required_ruby_version: !ruby/object:Gem::Requirement
159
160
  requirements:
160
- - - ! '>='
161
+ - - ">="
161
162
  - !ruby/object:Gem::Version
162
163
  version: '0'
163
164
  required_rubygems_version: !ruby/object:Gem::Requirement
164
165
  requirements:
165
- - - ! '>='
166
+ - - ">="
166
167
  - !ruby/object:Gem::Version
167
168
  version: '0'
168
169
  requirements: []
169
- rubyforge_project: Ruby Ghostscript Engine is a document creation and conversion API,
170
- support(PDF,PS,GIF,TIF,PNG,JPG...). It uses the GhostScript framework for the format
171
- conversion, utilizes EPS templates and is optimized to work with larger documents.
172
- rubygems_version: 2.2.2
170
+ rubygems_version: 3.0.4
173
171
  signing_key:
174
172
  specification_version: 4
175
173
  summary: Ruby Ghostscript Engine is a document creation and conversion API, support(PDF,PS,GIF,TIF,PNG,JPG...).