pdf_gen 0.7 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/base_region.rb +1 -1
- data/samples/div.rb +11 -1
- data/samples/div_illustration.rb +6 -4
- data/samples/headerfooter.rb +3 -3
- data/samples/simple.rb +3 -1
- data/samples/smart_table_image.rb +64 -0
- data/samples/table.rb +4 -4
- data/samples/table_illustration.rb +4 -4
- data/samples/tableindiv_ill.rb +5 -2
- metadata +4 -2
data/lib/base_region.rb
CHANGED
@@ -77,7 +77,7 @@ module PDFGen
|
|
77
77
|
|
78
78
|
def check_fit_in_height
|
79
79
|
if (self.height >= document.pdf.page_height-document.page_pad_top)
|
80
|
-
raise "
|
80
|
+
raise "There is too little space for this region on this page"
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
data/samples/div.rb
CHANGED
@@ -9,7 +9,17 @@ PDFGen::document PDF::Writer.new, 2.cm do
|
|
9
9
|
span :paddings => 0.5.cm, :border => true do
|
10
10
|
image image_data, :width => 5.cm
|
11
11
|
caption ' first '*50, :width => 3.cm
|
12
|
-
caption ' second '*
|
12
|
+
caption ' second '*50, :width => 3.cm
|
13
|
+
end
|
14
|
+
span :paddings => 0.5.cm, :border => true do
|
15
|
+
image image_data, :width => 5.cm
|
16
|
+
caption ' first '*50, :width => 3.cm
|
17
|
+
caption ' second '*50, :width => 3.cm
|
18
|
+
end
|
19
|
+
span :paddings => 0.5.cm, :border => true do
|
20
|
+
image image_data, :width => 5.cm
|
21
|
+
caption ' first '*50, :width => 3.cm
|
22
|
+
caption ' second '*50, :width => 3.cm
|
13
23
|
end
|
14
24
|
span :paddings => 0.5.cm, :border => true do
|
15
25
|
image image_data, :width => 5.cm
|
data/samples/div_illustration.rb
CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.expand_path(File.dirname(__FILE__) + "/../"))
|
|
2
2
|
require "lib/pdf_gen"
|
3
3
|
|
4
4
|
long_text = <<TEXT
|
5
|
-
|
5
|
+
A Software Requirements Specification (SRS) - a requirements
|
6
6
|
specification for a software system - is a complete description of the behavior
|
7
7
|
of a system to be developed. It includes a set of use cases that describe all
|
8
8
|
the interactions the users will have with the software.
|
@@ -12,17 +12,19 @@ In addition to use cases, the SRS also contains non-functional
|
|
12
12
|
which impose constraints on the design or implementation
|
13
13
|
(such as performance engineering requirements, quality standards,
|
14
14
|
or design constraints).
|
15
|
+
|
15
16
|
TEXT
|
16
17
|
PDFGen::document PDF::Writer.new, 2.cm do
|
17
18
|
caption ' Software Requirements Specification ', :text_color => Color::RGB::Grey,
|
18
19
|
:font_size => 16, :bold => true, :justification => :center
|
19
20
|
|
20
21
|
caption long_text,
|
21
|
-
:text_color => Color::RGB::Grey, :font_size => 12, :justification => :left
|
22
|
+
:text_color => Color::RGB::Grey, :font_size => 12, :justification => :left,
|
23
|
+
:pad_left => 2.5.cm, :pad_right => 2.cm
|
22
24
|
|
23
|
-
div :width =>
|
25
|
+
div :width => 20.cm, :horizontal_interval => 0.5.cm do
|
24
26
|
|
25
|
-
span :pad_left => 2.cm do
|
27
|
+
span :pad_left => 2.cm, :pad_top => 2.cm do
|
26
28
|
caption '1', :width => 2.cm
|
27
29
|
caption 'INTRODUCTION', :width => 12.cm
|
28
30
|
end
|
data/samples/headerfooter.rb
CHANGED
@@ -15,7 +15,7 @@ PDFGen::document PDF::Writer.new, 1.cm do
|
|
15
15
|
caption "This paper, copyright the IEEE, appears in IEEE Symposium on Security and Privacy 2004. IEEE Computer
|
16
16
|
Society Press, May 2004. This paper previously appeared as Johns Hopkins University Information Security
|
17
17
|
Institute Technical Report TR-2003-19, July 23, 2003.",
|
18
|
-
:width => av_width, :justification => :center, :pad_bottom =>
|
18
|
+
:width => av_width, :justification => :center, :pad_bottom => 1.5.cm,
|
19
19
|
:border => true, :border_bottom => false, :font_size => 9
|
20
20
|
end
|
21
21
|
end
|
@@ -23,8 +23,8 @@ Institute Technical Report TR-2003-19, July 23, 2003.",
|
|
23
23
|
body do
|
24
24
|
span do
|
25
25
|
caption "Analysis of an Electronic Voting System ",
|
26
|
-
:justification => :center, :pad_bottom => 1.
|
27
|
-
:border_left => true, :
|
26
|
+
:justification => :center, :pad_bottom => 1.cm, :border_right => true,
|
27
|
+
:border_left => true, :font_size => 16
|
28
28
|
end
|
29
29
|
|
30
30
|
span do
|
data/samples/simple.rb
CHANGED
@@ -2,6 +2,8 @@ $:.unshift(File.expand_path(File.dirname(__FILE__) + "/../"))
|
|
2
2
|
require "lib/pdf_gen"
|
3
3
|
|
4
4
|
PDFGen::document PDF::Writer.new, 2.cm do
|
5
|
-
|
5
|
+
span do
|
6
|
+
caption "text "*20, :width => 5.cm, :pad_bottom => 2.cm, :border => true
|
7
|
+
end
|
6
8
|
end.save("#{File.basename(__FILE__, ".rb")}.pdf")
|
7
9
|
|
@@ -0,0 +1,64 @@
|
|
1
|
+
$:.unshift(File.expand_path(File.dirname(__FILE__) + "/../"))
|
2
|
+
require "lib/pdf_gen"
|
3
|
+
|
4
|
+
|
5
|
+
PDFGen::document PDF::Writer.new, 1.cm do
|
6
|
+
|
7
|
+
|
8
|
+
table_data = {:columns => ['id', 'name', 'email', 'image'],
|
9
|
+
:body => [["1", "Test1_name", "lalala@mail.ru", "sampl1_1.png"],
|
10
|
+
["2", "Test2_name", "lalala@gmail.com", "sampl1_1.png"],
|
11
|
+
["3", "Test2_name", "lalala@gmail.com", "sampl1_1.png"],
|
12
|
+
["4", "Test2_name", "lalala@gmail.com", "sampl1_1.png"],
|
13
|
+
["5", "Test2_name", "lalala@gmail.com", "sampl1_1.png"],
|
14
|
+
["6", "Test2_name", "lalala@gmail.com", "sampl1_1.png"],
|
15
|
+
["7", "Test2_name", "lalala@gmail.com", "sampl1_1.png"],
|
16
|
+
["8", "Test2_name", "lalala@gmail.com", "sampl1_1.png"],
|
17
|
+
["9", "Test2_name", "lalala@gmail.com", "sampl1_1.png"],
|
18
|
+
["10", "Test3_name", "lll@mail.ru", "sampl1_1.png"]] }
|
19
|
+
|
20
|
+
div :pad_left => 2.cm, :pad_right => 1.5.cm do
|
21
|
+
table :data_source => table_data, :repeat_header_on_each_page => true,
|
22
|
+
:repeat_footer_on_each_page => true do
|
23
|
+
|
24
|
+
|
25
|
+
title do
|
26
|
+
caption " TABLE 1 ", :justification => :center
|
27
|
+
end
|
28
|
+
|
29
|
+
header do
|
30
|
+
row do
|
31
|
+
cell ds.columns[0]
|
32
|
+
cell ds.columns[1]
|
33
|
+
cell ds.columns[2]
|
34
|
+
cell ds.columns[3]
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
body do
|
40
|
+
ds.each do |datarow|
|
41
|
+
row do
|
42
|
+
cell datarow[0], :width => av_width / 4
|
43
|
+
cell datarow[1], :width => av_width / 4
|
44
|
+
cell datarow[2], :width => av_width / 4
|
45
|
+
cell( div :width => av_width / 4, :paddings => 0.2.cm, :border_left => true do
|
46
|
+
image(open(File.expand_path("#{datarow[3]}"), "rb") { |file| file.read },
|
47
|
+
:width => av_width*0.5)
|
48
|
+
end)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
footer do
|
54
|
+
span do
|
55
|
+
caption "footer", :width => av_width, :justification => :center
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
end.save("#{File.basename(__FILE__, ".rb")}.pdf")
|
64
|
+
|
data/samples/table.rb
CHANGED
@@ -7,14 +7,14 @@ PDFGen::document PDF::Writer.new, 2.cm do
|
|
7
7
|
div :paddings => 15 do
|
8
8
|
table do
|
9
9
|
title do
|
10
|
-
caption "<i>Table 1.1.</i> <b>Users</b>"
|
10
|
+
caption "<i>Table 1.1.</i> <b>Users</b>"
|
11
11
|
end
|
12
12
|
header do
|
13
13
|
span do
|
14
14
|
caption "name", :width => av_width/3
|
15
15
|
caption "Last name", :width => av_width/3
|
16
16
|
caption "Email", :width => av_width/3
|
17
|
-
elements :border => true
|
17
|
+
elements :border => true,:justification => :center
|
18
18
|
end
|
19
19
|
end
|
20
20
|
body do
|
@@ -22,13 +22,13 @@ PDFGen::document PDF::Writer.new, 2.cm do
|
|
22
22
|
caption "Valeriy", :width => av_width/3
|
23
23
|
caption "Sizov", :width => av_width/3
|
24
24
|
caption "example@gmail.com", :width => av_width/3
|
25
|
-
elements :border => true
|
25
|
+
elements :border => true
|
26
26
|
end
|
27
27
|
span do
|
28
28
|
caption "Dmitriy", :width => av_width/3
|
29
29
|
caption "Landberg", :width => av_width/3
|
30
30
|
caption "example1@gmail.com", :width => av_width/3
|
31
|
-
elements :border => true
|
31
|
+
elements :border => true
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -3,7 +3,7 @@ require "lib/pdf_gen"
|
|
3
3
|
|
4
4
|
|
5
5
|
PDFGen::document PDF::Writer.new, 1.cm do
|
6
|
-
div :
|
6
|
+
div :pad_left => 2.cm, :pad_right => 1.2.cm do
|
7
7
|
table do
|
8
8
|
title do
|
9
9
|
caption "Financial Report", :text_color => Color::RGB::Green,
|
@@ -13,8 +13,8 @@ PDFGen::document PDF::Writer.new, 1.cm do
|
|
13
13
|
header do
|
14
14
|
span do
|
15
15
|
caption "Characteristic",
|
16
|
-
:width => av_width / 8, :justification => :
|
17
|
-
:border => true, :font_size =>
|
16
|
+
:width => av_width / 8, :justification => :left,
|
17
|
+
:border => true, :font_size => 8
|
18
18
|
|
19
19
|
caption "2005",
|
20
20
|
:width => av_width / 8, :justification => :center,
|
@@ -174,4 +174,4 @@ PDFGen::document PDF::Writer.new, 1.cm do
|
|
174
174
|
end
|
175
175
|
end
|
176
176
|
end
|
177
|
-
end.save("#{File.basename(__FILE__, ".rb")}.pdf")
|
177
|
+
end.save("#{File.basename(__FILE__, ".rb")}.pdf")
|
data/samples/tableindiv_ill.rb
CHANGED
@@ -2,12 +2,13 @@ $:.unshift(File.expand_path(File.dirname(__FILE__) + "/../"))
|
|
2
2
|
require "lib/pdf_gen"
|
3
3
|
|
4
4
|
|
5
|
-
PDFGen::document PDF::Writer.new,
|
5
|
+
PDFGen::document PDF::Writer.new, 1.cm do
|
6
6
|
caption " SWOT analysis is a strategic planning method used to evaluate the Strengths, Weaknesses,
|
7
7
|
Opportunities, and Threats involved in a project or in a business venture. It involves specifying
|
8
8
|
the objective of the business venture or project and identifying the internal and external factors that
|
9
9
|
are favorable and unfavorable to achieve that objective. The technique is credited to Albert Humphrey,
|
10
10
|
who led a convention at Stanford University in the 1960s and 1970s using data from Fortune 500 companies. ",
|
11
|
+
:pad_left => 2.cm, :pad_right => 1.cm, :pad_top => 0.5.cm, :pad_bottom => 0.5.cm,
|
11
12
|
:justification => :left, :font_size => 12
|
12
13
|
|
13
14
|
caption " A SWOT analysis must first start with defining a desired end state or objective.
|
@@ -20,9 +21,10 @@ used in academia to highlight and identify strengths, weaknesses, opportunities
|
|
20
21
|
It is particularly helpful in identifying areas for development. The aim of any SWOT analysis is to identify
|
21
22
|
the key internal and external factors that are important to achieving the objective. These come from within the
|
22
23
|
company's unique value chain. ",
|
24
|
+
:pad_left => 2.cm, :pad_right => 1.cm, :pad_top => 0.5.cm, :pad_bottom => 0.5.cm,
|
23
25
|
:justification => :left, :font_size => 12
|
24
26
|
|
25
|
-
div :width =>
|
27
|
+
div :width => 17.cm, :pad_left => 5.cm do
|
26
28
|
|
27
29
|
table do
|
28
30
|
title do
|
@@ -94,6 +96,7 @@ weak opportunities may appear to balance strong threats. It is prudent not to el
|
|
94
96
|
quickly any candidate SWOT entry. The importance of individual SWOTs will be revealed by
|
95
97
|
the value of the strategies it generates. A SWOT item that produces valuable strategies is important.
|
96
98
|
A SWOT item that generates no strategies is not important. ",
|
99
|
+
:pad_left => 2.cm, :pad_right => 1.cm, :pad_top => 0.5.cm, :pad_bottom => 0.5.cm,
|
97
100
|
:justification => :left, :font_size => 12
|
98
101
|
|
99
102
|
end.save("#{File.basename(__FILE__, ".rb")}.pdf")
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdf_gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 0.7.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Sphere Consulting Inc.
|
@@ -78,6 +79,7 @@ files:
|
|
78
79
|
- samples/sampl1_3.png
|
79
80
|
- samples/simple.rb
|
80
81
|
- samples/smart_table.rb
|
82
|
+
- samples/smart_table_image.rb
|
81
83
|
- samples/span.rb
|
82
84
|
- samples/spanindiv_ill.rb
|
83
85
|
- samples/span_illustration.rb
|