rghost 0.7.4 → 0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rghost/border.rb +44 -0
- data/lib/rghost/callback.rb +25 -22
- data/lib/rghost/circle.rb +102 -0
- data/lib/rghost/color.rb +81 -56
- data/lib/rghost/constants.rb +599 -589
- data/lib/rghost/convert.rb +26 -7
- data/lib/rghost/cursor.rb +90 -58
- data/lib/rghost/dash.rb +59 -0
- data/lib/rghost/document.rb +334 -311
- data/lib/rghost/document_callback_facade.rb +64 -0
- data/lib/rghost/dsc_entry.rb +12 -12
- data/lib/rghost/dynamic_document_callback.rb +6 -18
- data/lib/rghost/eps.rb +17 -8
- data/lib/rghost/font.rb +19 -23
- data/lib/rghost/font_map.rb +40 -0
- data/lib/rghost/frame.rb +105 -0
- data/lib/rghost/function.rb +19 -21
- data/lib/rghost/gif.rb +22 -9
- data/lib/rghost/graphic.rb +3 -3
- data/lib/rghost/grid/base_grid.rb +218 -0
- data/lib/rghost/grid/callback_facade.rb +136 -0
- data/lib/rghost/grid/csv_grid.rb +50 -0
- data/lib/rghost/{data_grid → grid}/dynamic_callback.rb +2 -2
- 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 +70 -0
- data/lib/rghost/{data_grid → grid}/static_callback.rb +4 -4
- data/lib/rghost/grid/style/border_lines.rb +46 -0
- data/lib/rghost/grid/style/bottom_lines.rb +30 -0
- data/lib/rghost/grid/style/old_forms.rb +30 -0
- data/lib/rghost/grid/style/style.rb +8 -0
- data/lib/rghost/gs_alone.rb +7 -5
- data/lib/rghost/helpers.rb +4 -4
- data/lib/rghost/horizontal_line.rb +35 -19
- data/lib/rghost/how_to.rb +75 -0
- data/lib/rghost/image.rb +8 -8
- data/lib/rghost/jpeg.rb +21 -8
- data/lib/rghost/line.rb +66 -17
- data/lib/rghost/line_width.rb +19 -8
- data/lib/rghost/load.rb +24 -22
- data/lib/rghost/newpath.rb +8 -7
- data/lib/rghost/paper.rb +100 -41
- data/lib/rghost/parse_text.rb +53 -0
- data/lib/rghost/point.rb +9 -8
- data/lib/rghost/point_with_command.rb +5 -5
- data/lib/rghost/polygon.rb +75 -0
- data/lib/rghost/ps/AdobeExpert.enc +0 -0
- data/lib/rghost/ps/AdobeLatinEncoding.enc +0 -0
- data/lib/rghost/ps/Bengali.enc +0 -0
- data/lib/rghost/ps/CodePage1250.enc +0 -0
- data/lib/rghost/ps/CodePage1251.enc +0 -0
- data/lib/rghost/ps/CodePage1252.enc +0 -0
- data/lib/rghost/ps/CodePage1253.enc +0 -0
- data/lib/rghost/ps/CodePage1254.enc +0 -0
- data/lib/rghost/ps/CodePage1256.enc +0 -0
- data/lib/rghost/ps/CodePage1257.enc +0 -0
- data/lib/rghost/ps/CodePage1258.enc +0 -0
- data/lib/rghost/ps/CodePage874.enc +0 -0
- data/lib/rghost/ps/Fontmap +5 -0
- data/lib/rghost/ps/IsoLatin.enc +0 -0
- data/lib/rghost/ps/MacCentralEuropean.enc +0 -0
- data/lib/rghost/ps/{MacCyrillice.enc → MacCyrillice.desnc} +0 -0
- data/lib/rghost/ps/MacGreek.enc +0 -0
- data/lib/rghost/ps/MacHebrew.enc +0 -0
- data/lib/rghost/ps/TeX-CorkEncoding.enc +0 -0
- data/lib/rghost/ps/TeX-LGR-Greek.enc +0 -0
- data/lib/rghost/ps/TeX-T2AModified2Encoding.enc +0 -0
- data/lib/rghost/ps/TeX-T2BAdobeEncoding.enc +0 -0
- data/lib/rghost/ps/TeX-T2CAdobeEncoding.enc +0 -0
- data/lib/rghost/ps/TeX-X2AdobeEncoding.enc +0 -0
- data/lib/rghost/ps/TeX-XL2encoding.enc +0 -0
- data/lib/rghost/ps/TeXMathExtensionEncoding.enc +0 -0
- data/lib/rghost/ps/TeXMathItalicEncoding.enc +0 -0
- data/lib/rghost/ps/TeXMathSymbolEncoding.enc +0 -0
- data/lib/rghost/ps/US-ASCII.enc +0 -0
- data/lib/rghost/ps/UTF-8.enc +0 -0
- data/lib/rghost/ps/__datagrid.ps +52 -0
- data/lib/rghost/ps/_cusor.ps +46 -0
- data/lib/rghost/ps/basic.ps +12 -1
- data/lib/rghost/ps/begin_document.ps +1 -0
- data/lib/rghost/ps/callbacks.ps +32 -3
- data/lib/rghost/ps/code128.font +0 -0
- data/lib/rghost/ps/code39.font +0 -0
- data/lib/rghost/ps/cursor.ps +77 -13
- data/lib/rghost/ps/datagrid.ps +4 -1
- data/lib/rghost/ps/developer.ps +237 -0
- data/lib/rghost/ps/ean.font +0 -0
- data/lib/rghost/ps/eps.ps +0 -0
- data/lib/rghost/ps/font.ps +8 -1
- data/lib/rghost/ps/frame.ps +16 -0
- data/lib/rghost/ps/gif.ps +0 -0
- data/lib/rghost/ps/horizontal_line.ps +4 -3
- data/lib/rghost/ps/i25.font +0 -0
- data/lib/rghost/ps/jpeg.ps +0 -0
- data/lib/rghost/ps/paper.ps +0 -0
- data/lib/rghost/ps/rectangle.ps +0 -0
- data/lib/rghost/ps/rghost_default_template.eps +1532 -0
- data/lib/rghost/ps/row.ps +0 -0
- data/lib/rghost/ps/show.ps +2 -1
- data/lib/rghost/ps/table_callbacks.ps +0 -0
- data/lib/rghost/ps/text.ps +63 -0
- data/lib/rghost/ps/textarea.ps +1 -1
- data/lib/rghost/ps/type.ps +0 -0
- data/lib/rghost/ps/unit.ps +0 -0
- data/lib/rghost/ps/vertical_line.ps +2 -4
- data/lib/rghost/ps/virtual_pages.ps +55 -0
- data/lib/rghost/ps_facade.rb +256 -0
- data/lib/rghost/ps_object.rb +24 -20
- data/lib/rghost/rgengine.so +0 -0
- data/lib/rghost/ruby_ghost_config.rb +224 -16
- data/lib/rghost/ruby_ghost_engine.rb +32 -55
- data/lib/rghost/ruby_ghost_version.rb +8 -0
- data/lib/rghost/ruby_to_ps.rb +52 -78
- data/lib/rghost/scale.rb +22 -7
- data/lib/rghost/shape_content.rb +23 -0
- data/lib/rghost/show.rb +77 -20
- data/lib/rghost/static_document_callback.rb +3 -7
- data/lib/rghost/text.rb +44 -0
- data/lib/rghost/text_in.rb +36 -14
- data/lib/rghost/textarea.rb +66 -93
- data/lib/rghost/units.rb +45 -44
- data/lib/rghost/variable.rb +4 -4
- data/lib/rghost/vertical_line.rb +27 -19
- data/lib/rghost/virtual_pages.rb +42 -0
- data/lib/rghost.rb +16 -2
- metadata +153 -500
- data/lib/rghost/arc.rb +0 -39
- data/lib/rghost/barcode.rb +0 -40
- data/lib/rghost/data_grid/basic_grid.rb +0 -136
- data/lib/rghost/data_grid/csv_grid.rb +0 -27
- data/lib/rghost/data_grid/data_grid.rb +0 -14
- data/lib/rghost/data_grid/field_format.rb +0 -60
- data/lib/rghost/data_grid/grid.rb +0 -18
- data/lib/rghost/data_grid/header.rb +0 -111
- data/lib/rghost/data_grid/rails_grid.rb +0 -62
- data/lib/rghost/data_grid/style/border_lines.rb +0 -47
- data/lib/rghost/data_grid/style/bottom_lines.rb +0 -30
- data/lib/rghost/data_grid/style/old_forms.rb +0 -30
- data/lib/rghost/data_grid/style/style.rb +0 -8
- data/lib/rghost/doc/classes/Arc.html +0 -200
- data/lib/rghost/doc/classes/Arc.src/M000049.html +0 -18
- data/lib/rghost/doc/classes/Arc.src/M000050.html +0 -23
- data/lib/rghost/doc/classes/Barcode.html +0 -214
- data/lib/rghost/doc/classes/Barcode.src/M000001.html +0 -19
- data/lib/rghost/doc/classes/Barcode.src/M000002.html +0 -18
- data/lib/rghost/doc/classes/Barcode.src/M000003.html +0 -19
- data/lib/rghost/doc/classes/Barcode.src/M000004.html +0 -27
- data/lib/rghost/doc/classes/CMYK.html +0 -209
- data/lib/rghost/doc/classes/CMYK.src/M000047.html +0 -18
- data/lib/rghost/doc/classes/CMYK.src/M000048.html +0 -24
- data/lib/rghost/doc/classes/Callback.html +0 -220
- data/lib/rghost/doc/classes/Callback.src/M000071.html +0 -21
- data/lib/rghost/doc/classes/Callback.src/M000072.html +0 -26
- data/lib/rghost/doc/classes/Color.html +0 -175
- data/lib/rghost/doc/classes/Color.src/M000028.html +0 -33
- data/lib/rghost/doc/classes/Constants/Colors.html +0 -129
- data/lib/rghost/doc/classes/Constants/Devices.html +0 -163
- data/lib/rghost/doc/classes/Constants/Devices.src/M000168.html +0 -22
- data/lib/rghost/doc/classes/Constants/Fonts.html +0 -144
- data/lib/rghost/doc/classes/Constants/Papers.html +0 -124
- data/lib/rghost/doc/classes/Constants.html +0 -120
- data/lib/rghost/doc/classes/Convert.html +0 -189
- data/lib/rghost/doc/classes/Convert.src/M000067.html +0 -20
- data/lib/rghost/doc/classes/Convert.src/M000068.html +0 -24
- data/lib/rghost/doc/classes/Cursor.html +0 -330
- data/lib/rghost/doc/classes/Cursor.src/M000031.html +0 -21
- data/lib/rghost/doc/classes/Cursor.src/M000032.html +0 -21
- data/lib/rghost/doc/classes/Cursor.src/M000033.html +0 -20
- data/lib/rghost/doc/classes/Cursor.src/M000034.html +0 -18
- data/lib/rghost/doc/classes/Cursor.src/M000035.html +0 -18
- data/lib/rghost/doc/classes/Cursor.src/M000036.html +0 -19
- data/lib/rghost/doc/classes/Cursor.src/M000037.html +0 -22
- data/lib/rghost/doc/classes/Cursor.src/M000038.html +0 -18
- data/lib/rghost/doc/classes/Cursor.src/M000039.html +0 -18
- data/lib/rghost/doc/classes/DSCEntry.html +0 -173
- data/lib/rghost/doc/classes/DSCEntry.src/M000059.html +0 -19
- data/lib/rghost/doc/classes/DSCEntry.src/M000060.html +0 -19
- data/lib/rghost/doc/classes/DataGrid/BasicGrid.html +0 -343
- data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000140.html +0 -27
- data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000141.html +0 -26
- data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000142.html +0 -22
- data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000143.html +0 -19
- data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000144.html +0 -26
- data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000145.html +0 -34
- data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000146.html +0 -18
- data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000147.html +0 -37
- data/lib/rghost/doc/classes/DataGrid/BasicGrid.src/M000148.html +0 -26
- data/lib/rghost/doc/classes/DataGrid/CSVGrid.html +0 -152
- data/lib/rghost/doc/classes/DataGrid/CSVGrid.src/M000139.html +0 -32
- data/lib/rghost/doc/classes/DataGrid/DynamicCallback.html +0 -158
- data/lib/rghost/doc/classes/DataGrid/DynamicCallback.src/M000149.html +0 -19
- data/lib/rghost/doc/classes/DataGrid/FieldFormat/Custom.html +0 -176
- data/lib/rghost/doc/classes/DataGrid/FieldFormat/Custom.src/M000136.html +0 -18
- data/lib/rghost/doc/classes/DataGrid/FieldFormat/Custom.src/M000137.html +0 -18
- data/lib/rghost/doc/classes/DataGrid/FieldFormat/Custom.src/M000138.html +0 -18
- data/lib/rghost/doc/classes/DataGrid/FieldFormat.html +0 -216
- data/lib/rghost/doc/classes/DataGrid/FieldFormat.src/M000131.html +0 -19
- data/lib/rghost/doc/classes/DataGrid/FieldFormat.src/M000132.html +0 -18
- data/lib/rghost/doc/classes/DataGrid/FieldFormat.src/M000133.html +0 -23
- data/lib/rghost/doc/classes/DataGrid/FieldFormat.src/M000134.html +0 -18
- data/lib/rghost/doc/classes/DataGrid/FieldFormat.src/M000135.html +0 -22
- data/lib/rghost/doc/classes/DataGrid/Grid.html +0 -148
- data/lib/rghost/doc/classes/DataGrid/Grid.src/M000160.html +0 -19
- data/lib/rghost/doc/classes/DataGrid/Header.html +0 -367
- data/lib/rghost/doc/classes/DataGrid/Header.src/M000150.html +0 -26
- data/lib/rghost/doc/classes/DataGrid/Header.src/M000151.html +0 -25
- data/lib/rghost/doc/classes/DataGrid/Header.src/M000152.html +0 -24
- data/lib/rghost/doc/classes/DataGrid/Header.src/M000153.html +0 -19
- data/lib/rghost/doc/classes/DataGrid/Header.src/M000154.html +0 -18
- data/lib/rghost/doc/classes/DataGrid/Header.src/M000155.html +0 -18
- data/lib/rghost/doc/classes/DataGrid/Header.src/M000156.html +0 -18
- data/lib/rghost/doc/classes/DataGrid/Header.src/M000157.html +0 -18
- data/lib/rghost/doc/classes/DataGrid/Header.src/M000158.html +0 -19
- data/lib/rghost/doc/classes/DataGrid/Header.src/M000159.html +0 -19
- data/lib/rghost/doc/classes/DataGrid/RailsGrid.html +0 -234
- data/lib/rghost/doc/classes/DataGrid/RailsGrid.src/M000161.html +0 -27
- data/lib/rghost/doc/classes/DataGrid/RailsGrid.src/M000162.html +0 -23
- data/lib/rghost/doc/classes/DataGrid/RailsGrid.src/M000163.html +0 -18
- data/lib/rghost/doc/classes/DataGrid/StaticCallback.html +0 -158
- data/lib/rghost/doc/classes/DataGrid/StaticCallback.src/M000164.html +0 -19
- data/lib/rghost/doc/classes/DataGrid/Style/BorderLines.html +0 -137
- data/lib/rghost/doc/classes/DataGrid/Style/BorderLines.src/M000128.html +0 -55
- data/lib/rghost/doc/classes/DataGrid/Style/BottomLines.html +0 -137
- data/lib/rghost/doc/classes/DataGrid/Style/BottomLines.src/M000129.html +0 -38
- data/lib/rghost/doc/classes/DataGrid/Style/OldForms.html +0 -137
- data/lib/rghost/doc/classes/DataGrid/Style/OldForms.src/M000130.html +0 -38
- data/lib/rghost/doc/classes/DataGrid/Style.html +0 -113
- data/lib/rghost/doc/classes/DataGrid.html +0 -133
- data/lib/rghost/doc/classes/Document.html +0 -990
- data/lib/rghost/doc/classes/Document.src/M000075.html +0 -32
- data/lib/rghost/doc/classes/Document.src/M000076.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000077.html +0 -29
- data/lib/rghost/doc/classes/Document.src/M000078.html +0 -33
- data/lib/rghost/doc/classes/Document.src/M000079.html +0 -20
- data/lib/rghost/doc/classes/Document.src/M000080.html +0 -21
- data/lib/rghost/doc/classes/Document.src/M000081.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000082.html +0 -19
- data/lib/rghost/doc/classes/Document.src/M000083.html +0 -21
- data/lib/rghost/doc/classes/Document.src/M000084.html +0 -22
- data/lib/rghost/doc/classes/Document.src/M000085.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000086.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000087.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000088.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000089.html +0 -19
- data/lib/rghost/doc/classes/Document.src/M000090.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000091.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000092.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000093.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000094.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000095.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000096.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000097.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000098.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000099.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000100.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000101.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000102.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000103.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000104.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000105.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000106.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000107.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000108.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000109.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000110.html +0 -18
- data/lib/rghost/doc/classes/Document.src/M000111.html +0 -20
- data/lib/rghost/doc/classes/Document.src/M000112.html +0 -19
- data/lib/rghost/doc/classes/Document.src/M000113.html +0 -19
- data/lib/rghost/doc/classes/DynamicDocumentCallback.html +0 -175
- data/lib/rghost/doc/classes/DynamicDocumentCallback.src/M000022.html +0 -19
- data/lib/rghost/doc/classes/Eps.html +0 -168
- data/lib/rghost/doc/classes/Eps.src/M000063.html +0 -20
- data/lib/rghost/doc/classes/Eps.src/M000064.html +0 -20
- data/lib/rghost/doc/classes/Font.html +0 -205
- data/lib/rghost/doc/classes/Font.src/M000061.html +0 -22
- data/lib/rghost/doc/classes/Font.src/M000062.html +0 -37
- data/lib/rghost/doc/classes/Function.html +0 -196
- data/lib/rghost/doc/classes/Function.src/M000045.html +0 -27
- data/lib/rghost/doc/classes/Function.src/M000046.html +0 -20
- data/lib/rghost/doc/classes/GSAlone.html +0 -154
- data/lib/rghost/doc/classes/GSAlone.src/M000065.html +0 -19
- data/lib/rghost/doc/classes/GSAlone.src/M000066.html +0 -22
- data/lib/rghost/doc/classes/Gif.html +0 -148
- data/lib/rghost/doc/classes/Gif.src/M000040.html +0 -30
- data/lib/rghost/doc/classes/Graphic.html +0 -153
- data/lib/rghost/doc/classes/Graphic.src/M000014.html +0 -18
- data/lib/rghost/doc/classes/Gray.html +0 -181
- data/lib/rghost/doc/classes/Gray.src/M000026.html +0 -18
- data/lib/rghost/doc/classes/Gray.src/M000027.html +0 -19
- data/lib/rghost/doc/classes/Helpers/HashKeyMethod.html +0 -131
- data/lib/rghost/doc/classes/Helpers/HashKeyMethod.src/M000127.html +0 -18
- data/lib/rghost/doc/classes/Helpers/HashKeyMethodClass.html +0 -118
- data/lib/rghost/doc/classes/Helpers.html +0 -112
- data/lib/rghost/doc/classes/HorizontalLine.html +0 -186
- data/lib/rghost/doc/classes/HorizontalLine.src/M000023.html +0 -23
- data/lib/rghost/doc/classes/Image.html +0 -176
- data/lib/rghost/doc/classes/Image.src/M000042.html +0 -20
- data/lib/rghost/doc/classes/Image.src/M000043.html +0 -26
- data/lib/rghost/doc/classes/Jpeg.html +0 -148
- data/lib/rghost/doc/classes/Jpeg.src/M000013.html +0 -28
- data/lib/rghost/doc/classes/Line.html +0 -190
- data/lib/rghost/doc/classes/Line.src/M000069.html +0 -20
- data/lib/rghost/doc/classes/Line.src/M000070.html +0 -19
- data/lib/rghost/doc/classes/LineWidth.html +0 -172
- data/lib/rghost/doc/classes/LineWidth.src/M000005.html +0 -18
- data/lib/rghost/doc/classes/LineWidth.src/M000006.html +0 -18
- data/lib/rghost/doc/classes/Load.html +0 -161
- data/lib/rghost/doc/classes/Load.src/M000165.html +0 -21
- data/lib/rghost/doc/classes/Load.src/M000166.html +0 -34
- data/lib/rghost/doc/classes/Load.src/M000167.html +0 -19
- data/lib/rghost/doc/classes/NewPath.html +0 -153
- data/lib/rghost/doc/classes/NewPath.src/M000041.html +0 -18
- data/lib/rghost/doc/classes/Paper.html +0 -213
- data/lib/rghost/doc/classes/Paper.src/M000010.html +0 -20
- data/lib/rghost/doc/classes/Paper.src/M000011.html +0 -24
- data/lib/rghost/doc/classes/Paper.src/M000012.html +0 -20
- data/lib/rghost/doc/classes/Point.html +0 -180
- data/lib/rghost/doc/classes/Point.src/M000073.html +0 -20
- data/lib/rghost/doc/classes/Point.src/M000074.html +0 -18
- data/lib/rghost/doc/classes/PointWithCommand.html +0 -150
- data/lib/rghost/doc/classes/PointWithCommand.src/M000115.html +0 -22
- data/lib/rghost/doc/classes/PsObject.html +0 -269
- data/lib/rghost/doc/classes/PsObject.src/M000015.html +0 -25
- data/lib/rghost/doc/classes/PsObject.src/M000016.html +0 -18
- data/lib/rghost/doc/classes/PsObject.src/M000017.html +0 -18
- data/lib/rghost/doc/classes/PsObject.src/M000018.html +0 -18
- data/lib/rghost/doc/classes/PsObject.src/M000019.html +0 -21
- data/lib/rghost/doc/classes/PsObject.src/M000020.html +0 -19
- data/lib/rghost/doc/classes/PsObject.src/M000021.html +0 -18
- data/lib/rghost/doc/classes/RGB.html +0 -213
- data/lib/rghost/doc/classes/RGB.src/M000024.html +0 -21
- data/lib/rghost/doc/classes/RGB.src/M000025.html +0 -25
- data/lib/rghost/doc/classes/Rectangle.html +0 -226
- data/lib/rghost/doc/classes/Rectangle.src/M000056.html +0 -18
- data/lib/rghost/doc/classes/Rectangle.src/M000057.html +0 -24
- data/lib/rghost/doc/classes/Rectangle.src/M000058.html +0 -21
- data/lib/rghost/doc/classes/RubyGhostConfig.html +0 -144
- data/lib/rghost/doc/classes/RubyGhostConfig.src/M000118.html +0 -22
- data/lib/rghost/doc/classes/RubyGhostEngine.html +0 -261
- data/lib/rghost/doc/classes/RubyGhostEngine.src/M000007.html +0 -24
- data/lib/rghost/doc/classes/RubyGhostEngine.src/M000008.html +0 -96
- data/lib/rghost/doc/classes/RubyGhostEngine.src/M000009.html +0 -21
- data/lib/rghost/doc/classes/RubyToPs.html +0 -272
- data/lib/rghost/doc/classes/RubyToPs.src/M000119.html +0 -23
- data/lib/rghost/doc/classes/RubyToPs.src/M000120.html +0 -18
- data/lib/rghost/doc/classes/RubyToPs.src/M000121.html +0 -18
- data/lib/rghost/doc/classes/RubyToPs.src/M000122.html +0 -19
- data/lib/rghost/doc/classes/RubyToPs.src/M000123.html +0 -30
- data/lib/rghost/doc/classes/RubyToPs.src/M000124.html +0 -18
- data/lib/rghost/doc/classes/RubyToPs.src/M000125.html +0 -18
- data/lib/rghost/doc/classes/RubyToPs.src/M000126.html +0 -30
- data/lib/rghost/doc/classes/Scale.html +0 -153
- data/lib/rghost/doc/classes/Scale.src/M000114.html +0 -18
- data/lib/rghost/doc/classes/Show.html +0 -203
- data/lib/rghost/doc/classes/Show.src/M000052.html +0 -20
- data/lib/rghost/doc/classes/Show.src/M000053.html +0 -19
- data/lib/rghost/doc/classes/StaticDocumentCallback.html +0 -168
- data/lib/rghost/doc/classes/StaticDocumentCallback.src/M000051.html +0 -19
- data/lib/rghost/doc/classes/TextArea.html +0 -217
- data/lib/rghost/doc/classes/TextArea.src/M000029.html +0 -22
- data/lib/rghost/doc/classes/TextArea.src/M000030.html +0 -24
- data/lib/rghost/doc/classes/TextIn.html +0 -201
- data/lib/rghost/doc/classes/TextIn.src/M000054.html +0 -19
- data/lib/rghost/doc/classes/TextIn.src/M000055.html +0 -24
- data/lib/rghost/doc/classes/Units/Cm.html +0 -145
- data/lib/rghost/doc/classes/Units/Cm.src/M000175.html +0 -19
- data/lib/rghost/doc/classes/Units/Inch.html +0 -145
- data/lib/rghost/doc/classes/Units/Inch.src/M000174.html +0 -18
- data/lib/rghost/doc/classes/Units/PSUnit.html +0 -139
- data/lib/rghost/doc/classes/Units/PSUnit.src/M000170.html +0 -18
- data/lib/rghost/doc/classes/Units/Unit.html +0 -190
- data/lib/rghost/doc/classes/Units/Unit.src/M000171.html +0 -18
- data/lib/rghost/doc/classes/Units/Unit.src/M000172.html +0 -19
- data/lib/rghost/doc/classes/Units/Unit.src/M000173.html +0 -18
- data/lib/rghost/doc/classes/Units.html +0 -166
- data/lib/rghost/doc/classes/Units.src/M000169.html +0 -22
- data/lib/rghost/doc/classes/Variable.html +0 -152
- data/lib/rghost/doc/classes/Variable.src/M000044.html +0 -18
- data/lib/rghost/doc/classes/VerticalLine.html +0 -175
- data/lib/rghost/doc/classes/VerticalLine.src/M000116.html +0 -23
- data/lib/rghost/doc/classes/VerticalLine.src/M000117.html +0 -19
- data/lib/rghost/doc/created.rid +0 -1
- data/lib/rghost/doc/files/arc_rb.html +0 -109
- data/lib/rghost/doc/files/barcode_rb.html +0 -108
- data/lib/rghost/doc/files/callback_rb.html +0 -109
- data/lib/rghost/doc/files/color_rb.html +0 -110
- data/lib/rghost/doc/files/constants_rb.html +0 -108
- data/lib/rghost/doc/files/convert_rb.html +0 -107
- data/lib/rghost/doc/files/cursor_rb.html +0 -110
- data/lib/rghost/doc/files/data_grid/basic_grid_rb.html +0 -108
- data/lib/rghost/doc/files/data_grid/csv_grid_rb.html +0 -108
- data/lib/rghost/doc/files/data_grid/data_grid_rb.html +0 -116
- data/lib/rghost/doc/files/data_grid/dynamic_callback_rb.html +0 -108
- data/lib/rghost/doc/files/data_grid/field_format_rb.html +0 -109
- data/lib/rghost/doc/files/data_grid/grid_rb.html +0 -108
- data/lib/rghost/doc/files/data_grid/header_rb.html +0 -113
- data/lib/rghost/doc/files/data_grid/rails_grid_rb.html +0 -108
- data/lib/rghost/doc/files/data_grid/static_callback_rb.html +0 -109
- data/lib/rghost/doc/files/data_grid/style/border_lines_rb.html +0 -101
- data/lib/rghost/doc/files/data_grid/style/bottom_lines_rb.html +0 -101
- data/lib/rghost/doc/files/data_grid/style/old_forms_rb.html +0 -101
- data/lib/rghost/doc/files/data_grid/style/style_rb.html +0 -110
- data/lib/rghost/doc/files/document_rb.html +0 -150
- data/lib/rghost/doc/files/dsc_entry_rb.html +0 -108
- data/lib/rghost/doc/files/dynamic_document_callback_rb.html +0 -108
- data/lib/rghost/doc/files/eps_rb.html +0 -108
- data/lib/rghost/doc/files/font_rb.html +0 -110
- data/lib/rghost/doc/files/function_rb.html +0 -108
- data/lib/rghost/doc/files/gif_rb.html +0 -114
- data/lib/rghost/doc/files/graphic_rb.html +0 -113
- data/lib/rghost/doc/files/gs_alone_rb.html +0 -101
- data/lib/rghost/doc/files/helpers_rb.html +0 -101
- data/lib/rghost/doc/files/horizontal_line_rb.html +0 -109
- data/lib/rghost/doc/files/image_rb.html +0 -108
- data/lib/rghost/doc/files/jpeg_rb.html +0 -112
- data/lib/rghost/doc/files/line_rb.html +0 -109
- data/lib/rghost/doc/files/line_width_rb.html +0 -108
- data/lib/rghost/doc/files/load_rb.html +0 -108
- data/lib/rghost/doc/files/newpath_rb.html +0 -113
- data/lib/rghost/doc/files/paper_rb.html +0 -112
- data/lib/rghost/doc/files/point_rb.html +0 -109
- data/lib/rghost/doc/files/point_with_command_rb.html +0 -109
- data/lib/rghost/doc/files/ps_object_rb.html +0 -107
- data/lib/rghost/doc/files/rectangle_rb.html +0 -110
- data/lib/rghost/doc/files/rghost_rb.html +0 -109
- data/lib/rghost/doc/files/ruby_ghost_config_rb.html +0 -109
- data/lib/rghost/doc/files/ruby_ghost_engine_rb.html +0 -111
- data/lib/rghost/doc/files/ruby_to_ps_rb.html +0 -107
- data/lib/rghost/doc/files/scale_rb.html +0 -108
- data/lib/rghost/doc/files/show_rb.html +0 -109
- data/lib/rghost/doc/files/static_document_callback_rb.html +0 -109
- data/lib/rghost/doc/files/text_in_rb.html +0 -110
- data/lib/rghost/doc/files/textarea_rb.html +0 -111
- data/lib/rghost/doc/files/units_rb.html +0 -109
- data/lib/rghost/doc/files/variable_rb.html +0 -108
- data/lib/rghost/doc/files/version_rb.html +0 -101
- data/lib/rghost/doc/files/vertical_line_rb.html +0 -110
- data/lib/rghost/doc/fr_class_index.html +0 -93
- data/lib/rghost/doc/fr_file_index.html +0 -81
- data/lib/rghost/doc/fr_method_index.html +0 -201
- data/lib/rghost/doc/index.html +0 -24
- data/lib/rghost/ps/functions.ps +0 -646
- data/lib/rghost/rectangle.rb +0 -39
- data/lib/rghost/rghost.rb +0 -3
- data/lib/rghost/version.rb +0 -9
data/lib/rghost/document.rb
CHANGED
@@ -8,380 +8,403 @@
|
|
8
8
|
# http://creativecommons.org/licenses/by-sa/2.5/br/
|
9
9
|
##
|
10
10
|
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
|
17
|
-
require "vertical_line"
|
18
|
-
require "function"
|
19
|
-
require "font"
|
20
|
-
require "cursor"
|
21
|
-
require "show"
|
22
|
-
require "rectangle"
|
23
|
-
require "color"
|
24
|
-
require "graphic"
|
25
|
-
require "arc"
|
26
|
-
require "newpath"
|
27
|
-
require "line"
|
28
|
-
require "line_width"
|
29
|
-
require "textarea"
|
30
|
-
require "variable"
|
31
|
-
require "eps"
|
32
|
-
require "jpeg"
|
33
|
-
require "gif"
|
34
|
-
require "text_in"
|
35
|
-
require "ruby_ghost_engine"
|
36
|
-
require "barcode"
|
37
|
-
require "convert"
|
11
|
+
require 'ps_object'
|
12
|
+
require 'ps_facade'
|
13
|
+
require 'document_callback_facade'
|
14
|
+
require 'virtual_pages'
|
15
|
+
require 'variable'
|
16
|
+
#The Document class child of PsFacade is used to join postscript objects to generate output file.
|
38
17
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
18
|
+
class RGhost::Document < RGhost::PsFacade
|
19
|
+
include RGhost::DocumentCallbackFacade
|
20
|
+
DISABLE_VIRTUAL_PAGE=RGhost::Variable.new(:has_vp?, false)
|
21
|
+
ENABLE_VIRTUAL_PAGE=RGhost::Variable.new(:has_vp?, true)
|
43
22
|
DEFAULT_OPTIONS={
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
23
|
+
:rows_per_page => 80 ,
|
24
|
+
:count_pages => 10,
|
25
|
+
:row_height => 0.4,
|
26
|
+
:row_padding => 0.1,
|
27
|
+
:font_encoding=> RGhost::Config::GS[:font_encoding],
|
28
|
+
:paper => RGhost::Paper::DEFAULT_OPTIONS
|
50
29
|
}
|
51
|
-
|
52
|
-
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
# :tumble => false # true - tipo do duplex(para impress�o)
|
30
|
+
|
31
|
+
#===Examples
|
32
|
+
#Creating document with 80 rows per page and custom paper
|
33
|
+
# doc=Document.new :rows_per_page => 80, paper => [30,5]
|
34
|
+
#Document A4 with row height 0.5 and font encoding CodePage1252
|
35
|
+
# doc=Document.new :row_height => 0.5, :font_encoding => 'CodePage1252'
|
36
|
+
#Defining all margins
|
37
|
+
# doc=Document.new :margin => 0.5
|
38
|
+
#
|
39
|
+
#
|
40
|
+
#==Parameters
|
41
|
+
#* <tt>:paper</tt> - Facade to +paper+ defined on the construction of Paper class
|
42
|
+
#* <tt>:margin, :duplex and :tuble</tt> - Facade to +options+ defined on the construction of Paper class
|
43
|
+
#* <tt>:rows_per_page</tt> - Specifies count of rows per pages.
|
44
|
+
#* <tt>:landscape</tt> - Whether true invert de size(width per height)
|
45
|
+
#* <tt>:count_pages</tt> - Defines postscript internal variable to display with class TextIn. Example:
|
68
46
|
#
|
69
|
-
#
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
47
|
+
# doc=Document.new :count_pages => 10
|
48
|
+
# doc.before_page_create :except => 1 do
|
49
|
+
# text_in :x => 15, :y => 5, :write => "Page %current_page% of %count_pages%"
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
#The value above %count_pages% will be evaluated inside of document for all pages except page one.
|
53
|
+
#* <tt>:fontsize</tt> - Defines the size of tag :default_font.
|
54
|
+
#* <tt>:row_height and row_padding</tt> - Its names say by itself :)
|
55
|
+
#* <tt>:font_encoding</tt> - Specifies encoding of data input. You can look for supported encoding using the method RGhost::Config.encode_test
|
56
|
+
def initialize(options={})
|
57
|
+
super()
|
58
|
+
@head,@callbacks=RGhost::PsObject.new,RGhost::PsObject.new
|
59
|
+
@head.set RGhost::Load.library(:type)
|
60
|
+
@head.set RGhost::Load.library(:unit)
|
75
61
|
|
76
62
|
@variables=DEFAULT_OPTIONS.dup.merge(options)
|
77
63
|
default_encoding
|
78
|
-
@paper=Paper.new(options[:paper] || :A4, options)
|
64
|
+
@paper=RGhost::Paper.new(options[:paper] || :A4, options)
|
79
65
|
@head.set @paper
|
80
|
-
|
66
|
+
@done=false
|
81
67
|
|
82
68
|
@defines=[]
|
83
69
|
|
84
70
|
default_variables
|
85
|
-
instance_eval(&block) if block
|
86
|
-
end
|
87
|
-
#Facade Paper.gs_paper
|
88
|
-
#Obtem o valor no formato esperado pelo GS.
|
89
|
-
def gs_paper
|
90
|
-
@paper.gs_paper
|
91
71
|
end
|
92
|
-
|
93
72
|
|
94
|
-
|
95
|
-
|
96
|
-
# doc.before_page_create :only => [1,2] do
|
97
|
-
# set HorizontalLine.new
|
98
|
-
# end
|
99
|
-
# doc.even_pages :except => [1] do
|
100
|
-
# set Show.new("ET say: Hello Humans!!")
|
101
|
-
# end
|
102
|
-
# doc.last_page do
|
103
|
-
# set Cursor.jump_rows(3)
|
104
|
-
# set TextIn.new(:x=> 4, :y => 15.5, :text => "Total: %current_page%")
|
105
|
-
# end
|
106
|
-
def method_missing(name,*args,&block)
|
107
|
-
case name
|
108
|
-
when *DynamicDocumentCallback::ACCEPT:
|
109
|
-
|
110
|
-
@callbacks.set DynamicDocumentCallback.new(name,args.shift || {},&block) #args.shift || {} without args
|
111
|
-
|
112
|
-
when *StaticDocumentCallback::ACCEPT:
|
113
|
-
|
114
|
-
@callbacks.set StaticDocumentCallback.new(name,&block)
|
115
|
-
|
116
|
-
else
|
117
|
-
raise NameError.new(name.to_s)
|
118
|
-
end
|
73
|
+
def gs_paper #:nodoc:
|
74
|
+
@paper.gs_paper
|
119
75
|
end
|
76
|
+
#
|
120
77
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
78
|
+
#Creates map of tags if will be use in 'writable' classes(Show, Text, TextIn and TextArea).
|
79
|
+
#The font names file catalog can be generated by code below
|
80
|
+
# RGhost::Config.enviroment_fonts.render :pdf, :filename => "mycatalog.pdf"
|
81
|
+
#this can take while. If waiting for much time you has any font with problem, remove some fonts mostly international fonts not used often.
|
82
|
+
#Below little piece of catalog
|
83
|
+
#link:images/font_catalog.png
|
84
|
+
#
|
85
|
+
#After genereted catalog you can map your tags.
|
86
|
+
#
|
87
|
+
#
|
88
|
+
#Tags has +name+ of tag(as Symbol) and its options. The options are
|
89
|
+
#
|
90
|
+
#* <tt>:name</tt> - Font name from catalog.
|
91
|
+
#* <tt>:size</tt> - Font size.
|
92
|
+
#* <tt>:color</tt> - Color.create facade
|
93
|
+
#* <tt>:encoding</tt> - If true the font will be encoding using de pattern :font_encoding of the document.
|
94
|
+
#===Examples
|
95
|
+
# d=Document.new :encoding => 'IsoLatin'
|
96
|
+
# d.define_tags do
|
97
|
+
# tag :my_italic, :name => 'Hershey-Gothic-Italian-Oblique', :size => 10
|
98
|
+
# tag :myfont, :name => 'Hershey-Plain'
|
99
|
+
# tag :font_encoded, :name => 'NimbusMonL-Regu', :size => 8, :color => 0.5, :encoding => true
|
100
|
+
# tag :other_font, :name => 'NimbusMonL-Regu', :size => 10
|
101
|
+
# tag :arial, :name => 'Arial-ItalicMT', :color => '#ADAD66'
|
102
|
+
# tag :arial_bold, :name => 'NimbusSanL-BoldItal',:size => 12, :color => '#ADAD66'
|
103
|
+
# end
|
104
|
+
#You can use :default_font tag for custom the default font.
|
105
|
+
#===Using tags
|
106
|
+
#====With Show class
|
107
|
+
# doc.show 'My Text on this row', :with => :my_italic, :align => :page_center
|
108
|
+
#====With Show class overrinding tag's color.
|
109
|
+
# doc.show 'My Text on this row', :with => :my_italic, :align => :page_center, :color => :red
|
110
|
+
#====With TextIn class.
|
111
|
+
# doc.text_in :x=> 3, :y=> 10, :tag => :arial_bold , :write => "Here's point(3,10)"
|
112
|
+
#====With Text
|
113
|
+
# doc.text '<myfont>My Text</myfont>on this row.<arial>Other text</arial><my_italic>Italic font</my_italic>'
|
114
|
+
#====With TextArea
|
115
|
+
# txt='<myfont>My Text</myfont>on this row.<arial>Other text</arial><my_italic>Italic font</my_italic>'
|
116
|
+
# doc.text_area txt, :text_align => :center, :width => 5, :x => 3, :y => 10
|
117
|
+
#====Using tag
|
118
|
+
# doc.use_tag :myfont
|
119
|
+
# doc.show "Simple Text", :tag => nil # it will use :myfont
|
120
|
+
# doc.show "Simple Text2", :tag => nil # it will use :myfont too
|
121
|
+
def define_tags(&block)
|
122
|
+
RGhost::Config::FONTMAP.instance_eval(&block)
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
def ps #:nodoc:
|
127
|
+
done unless @done
|
128
|
+
|
129
|
+
out=RGhost::PsObject.new
|
130
|
+
out.set @head
|
131
|
+
out.set @default_variables
|
132
|
+
out.set RGhost::Load.rg_enviroment
|
133
|
+
out.raw @defines.join
|
134
|
+
out.set RGhost::Cursor.moveto
|
135
|
+
out.set RGhost::Config::FONTMAP
|
136
|
+
out.set @callbacks
|
137
|
+
out.set RGhost::Load.library(:begin_document)
|
138
|
+
RGhost::Config::GS[:preload].uniq.each{|v| out.set RGhost::Load.library(v) }
|
139
|
+
out.set RGhost::Cursor.moveto
|
140
|
+
out.raw super
|
141
|
+
out.raw "\n\n"
|
142
|
+
|
143
|
+
"#{out} "
|
134
144
|
|
135
145
|
#"#{@head} \n%%endhead\n#{@default_variables}\n\n #{Load.rg_enviroment} #{@defines.join} #{@callbacks} #{Load.library(:begin_document)}\n #{Cursor.moveto}#{super}"
|
136
146
|
|
137
147
|
|
138
148
|
end
|
139
149
|
|
140
|
-
#Facade RubyGhostEngine.render
|
141
|
-
#
|
142
|
-
#
|
150
|
+
#Facade to RubyGhostEngine.render
|
151
|
+
#Converts a document to an output format, such as :pdf, :png, :ps, :jpeg, :tiff etc
|
152
|
+
#The paramter device can be found at RGhost::Constants::Devices or at http://pages.cs.wisc.edu/~ghost/doc/cvs/Devices.htm
|
153
|
+
#===Options
|
154
|
+
#Method render have the following options available.
|
155
|
+
#* <tt>:filename</tt> - File path.
|
156
|
+
#* <tt>:logfile</tt> - Writes the converter's process into a file.
|
157
|
+
#* <tt>:multipage</tt> - Whether true the output will be one page per file posfixed by _0001.ext, for example, for one file name 'test.png' with two pages will create test_001.png and test_002.png
|
158
|
+
#* <tt>:resolution</tt> - Integer value to output resolution.
|
159
|
+
#* <tt>:size</tt> - Crops a single page using a string of dimension, example, '200x180', '140x90'.
|
160
|
+
#* <tt>:range</tt> - Specifies range of pages(PDF only)
|
161
|
+
#====Ghostscript interpreter options
|
143
162
|
#
|
144
|
-
#
|
145
|
-
#
|
146
|
-
# :
|
147
|
-
# :resolution => 72 # Resolu��o
|
148
|
-
# :size => "200x180" # Para crop da imagem de sa�da
|
149
|
-
# :range =>2..3 # Range de p�ginas (PDF Only)
|
150
|
-
# Array contendo um Hash para op��es em modo raw do Ghostscript :d ou :s
|
151
|
-
# :s => [{:GenericResourceDir => /dir, :DEFAULTPAPERSIZE=> "a3"}]
|
163
|
+
#Array of Hashes for Ghostscript interpreter look at http://pages.cs.wisc.edu/~ghost/doc/cvs/Use.htm#Parameter_switches for more details.
|
164
|
+
#You can use two parameter :s and :d, examples
|
165
|
+
# :s => [{:GenericResourceDir => /dir, :DEFAULTPAPERSIZE=> "a3"}]
|
152
166
|
# :d => [ {:TextAlphaBits => 2} ]
|
153
|
-
#
|
167
|
+
#Or one string using the parameter :raw, as below
|
154
168
|
# :raw => "-sGenericResourceDir=/test -dTextAlphaBits=2"
|
155
169
|
#
|
156
|
-
|
157
|
-
#
|
158
|
-
# #
|
170
|
+
#===Examples
|
171
|
+
# doc=Document.new
|
172
|
+
# #do something
|
159
173
|
#
|
160
|
-
#
|
161
|
-
#
|
162
|
-
#
|
163
|
-
#
|
174
|
+
# doc.render :pdf, :filename => 'foo.pdf # PDF output
|
175
|
+
# doc.render :jpeg, :filename => 'foo.jpg' # JPEG output
|
176
|
+
# doc.render :png, :filename => 'foo.png', :multipage => true # PNG output one page per file
|
177
|
+
# doc.render :tiff, :filename => 'foo.tiff', :resolution => 300 # TIFF with 300dpi
|
178
|
+
# doc.render :ps, :raw => '-sFONTMAP=/var/myoptional/font/map', :filename => 'test.ps'
|
179
|
+
#
|
180
|
+
#===Testing if has errors
|
181
|
+
# doc=Document.new
|
182
|
+
# doc.raw "hahahah!" #it produce error in ps stack
|
183
|
+
# doc.render :jpeg, :filename => 'with_error.jpg'
|
184
|
+
# puts r.errors if r.error? #=> GPL Ghostscript 8.61: Unrecoverable error, exit code 1.\ Error: /undefined in hahahah!
|
185
|
+
#
|
186
|
+
#===Printing
|
187
|
+
#====Using printing system
|
188
|
+
# doc=Document.new
|
189
|
+
# #do something
|
190
|
+
# f="myjob.prn"
|
191
|
+
# doc.render :laserjet, :filename => f
|
192
|
+
# `lpr #{f}`
|
193
|
+
#====Windows shared printer
|
194
|
+
# doc.render :eps9mid, :filename => "//machine/printer"
|
164
195
|
def render(device,options={})
|
165
|
-
rg=
|
196
|
+
rg=RGhost::Engine.new(self,options)
|
166
197
|
rg.render(device)
|
167
198
|
rg
|
168
199
|
end
|
169
|
-
#
|
200
|
+
#Behavior as render but returns content file after convertion.
|
201
|
+
#===Example with Rails
|
202
|
+
# def my_action
|
203
|
+
# doc=RGhost::Document.new
|
204
|
+
# #do something
|
205
|
+
# send_data doc.render_stream(:pdf), :filename => "/tmp/myReport.pdf"
|
206
|
+
# end
|
207
|
+
#
|
208
|
+
#===TCP/IP direct printer
|
209
|
+
# require 'socket'
|
210
|
+
#
|
211
|
+
# doc=Document.new
|
212
|
+
# #do something
|
213
|
+
# printer = TCPSocket.open('192.168.1.70', 9100)
|
214
|
+
# printer.write doc.render_stream(:ps)
|
215
|
+
# printer.close
|
170
216
|
def render_stream(device,options={})
|
171
217
|
rg=render(device,options)
|
172
218
|
out=rg.output.readlines.join
|
173
219
|
rg.clear_output
|
174
220
|
out
|
175
221
|
end
|
176
|
-
#Facade Function.new
|
177
|
-
#
|
178
|
-
|
179
|
-
#
|
180
|
-
#
|
181
|
-
#
|
182
|
-
#
|
222
|
+
#Facade to Function.new
|
223
|
+
#Defines low level function to optimize repetitive piece of code.
|
224
|
+
#===Example
|
225
|
+
# doc=Document.new
|
226
|
+
# doc.define :piece do
|
227
|
+
# set Show.new("Hello")
|
228
|
+
# set Cursor.next_row
|
229
|
+
# set HorizontalLine.new(:middle)
|
230
|
+
# set Cursor.next_row
|
231
|
+
# end
|
232
|
+
# #Repeting ten times the same code
|
233
|
+
# 10.times{ doc.call :piece }
|
183
234
|
def define(name,&block)
|
184
|
-
@defines << Function.new(name,&block)
|
235
|
+
@defines << RGhost::Function.new(name,&block)
|
185
236
|
end
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
#
|
190
|
-
# end
|
237
|
+
def define_variable(name,value)
|
238
|
+
set RGhost::Variable.new(name,value)
|
239
|
+
end
|
240
|
+
#Defines a function using the method define after that call de function one time.
|
191
241
|
def define_and_call(name,&block)
|
192
242
|
define(name,&block)
|
193
243
|
call(name)
|
194
244
|
end
|
195
|
-
|
196
|
-
#
|
197
|
-
|
198
|
-
#
|
199
|
-
#
|
200
|
-
#
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
#File.open(__FILE__).each do |line|
|
207
|
-
# doc.next_row do
|
208
|
-
# set HorizontalLine.new(:top)
|
209
|
-
# set Show.new(line)
|
210
|
-
# end
|
211
|
-
#end
|
212
|
-
def next_row(&block)
|
213
|
-
set PsObject.new(&block)
|
214
|
-
set Cursor.next_row
|
245
|
+
|
246
|
+
#Prints the text file using the predefined tag +:pre+
|
247
|
+
#===Example
|
248
|
+
# doc=Document.new :paper => :A4, :landscape => true
|
249
|
+
# doc.print_file "/etc/passwd"
|
250
|
+
# doc.render :pdf, :filename => "/tmp/passwd.pdf
|
251
|
+
def print_file(file)
|
252
|
+
s=File.open(file).readlines.join.gsub(/</,'<').gsub(/>/,'>').gsub(/\n/,'<br/>')
|
253
|
+
|
254
|
+
use_tag :pre
|
255
|
+
set RGhost::Text.new(s,true)
|
215
256
|
|
216
|
-
|
217
257
|
end
|
218
|
-
#
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
258
|
+
#With method virtual_pages you can define any virtual pages per physical page.
|
259
|
+
#The cursor into virtual page jumps in column for each virtual page and run primitives next_page when ends columns. Look the example below.
|
260
|
+
#Example for a document without virtual pages we will has
|
261
|
+
# doc=Document.new
|
262
|
+
# doc.text File.readlines("/tmp/mytext.txt")
|
263
|
+
#will generate
|
264
|
+
#
|
265
|
+
#link:images/virtual_page1.png
|
266
|
+
#
|
267
|
+
#Now for a document with 3 virtual pages
|
268
|
+
# doc=Document.new
|
269
|
+
# doc.virtual_pages do
|
270
|
+
# new_page :width => 4
|
271
|
+
# new_page :width => 7, :margin_left => 1
|
272
|
+
# new_page :width => 4, :margin_left => 1
|
273
|
+
# end
|
274
|
+
# doc.text File.readlines("/tmp/mytext.txt")
|
275
|
+
#will generate
|
276
|
+
#
|
277
|
+
#link:images/virtual_page2.png
|
278
|
+
#
|
279
|
+
#PS: The parameter margin left of first virtual page won't be used because it's will use page's margin left.
|
280
|
+
def virtual_pages(&block)
|
281
|
+
set RGhost::VirtualPages.new(&block)
|
225
282
|
end
|
226
283
|
|
227
|
-
#Salta a p�gina com controlando o documento.
|
228
|
-
def next_page
|
229
|
-
call :next_page
|
230
|
-
end
|
231
|
-
#Facade Graphic
|
232
|
-
#Condiciona em um bloco gr�fico. Defini��es gr�ficas v�lidas apenas para o escopo do bloco n�o interferindo nos demais gr�ficos.
|
233
|
-
# doc=Document.new
|
234
|
-
# doc.graphic do
|
235
|
-
# set LineWidth.new(0)
|
236
|
-
# set Line.lineto(5,7)
|
237
|
-
# end
|
238
|
-
def graphic(ps_obj=PsObject.new,&block)
|
239
|
-
set Graphic.new(ps_obj,&block)
|
240
|
-
end
|
241
|
-
#Facade Newpath
|
242
|
-
#Cria um bloco que cria um novo path sem alterar o path corrente. O path v�lido apenas para o escopo do bloco. Contudo fecha o path(closepath) ao fim do bloco.
|
243
|
-
# doc=Document.new
|
244
|
-
# doc.newpath do
|
245
|
-
# set Arc.new(:x => 10, :y => 10, :radius => 100)
|
246
|
-
# end
|
247
|
-
def newpath(ps_obj=PsObject.new,&block)
|
248
|
-
set NewPath.new(ps_obj,&block)
|
249
|
-
end
|
250
|
-
#Facade Variable.new
|
251
|
-
#Define uma vari�vel global em Postscript.
|
252
|
-
# d=Document.new
|
253
|
-
# d.define_variable(:my_var,[3,4,5,6])
|
254
|
-
#
|
255
|
-
def define_variable(name,value)
|
256
|
-
@defines << Variable.new(name,value)
|
257
|
-
end
|
258
|
-
#Use showpage para o fim do documento ou para saltar p�ginas.
|
259
|
-
# Obs.: showpage n�o reseta os contadores de p�ginas,faixas, etc.
|
260
|
-
def showpage
|
261
|
-
call :stroke
|
262
|
-
call :showpage
|
263
|
-
end
|
264
284
|
|
265
|
-
#
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
#
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
set Cursor.rmoveto(point)
|
284
|
-
end
|
285
|
-
#Facade Cursor.translate
|
286
|
-
def translate(point={})
|
287
|
-
set Cursor.translate(point)
|
288
|
-
end
|
289
|
-
#Facade DSCEntry.new
|
290
|
-
def dsc_entry(&block)
|
291
|
-
set DSCEntry.new(&block)
|
292
|
-
end
|
293
|
-
#Facade EPS.new
|
294
|
-
def template(file_path,options={})
|
295
|
-
set EPS.new(file_path,options)
|
296
|
-
end
|
297
|
-
#Define um template/eps
|
298
|
-
# dt=Document.new
|
299
|
-
# dt.define_template(:myform, '/local/template/form1.eps', :x=> 3, :y => 5)
|
300
|
-
# dt.call :myform # Executa o template
|
301
|
-
def define_template(name,file_path,options)
|
302
|
-
set Function.new(name,EPS.new(file_path,options))
|
303
|
-
end
|
304
|
-
#Facade Font.new
|
305
|
-
def font(options)
|
306
|
-
set Font.new(options)
|
307
|
-
end
|
308
|
-
#Facade Image.for
|
309
|
-
def image(path,options={})
|
310
|
-
set Image.for(path,options)
|
311
|
-
end
|
312
|
-
#Idem horizontal_line
|
313
|
-
def hl(valign=:middle,options={})
|
314
|
-
set HorizontalLine.new(valign,options)
|
315
|
-
end
|
316
|
-
#Facade HorizontalLine.new
|
317
|
-
def horizontal_line(valign=:middle,options={})
|
318
|
-
hl(valign,options)
|
319
|
-
end
|
320
|
-
#Facade Rectangle.new
|
321
|
-
def rectangle(options={})
|
322
|
-
set Rectangle.new(options)
|
323
|
-
end
|
324
|
-
#Facade Rectangle.background_row
|
325
|
-
def background_row(options={})
|
326
|
-
set Rectangle.background_row(options={})
|
327
|
-
end
|
328
|
-
#Facade Scale.new
|
329
|
-
def scale(sx,sy)
|
330
|
-
set Scale.new(sx,sy)
|
331
|
-
end
|
332
|
-
#Facade TextIn.new
|
333
|
-
def text_in(options={})
|
334
|
-
set TextIn.new(options)
|
335
|
-
end
|
336
|
-
#Facade Show.new
|
337
|
-
def text(text,align={ :align=>:show_left })
|
338
|
-
set Show.new(text,align)
|
339
|
-
end
|
340
|
-
#Facade Show.new
|
341
|
-
def show(text,align={ :align=>:show_left })
|
342
|
-
set Show.new(text,align)
|
343
|
-
end
|
344
|
-
#Facade TextArea.new
|
345
|
-
def text_area(text,options={})
|
346
|
-
set TextArea.new(text,options)
|
285
|
+
#Starts and Ends internal benckmark will write in bottom of page.
|
286
|
+
#===Example
|
287
|
+
# doc=Document.new
|
288
|
+
# doc.benchmark :start
|
289
|
+
# doc.... #do something
|
290
|
+
# doc.benchmarck :stop
|
291
|
+
# doc.render ...
|
292
|
+
def benchmark(state=:start)
|
293
|
+
case state
|
294
|
+
when :stop
|
295
|
+
moveto(:x => "20", :y => "20")
|
296
|
+
raw %Q{
|
297
|
+
default_font (RGhost::Ghostscript benchmark: ) show
|
298
|
+
realtime benchmark sub 1000 div 20 string cvs show ( seconds ) show
|
299
|
+
}
|
300
|
+
when :start
|
301
|
+
set RGhost::Variable.new(:benchmark,"realtime")
|
302
|
+
end
|
347
303
|
end
|
348
|
-
|
349
|
-
|
350
|
-
|
304
|
+
|
305
|
+
#Rghost can make use of Encapsulated Postscript files to act as templates(EPS).
|
306
|
+
#This way you can create the visual layout of the page using a graphics tool and just paint the dynamic pieces over using Rghost.
|
307
|
+
#
|
308
|
+
#link:images/templates_demo.jpg
|
309
|
+
#
|
310
|
+
#Above we have mytemplate.eps that was generated by a graphic app, my_ruby_program.rb that takes care of the positioning and at last the generated output.
|
311
|
+
#
|
312
|
+
#
|
313
|
+
#A Template use example
|
314
|
+
#Let's say that the files first.eps and content.eps already exist. Now we shall see how to create a document that uses the template first.eps for the cover and the rest of the document uses content.eps.
|
315
|
+
#
|
316
|
+
# d = Document.new :margin_top => 5, :margin_bottom => 2
|
317
|
+
#
|
318
|
+
#Just for the first page
|
319
|
+
#
|
320
|
+
# d.first_page do
|
321
|
+
# image "/my/dir/first.eps" #loads the template
|
322
|
+
# text_in :x=> 5, :y=> 17, :text => "My Report", :with => :big
|
323
|
+
# next_page #go to the next page using cursors
|
324
|
+
# end
|
325
|
+
#Callback for all other pages.
|
326
|
+
#
|
327
|
+
# d.before_page_create :except => 1 do
|
328
|
+
# image "/my/dir/content.eps"
|
329
|
+
# text_in :text => "Page %current_page% of %count_pages%", :x => 18, :y => 27, :with => :normal
|
330
|
+
# end
|
331
|
+
#
|
332
|
+
#1500 rows
|
333
|
+
#
|
334
|
+
# 1500.times do |n|
|
335
|
+
# d.show "Value #{n}"
|
336
|
+
# d.next_row
|
337
|
+
# end
|
338
|
+
#We have a cover page and 1500 rows, judging by the margins each page supports 46 rows, so we have 1500/46 = 32.60 pages plus the cover. Rounding it up totals 34 pages for the :count_pages
|
339
|
+
#
|
340
|
+
# d.define_variable(:count_pages, 34)
|
341
|
+
# d.showpage
|
342
|
+
# d.render :pdf, :filename => "/tmp/test.pdf"
|
343
|
+
#
|
344
|
+
#If we knew the amount of pages beforehand we could state it on the creation of the document, i.e.
|
345
|
+
#
|
346
|
+
# :current_pages => 34
|
347
|
+
#
|
348
|
+
#The example uses one template per page, but this is not a limit in RGhost. You can have multiple images and templates on per page. Just have to define the template:
|
349
|
+
#
|
350
|
+
# d=Document.new :margin_top => 5, :margin_bottom => 2
|
351
|
+
# d.define_template(:myform, '/local/template/form1.eps', :x=> 3, :y => 5)
|
352
|
+
#
|
353
|
+
#and call it on the document.
|
354
|
+
# d.use_template :myform
|
355
|
+
#
|
356
|
+
#===Arguments
|
357
|
+
#* <tt>:name</tt> - Template's name.
|
358
|
+
#* <tt>:file_path</tt> - Path to file.
|
359
|
+
#* <tt>:options</tt> - Options facade to Image.for(or image)
|
360
|
+
def define_template(name,file_path,options={})
|
361
|
+
|
362
|
+
@defines << RGhost::Function.new("_#{name}",RGhost::Image.for(file_path,options))
|
351
363
|
end
|
352
|
-
|
353
|
-
|
364
|
+
|
365
|
+
|
366
|
+
#Informs is ready to converts/prints
|
367
|
+
def done
|
368
|
+
@done=true
|
369
|
+
raw "\n\n"
|
370
|
+
call :after_page_create
|
371
|
+
call :callback
|
372
|
+
call :after_document_create
|
354
373
|
|
355
|
-
|
356
|
-
|
374
|
+
showpage
|
375
|
+
raw "\n%%EOF"
|
357
376
|
end
|
358
|
-
|
359
|
-
|
377
|
+
def enable_virtual_pages
|
378
|
+
set RGhost::Variable.new(:has_vp?, true)
|
360
379
|
|
361
|
-
call :stroke
|
362
380
|
end
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
381
|
+
def disable_virtual_pages
|
382
|
+
set RGhost::Variable.new(:has_vp?, false)
|
383
|
+
set RGhost::Variable.new(:limit_left, 'source_limit_left')
|
384
|
+
set RGhost::Variable.new(:limit_right, 'source_limit_right')
|
385
|
+
|
367
386
|
end
|
368
387
|
|
388
|
+
|
389
|
+
# def load_library(name)
|
390
|
+
# raw RGhost::Load.library(name)
|
391
|
+
# end
|
369
392
|
private
|
393
|
+
|
370
394
|
def default_variables
|
371
|
-
ps=PsObject.new
|
372
|
-
ps.set Variable.new(:rows_per_page,@variables[:rows_per_page])
|
373
|
-
ps.set Variable.new(:count_pages,@variables[:count_pages])
|
374
|
-
ps.set Variable.new(:row_height,Units::parse(@variables[:row_height]))
|
375
|
-
ps.set Variable.new(:row_padding,Units::parse(@variables[:row_padding]))
|
376
|
-
|
395
|
+
ps=RGhost::PsObject.new
|
396
|
+
ps.set RGhost::Variable.new(:rows_per_page,@variables[:rows_per_page])
|
397
|
+
ps.set RGhost::Variable.new(:count_pages,@variables[:count_pages])
|
398
|
+
ps.set RGhost::Variable.new(:row_height,RGhost::Units::parse(@variables[:row_height]))
|
399
|
+
ps.set RGhost::Variable.new(:row_padding,RGhost::Units::parse(@variables[:row_padding]))
|
377
400
|
|
378
401
|
@default_variables=ps
|
379
|
-
|
380
402
|
|
381
403
|
end
|
404
|
+
|
382
405
|
def default_encoding
|
383
|
-
@head.set Load.library(@variables[:font_encoding],:enc)
|
384
|
-
@head.set Variable.new(:default_encoding,@variables[:font_encoding])
|
406
|
+
@head.set RGhost::Load.library(@variables[:font_encoding],:enc)
|
407
|
+
@head.set RGhost::Variable.new(:default_encoding,@variables[:font_encoding])
|
385
408
|
|
386
409
|
end
|
387
410
|
|