rghost-ruby1.9-beta 0.8.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. data/lib/rghost.rb +18 -0
  2. data/lib/rghost/border.rb +44 -0
  3. data/lib/rghost/callback.rb +58 -0
  4. data/lib/rghost/circle.rb +102 -0
  5. data/lib/rghost/color.rb +175 -0
  6. data/lib/rghost/constants.rb +626 -0
  7. data/lib/rghost/convert.rb +43 -0
  8. data/lib/rghost/cursor.rb +124 -0
  9. data/lib/rghost/dash.rb +59 -0
  10. data/lib/rghost/document.rb +546 -0
  11. data/lib/rghost/document_callback_facade.rb +64 -0
  12. data/lib/rghost/dsc_entry.rb +20 -0
  13. data/lib/rghost/dynamic_document_callback.rb +15 -0
  14. data/lib/rghost/eps.rb +31 -0
  15. data/lib/rghost/font.rb +48 -0
  16. data/lib/rghost/font_map.rb +54 -0
  17. data/lib/rghost/frame.rb +105 -0
  18. data/lib/rghost/function.rb +38 -0
  19. data/lib/rghost/gif.rb +41 -0
  20. data/lib/rghost/graphic.rb +26 -0
  21. data/lib/rghost/grid/base_grid.rb +228 -0
  22. data/lib/rghost/grid/callback_facade.rb +136 -0
  23. data/lib/rghost/grid/csv_grid.rb +51 -0
  24. data/lib/rghost/grid/dynamic_callback.rb +12 -0
  25. data/lib/rghost/grid/field_format.rb +43 -0
  26. data/lib/rghost/grid/grid.rb +15 -0
  27. data/lib/rghost/grid/header.rb +120 -0
  28. data/lib/rghost/grid/matrix.rb +10 -0
  29. data/lib/rghost/grid/rails_grid.rb +74 -0
  30. data/lib/rghost/grid/static_callback.rb +13 -0
  31. data/lib/rghost/grid/style/border_lines.rb +44 -0
  32. data/lib/rghost/grid/style/bottom_lines.rb +28 -0
  33. data/lib/rghost/grid/style/old_forms.rb +28 -0
  34. data/lib/rghost/grid/style/style.rb +8 -0
  35. data/lib/rghost/gs_alone.rb +25 -0
  36. data/lib/rghost/helpers.rb +13 -0
  37. data/lib/rghost/horizontal_line.rb +45 -0
  38. data/lib/rghost/how_to.rb +75 -0
  39. data/lib/rghost/image.rb +26 -0
  40. data/lib/rghost/jpeg.rb +39 -0
  41. data/lib/rghost/line.rb +89 -0
  42. data/lib/rghost/line_width.rb +28 -0
  43. data/lib/rghost/load.rb +43 -0
  44. data/lib/rghost/newpath.rb +19 -0
  45. data/lib/rghost/paper.rb +147 -0
  46. data/lib/rghost/parse_text.rb +53 -0
  47. data/lib/rghost/pdf_security.rb +36 -0
  48. data/lib/rghost/point.rb +23 -0
  49. data/lib/rghost/point_with_command.rb +17 -0
  50. data/lib/rghost/polygon.rb +75 -0
  51. data/lib/rghost/ps/AdobeExpert.enc +258 -0
  52. data/lib/rghost/ps/AdobeLatinEncoding.enc +258 -0
  53. data/lib/rghost/ps/Bengali.enc +386 -0
  54. data/lib/rghost/ps/CodePage1250.enc +258 -0
  55. data/lib/rghost/ps/CodePage1251.enc +258 -0
  56. data/lib/rghost/ps/CodePage1252.enc +258 -0
  57. data/lib/rghost/ps/CodePage1253.enc +258 -0
  58. data/lib/rghost/ps/CodePage1254.enc +258 -0
  59. data/lib/rghost/ps/CodePage1256.enc +258 -0
  60. data/lib/rghost/ps/CodePage1257.enc +258 -0
  61. data/lib/rghost/ps/CodePage1258.enc +258 -0
  62. data/lib/rghost/ps/CodePage874.enc +258 -0
  63. data/lib/rghost/ps/Fontmap +5 -0
  64. data/lib/rghost/ps/IsoLatin.enc +352 -0
  65. data/lib/rghost/ps/MacCentralEuropean.enc +258 -0
  66. data/lib/rghost/ps/MacCyrillice.desnc +258 -0
  67. data/lib/rghost/ps/MacGreek.enc +258 -0
  68. data/lib/rghost/ps/MacHebrew.enc +258 -0
  69. data/lib/rghost/ps/TeX-CorkEncoding.enc +258 -0
  70. data/lib/rghost/ps/TeX-LGR-Greek.enc +258 -0
  71. data/lib/rghost/ps/TeX-T2AModified2Encoding.enc +258 -0
  72. data/lib/rghost/ps/TeX-T2BAdobeEncoding.enc +258 -0
  73. data/lib/rghost/ps/TeX-T2CAdobeEncoding.enc +258 -0
  74. data/lib/rghost/ps/TeX-X2AdobeEncoding.enc +258 -0
  75. data/lib/rghost/ps/TeX-XL2encoding.enc +258 -0
  76. data/lib/rghost/ps/TeXMathExtensionEncoding.enc +258 -0
  77. data/lib/rghost/ps/TeXMathItalicEncoding.enc +258 -0
  78. data/lib/rghost/ps/TeXMathSymbolEncoding.enc +258 -0
  79. data/lib/rghost/ps/US-ASCII.enc +258 -0
  80. data/lib/rghost/ps/UTF-8.enc +3 -0
  81. data/lib/rghost/ps/_cusor.ps +46 -0
  82. data/lib/rghost/ps/basic.ps +25 -0
  83. data/lib/rghost/ps/begin_document.ps +8 -0
  84. data/lib/rghost/ps/callbacks.ps +175 -0
  85. data/lib/rghost/ps/code128.font +344 -0
  86. data/lib/rghost/ps/code39.font +195 -0
  87. data/lib/rghost/ps/cursor.ps +106 -0
  88. data/lib/rghost/ps/datagrid.ps +55 -0
  89. data/lib/rghost/ps/developer.ps +237 -0
  90. data/lib/rghost/ps/ean.font +150 -0
  91. data/lib/rghost/ps/eps.ps +42 -0
  92. data/lib/rghost/ps/font.ps +38 -0
  93. data/lib/rghost/ps/frame.ps +16 -0
  94. data/lib/rghost/ps/gif.ps +150 -0
  95. data/lib/rghost/ps/horizontal_line.ps +4 -0
  96. data/lib/rghost/ps/i25.font +103 -0
  97. data/lib/rghost/ps/jpeg.ps +122 -0
  98. data/lib/rghost/ps/link.ps +22 -0
  99. data/lib/rghost/ps/paper.ps +8 -0
  100. data/lib/rghost/ps/rect_link.ps +17 -0
  101. data/lib/rghost/ps/rectangle.ps +5 -0
  102. data/lib/rghost/ps/rghost_default_template.eps +1532 -0
  103. data/lib/rghost/ps/row.ps +4 -0
  104. data/lib/rghost/ps/show.ps +21 -0
  105. data/lib/rghost/ps/table_callbacks.ps +96 -0
  106. data/lib/rghost/ps/text.ps +63 -0
  107. data/lib/rghost/ps/textarea.ps +11 -0
  108. data/lib/rghost/ps/type.ps +1 -0
  109. data/lib/rghost/ps/unit.ps +3 -0
  110. data/lib/rghost/ps/vertical_line.ps +12 -0
  111. data/lib/rghost/ps/virtual_pages.ps +55 -0
  112. data/lib/rghost/ps_facade.rb +253 -0
  113. data/lib/rghost/ps_object.rb +55 -0
  114. data/lib/rghost/rectangle_link.rb +65 -0
  115. data/lib/rghost/rgengine.so +0 -0
  116. data/lib/rghost/ruby_ghost_config.rb +243 -0
  117. data/lib/rghost/ruby_ghost_engine.rb +156 -0
  118. data/lib/rghost/ruby_ghost_version.rb +8 -0
  119. data/lib/rghost/ruby_to_ps.rb +78 -0
  120. data/lib/rghost/scale.rb +29 -0
  121. data/lib/rghost/shape_content.rb +23 -0
  122. data/lib/rghost/show.rb +88 -0
  123. data/lib/rghost/static_document_callback.rb +18 -0
  124. data/lib/rghost/text.rb +44 -0
  125. data/lib/rghost/text_in.rb +51 -0
  126. data/lib/rghost/text_link_in.rb +42 -0
  127. data/lib/rghost/textarea.rb +88 -0
  128. data/lib/rghost/units.rb +82 -0
  129. data/lib/rghost/variable.rb +12 -0
  130. data/lib/rghost/vertical_line.rb +37 -0
  131. data/lib/rghost/virtual_pages.rb +42 -0
  132. metadata +185 -0
@@ -0,0 +1,26 @@
1
+ require "rghost/ps_object"
2
+ #Super class of GIF and JPEG.
3
+ class RGhost::Image < RGhost::PsObject
4
+ DEFAULT_OPTIONS={:x=> :limit_left, :y=> 1, :zoom => 100, :rotate => 0}
5
+
6
+ def initialize(image_path,options={})
7
+ super("")
8
+ @options=DEFAULT_OPTIONS.dup.merge(options)
9
+ @file=image_path
10
+ end
11
+
12
+ #Facade method for load image by file extension. Uses Eps, Gif and Jpeg class. Accepts gif, jpeg, jpg and eps
13
+ def self.for(path,options={})
14
+
15
+ clazz=case path
16
+ when /gif$/i then RGhost::Gif
17
+ when /jpe?g$/i then RGhost::Jpeg
18
+ when /(eps|template)$/i then RGhost::Eps
19
+ else raise NameError.new("Unsupported format")
20
+ end
21
+
22
+ clazz.new(path,options)
23
+ end
24
+
25
+
26
+ end
@@ -0,0 +1,39 @@
1
+ require "rghost/ps_object"
2
+ require "rghost/graphic"
3
+ require "rghost/cursor"
4
+ require "rghost/variable"
5
+ require "rghost/image"
6
+ #Loads JPEG image from file
7
+ #===Examples
8
+ # doc=Document.new
9
+ # doc.set Jpeg.new "../public/images/button.jpg", :x => 10, :y => 3
10
+ #Using Image.for facade
11
+ # doc.set Image.for "../public/images/button.jpg", :x => 10, :y => 3
12
+ #Using PsFacade or Document
13
+ # doc.image "images/button.jpg", :x => 10, :y => 3
14
+ #Using Zoom of the 200 percent
15
+ # doc.image "images/button.jpg", :zoom => 200
16
+ #===Options
17
+ #
18
+ #* <tt>:x and :y</tt> - Coordinates to position.
19
+ #* <tt>:rotate</tt> - Angle to image rotation if there is one.
20
+ #* <tt>:zoom</tt> - Resize proportionally the image
21
+ class RGhost::Jpeg < RGhost::Image
22
+
23
+
24
+
25
+ def ps
26
+ #x=Units::parse( @options[:x] )
27
+ #y=Units::parse( @options[:y] )
28
+
29
+ g=RGhost::Graphic.new
30
+ g.set RGhost::Cursor.translate(@options)
31
+ #set Cursor.translate()
32
+ g.set RGhost::Cursor.rotate(@options[:rotate])
33
+ g.set RGhost::Variable.new(:zoom,@options[:zoom]/100.0)
34
+ g.set RGhost::PsObject.new("(#{@file}) viewJPEG")
35
+ g.ps
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,89 @@
1
+ require "rghost/ps_object"
2
+ require "rghost/point"
3
+
4
+ #Creates straight lines
5
+ class RGhost::Line < RGhost::PsObject
6
+ DEFAULT_POINT={:x => :limit_left , :y => :current_row}
7
+
8
+ #Draw line the one pont until another, the first point is creates by moveto and de last point using the method lineto.
9
+ #===Examples
10
+ # doc=Document.new
11
+ # doc.moveto :x => 2, :y => 3
12
+ # doc.lineto :x => 5, :y => 2
13
+ #
14
+ #link:images/line01.png
15
+ #
16
+ # doc=Document.new
17
+ # doc.moveto :x => 2, :y => 3
18
+ # doc.lineto :x => 4, :y => 4
19
+ #
20
+ #link:images/line02.png
21
+ #
22
+ # doc=Document.new
23
+ # doc.border :color => '#AAFA49', :width => 4
24
+ # doc.moveto :x => 2, :y => 3
25
+ # doc.lineto :x => 4, :y => 1
26
+ #
27
+ #link:images/line03.png
28
+ #
29
+ # doc=Document.new
30
+ # doc.border :color => '#49AAFA', :width => 1
31
+ # doc.moveto :x => 2, :y => 3
32
+ # doc.lineto :x => 4, :y => 1
33
+ # doc.moveto :x => 2, :y => 3
34
+ # doc.lineto :x => 2, :y => 1
35
+ #
36
+ #link:images/line04.png
37
+ #
38
+ #Using graphic state to close path shape
39
+ #
40
+ # doc=Document.new
41
+ # doc.graphic do
42
+ # doc.border :color => '#49AAFA', :width => 1
43
+ # doc.moveto :x => 2, :y => 3
44
+ # doc.lineto :x => 4, :y => 1
45
+ # doc.lineto :x => 2, :y => 1
46
+ # doc.shape_content :color => "#F0FFFF"
47
+ # doc.closepath
48
+ # end
49
+ #
50
+ #link:images/line05.png
51
+ def self.lineto(point={})
52
+
53
+ RGhost::Line.make_command(:lineto,point)
54
+
55
+ end
56
+ #(Relative lineto) Draw straingh line in the same manner as lineto, but from current point to distance for next :x and :y. That is, rlineto constructs a line from (x, y) to (x + dx, y + dy) and makes (x + dx, y + dy) the new current point.
57
+ #
58
+ #===Examples
59
+ # doc=Document.new
60
+ # doc.moveto :x => 2, :y => 1
61
+ # doc.rlineto :x => 3, :y => 2
62
+ #
63
+ #link:images/line06.png
64
+ #
65
+ # doc=Document.new
66
+ # doc.moveto :x => 2, :y => 1
67
+ # doc.rlineto :x => 3, :y => 2
68
+ # doc.rlineto :x => 0, :y => -2
69
+ #link:images/line07.png
70
+ def self.rlineto(point={})
71
+ line=RGhost::Line.make_command(:rlineto,point)
72
+
73
+ end
74
+
75
+
76
+ private
77
+ def self.make_command(command,point={})
78
+
79
+ p=DEFAULT_POINT.dup.merge(point)
80
+ p=RGhost::Point.new(p[:x],p[:y])
81
+ RGhost::PsObject.new "#{p.ps}#{command}"
82
+ end
83
+
84
+ end
85
+
86
+
87
+
88
+
89
+
@@ -0,0 +1,28 @@
1
+ require "rghost/ps_object"
2
+ #Sets the line width parameter in the graphics state.
3
+ class RGhost::LineWidth < RGhost::PsObject
4
+
5
+ #Examples
6
+ #The more tiny line
7
+ # doc=Document.new
8
+ # doc.line_width 0
9
+ #
10
+ #link:images/line_width01.png
11
+ #
12
+ # doc.line_width 1
13
+ #
14
+ #link:images/line_width02.png
15
+ #
16
+ # doc.line_width 2
17
+ #
18
+ #link:images/line_width03.png
19
+ #
20
+ def initialize(value=0.3)
21
+ @value=value
22
+ end
23
+
24
+ def ps
25
+ "#{@value} setlinewidth "
26
+ end
27
+
28
+ end
@@ -0,0 +1,43 @@
1
+ require "rghost/ps_object"
2
+ module RGhost::Load
3
+ #Loads library
4
+ def self.library(name, type=:ps)
5
+ #PsObject.new File.open(File.dirname(__FILE__)+File::SEPARATOR+type.to_s+File::SEPARATOR+name.to_s+"."+type.to_s).readlines.join("")
6
+
7
+ RGhost::PsObject.new("(#{name.to_s}.#{type}) runlibfile\n")
8
+
9
+ end
10
+
11
+ def self.rg_enviroment
12
+ RGhost::PsObject.new do
13
+ raw RGhost::Load.library(:basic)
14
+ raw RGhost::Load.library(:cursor)
15
+ raw RGhost::Load.library(:rectangle)
16
+ raw RGhost::Load.library(:font)
17
+ raw RGhost::Load.library(:textarea)
18
+ raw RGhost::Load.library(:horizontal_line)
19
+ raw RGhost::Load.library(:vertical_line)
20
+ raw RGhost::Load.library(:callbacks)
21
+ raw RGhost::Load.library(:show)
22
+ raw RGhost::Load.library(:eps)
23
+ raw RGhost::Load.library(:jpeg)
24
+ raw RGhost::Load.library(:gif)
25
+ raw RGhost::Load.library(:begin_document)
26
+ raw RGhost::Load.library(:datagrid)
27
+ raw RGhost::Load.library(:text)
28
+ raw RGhost::Load.library(:frame)
29
+ raw RGhost::Load.library(:link)
30
+ raw RGhost::Load.library(:rect_link)
31
+
32
+ end
33
+ end
34
+ #Loads binary library
35
+ def self.binary(path)
36
+ File.open(path).readlines.join
37
+
38
+ end
39
+
40
+
41
+
42
+ end
43
+
@@ -0,0 +1,19 @@
1
+ require "rghost/ps_object"
2
+ require "rghost/cursor"
3
+ require "rghost/point"
4
+ require "rghost/line_width"
5
+
6
+ #Initializes the current path to be empty, causing the current point to become undefined.
7
+ class RGhost::NewPath < RGhost::PsObject
8
+
9
+ def initialize(&block)
10
+ @body=RGhost::PsFacade.new(&block)
11
+
12
+ end
13
+
14
+ def ps
15
+ "newpath #{@body} closepath"
16
+ end
17
+
18
+
19
+ end
@@ -0,0 +1,147 @@
1
+ require "rghost/ps_object"
2
+ require "rghost/units"
3
+ require "rghost/load"
4
+ require "rghost/constants"
5
+ require "rghost/ruby_to_ps"
6
+ #Paper is the area where the Postscript elements/objects are drawn.
7
+ #The margin is the document's non-printable area (both by the cursors and by the page's internal controllers).
8
+ #The :area_x and :area_y are the printable section of the paper.
9
+ #It's used to configure definitions of paper. It automatically defined into Document by :paper parameter.
10
+ #
11
+ #link:images/paper01.png
12
+ #
13
+ class RGhost::Paper < RGhost::PsObject
14
+
15
+
16
+ DEFAULT_OPTIONS={ :landscape => false,
17
+ :margin_top => 1,
18
+ :margin_right => 1,
19
+ :margin_bottom => 1,
20
+ :margin_left => 1,
21
+ :duplex => false,
22
+ :tumble => false
23
+ }
24
+
25
+ include RGhost::RubyToPs
26
+ #===Examples
27
+ #
28
+ #====Create paper by name
29
+ # doc=Document.new :paper => :A4
30
+ #====Create paper by name in landscape
31
+ # doc=Document.new :paper => :A4 , :landscape => true
32
+ #====Create custom paper
33
+ # doc=Document.new :paper => [10,15]
34
+ #====Defining all margins
35
+ # doc=Document.new :paper => :A5, :margin => 0.5
36
+ #====Defining custom margins
37
+ # doc=Document.new :paper => :A5, :margin => [0.5, 1, 0.5, 2] #=>[top,right,bottom,left] clockwise
38
+ #====Defining particular margin
39
+ # doc=Document.new :paper => :A5, :margin_top => 1, :margin_left => 0.3
40
+ #====Defining two faces document to printer
41
+ # doc=Document.new :paper => :A5, :duplex => true
42
+ #===Parameters
43
+ #* paper - The paper parameter can be either a Symbol or a Array. If paper parameter is a Symbol its value will search in RGhost::Constants::Papers . If paper parameter is a Array(with two numeric elements) will be position [0] width and [1] height of page. Example:
44
+ # doc=Document.new :paper => :A3 #=> Build new A3 paper
45
+ # doc=Document.new :paper => [5,5] #=> Build new custom paper 5x5, using default unit defined in RGhost::Config::GS[:unit].
46
+ #
47
+ #====Configuration options:
48
+ #* <tt>:landscape</tt> - If set to true will invert width to height and height to width.
49
+ #* <tt>:margin</tt> - Specifies margins non-printable area. It can be one Numeric for all margins or Array [top,right,bottom,left] margins.
50
+ #* <tt>:duplex</tt> - Specifies two faces(for print)
51
+ #* <tt>:tumble</tt> - Specifies kind of duplex
52
+ #
53
+ #
54
+ def initialize(paper=:A4, options={})
55
+
56
+ @options=DEFAULT_OPTIONS.merge(options)
57
+ @paper=paper
58
+ end
59
+
60
+ def ps
61
+ d=format_duplex
62
+ p=format_paper[:rg]
63
+ m=format_margin
64
+
65
+ lib=RGhost::Load.library :paper
66
+
67
+ d<< p << m << lib.ps
68
+ end
69
+
70
+
71
+ def gs_paper #:nodoc:
72
+ fp=format_paper
73
+ p=fp[:gs]
74
+ #["-dDEVICEWIDTHPOINTS=#{p[0]}", "-dDEVICEHEIGHTPOINTS=#{p[1]}"]
75
+ if fp[:done]
76
+ ["-dDEVICEWIDTHPOINTS=#{p[0]}", "-dDEVICEHEIGHTPOINTS=#{p[1]}"]
77
+ else
78
+ ["-dDEVICEWIDTHPOINTS=#{to_pt(p[0])}", "-dDEVICEHEIGHTPOINTS=#{to_pt(p[1])}"]
79
+ end
80
+
81
+ end
82
+
83
+
84
+ private
85
+
86
+ def to_pt(value)
87
+
88
+
89
+ return case RGhost::Config::GS[:unit].new
90
+ when RGhost::Units::Cm then (value.to_f*72/2.545).to_i
91
+ when RGhost::Units::Inch then (value.to_f*72).to_i
92
+ else
93
+ value
94
+ end
95
+
96
+ end
97
+ def format_margin
98
+ #if @options[:margin]
99
+ # mt=mr=mb=ml=RGhost::Units::parse(@options[:margin])
100
+ #else
101
+ # mt=RGhost::Units::parse(@options[:margin_top])
102
+ # mr=RGhost::Units::parse(@options[:margin_right])
103
+ # mb=RGhost::Units::parse(@options[:margin_bottom])
104
+ # ml=RGhost::Units::parse(@options[:margin_left])
105
+ #end
106
+
107
+ case @options[:margin]
108
+ when Numeric then mt=mr=mb=ml=RGhost::Units::parse(@options[:margin])
109
+ when Array then
110
+ mt=RGhost::Units::parse(@options[:margin][0] || DEFAULT_OPTIONS[:margin_top] )
111
+ mr=RGhost::Units::parse(@options[:margin][1] || DEFAULT_OPTIONS[:margin_right])
112
+ mb=RGhost::Units::parse(@options[:margin][2] || DEFAULT_OPTIONS[:margin_bottom])
113
+ ml=RGhost::Units::parse(@options[:margin][3] || DEFAULT_OPTIONS[:margin_left] )
114
+ when Hash,NilClass
115
+ mt=RGhost::Units::parse(@options[:margin_top ] || DEFAULT_OPTIONS[:margin_top] )
116
+ mr=RGhost::Units::parse(@options[:margin_right ] || DEFAULT_OPTIONS[:margin_right])
117
+ mb=RGhost::Units::parse(@options[:margin_bottom] || DEFAULT_OPTIONS[:margin_bottom])
118
+ ml=RGhost::Units::parse(@options[:margin_left ] || DEFAULT_OPTIONS[:margin_left] )
119
+ end
120
+
121
+ "/margin 3 dict def margin begin /top #{mt} def /right #{mr} def /bottom #{mb} def /left #{ml} def end\n"
122
+ end
123
+
124
+ def format_paper
125
+
126
+ case @paper
127
+ when Symbol then
128
+
129
+ p=RGhost::Constants::Papers::STANDARD[@paper.to_s.downcase.to_sym]
130
+ p.reverse! if @options[:landscape]
131
+ {:rg => "/pagesize #{to_array( p ) } def\n", :gs => p, :done => true}
132
+ when Array then
133
+ @paper.reverse! if @options[:landscape]
134
+ {:rg => "/pagesize #{to_array( @paper.map{|v| to_pt(v) } ) } def\n", :gs => @paper, :done => false}
135
+ end
136
+
137
+
138
+ end
139
+
140
+
141
+ def format_duplex
142
+ "\n<< /Duplex #{@options[:duplex]} /Tumble #{@options[:tumble]} >> setpagedevice\n"
143
+ end
144
+
145
+ end
146
+
147
+ #puts Paper.new(:A4, :landscape => true, :duplex => true, :margin=> [2,3,4,5])
@@ -0,0 +1,53 @@
1
+
2
+ module RGhost::ParseText #:nodoc:
3
+
4
+ def text_to_ps
5
+
6
+ unless @tag_parse
7
+ case @options[:text_align]
8
+ when :center, :right then
9
+ @text.split(/\n/).map{|l| "#{to_string(l)} :text_proc_cr :nbw " }.to_s
10
+ jump_with=':nbw'
11
+ when :left,nil then
12
+ if self.class == RGhost::Text
13
+ return @text.split(/\n/).map{|l| " :text #{to_string(l)} :text_proc nrdp " }.to_s
14
+
15
+ else
16
+ @text.split(/\n/).map{|l| " :text_area #{to_string(l)} :text_proc_cr :nbw " }.to_s
17
+ jump_with='nrdp'
18
+ end
19
+ end
20
+ end
21
+
22
+
23
+
24
+ jump_with=':nbw' if self.class == RGhost::TextArea
25
+
26
+
27
+ ret=@text.split(/<br\/?>|\n/).map do |piece|
28
+ text_ok=""
29
+ piece.scan(/<([^>]+)>([^<]*.)<\/\1>|([^<>]+)/).each do |t|
30
+ t.compact!
31
+ if t && t.size == 1
32
+ text_ok << ta_entry(t.first.to_s)
33
+ else
34
+ text_ok << ta_entry(t[1],t.first)
35
+ end
36
+ end
37
+ text_ok
38
+ end
39
+
40
+ ret.join(" #{jump_with || 'nrdp' } ").gsub(/&lt/,'<').gsub(/&gt/,'>')
41
+ end
42
+
43
+ def ta_entry(e,tag="default_font")
44
+ if self.class == RGhost::Text and @options[:text_align] == :left
45
+ " :text _#{tag} #{to_string(e)} :text_proc "
46
+ elsif self.class == RGhost::TextArea and @options[:text_align] == :left
47
+ " :text_area _#{tag} #{to_string(e)} :text_proc "
48
+ else
49
+ " _#{tag} #{to_string(e)} :text_proc_cr "
50
+ end
51
+ end
52
+
53
+ end