wizport 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/lib/wizport/builder/rtf.rb +1 -1
- data/lib/wizport/document/Rtf/cell.rb +27 -21
- data/lib/wizport/document/Rtf/document.rb +0 -10
- data/lib/wizport/document/Rtf/row.rb +34 -0
- data/lib/wizport/document/html/document.rb +42 -0
- data/lib/wizport/document/html/element.rb +14 -0
- data/lib/wizport/document/html/table.rb +49 -0
- data/lib/wizport/document/html/text.rb +19 -0
- data/lib/wizport/document/pdf/catalog.rb +15 -0
- data/lib/wizport/document/pdf/document.rb +35 -0
- data/lib/wizport/document/pdf/element.rb +28 -3
- data/lib/wizport/document/pdf/page.rb +15 -0
- data/lib/wizport/document/pdf/pages.rb +15 -0
- data/lib/wizport/document/pdf/pdf_builder.rb +63 -0
- data/lib/wizport/document/pdf/x_ref_tbl.rb +24 -0
- data/lib/wizport/document/pdf.rb +2 -1
- data/lib/wizport/document/pdf_table.rb +21 -0
- data/lib/wizport/document/rtf.rb +5 -6
- data/lib/wizport/version.rb +1 -1
- data/lib/wizport.rb +16 -1
- data/spec/wizport/document/html/document_spec.rb +19 -0
- data/spec/wizport/document/pdf/document_spec.rb +22 -0
- data/spec/wizport/document/pdf_spec.rb +23 -0
- data/spec/wizport/document/rtf/document_spec.rb +4 -1
- data/spec/wizport/document/rtf_spec.rb +1 -1
- data/wizport.gemspec +1 -1
- metadata +16 -18
data/Gemfile
CHANGED
data/lib/wizport/builder/rtf.rb
CHANGED
@@ -6,30 +6,29 @@
|
|
6
6
|
module Wizport
|
7
7
|
module Rtf
|
8
8
|
class Cell
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :colspan, :rowspan
|
10
10
|
|
11
11
|
def initialize(data, row = nil)
|
12
12
|
@row = row
|
13
13
|
@index = @row.cells.size
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
14
|
+
@colspan = 1
|
15
|
+
@rowspan = 1
|
16
|
+
@content = data
|
17
|
+
#:content => "2x1", :colspan
|
17
18
|
if data.is_a?(Hash)
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
21
|
-
else
|
22
|
-
@text = data
|
19
|
+
@colspan = data[:colspan] if data[:colspan]
|
20
|
+
@rowspan = data[:rowspan] if data[:rowspan]
|
21
|
+
@content = data[:content]
|
23
22
|
end
|
24
23
|
|
25
|
-
unless col_spanned?
|
24
|
+
#unless col_spanned?
|
26
25
|
@row.table.elements << Command.new(:celld)
|
27
|
-
@row.table.elements << Command.new(:clvmgf) if @
|
26
|
+
@row.table.elements << Command.new(:clvmgf) if @rowspan > 1
|
28
27
|
@row.table.elements << Command.new(:clvmrg) if row_spanned?
|
29
|
-
@row.table.elements << Command.new(:cellx, (
|
30
|
-
@row.table.elements << Plaintext.new(@
|
28
|
+
@row.table.elements << Command.new(:cellx, (col_spanned)*1000)
|
29
|
+
@row.table.elements << Plaintext.new(@content.to_s)
|
31
30
|
@row.table.elements << Command.new(:cell)
|
32
|
-
end
|
31
|
+
#end
|
33
32
|
|
34
33
|
#@row.cellx_command Command.new(:clvmgf) if @row_span > 1
|
35
34
|
#@row.cellx_command Command.new(:clvmrg) if row_spanned?
|
@@ -39,17 +38,24 @@ module Wizport
|
|
39
38
|
end
|
40
39
|
|
41
40
|
def col_spanned?
|
42
|
-
@index
|
43
|
-
|
41
|
+
col_spanned >= (@index + 1) && colspan == 1
|
42
|
+
end
|
43
|
+
|
44
|
+
def col_spanned
|
45
|
+
cols = 0
|
46
|
+
(@index).times do |c|
|
47
|
+
cols += @row.cells[c].colspan
|
44
48
|
end
|
45
|
-
|
49
|
+
cols += colspan
|
46
50
|
end
|
47
51
|
|
52
|
+
|
48
53
|
def row_spanned?
|
49
|
-
@row.
|
50
|
-
|
51
|
-
|
52
|
-
|
54
|
+
@row.row_spanned?(col_spanned - colspan)
|
55
|
+
#@row.index.times do |r|
|
56
|
+
# return true if @row.table.rows[r].cells[@index] && @row.table.rows[r].cells[@index].rowspan + r > @row.index
|
57
|
+
#end
|
58
|
+
#return false
|
53
59
|
end
|
54
60
|
|
55
61
|
|
@@ -59,16 +59,6 @@ module Wizport
|
|
59
59
|
end
|
60
60
|
|
61
61
|
if __FILE__ == $0
|
62
|
-
require "../../visitor"
|
63
|
-
require "./element"
|
64
|
-
require "./plaintext"
|
65
|
-
require "./command"
|
66
|
-
require "./group"
|
67
|
-
require "./text"
|
68
|
-
require "./cell"
|
69
|
-
require "./row"
|
70
|
-
require "./table"
|
71
|
-
require "./rtf_builder"
|
72
62
|
|
73
63
|
d = Wizport::Rtf::Document.new('c:/file.rtf') do
|
74
64
|
text "我们", :align => :center, :size => 48
|
@@ -18,11 +18,45 @@ module Wizport
|
|
18
18
|
columns.each_index do |i|
|
19
19
|
@cellx_index = nil
|
20
20
|
@cellt_index = nil
|
21
|
+
temp = 0
|
22
|
+
if columns[i].is_a?(Hash)
|
23
|
+
temp += columns[i][:colspan].to_i
|
24
|
+
else
|
25
|
+
temp += 1
|
26
|
+
end
|
27
|
+
|
28
|
+
if row_spanned?(temp)
|
29
|
+
@cells << Cell.new("",self)
|
30
|
+
end
|
21
31
|
@cells << Cell.new(columns[i],self)
|
32
|
+
#if columns[i].is_a?(Hash)
|
33
|
+
# if columns[i][:colspan] && columns[i][:colspan] > 1
|
34
|
+
# (columns[i][:colspan]-1).times do
|
35
|
+
# @cells << Cell.new("",self)
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
#end
|
22
39
|
end
|
23
40
|
@table.elements << Command.new(:row)
|
24
41
|
end
|
25
42
|
|
43
|
+
def row_spanned?(c_i)
|
44
|
+
rs = 0
|
45
|
+
|
46
|
+
(@index).times do |r|
|
47
|
+
t = 0
|
48
|
+
@table.rows[r].cells.each do |c|
|
49
|
+
t += c.colspan
|
50
|
+
if t == c_i + 1
|
51
|
+
rs += c.rowspan
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
#rs += @table.rows[r].cells[c_i].rowspan if @table.rows[r].cells[c_i] && @table.rows[r].cells[c_i].rowspan > 1
|
56
|
+
end
|
57
|
+
rs >= (@index + 1)
|
58
|
+
end
|
59
|
+
|
26
60
|
def cellx_command(cmd)
|
27
61
|
@cellx_index = @cellx_index || @table.elements.size
|
28
62
|
@table.elements.insert @cellx_index, cmd
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Wizport: A gem for creating reports by specifying columns, groups, styles, etc.
|
4
|
+
# Copyright 2012 by sgzhe@163.com
|
5
|
+
|
6
|
+
require "stringio"
|
7
|
+
module Wizport
|
8
|
+
module Html
|
9
|
+
class Document
|
10
|
+
def initialize(&block)
|
11
|
+
@html = StringIO.new
|
12
|
+
@html << "<div class='rpt'>"
|
13
|
+
block.arity<1 ? self.instance_eval(&block) : block.call(self) if block_given?
|
14
|
+
end
|
15
|
+
|
16
|
+
def text(txt)
|
17
|
+
Wizport::Html::Text.new(self,txt)
|
18
|
+
end
|
19
|
+
|
20
|
+
def table(rows = [], &block)
|
21
|
+
Wizport::Html::Table.new(self, rows, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def write(txt)
|
25
|
+
@html << txt
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_html
|
29
|
+
@html << '</div>'
|
30
|
+
@html.string
|
31
|
+
end
|
32
|
+
|
33
|
+
def render
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def save(file)
|
38
|
+
File.open(file, 'w') { |file| file.write(to_html) }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Wizport: A gem for creating reports by specifying columns, groups, styles, etc.
|
4
|
+
# Copyright 2012 by sgzhe@163.com
|
5
|
+
|
6
|
+
module Wizport
|
7
|
+
module Html
|
8
|
+
class Element
|
9
|
+
def initialize(html)
|
10
|
+
@html = html
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Wizport: A gem for creating reports by specifying columns, groups, styles, etc.
|
4
|
+
# Copyright 2012 by sgzhe@163.com
|
5
|
+
|
6
|
+
module Wizport
|
7
|
+
module Html
|
8
|
+
class Table < Element
|
9
|
+
def initialize(html,rows = [],options = {},&block)
|
10
|
+
super html
|
11
|
+
@html.write '<table><tbody>'
|
12
|
+
rows.each do |row|
|
13
|
+
add_row row, :headed => options[:headed]
|
14
|
+
end
|
15
|
+
block.arity<1 ? self.instance_eval(&block) : block.call(self) if block_given?
|
16
|
+
@html.write '</tbody></table>'
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_row(columns,options = {})
|
20
|
+
tag_name = options[:headed] ? 'thread' : 'tr'
|
21
|
+
@html.write '<'
|
22
|
+
@html.write tag_name
|
23
|
+
@html.write '>'
|
24
|
+
columns.each do |column|
|
25
|
+
add_cell column
|
26
|
+
end
|
27
|
+
@html.write '</'
|
28
|
+
@html.write tag_name
|
29
|
+
@html.write '>'
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_cell(column)
|
33
|
+
if column.is_a?(Hash)
|
34
|
+
colspan = column[:colspan]
|
35
|
+
rowspan = column[:rowspan]
|
36
|
+
column = column[:content]
|
37
|
+
@html.write '<td'
|
38
|
+
@html.write " colspan='#{colspan}'" if colspan
|
39
|
+
@html.write " rowspan='#{rowspan}'" if rowspan
|
40
|
+
@html.write '>'
|
41
|
+
else
|
42
|
+
@html.write '<td>'
|
43
|
+
end
|
44
|
+
@html.write column
|
45
|
+
@html.write '</td>'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Wizport: A gem for creating reports by specifying columns, groups, styles, etc.
|
4
|
+
# Copyright 2012 by sgzhe@163.com
|
5
|
+
|
6
|
+
module Wizport
|
7
|
+
module Html
|
8
|
+
class Text < Element
|
9
|
+
def initialize(html,txt)
|
10
|
+
super html
|
11
|
+
@html.write '<p>'
|
12
|
+
@html.write txt
|
13
|
+
@html.write '</p>'
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Wizport: A gem for creating reports by specifying columns, groups, styles, etc.
|
4
|
+
# Copyright 2012 by sgzhe@163.com
|
5
|
+
|
6
|
+
module Wizport
|
7
|
+
module Pdf
|
8
|
+
class Catalog < Element
|
9
|
+
def initialize(id, ver)
|
10
|
+
super(id, ver)
|
11
|
+
dict '/Type', '/Catalog'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Wizport: A gem for creating reports by specifying columns, groups, styles, etc.
|
4
|
+
# Copyright 2012 by sgzhe@163.com
|
5
|
+
|
6
|
+
module Wizport
|
7
|
+
module Pdf
|
8
|
+
class Document < Element
|
9
|
+
attr_reader :objs
|
10
|
+
def initialize
|
11
|
+
@objs = []
|
12
|
+
@objs << @catalog = Catalog.new(make_id, 0)
|
13
|
+
@objs << @pages = Pages.new(make_id, 0)
|
14
|
+
@catalog.dict '/Pages', @pages
|
15
|
+
@objs << @page = Page.new(make_id, 0)
|
16
|
+
@page.dict '/Parent', @pages
|
17
|
+
end
|
18
|
+
|
19
|
+
def make_id
|
20
|
+
@objs.size + 1
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_pdf
|
24
|
+
builder = PdfBuilder.new
|
25
|
+
accept(builder)
|
26
|
+
builder.to_pdf
|
27
|
+
end
|
28
|
+
|
29
|
+
def save(file)
|
30
|
+
File.open(file, 'w') { |file| file.write(to_pdf) }
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -6,9 +6,34 @@
|
|
6
6
|
module Wizport
|
7
7
|
module Pdf
|
8
8
|
class Element
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
include Wizport::Visitable
|
10
|
+
attr_reader :id, :ver, :dicts
|
11
|
+
def initialize(id = nil,ver = 0, &block)
|
12
|
+
@id = id
|
13
|
+
@ver = ver
|
14
|
+
@dicts = {}
|
15
|
+
@streams = {}
|
16
|
+
block.arity<1 ? self.instance_eval(&block) : block.call(self) if block_given?
|
17
|
+
end
|
18
|
+
|
19
|
+
def type
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
def parent
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def dict(k, v)
|
28
|
+
@dicts[k] = v
|
29
|
+
end
|
30
|
+
|
31
|
+
def stream(k, v)
|
32
|
+
@streams[k] = v
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_s
|
36
|
+
"#{id} #{ver} R"
|
12
37
|
end
|
13
38
|
end
|
14
39
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Wizport: A gem for creating reports by specifying columns, groups, styles, etc.
|
4
|
+
# Copyright 2012 by sgzhe@163.com
|
5
|
+
|
6
|
+
module Wizport
|
7
|
+
module Pdf
|
8
|
+
class Page < Element
|
9
|
+
def initialize(id, ver)
|
10
|
+
super(id, ver)
|
11
|
+
dict '/Type', '/Page'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Wizport: A gem for creating reports by specifying columns, groups, styles, etc.
|
4
|
+
# Copyright 2012 by sgzhe@163.com
|
5
|
+
|
6
|
+
module Wizport
|
7
|
+
module Pdf
|
8
|
+
class Pages < Element
|
9
|
+
def initialize(id, ver)
|
10
|
+
super(id,ver)
|
11
|
+
dict '/Type', '/Pages'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Wizport: A gem for creating reports by specifying columns, groups, styles, etc.
|
4
|
+
# Copyright 2012 by sgzhe@163.com
|
5
|
+
|
6
|
+
require "stringio"
|
7
|
+
module Wizport
|
8
|
+
module Pdf
|
9
|
+
class PdfBuilder
|
10
|
+
include Wizport::Visitor
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@pdf = StringIO.new
|
14
|
+
end
|
15
|
+
|
16
|
+
visit Document do |obj|
|
17
|
+
xref = XRefTbl.new(obj.objs.size)
|
18
|
+
@pdf << "%PDF-1.4\n"
|
19
|
+
obj.objs.each do |o|
|
20
|
+
o.accept(self)
|
21
|
+
xref.add(@pdf.pos)
|
22
|
+
end
|
23
|
+
xref_pos = @pdf.pos
|
24
|
+
@pdf << xref.to_s
|
25
|
+
@pdf << "trailer <<\n"
|
26
|
+
@pdf << "/Size #{obj.objs.size}\n"
|
27
|
+
@pdf << "/Root #{obj.objs.first}\n"
|
28
|
+
@pdf << ">>\n"
|
29
|
+
@pdf << "startxref\n"
|
30
|
+
@pdf << "#{xref_pos}\n"
|
31
|
+
@pdf << "%%EOF\n"
|
32
|
+
end
|
33
|
+
|
34
|
+
visit Catalog do |obj|
|
35
|
+
@pdf << "#{obj.id} #{obj.ver} obj <<\n"
|
36
|
+
obj.dicts.each do |k, v|
|
37
|
+
@pdf << "#{k} #{v.to_s}\n"
|
38
|
+
end
|
39
|
+
@pdf << ">>endobj\n"
|
40
|
+
end
|
41
|
+
|
42
|
+
visit Pages do |obj|
|
43
|
+
@pdf << "#{obj.id} #{obj.ver} obj <<\n"
|
44
|
+
obj.dicts.each do |k, v|
|
45
|
+
@pdf << "#{k} #{v.to_s}\n"
|
46
|
+
end
|
47
|
+
@pdf << ">>endobj\n"
|
48
|
+
end
|
49
|
+
|
50
|
+
visit Page do |obj|
|
51
|
+
@pdf << "#{obj.id} #{obj.ver} obj <<\n"
|
52
|
+
obj.dicts.each do |k, v|
|
53
|
+
@pdf << "#{k} #{v.to_s}\n"
|
54
|
+
end
|
55
|
+
@pdf << ">>endobj\n"
|
56
|
+
end
|
57
|
+
|
58
|
+
def to_pdf
|
59
|
+
@pdf.string
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Wizport: A gem for creating reports by specifying columns, groups, styles, etc.
|
4
|
+
# Copyright 2012 by sgzhe@163.com
|
5
|
+
|
6
|
+
module Wizport
|
7
|
+
module Pdf
|
8
|
+
class XRefTbl
|
9
|
+
def initialize(count)
|
10
|
+
@tbl = StringIO.new
|
11
|
+
@tbl << "xref\n0 #{count}\n0000000000 65535 f \n";
|
12
|
+
end
|
13
|
+
|
14
|
+
def add(pos, ver = '00000', used = 'n')
|
15
|
+
@tbl.printf "%010d #{ver} #{used} \n", pos
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
@tbl.string
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/wizport/document/pdf.rb
CHANGED
@@ -16,7 +16,8 @@ module Wizport
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def table(rows,options={}, &block)
|
19
|
-
|
19
|
+
tbl = PdfTable.new(rows,&block)
|
20
|
+
@pdf.table(tbl.rows,options.merge({:width => @pdf.bounds.width}))
|
20
21
|
end
|
21
22
|
|
22
23
|
def make_table(rows)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Wizport: A gem for creating reports by specifying columns, groups, styles, etc.
|
4
|
+
# Copyright 2012 by sgzhe@163.com
|
5
|
+
|
6
|
+
module Wizport
|
7
|
+
module Document
|
8
|
+
class PdfTable
|
9
|
+
attr_accessor :rows
|
10
|
+
def initialize(rows = nil,&block)
|
11
|
+
@rows = rows || []
|
12
|
+
block.arity<1 ? self.instance_eval(&block) : block.call(self) if block_given?
|
13
|
+
end
|
14
|
+
|
15
|
+
def row(cells)
|
16
|
+
@rows << cells
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
data/lib/wizport/document/rtf.rb
CHANGED
@@ -19,12 +19,11 @@ module Wizport
|
|
19
19
|
r = rows.length
|
20
20
|
c = rows.first && rows.first.length
|
21
21
|
tbl = @rtf.table r, c
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
#end
|
22
|
+
rows.each_index do |row|
|
23
|
+
rows[row].each_index do |col|
|
24
|
+
tbl[row][col] << rows[row][col].to_s
|
25
|
+
end
|
26
|
+
end
|
28
27
|
tbl
|
29
28
|
end
|
30
29
|
|
data/lib/wizport/version.rb
CHANGED
data/lib/wizport.rb
CHANGED
@@ -2,8 +2,14 @@ require "prawn"
|
|
2
2
|
|
3
3
|
require "wizport/version"
|
4
4
|
|
5
|
+
require "wizport/document/pdf_table"
|
5
6
|
require "wizport/document/pdf"
|
6
7
|
|
8
|
+
require "wizport/document/html/element"
|
9
|
+
require "wizport/document/html/text"
|
10
|
+
require "wizport/document/html/table"
|
11
|
+
require "wizport/document/html/document"
|
12
|
+
|
7
13
|
require "wizport/visitor"
|
8
14
|
require "wizport/document/rtf/element"
|
9
15
|
require "wizport/document/rtf/plaintext"
|
@@ -13,9 +19,18 @@ require "wizport/document/rtf/text"
|
|
13
19
|
require "wizport/document/rtf/cell"
|
14
20
|
require "wizport/document/rtf/row"
|
15
21
|
require "wizport/document/rtf/table"
|
16
|
-
require "wizport/document/rtf/rtf_builder"
|
17
22
|
require "wizport/document/rtf/document"
|
18
23
|
require "wizport/document/rtf"
|
24
|
+
require "wizport/document/rtf/rtf_builder"
|
25
|
+
|
26
|
+
require "wizport/document/pdf/element"
|
27
|
+
require "wizport/document/pdf/catalog"
|
28
|
+
require "wizport/document/pdf/pages"
|
29
|
+
require "wizport/document/pdf/page"
|
30
|
+
require "wizport/document/pdf/document"
|
31
|
+
require "wizport/document/pdf/x_ref_tbl"
|
32
|
+
require "wizport/document/pdf/pdf_builder"
|
33
|
+
|
19
34
|
|
20
35
|
require "wizport/builder/pdf"
|
21
36
|
require "wizport/builder/rtf"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "../../../../spec/spec_helper"
|
4
|
+
|
5
|
+
describe Wizport::Html::Document do
|
6
|
+
|
7
|
+
it "should do something" do
|
8
|
+
html = Wizport::Html::Document.new
|
9
|
+
html.text "报表"
|
10
|
+
html.table [[1,2,3]] do
|
11
|
+
add_row [4,{content:'ss',colspan:2}]
|
12
|
+
end
|
13
|
+
|
14
|
+
p html.to_html
|
15
|
+
html.save('c:\h.html')
|
16
|
+
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "../../../../spec/spec_helper"
|
4
|
+
|
5
|
+
describe Wizport::Pdf::Document do
|
6
|
+
|
7
|
+
it "a simple example of pdf" do
|
8
|
+
pdf = Wizport::Pdf::Document.new
|
9
|
+
|
10
|
+
pdf.save('c:\t.pdf')
|
11
|
+
pdf.to_pdf.each_line do |line|
|
12
|
+
p line
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it "ss" do
|
17
|
+
str = StringIO.new
|
18
|
+
str << "hello"
|
19
|
+
p str.pos
|
20
|
+
printf("%010d", str.pos)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Wizport: A gem for creating reports by specifying columns, groups, styles, etc.
|
4
|
+
# Copyright 2012 by sgzhe@163.com
|
5
|
+
|
6
|
+
require "../../../spec/spec_helper"
|
7
|
+
|
8
|
+
describe "My behaviour" do
|
9
|
+
|
10
|
+
it "should do something" do
|
11
|
+
|
12
|
+
pdf = Wizport::Document::Pdf.new
|
13
|
+
pdf.text "hello sgz"
|
14
|
+
pdf.table([
|
15
|
+
["A", {:content => "2x1", :colspan => 2}, "B"],
|
16
|
+
[{:content => "1x2", :rowspan => 2}, "C", "D", "E"],
|
17
|
+
[{:content => "2x2", :colspan => 2, :rowspan => 2}, "F"]
|
18
|
+
]) do
|
19
|
+
row ["G", "H"]
|
20
|
+
end
|
21
|
+
pdf.save('c:/p.pdf')
|
22
|
+
end
|
23
|
+
end
|
@@ -7,7 +7,10 @@ describe Wizport::Rtf::Document do
|
|
7
7
|
it "a simple example of Rtf" do
|
8
8
|
rtf = Wizport::Rtf::Document.new
|
9
9
|
rtf.text "学生综合素质评价"
|
10
|
-
rtf.table [[
|
10
|
+
rtf.table [[{content:'s',rowspan:3},{content:'s',colspan:2},{content:'s',colspan:2},{content:'s',rowspan:2},"ss"],
|
11
|
+
[1,2,3,4,11,6],
|
12
|
+
[1,2,3,4,11,6],
|
13
|
+
[0,1,2,3,4,11,6]]
|
11
14
|
rtf.save('c:/r.rtf')
|
12
15
|
end
|
13
16
|
end
|
@@ -8,7 +8,7 @@ require "../../../spec/spec_helper"
|
|
8
8
|
describe Wizport::Rtf::Document do
|
9
9
|
|
10
10
|
it "a simple example of Rtf" do
|
11
|
-
rtf = Wizport::Rtf
|
11
|
+
rtf = Wizport::Document::Rtf.new
|
12
12
|
rtf.text "hello sgz"
|
13
13
|
rtf.table [[1,1,1,""],[1,1,1,2],[1,1,1,3]]
|
14
14
|
rtf.save('c:/r.rtf')
|
data/wizport.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
# specify any dependencies here; for example:
|
22
22
|
s.add_development_dependency "rspec"
|
23
|
-
s.add_runtime_dependency "prawn"
|
23
|
+
#s.add_runtime_dependency "prawn", :git => "git://github.com/sandal/prawn.git"
|
24
24
|
s.add_runtime_dependency "rtf"
|
25
25
|
|
26
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wizport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -27,22 +27,6 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: prawn
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
30
|
- !ruby/object:Gem::Dependency
|
47
31
|
name: rtf
|
48
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -83,8 +67,19 @@ files:
|
|
83
67
|
- lib/wizport/document/Rtf/spec.rb
|
84
68
|
- lib/wizport/document/Rtf/table.rb
|
85
69
|
- lib/wizport/document/Rtf/text.rb
|
70
|
+
- lib/wizport/document/html/document.rb
|
71
|
+
- lib/wizport/document/html/element.rb
|
72
|
+
- lib/wizport/document/html/table.rb
|
73
|
+
- lib/wizport/document/html/text.rb
|
86
74
|
- lib/wizport/document/pdf.rb
|
75
|
+
- lib/wizport/document/pdf/catalog.rb
|
76
|
+
- lib/wizport/document/pdf/document.rb
|
87
77
|
- lib/wizport/document/pdf/element.rb
|
78
|
+
- lib/wizport/document/pdf/page.rb
|
79
|
+
- lib/wizport/document/pdf/pages.rb
|
80
|
+
- lib/wizport/document/pdf/pdf_builder.rb
|
81
|
+
- lib/wizport/document/pdf/x_ref_tbl.rb
|
82
|
+
- lib/wizport/document/pdf_table.rb
|
88
83
|
- lib/wizport/document/rtf.rb
|
89
84
|
- lib/wizport/document/txt.rb
|
90
85
|
- lib/wizport/engine/active_source.rb
|
@@ -97,6 +92,9 @@ files:
|
|
97
92
|
- lib/wizport/version.rb
|
98
93
|
- lib/wizport/visitor.rb
|
99
94
|
- spec/spec_helper.rb
|
95
|
+
- spec/wizport/document/html/document_spec.rb
|
96
|
+
- spec/wizport/document/pdf/document_spec.rb
|
97
|
+
- spec/wizport/document/pdf_spec.rb
|
100
98
|
- spec/wizport/document/rtf/document_spec.rb
|
101
99
|
- spec/wizport/document/rtf/text_spec.rb
|
102
100
|
- spec/wizport/document/rtf_spec.rb
|