rghost 0.8.3 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. data/lib/rghost.rb +0 -0
  2. data/lib/rghost/callback.rb +0 -0
  3. data/lib/rghost/color.rb +11 -4
  4. data/lib/rghost/constants.rb +0 -0
  5. data/lib/rghost/convert.rb +0 -0
  6. data/lib/rghost/cursor.rb +0 -0
  7. data/lib/rghost/document.rb +128 -22
  8. data/lib/rghost/document_callback_facade.rb +0 -0
  9. data/lib/rghost/dsc_entry.rb +0 -0
  10. data/lib/rghost/dynamic_document_callback.rb +0 -0
  11. data/lib/rghost/eps.rb +0 -0
  12. data/lib/rghost/font.rb +0 -0
  13. data/lib/rghost/font_map.rb +15 -1
  14. data/lib/rghost/frame.rb +0 -0
  15. data/lib/rghost/function.rb +5 -1
  16. data/lib/rghost/gif.rb +1 -1
  17. data/lib/rghost/graphic.rb +0 -0
  18. data/lib/rghost/grid/base_grid.rb +1 -1
  19. data/lib/rghost/grid/csv_grid.rb +2 -1
  20. data/lib/rghost/grid/dynamic_callback.rb +0 -0
  21. data/lib/rghost/grid/field_format.rb +0 -0
  22. data/lib/rghost/grid/grid.rb +0 -0
  23. data/lib/rghost/grid/header.rb +0 -0
  24. data/lib/rghost/grid/matrix.rb +0 -0
  25. data/lib/rghost/grid/rails_grid.rb +0 -0
  26. data/lib/rghost/grid/static_callback.rb +0 -0
  27. data/lib/rghost/grid/style/border_lines.rb +0 -0
  28. data/lib/rghost/grid/style/bottom_lines.rb +0 -0
  29. data/lib/rghost/grid/style/old_forms.rb +0 -0
  30. data/lib/rghost/grid/style/style.rb +0 -0
  31. data/lib/rghost/gs_alone.rb +8 -2
  32. data/lib/rghost/helpers.rb +0 -0
  33. data/lib/rghost/horizontal_line.rb +0 -0
  34. data/lib/rghost/image.rb +0 -0
  35. data/lib/rghost/jpeg.rb +1 -1
  36. data/lib/rghost/line.rb +0 -0
  37. data/lib/rghost/line_width.rb +0 -0
  38. data/lib/rghost/load.rb +2 -0
  39. data/lib/rghost/newpath.rb +0 -0
  40. data/lib/rghost/paper.rb +0 -0
  41. data/lib/rghost/pdf_security.rb +36 -0
  42. data/lib/rghost/point.rb +0 -0
  43. data/lib/rghost/point_with_command.rb +0 -0
  44. data/lib/rghost/ps/AdobeExpert.enc +0 -0
  45. data/lib/rghost/ps/AdobeLatinEncoding.enc +0 -0
  46. data/lib/rghost/ps/Bengali.enc +0 -0
  47. data/lib/rghost/ps/CodePage1250.enc +0 -0
  48. data/lib/rghost/ps/CodePage1251.enc +0 -0
  49. data/lib/rghost/ps/CodePage1252.enc +0 -0
  50. data/lib/rghost/ps/CodePage1253.enc +0 -0
  51. data/lib/rghost/ps/CodePage1254.enc +0 -0
  52. data/lib/rghost/ps/CodePage1256.enc +0 -0
  53. data/lib/rghost/ps/CodePage1257.enc +0 -0
  54. data/lib/rghost/ps/CodePage1258.enc +0 -0
  55. data/lib/rghost/ps/CodePage874.enc +0 -0
  56. data/lib/rghost/ps/IsoLatin.enc +0 -0
  57. data/lib/rghost/ps/MacCentralEuropean.enc +0 -0
  58. data/lib/rghost/ps/MacCyrillice.desnc +0 -0
  59. data/lib/rghost/ps/MacGreek.enc +0 -0
  60. data/lib/rghost/ps/MacHebrew.enc +0 -0
  61. data/lib/rghost/ps/TeX-CorkEncoding.enc +0 -0
  62. data/lib/rghost/ps/TeX-LGR-Greek.enc +0 -0
  63. data/lib/rghost/ps/TeX-T2AModified2Encoding.enc +0 -0
  64. data/lib/rghost/ps/TeX-T2BAdobeEncoding.enc +0 -0
  65. data/lib/rghost/ps/TeX-T2CAdobeEncoding.enc +0 -0
  66. data/lib/rghost/ps/TeX-X2AdobeEncoding.enc +0 -0
  67. data/lib/rghost/ps/TeX-XL2encoding.enc +0 -0
  68. data/lib/rghost/ps/TeXMathExtensionEncoding.enc +0 -0
  69. data/lib/rghost/ps/TeXMathItalicEncoding.enc +0 -0
  70. data/lib/rghost/ps/TeXMathSymbolEncoding.enc +0 -0
  71. data/lib/rghost/ps/US-ASCII.enc +0 -0
  72. data/lib/rghost/ps/UTF-8.enc +0 -0
  73. data/lib/rghost/ps/basic.ps +0 -0
  74. data/lib/rghost/ps/begin_document.ps +0 -0
  75. data/lib/rghost/ps/callbacks.ps +0 -0
  76. data/lib/rghost/ps/code128.font +0 -0
  77. data/lib/rghost/ps/code39.font +0 -0
  78. data/lib/rghost/ps/cursor.ps +0 -0
  79. data/lib/rghost/ps/datagrid.ps +0 -0
  80. data/lib/rghost/ps/developer.ps +0 -0
  81. data/lib/rghost/ps/ean.font +0 -0
  82. data/lib/rghost/ps/eps.ps +0 -0
  83. data/lib/rghost/ps/font.ps +0 -0
  84. data/lib/rghost/ps/frame.ps +0 -0
  85. data/lib/rghost/ps/gif.ps +0 -0
  86. data/lib/rghost/ps/horizontal_line.ps +0 -0
  87. data/lib/rghost/ps/i25.font +0 -0
  88. data/lib/rghost/ps/jpeg.ps +0 -0
  89. data/lib/rghost/ps/link.ps +22 -0
  90. data/lib/rghost/ps/paper.ps +0 -0
  91. data/lib/rghost/ps/rect_link.ps +17 -0
  92. data/lib/rghost/ps/rectangle.ps +0 -0
  93. data/lib/rghost/ps/rghost_default_template.eps +0 -0
  94. data/lib/rghost/ps/row.ps +0 -0
  95. data/lib/rghost/ps/show.ps +0 -0
  96. data/lib/rghost/ps/table_callbacks.ps +0 -0
  97. data/lib/rghost/ps/text.ps +0 -0
  98. data/lib/rghost/ps/textarea.ps +0 -0
  99. data/lib/rghost/ps/type.ps +0 -0
  100. data/lib/rghost/ps/unit.ps +0 -0
  101. data/lib/rghost/ps/vertical_line.ps +0 -0
  102. data/lib/rghost/ps_facade.rb +22 -4
  103. data/lib/rghost/ps_object.rb +0 -0
  104. data/lib/rghost/rectangle_link.rb +65 -0
  105. data/lib/rghost/rgengine.so +0 -0
  106. data/lib/rghost/ruby_ghost_config.rb +7 -4
  107. data/lib/rghost/ruby_ghost_engine.rb +3 -1
  108. data/lib/rghost/ruby_ghost_version.rb +2 -2
  109. data/lib/rghost/ruby_to_ps.rb +0 -0
  110. data/lib/rghost/scale.rb +0 -0
  111. data/lib/rghost/show.rb +0 -0
  112. data/lib/rghost/static_document_callback.rb +0 -0
  113. data/lib/rghost/text.rb +0 -0
  114. data/lib/rghost/text_in.rb +1 -1
  115. data/lib/rghost/text_link_in.rb +42 -0
  116. data/lib/rghost/textarea.rb +0 -0
  117. data/lib/rghost/units.rb +0 -0
  118. data/lib/rghost/variable.rb +0 -0
  119. data/lib/rghost/vertical_line.rb +0 -0
  120. metadata +140 -142
data/lib/rghost/line.rb CHANGED
File without changes
File without changes
data/lib/rghost/load.rb CHANGED
@@ -26,6 +26,8 @@ module RGhost::Load
26
26
  raw RGhost::Load.library(:datagrid)
27
27
  raw RGhost::Load.library(:text)
28
28
  raw RGhost::Load.library(:frame)
29
+ raw RGhost::Load.library(:link)
30
+ raw RGhost::Load.library(:rect_link)
29
31
 
30
32
  end
31
33
  end
File without changes
data/lib/rghost/paper.rb CHANGED
File without changes
@@ -0,0 +1,36 @@
1
+
2
+ class RGhost::PdfSecurity
3
+ PERMISSION_VALUES={
4
+ :base => -4,
5
+ :print => -4,
6
+ :modify => -8,
7
+ :copy => -16,
8
+ :annotate => -32,
9
+ :interactive => -256,
10
+ :copy_access => -512,
11
+ :assemble => -1024,
12
+ :high_quality_print => -2048,
13
+ :all => -3904
14
+
15
+ }
16
+ attr_accessor :owner_password,:user_password,:key_length
17
+ def initialize
18
+ @permission_value=PERMISSION_VALUES[:all]
19
+ @key_lenght=128
20
+ @owner_password="unknow"
21
+ @user_password="unknow"
22
+ end
23
+ def disable(*permissions)
24
+ @permission_value=permissions.map{|p| PERMISSION_VALUES[p] }.inject(0){|n,i| i+=n}
25
+ end
26
+ def gs_params
27
+ "-sOwnerPassword##{clear_space(@owner_password)} -sUserPassword##{clear_space(@user_password)} -dEncryptionR#3 -dKeyLength##{@key_lenght} -dPermissions##{@permission_value}"
28
+ end
29
+ private
30
+
31
+ def clear_space(value)
32
+ value.to_s.gsub(/([^\w])/,'')
33
+ end
34
+ end
35
+
36
+
data/lib/rghost/point.rb CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/lib/rghost/ps/eps.ps CHANGED
File without changes
File without changes
File without changes
data/lib/rghost/ps/gif.ps CHANGED
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,22 @@
1
+ /:fh{ currentfont /FontMatrix get 3 get 1000 mul } def
2
+ /:link_str () def
3
+ /:link_uri () def
4
+ /:link_rect 4 array def
5
+
6
+ /:link_make{
7
+ :link_rect 0 X put
8
+ :link_rect 1 Y put
9
+ :link_rect 2 :link_str stringwidth pop X add put
10
+ :link_rect 3 :fh Y add put
11
+ :link_rect
12
+
13
+ [ /Rect :link_rect
14
+ /Action /Launch
15
+ /Border [0 0 0]
16
+ /Color [0 0 0]
17
+ /URI :link_uri
18
+ /Subtype /Link
19
+ /ANN pdfmark
20
+ :link_str show
21
+
22
+ } def
File without changes
@@ -0,0 +1,17 @@
1
+ /:rect_x 0 def
2
+ /:rect_y 0 def
3
+ /:rect_w 0 def
4
+ /:rect_h 0 def
5
+ /:rect_uri (http://rghost.rubyforge.org) def
6
+
7
+ /:rect_link{
8
+ :rect_x :rect_y moveto
9
+ [ /Rect [:rect_x :rect_y :rect_w X add :rect_h Y add]
10
+ /Action /Launch
11
+ /Border [0 0 1]
12
+ /Color :rect_color
13
+ /URI :rect_uri
14
+ /Subtype /Link
15
+ /ANN pdfmark
16
+
17
+ } def
File without changes
File without changes
data/lib/rghost/ps/row.ps CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -20,6 +20,7 @@ require "eps"
20
20
  require "jpeg"
21
21
  require "gif"
22
22
  require "text_in"
23
+ require "text_link_in"
23
24
  require "ruby_ghost_engine"
24
25
  require "convert"
25
26
  require "text"
@@ -33,7 +34,7 @@ require "frame"
33
34
  require "polygon"
34
35
  require "circle"
35
36
  require "how_to"
36
-
37
+ require 'rectangle_link'
37
38
 
38
39
 
39
40
  #PsFacade is just a big facade involving an instance of most postscript objects.
@@ -161,6 +162,12 @@ class RGhost::PsFacade < RGhost::PsObject
161
162
  set RGhost::TextIn.new(options)
162
163
  end
163
164
 
165
+ #A facade for the class TextLinkIn
166
+ def text_link(label,options={})
167
+ options[:label]=label
168
+ set RGhost::TextLinkIn.new(options)
169
+ end
170
+
164
171
  #A facade for the class Text
165
172
  def text(text,tag_parse=true)
166
173
  set RGhost::Text.new(text.to_s,tag_parse)
@@ -184,6 +191,11 @@ class RGhost::PsFacade < RGhost::PsObject
184
191
  call "_#{name}"
185
192
  end
186
193
 
194
+ #Call internal function by name
195
+ def use_function(name)
196
+ call "_#{name}"
197
+ end
198
+
187
199
  #A facade for the class TextArea
188
200
  def text_area(text,options={},tag_parse=true)
189
201
  ta=RGhost::TextArea.new(text,options,tag_parse)
@@ -228,12 +240,12 @@ class RGhost::PsFacade < RGhost::PsObject
228
240
  end
229
241
 
230
242
  #A facade for the class Border
231
- def border(options)
243
+ def border(options={})
232
244
  set RGhost::Border.new(options)
233
245
  end
234
246
 
235
247
  #A facade for the class ShapeContent
236
- def shape_content(options)
248
+ def shape_content(options={})
237
249
  set RGhost::ShapeContent.new(options)
238
250
  end
239
251
 
@@ -247,9 +259,15 @@ class RGhost::PsFacade < RGhost::PsObject
247
259
  end
248
260
 
249
261
  #A facade for the class Circle
250
- def circle(options)
262
+ def circle(option={})
251
263
  set RGhost::Circle.new(options)
252
264
  end
265
+
266
+ #A facade for the class RectangleLink
267
+ def rectangle_link(options={})
268
+ set RGhost::RectangleLink.new(options)
269
+ end
270
+
253
271
 
254
272
  end
255
273
 
File without changes
@@ -0,0 +1,65 @@
1
+ #Creates one rectangle or one shape with rounded corners.
2
+ #===Options
3
+ #
4
+ #* <tt>:x and :y</tt> - Coordinates to position.
5
+ #* <tt>:corners</tt> - Value for rounded corners. Use 0 to straight angle.
6
+ #* <tt>:width and :height</tt> - Size of frame
7
+ #* <tt>:content</tt> - facade to ShapeContent with same parameters.
8
+ #* <tt>:border</tt> - facade to Border with same parameters.
9
+ #===Examples using facade frame method inside of Document
10
+ # d=Document.new
11
+ # d.frame :x => 3, :width => 7, :height => 5, :content => {:fill => false}
12
+ #
13
+ #link:images/frame01.png
14
+ # d=Document.new
15
+ # d.frame :x => 3, :width => 7, :height => 5, :content => {:color => '#35F6A3' }
16
+ #
17
+ #link:images/frame02.png
18
+ #
19
+ # d=Document.new
20
+ # d.frame :x => 3, :width => 7, :height => 5, :content => {:color => '#35F6A3' }, :border =>{:width => 5, :dash => [1,3,10]}
21
+ #
22
+ #link:images/frame03.png
23
+ #
24
+ # d=Document.new
25
+ # d.frame :x => 3, :width => 7, :height => 5, :content => {:color => '#35F6A3' }, :corners => 20
26
+ #
27
+ #link:images/frame04.png
28
+ #
29
+ # d=Document.new
30
+ # d.frame :x => 3, :width => 7, :height => 5, :content => {:color => :yellow }, :border => {:color => :red, :width => 4}, :corners => 20
31
+ #
32
+ #link:images/frame05.png
33
+ class RGhost::RectangleLink < RGhost::PsObject
34
+ include RGhost::RubyToPs
35
+ DEFAULT_OPTIONS={
36
+ :x => :limit_left,
37
+ :y => :current_row,
38
+ :width => 5,
39
+ :height => 3.5,
40
+ :url => "http://rghost.rubyforge.org",
41
+ :border_color => RGhost::Border::DEFAULT_OPTIONS[:color]
42
+
43
+
44
+ }
45
+ def initialize(options={})
46
+
47
+ @options = DEFAULT_OPTIONS.dup.merge(options)
48
+
49
+ end
50
+
51
+
52
+ def ps
53
+ x=RGhost::Units::parse(@options[:x])
54
+ y=RGhost::Units::parse(@options[:y])
55
+
56
+ h=RGhost::Units::parse(@options[:height])
57
+ w=RGhost::Units::parse(@options[:width])
58
+ url=@options[:url]
59
+ scolor=RGhost::Color.create(@options[:border_color]).ps.gsub(/setrgbcolor/,'')
60
+ "/:rect_color [#{scolor}] def /:rect_x #{x} def /:rect_y #{y} def /:rect_w #{w} def /:rect_h #{h} def /:rect_uri #{to_string(url)} def :rect_link"
61
+
62
+
63
+ end
64
+
65
+ end
File without changes
@@ -56,7 +56,7 @@ module RGhost::Config
56
56
  GS={
57
57
  :mode => :gsparams,
58
58
  :plugin => nil,
59
- :path => "/usr/bin/gs",
59
+ :path => nil,
60
60
  :tmpdir => ENV["TMP"] || ENV["TMPDIR"] || ENV["TEMPDIR"] || ENV["TEMP"] || "/tmp",
61
61
  :pslibdir => File.join( File.dirname(__FILE__),"ps"),
62
62
  :extensions => [],
@@ -77,9 +77,12 @@ module RGhost::Config
77
77
  def self.config_platform #:nodoc:
78
78
 
79
79
  GS[:path]=case PLATFORM
80
- when /linux|darwin|freebsd/: "/usr/bin/gs"
81
- when /mswin/: "C:\\gs\\bin\\gswin32\\gswin32c.exe"
80
+ when /linux|darwin|freebsd/ then "/usr/bin/gs"
81
+ when /darwin|freebsd/ then "/opt/local/bin/gs"
82
+ when /mswin/ then "C:\\gs\\bin\\gswin32\\gswin32c.exe"
82
83
  end
84
+ not_found_msg="\nGhostscript not found in your environment.\nInstall it and set the variable RGhost::Config::GS[:path] with the executable.\nExample: RGhost::Config::GS[:path]='/path/to/my/gs' #unix-style\n RGhost::Config::GS[:path]=\"C:\\\\gs\\\\bin\\\\gswin32c.exe\" #windows-style\n"
85
+ raise not_found_msg unless (File.exists? GS[:path])
83
86
  end
84
87
  #Test if your environment is ready to works. If yes the page below will show.
85
88
  #
@@ -216,7 +219,7 @@ module RGhost::Config
216
219
  # new :pre, :name => "Courier"
217
220
  # end
218
221
  #
219
- FONTMAP=RGhost::FontMap.new :name => "Helvetica", :size => 8, :encoding => false do
222
+ FONTMAP=RGhost::FontMap.new :name => "Helvetica", :size => 8, :encoding => true do
220
223
  new :span
221
224
  new :b, :name => "Helvetica-Bold"
222
225
  new :bold, :name => "Helvetica-Bold"
@@ -35,7 +35,9 @@ class RGhost::Engine
35
35
  file_out.gsub!(/\./,"_%04d.") if multipage
36
36
 
37
37
  params=RGhost::Config::GS[:default_params].dup #default parameters gs engine
38
+ params << @document.additional_params.join(" ")
38
39
  params << "-I#{RGhost::Config::GS[:pslibdir]}"
40
+ params << "-dPDFSETTINGS=/#{@options[:quality]}" if (@options[:device] ==:pdf && @options[:quality])
39
41
  params << "-I#{RGhost::Config::GS[:extensions].join(' -I')}" if RGhost::Config::GS[:extensions]
40
42
  params << "-sDEVICE=#{device_for(device)}"
41
43
  params.concat format_params(@options[:d],"-d") if @options[:d]
@@ -81,7 +83,7 @@ class RGhost::Engine
81
83
  end
82
84
 
83
85
  if @error # if error
84
- @errors=File.open(file_err).readlines
86
+ @errors=File.open(file_err).readlines if File.exists?(file_err)
85
87
  else
86
88
  if multipage
87
89
  file_out.gsub!(/_%04d/,"_*")
@@ -1,8 +1,8 @@
1
1
  module RGhost::VERSION #:nodoc:
2
2
  MAJOR = 0
3
3
  MINOR = 8
4
- TINY = 3
5
- DATE=1211385093
4
+ TINY = 5
5
+ DATE=1221144147
6
6
  STRING = [MAJOR, MINOR, TINY].join('.')
7
7
 
8
8
  end