rghost-ruby1.9-beta 0.8.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rghost.rb +18 -0
- data/lib/rghost/border.rb +44 -0
- data/lib/rghost/callback.rb +58 -0
- data/lib/rghost/circle.rb +102 -0
- data/lib/rghost/color.rb +175 -0
- data/lib/rghost/constants.rb +626 -0
- data/lib/rghost/convert.rb +43 -0
- data/lib/rghost/cursor.rb +124 -0
- data/lib/rghost/dash.rb +59 -0
- data/lib/rghost/document.rb +546 -0
- data/lib/rghost/document_callback_facade.rb +64 -0
- data/lib/rghost/dsc_entry.rb +20 -0
- data/lib/rghost/dynamic_document_callback.rb +15 -0
- data/lib/rghost/eps.rb +31 -0
- data/lib/rghost/font.rb +48 -0
- data/lib/rghost/font_map.rb +54 -0
- data/lib/rghost/frame.rb +105 -0
- data/lib/rghost/function.rb +38 -0
- data/lib/rghost/gif.rb +41 -0
- data/lib/rghost/graphic.rb +26 -0
- data/lib/rghost/grid/base_grid.rb +228 -0
- data/lib/rghost/grid/callback_facade.rb +136 -0
- data/lib/rghost/grid/csv_grid.rb +51 -0
- data/lib/rghost/grid/dynamic_callback.rb +12 -0
- data/lib/rghost/grid/field_format.rb +43 -0
- data/lib/rghost/grid/grid.rb +15 -0
- data/lib/rghost/grid/header.rb +120 -0
- data/lib/rghost/grid/matrix.rb +10 -0
- data/lib/rghost/grid/rails_grid.rb +74 -0
- data/lib/rghost/grid/static_callback.rb +13 -0
- data/lib/rghost/grid/style/border_lines.rb +44 -0
- data/lib/rghost/grid/style/bottom_lines.rb +28 -0
- data/lib/rghost/grid/style/old_forms.rb +28 -0
- data/lib/rghost/grid/style/style.rb +8 -0
- data/lib/rghost/gs_alone.rb +25 -0
- data/lib/rghost/helpers.rb +13 -0
- data/lib/rghost/horizontal_line.rb +45 -0
- data/lib/rghost/how_to.rb +75 -0
- data/lib/rghost/image.rb +26 -0
- data/lib/rghost/jpeg.rb +39 -0
- data/lib/rghost/line.rb +89 -0
- data/lib/rghost/line_width.rb +28 -0
- data/lib/rghost/load.rb +43 -0
- data/lib/rghost/newpath.rb +19 -0
- data/lib/rghost/paper.rb +147 -0
- data/lib/rghost/parse_text.rb +53 -0
- data/lib/rghost/pdf_security.rb +36 -0
- data/lib/rghost/point.rb +23 -0
- data/lib/rghost/point_with_command.rb +17 -0
- data/lib/rghost/polygon.rb +75 -0
- data/lib/rghost/ps/AdobeExpert.enc +258 -0
- data/lib/rghost/ps/AdobeLatinEncoding.enc +258 -0
- data/lib/rghost/ps/Bengali.enc +386 -0
- data/lib/rghost/ps/CodePage1250.enc +258 -0
- data/lib/rghost/ps/CodePage1251.enc +258 -0
- data/lib/rghost/ps/CodePage1252.enc +258 -0
- data/lib/rghost/ps/CodePage1253.enc +258 -0
- data/lib/rghost/ps/CodePage1254.enc +258 -0
- data/lib/rghost/ps/CodePage1256.enc +258 -0
- data/lib/rghost/ps/CodePage1257.enc +258 -0
- data/lib/rghost/ps/CodePage1258.enc +258 -0
- data/lib/rghost/ps/CodePage874.enc +258 -0
- data/lib/rghost/ps/Fontmap +5 -0
- data/lib/rghost/ps/IsoLatin.enc +352 -0
- data/lib/rghost/ps/MacCentralEuropean.enc +258 -0
- data/lib/rghost/ps/MacCyrillice.desnc +258 -0
- data/lib/rghost/ps/MacGreek.enc +258 -0
- data/lib/rghost/ps/MacHebrew.enc +258 -0
- data/lib/rghost/ps/TeX-CorkEncoding.enc +258 -0
- data/lib/rghost/ps/TeX-LGR-Greek.enc +258 -0
- data/lib/rghost/ps/TeX-T2AModified2Encoding.enc +258 -0
- data/lib/rghost/ps/TeX-T2BAdobeEncoding.enc +258 -0
- data/lib/rghost/ps/TeX-T2CAdobeEncoding.enc +258 -0
- data/lib/rghost/ps/TeX-X2AdobeEncoding.enc +258 -0
- data/lib/rghost/ps/TeX-XL2encoding.enc +258 -0
- data/lib/rghost/ps/TeXMathExtensionEncoding.enc +258 -0
- data/lib/rghost/ps/TeXMathItalicEncoding.enc +258 -0
- data/lib/rghost/ps/TeXMathSymbolEncoding.enc +258 -0
- data/lib/rghost/ps/US-ASCII.enc +258 -0
- data/lib/rghost/ps/UTF-8.enc +3 -0
- data/lib/rghost/ps/_cusor.ps +46 -0
- data/lib/rghost/ps/basic.ps +25 -0
- data/lib/rghost/ps/begin_document.ps +8 -0
- data/lib/rghost/ps/callbacks.ps +175 -0
- data/lib/rghost/ps/code128.font +344 -0
- data/lib/rghost/ps/code39.font +195 -0
- data/lib/rghost/ps/cursor.ps +106 -0
- data/lib/rghost/ps/datagrid.ps +55 -0
- data/lib/rghost/ps/developer.ps +237 -0
- data/lib/rghost/ps/ean.font +150 -0
- data/lib/rghost/ps/eps.ps +42 -0
- data/lib/rghost/ps/font.ps +38 -0
- data/lib/rghost/ps/frame.ps +16 -0
- data/lib/rghost/ps/gif.ps +150 -0
- data/lib/rghost/ps/horizontal_line.ps +4 -0
- data/lib/rghost/ps/i25.font +103 -0
- data/lib/rghost/ps/jpeg.ps +122 -0
- data/lib/rghost/ps/link.ps +22 -0
- data/lib/rghost/ps/paper.ps +8 -0
- data/lib/rghost/ps/rect_link.ps +17 -0
- data/lib/rghost/ps/rectangle.ps +5 -0
- data/lib/rghost/ps/rghost_default_template.eps +1532 -0
- data/lib/rghost/ps/row.ps +4 -0
- data/lib/rghost/ps/show.ps +21 -0
- data/lib/rghost/ps/table_callbacks.ps +96 -0
- data/lib/rghost/ps/text.ps +63 -0
- data/lib/rghost/ps/textarea.ps +11 -0
- data/lib/rghost/ps/type.ps +1 -0
- data/lib/rghost/ps/unit.ps +3 -0
- data/lib/rghost/ps/vertical_line.ps +12 -0
- data/lib/rghost/ps/virtual_pages.ps +55 -0
- data/lib/rghost/ps_facade.rb +253 -0
- data/lib/rghost/ps_object.rb +55 -0
- data/lib/rghost/rectangle_link.rb +65 -0
- data/lib/rghost/rgengine.so +0 -0
- data/lib/rghost/ruby_ghost_config.rb +243 -0
- data/lib/rghost/ruby_ghost_engine.rb +156 -0
- data/lib/rghost/ruby_ghost_version.rb +8 -0
- data/lib/rghost/ruby_to_ps.rb +78 -0
- data/lib/rghost/scale.rb +29 -0
- data/lib/rghost/shape_content.rb +23 -0
- data/lib/rghost/show.rb +88 -0
- data/lib/rghost/static_document_callback.rb +18 -0
- data/lib/rghost/text.rb +44 -0
- data/lib/rghost/text_in.rb +51 -0
- data/lib/rghost/text_link_in.rb +42 -0
- data/lib/rghost/textarea.rb +88 -0
- data/lib/rghost/units.rb +82 -0
- data/lib/rghost/variable.rb +12 -0
- data/lib/rghost/vertical_line.rb +37 -0
- data/lib/rghost/virtual_pages.rb +42 -0
- metadata +185 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
module RGhost::Grid
|
2
|
+
require 'rghost/grid/header'
|
3
|
+
require 'rghost/grid/callback_facade'
|
4
|
+
require 'rghost/grid/style/style'
|
5
|
+
require 'rghost/grid/base_grid'
|
6
|
+
require 'rghost/grid/rails_grid'
|
7
|
+
require 'rghost/grid/matrix'
|
8
|
+
require 'rghost/grid/csv_grid'
|
9
|
+
require 'rghost/grid/dynamic_callback'
|
10
|
+
require 'rghost/grid/static_callback'
|
11
|
+
require 'rghost/grid/field_format'
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
|
@@ -0,0 +1,120 @@
|
|
1
|
+
$LOAD_PATH << File.dirname(__FILE__)+File::SEPARATOR+"../"
|
2
|
+
require "rghost/ps_object"
|
3
|
+
require "rghost/ruby_to_ps"
|
4
|
+
require "rghost/variable"
|
5
|
+
require "rghost/units"
|
6
|
+
require "rghost/function"
|
7
|
+
require "rghost/callback"
|
8
|
+
|
9
|
+
# Grid's Header.
|
10
|
+
# You can get a header instance using:
|
11
|
+
# grid=Grid::Rails.new
|
12
|
+
# grid.header
|
13
|
+
#
|
14
|
+
# You can also define callbacks:
|
15
|
+
#
|
16
|
+
# grid.header.before_column :only => [1,2] do
|
17
|
+
# use_tag :span
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
class RGhost::Grid::Header < RGhost::PsObject
|
21
|
+
include RGhost::RubyToPs
|
22
|
+
|
23
|
+
DEFAULT_OPTIONS={:width => 4, :align => :center, :title_align => nil, :header_width => nil, :format => :string}
|
24
|
+
attr_reader :data_types, :titles, :size
|
25
|
+
|
26
|
+
def initialize(headings=true,options={},&block) #:nodoc:
|
27
|
+
@header=RGhost::PsObject.new
|
28
|
+
@data_types=[]
|
29
|
+
@options=[]
|
30
|
+
@titles=[]
|
31
|
+
@header.set RGhost::Variable.new(:new_page?,true)
|
32
|
+
@default_options=DEFAULT_OPTIONS.merge(options)
|
33
|
+
@header.set RGhost::Variable.new(:headings?,headings)
|
34
|
+
@size=0
|
35
|
+
instance_eval(&block) if block
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def ps
|
40
|
+
|
41
|
+
p,h=format_header
|
42
|
+
@header.set RGhost::Variable.new(:header_titles,to_array(@titles))
|
43
|
+
@header.set RGhost::Variable.new(:table_params," [\n #{p}] \n")
|
44
|
+
@header.set RGhost::Variable.new(:table_header," [\n #{h}] \n")
|
45
|
+
|
46
|
+
|
47
|
+
@header
|
48
|
+
end
|
49
|
+
|
50
|
+
def col(name="", options={}) #:nodoc:
|
51
|
+
|
52
|
+
opts=@default_options.merge(options)
|
53
|
+
@size+=opts[:width]
|
54
|
+
@data_types << opts[:format]
|
55
|
+
@options << opts
|
56
|
+
@titles << ps_escape(name.to_s)
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
def default_options(opts) #:nodoc:
|
61
|
+
@default_options.merge!(opts)
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
def column(name,options={}) #:nodoc:
|
66
|
+
col(name,options)
|
67
|
+
end
|
68
|
+
|
69
|
+
def next_column(name,options={}) #:nodoc:
|
70
|
+
col(name,options)
|
71
|
+
end
|
72
|
+
|
73
|
+
def before_create(&block)
|
74
|
+
#@header.set RGhost::Function.new(:before_header_create, &block )
|
75
|
+
new_static_callback(:before_header_create,&block)
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
def after_create(&block)
|
80
|
+
#@header.set RGhost::Function.new(:after_header_create, &block )
|
81
|
+
new_static_callback(:after_header_create,&block)
|
82
|
+
end
|
83
|
+
|
84
|
+
def before_column(options={},&block)
|
85
|
+
@header.set RGhost::Callback.new(:before_column_header, options,&block)
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
def after_column(options={},&block)
|
90
|
+
@header.set RGhost::Callback.new(:after_column_header,options,&block)
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
def new_static_callback(name,&block)
|
96
|
+
|
97
|
+
callback_body= RGhost::PsFacade.new(&block)
|
98
|
+
@header.set RGhost::Function.new(name,callback_body)
|
99
|
+
end
|
100
|
+
def format_header
|
101
|
+
p='' #params
|
102
|
+
h='' #params_head
|
103
|
+
o=@options.dup
|
104
|
+
o.each do |v|
|
105
|
+
v[:title_align]||=v[:align]
|
106
|
+
v[:header_width]||=v[:width]
|
107
|
+
p << "[ #{RGhost::Units::parse(v[:width])} /st_#{v[:align]}]\n "
|
108
|
+
h << "[ #{RGhost::Units::parse(v[:header_width])} /st_#{v[:title_align]}]\n "
|
109
|
+
end
|
110
|
+
|
111
|
+
return p,h
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'rghost/ps_object'
|
2
|
+
#
|
3
|
+
# Grid::Rails mapps grid columns to ActiveRecord attributes. For
|
4
|
+
# example, let's take a Calls class to represent telephone calls.
|
5
|
+
#
|
6
|
+
# ===Example
|
7
|
+
# rails_grid=Grid::Rails.new(:align => :center, :width => 3)
|
8
|
+
#
|
9
|
+
# Mapping, first the attribute name then the already known optionsName
|
10
|
+
# rails_grid.column :mobile, :title => "Mobile", :align => :right
|
11
|
+
# rails_grid.column :duration, :title => "Duration",:width => 3
|
12
|
+
# rails_grid.column :start, :title => "Start", :format => :eurodate
|
13
|
+
# rails_grid.column :called, :title => "Number", :align => :right, :title_align => :center
|
14
|
+
# Load data
|
15
|
+
# calls = Call.find(:all, :limit => 5000)
|
16
|
+
# rails_grid.data(calls)
|
17
|
+
# ====Relationships
|
18
|
+
# You can also use attributes of associated objects, via a block or
|
19
|
+
# string. For example consider Accounts and Customers
|
20
|
+
# relationship. Let's produce a grid od all Customers plus some data
|
21
|
+
# reffering to the first account the customer had created.
|
22
|
+
#
|
23
|
+
# class Accounts < ActiveRecord::Base
|
24
|
+
# belongs_to :customer
|
25
|
+
# end
|
26
|
+
# class Customers < ActiveRecord::Base
|
27
|
+
# has_many :accounts
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# c = Customers.find(:all, :include => :accounts )
|
31
|
+
#
|
32
|
+
# Using a block
|
33
|
+
# g=Grid::Rails.new :width => 4
|
34
|
+
# g.column :id, :title => "Customer id"
|
35
|
+
# g.column :name, :title => "Name", :width => 6
|
36
|
+
# g.column :created_on, :title => "Date ", :format => lambda{|d| d.strftime("%m/%d/%Y") }
|
37
|
+
# g.column lambda { accounts.first.login }, :title => "Login"
|
38
|
+
# g.column lambda { accounts.first.type }, :title => "Account Type"
|
39
|
+
# g.data(c)
|
40
|
+
# Or a String
|
41
|
+
# g.column 'accounts.first.login', :title => Login"
|
42
|
+
class RGhost::Grid::Rails < RGhost::Grid::Base
|
43
|
+
#The parameter +_data+ is an Array of ActiveRecord::Base objects.
|
44
|
+
def data(_data)
|
45
|
+
_data.collect do |d|
|
46
|
+
line=@rails_cols.collect do |c|
|
47
|
+
case c[:field_name]
|
48
|
+
when Symbol
|
49
|
+
d[c[:field_name]]
|
50
|
+
when String
|
51
|
+
d.instance_eval c[:field_name]
|
52
|
+
when Proc
|
53
|
+
d.instance_eval(&c[:field_name])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
proc_line(line)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def col(field_name, options={}) #:nodoc:
|
61
|
+
super(options[:title],options)
|
62
|
+
|
63
|
+
@rails_cols||=[]
|
64
|
+
owf=options.dup #from options with field
|
65
|
+
owf[:field_name]||=field_name
|
66
|
+
@rails_cols << owf
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
def column(field_name, options={}) #:nodoc:
|
71
|
+
col(field_name,options)
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "rghost/ps_object"
|
2
|
+
require "rghost/function"
|
3
|
+
|
4
|
+
class RGhost::Grid::StaticCallback < RGhost::Function
|
5
|
+
ACCEPT=[:before_table_create, :after_table_create]
|
6
|
+
|
7
|
+
def initialize(name,&block)
|
8
|
+
raise NameError.new("#{name} no accept in #{self.class}") unless ACCEPT.include? name
|
9
|
+
super(name,&block)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class RGhost::Grid::Style::BorderLines
|
2
|
+
|
3
|
+
def set_style(grid)
|
4
|
+
|
5
|
+
grid.before_row do |b|
|
6
|
+
|
7
|
+
b.horizontal_line(:top, :size => grid.width)
|
8
|
+
b.horizontal_line(:bottom, :size => grid.width)
|
9
|
+
end
|
10
|
+
|
11
|
+
grid.before_column :only => 0 do |b|
|
12
|
+
b.vertical_line_row
|
13
|
+
end
|
14
|
+
|
15
|
+
grid.after_column do |c|
|
16
|
+
c.vertical_line_row
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
grid.header.before_create do |c|
|
21
|
+
c.line_width(0)
|
22
|
+
c.use_tag :bold
|
23
|
+
c.horizontal_line(:top, :size => grid.width)
|
24
|
+
c.horizontal_line(:bottom,:size => grid.width)
|
25
|
+
end
|
26
|
+
|
27
|
+
grid.header.after_create {|a| a.use_tag :normal }
|
28
|
+
|
29
|
+
|
30
|
+
grid.header.before_column :only => 0 do |h|
|
31
|
+
h.vertical_line_row
|
32
|
+
end
|
33
|
+
|
34
|
+
grid.header.after_column do |h|
|
35
|
+
h.vertical_line_row
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class RGhost::Grid::Style::BottomLines
|
2
|
+
|
3
|
+
def set_style(grid)
|
4
|
+
|
5
|
+
size=grid.header.size
|
6
|
+
grid.before_row do |b|
|
7
|
+
b.horizontal_line(:bottom,:size => grid.width)
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
grid.header.before_create do |h|
|
12
|
+
h.line_width(0)
|
13
|
+
h.horizontal_line(:bottom,:size => grid.width)
|
14
|
+
h.use_tag :bold
|
15
|
+
end
|
16
|
+
|
17
|
+
grid.header.after_create {|h| h.use_tag :normal }
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class RGhost::Grid::Style::OldForms
|
2
|
+
|
3
|
+
def set_style(grid)
|
4
|
+
|
5
|
+
size=grid.header.size
|
6
|
+
grid.odd_row do |o|
|
7
|
+
o.background_row(:size => size)
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
grid.header.before_create do |h|
|
12
|
+
h.line_width(0)
|
13
|
+
h.background_row(:size => size, :color => RGhost::ShapeContent::DEFAULT_OPTIONS[:color] )
|
14
|
+
h.use_tag :bold
|
15
|
+
end
|
16
|
+
|
17
|
+
grid.header.after_create {|h| h.use_tag :normal }
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class RGhost::GSAlone #:nodoc:
|
2
|
+
|
3
|
+
def initialize(params,debug=false)
|
4
|
+
@params=params.dup
|
5
|
+
@params[0]=" "
|
6
|
+
@debug=debug
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
cmd=@params.join(" ")
|
11
|
+
#puts File.exists?(RGhost::Config::GS[:path].to_s)
|
12
|
+
unless File.exists?(RGhost::Config::GS[:path].to_s)
|
13
|
+
RGhost::Config.config_platform
|
14
|
+
end
|
15
|
+
r=system(RGhost::Config::GS[:path]+cmd)
|
16
|
+
|
17
|
+
puts RGhost::Config::GS[:path]+cmd if @debug
|
18
|
+
#puts r
|
19
|
+
r
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "rghost/ps_object"
|
2
|
+
require "rghost/units"
|
3
|
+
#Creates horizontal line on the current row.
|
4
|
+
class RGhost::HorizontalLine < RGhost::PsObject
|
5
|
+
|
6
|
+
DEFAULT_OPTIONS={:start_in => :limit_left, :size => :area_x,
|
7
|
+
:border => RGhost::Border::DEFAULT_OPTIONS
|
8
|
+
|
9
|
+
}
|
10
|
+
|
11
|
+
#Examples
|
12
|
+
#
|
13
|
+
#Drawing line on middle
|
14
|
+
#
|
15
|
+
# doc.show "Foo Bar"
|
16
|
+
# doc.horizontal_line :middle
|
17
|
+
#
|
18
|
+
#link:images/horizontal_line01.png
|
19
|
+
#
|
20
|
+
#Drawing line on bottom and customizing border attributes
|
21
|
+
#
|
22
|
+
# doc.show "Foo Bar"
|
23
|
+
# doc.horizontal_line :bottom, :border => {:dash => [1,2,2,2], :color => :red}
|
24
|
+
#
|
25
|
+
#link:images/horizontal_line02.png
|
26
|
+
#
|
27
|
+
#Specifies size and where will start of line
|
28
|
+
#
|
29
|
+
# doc.show "Foo Bar"
|
30
|
+
# doc.horizontal_line :top, :start_in => 2, :size => 5, :border => {:dash => [1,2,2,2], :color => :red}
|
31
|
+
#
|
32
|
+
#link:images/horizontal_line03.png
|
33
|
+
|
34
|
+
|
35
|
+
def initialize(valign=:middle,options={})
|
36
|
+
@options=DEFAULT_OPTIONS.dup.merge(options)
|
37
|
+
start_in= RGhost::Units::parse(@options[:start_in])
|
38
|
+
size= RGhost::Units::parse(@options[:size])
|
39
|
+
border=RGhost::Border.new(@options[:border])
|
40
|
+
super("gsave #{border.ps } #{start_in} #{size} horizontal_line_#{valign} grestore")
|
41
|
+
#super("#{start_in} #{size} horizontal_line_#{valign}")
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#=Ruby Ghostscript engine - Document Builder
|
2
|
+
#==About
|
3
|
+
#RubyGhost (RGhost) is a library for document developers wanting a quick and easy
|
4
|
+
#way to generate pdf files. Notable features include: inserting images,
|
5
|
+
#vector drawing , font suppoort , EPS template support and multiple output formats.
|
6
|
+
#RGhost acts as Ruby a wrapper over the Ghostscript engine enriched by predefined
|
7
|
+
#set Postscript(ps) functions. For example:
|
8
|
+
#
|
9
|
+
#Ruby code you'll write:
|
10
|
+
#
|
11
|
+
# h=HorizontalLine.new :middle, :start_in => 3, :size => 2
|
12
|
+
#
|
13
|
+
#gets translated to the following Postscript function. Note how this is not actually
|
14
|
+
#raw Postscript, instead it makes use of a set of predefined functions shipped with Rghost.
|
15
|
+
#
|
16
|
+
# 3 unit 2 unit exch gsave current_row row_height sqrt add moveto 0 rlineto stroke grestore
|
17
|
+
#
|
18
|
+
#Unless embarking into deep Postscript wizardry you don't need to be aware of this fact.
|
19
|
+
#Basically RGhost is a helper for creating of Postscript documents.
|
20
|
+
#The resulting Postscript document is rendered to the target format (usually pdf but not just)
|
21
|
+
#by invoking Ghostscript the free Postscript interpreter. Ghostscript settings very
|
22
|
+
#a lot depending on your platform. Initially RGhost was developed for *nix environments
|
23
|
+
#where Ghostscript is (almost always) native and used as a printing filter (CUPS, LPRng etc)
|
24
|
+
#and also as a document format converter. So it became necessary to make an interface
|
25
|
+
#between Ruby and Ghostscript in two ways:
|
26
|
+
#
|
27
|
+
#* gsapi - based on the exchange of data between Ruby and Ghostscript via rgengine.so using gslib.so.8 or gslib-esp.so.8
|
28
|
+
#* gsparams - In this mode RGhost just pass parameters to the Ghostscript framework.1.1 Files
|
29
|
+
#
|
30
|
+
#During the conversion of the postscript code to the desired format 4 files are created, 3 of them being temporary.
|
31
|
+
#
|
32
|
+
#====Input
|
33
|
+
#The input file is a pure postscript file with a .rgin extension that will be automatically removed after the conversion process, even if errors show up.
|
34
|
+
#
|
35
|
+
#====Errors
|
36
|
+
#Using a .rgerr extension, its content are the errors generated by ghostscript. It'll be deleted after the conversion. The content of the file is available on the errors variable of the RubyGhostEngine class.
|
37
|
+
#
|
38
|
+
#====Log
|
39
|
+
#The log file is set using the option :logfile of the RubyGhostEngine class, appending all logs to it. Disabled by default.
|
40
|
+
#
|
41
|
+
#====Output
|
42
|
+
#The output files will have the extension passed to the RGhost::Document#render method. For multi page formats it will return an array of files. These files aren't deleted automatically, meaning that the developer will have to deal with them.
|
43
|
+
#====Author
|
44
|
+
#Shairon Toledo shairon.toledo(at)gmail.com http://www.hashcode.eti.br Brazil Jun/2008
|
45
|
+
#====Thanks
|
46
|
+
#Dee Zsombor[http://deezsombor.com] and Mereghost
|
47
|
+
#
|
48
|
+
#==Installation and Setup
|
49
|
+
#====Ghostscript
|
50
|
+
#You need to have ESP Ghostscript 8.xx or GNU Ghostscript 8.xx installed
|
51
|
+
#
|
52
|
+
#=====Non-coupled installation: *gsparams* (recommended)
|
53
|
+
#This is the simplest setup, you'll have to dowload and install the Ghostscript framework(http://www.cs.wisc.edu/~ghost/).
|
54
|
+
#Rhgost will invoke the ghostscript interpreter in the background to generate the desired output.
|
55
|
+
#
|
56
|
+
#===== Coupled installation: *gslib* (Linux only)
|
57
|
+
#You can use the native ghostrcipt interface via the gs-esp and libgs-esp8 (libgs-esp.so) packages. This may be already set up for you on Linux or you'll have to compile ghostscript
|
58
|
+
#=====Installation via remote gem
|
59
|
+
# gem install rghost
|
60
|
+
#
|
61
|
+
#=====Rails plugin installation
|
62
|
+
#Gets last version in RubyForge[http://rubyforge.org/frs/?group_id=3796&release_id=18301] unpack on RAILS_ROOT/lib
|
63
|
+
#====Setup
|
64
|
+
#Look at RGhost::Config
|
65
|
+
#==Namespace
|
66
|
+
#You can work either full namespace of including RGhost module.
|
67
|
+
#=====Full namespace
|
68
|
+
# doc=RGhost::Document.new
|
69
|
+
#=====Including module RGhost
|
70
|
+
# include RGhost
|
71
|
+
# doc=Document.new
|
72
|
+
|
73
|
+
class RGhost::HowTo
|
74
|
+
|
75
|
+
end
|