prawn 1.0.0.rc1 → 1.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +18 -0
- data/README.md +5 -3
- data/Rakefile +8 -14
- data/data/pdfs/nested_pages.pdf +13 -13
- data/lib/prawn.rb +3 -1
- data/lib/prawn/compatibility.rb +46 -10
- data/lib/prawn/core.rb +3 -1
- data/lib/prawn/core/document_state.rb +2 -1
- data/lib/prawn/core/object_store.rb +61 -5
- data/lib/prawn/core/page.rb +3 -6
- data/lib/prawn/core/pdf_object.rb +21 -4
- data/lib/prawn/core/reference.rb +6 -2
- data/lib/prawn/core/text.rb +4 -4
- data/lib/prawn/core/text/formatted/line_wrap.rb +23 -8
- data/lib/prawn/document.rb +21 -15
- data/lib/prawn/document/bounding_box.rb +3 -3
- data/lib/prawn/document/column_box.rb +22 -4
- data/lib/prawn/document/snapshot.rb +1 -1
- data/lib/prawn/encoding.rb +1 -1
- data/lib/prawn/errors.rb +4 -0
- data/lib/prawn/font.rb +1 -1
- data/lib/prawn/font/afm.rb +30 -72
- data/lib/prawn/font/ttf.rb +6 -33
- data/lib/prawn/graphics.rb +148 -23
- data/lib/prawn/graphics/color.rb +8 -1
- data/lib/prawn/graphics/patterns.rb +137 -0
- data/lib/prawn/images.rb +25 -19
- data/lib/prawn/images/jpg.rb +4 -4
- data/lib/prawn/images/png.rb +18 -12
- data/lib/prawn/security.rb +6 -4
- data/lib/prawn/soft_mask.rb +94 -0
- data/lib/prawn/table.rb +136 -31
- data/lib/prawn/table/cell.rb +260 -29
- data/lib/prawn/table/cell/span_dummy.rb +88 -0
- data/lib/prawn/table/cell/text.rb +36 -14
- data/lib/prawn/table/cells.rb +91 -41
- data/lib/prawn/text.rb +3 -2
- data/lib/prawn/text/formatted/box.rb +14 -5
- data/lib/prawn/text/formatted/fragment.rb +33 -22
- data/lib/prawn/text/formatted/parser.rb +5 -2
- data/lib/prawn/utilities.rb +44 -0
- data/manual/basic_concepts/adding_pages.rb +27 -0
- data/manual/basic_concepts/basic_concepts.rb +34 -0
- data/manual/basic_concepts/creation.rb +39 -0
- data/manual/basic_concepts/cursor.rb +33 -0
- data/manual/basic_concepts/measurement.rb +25 -0
- data/manual/basic_concepts/origin.rb +38 -0
- data/manual/basic_concepts/other_cursor_helpers.rb +40 -0
- data/manual/bounding_box/bounding_box.rb +39 -0
- data/manual/bounding_box/bounds.rb +49 -0
- data/manual/bounding_box/canvas.rb +24 -0
- data/manual/bounding_box/creation.rb +23 -0
- data/manual/bounding_box/indentation.rb +46 -0
- data/manual/bounding_box/nesting.rb +45 -0
- data/manual/bounding_box/russian_boxes.rb +40 -0
- data/manual/bounding_box/stretchy.rb +31 -0
- data/manual/document_and_page_options/background.rb +27 -0
- data/manual/document_and_page_options/document_and_page_options.rb +31 -0
- data/manual/document_and_page_options/metadata.rb +23 -0
- data/manual/document_and_page_options/page_margins.rb +38 -0
- data/manual/document_and_page_options/page_size.rb +34 -0
- data/manual/example_file.rb +116 -0
- data/manual/example_helper.rb +430 -0
- data/manual/example_package.rb +53 -0
- data/manual/example_section.rb +46 -0
- data/manual/graphics/circle_and_ellipse.rb +22 -0
- data/manual/graphics/color.rb +24 -0
- data/manual/graphics/common_lines.rb +28 -0
- data/manual/graphics/fill_and_stroke.rb +42 -0
- data/manual/graphics/fill_rules.rb +37 -0
- data/manual/graphics/gradients.rb +37 -0
- data/manual/graphics/graphics.rb +58 -0
- data/manual/graphics/helper.rb +17 -0
- data/manual/graphics/line_width.rb +35 -0
- data/manual/graphics/lines_and_curves.rb +41 -0
- data/manual/graphics/polygon.rb +29 -0
- data/manual/graphics/rectangle.rb +21 -0
- data/manual/graphics/rotate.rb +28 -0
- data/manual/graphics/scale.rb +41 -0
- data/manual/graphics/soft_masks.rb +46 -0
- data/manual/graphics/stroke_cap.rb +31 -0
- data/manual/graphics/stroke_dash.rb +43 -0
- data/manual/graphics/stroke_join.rb +30 -0
- data/manual/graphics/translate.rb +29 -0
- data/manual/graphics/transparency.rb +35 -0
- data/manual/images/absolute_position.rb +23 -0
- data/manual/images/fit.rb +21 -0
- data/manual/images/horizontal.rb +25 -0
- data/manual/images/images.rb +40 -0
- data/manual/images/plain_image.rb +18 -0
- data/manual/images/scale.rb +22 -0
- data/manual/images/vertical.rb +28 -0
- data/manual/images/width_and_height.rb +25 -0
- data/manual/layout/boxes.rb +27 -0
- data/manual/layout/content.rb +25 -0
- data/manual/layout/layout.rb +28 -0
- data/manual/layout/simple_grid.rb +23 -0
- data/manual/manual/cover.rb +26 -0
- data/manual/manual/foreword.rb +13 -0
- data/manual/manual/how_to_read_this_manual.rb +41 -0
- data/manual/manual/manual.rb +36 -0
- data/manual/outline/add_subsection_to.rb +61 -0
- data/manual/outline/insert_section_after.rb +47 -0
- data/manual/outline/outline.rb +32 -0
- data/manual/outline/sections_and_pages.rb +67 -0
- data/manual/repeatable_content/page_numbering.rb +54 -0
- data/manual/repeatable_content/repeatable_content.rb +31 -0
- data/manual/repeatable_content/repeater.rb +55 -0
- data/manual/repeatable_content/stamp.rb +41 -0
- data/manual/security/encryption.rb +31 -0
- data/manual/security/permissions.rb +38 -0
- data/manual/security/security.rb +28 -0
- data/manual/syntax_highlight.rb +52 -0
- data/manual/table/basic_block.rb +53 -0
- data/manual/table/before_rendering_page.rb +26 -0
- data/manual/table/cell_border_lines.rb +24 -0
- data/manual/table/cell_borders_and_bg.rb +31 -0
- data/manual/table/cell_dimensions.rb +30 -0
- data/manual/table/cell_text.rb +38 -0
- data/manual/table/column_widths.rb +30 -0
- data/manual/table/content_and_subtables.rb +39 -0
- data/manual/table/creation.rb +27 -0
- data/manual/table/filtering.rb +36 -0
- data/manual/table/flow_and_header.rb +17 -0
- data/manual/table/image_cells.rb +33 -0
- data/manual/table/position.rb +29 -0
- data/manual/table/row_colors.rb +20 -0
- data/manual/table/span.rb +30 -0
- data/manual/table/style.rb +22 -0
- data/manual/table/table.rb +52 -0
- data/manual/table/width.rb +27 -0
- data/manual/templates/full_template.rb +23 -0
- data/manual/templates/page_template.rb +47 -0
- data/manual/templates/templates.rb +26 -0
- data/manual/text/alignment.rb +44 -0
- data/manual/text/color.rb +24 -0
- data/manual/text/column_box.rb +32 -0
- data/manual/text/fallback_fonts.rb +37 -0
- data/manual/text/font.rb +41 -0
- data/manual/text/font_size.rb +45 -0
- data/manual/text/font_style.rb +23 -0
- data/manual/text/formatted_callbacks.rb +60 -0
- data/manual/text/formatted_text.rb +50 -0
- data/manual/text/free_flowing_text.rb +51 -0
- data/manual/text/group.rb +29 -0
- data/manual/text/inline.rb +43 -0
- data/manual/text/kerning_and_character_spacing.rb +39 -0
- data/manual/text/leading.rb +25 -0
- data/manual/text/line_wrapping.rb +41 -0
- data/manual/text/paragraph_indentation.rb +26 -0
- data/manual/text/positioned_text.rb +38 -0
- data/manual/text/registering_families.rb +48 -0
- data/manual/text/rendering_and_color.rb +37 -0
- data/manual/text/right_to_left_text.rb +43 -0
- data/manual/text/rotation.rb +43 -0
- data/manual/text/single_usage.rb +37 -0
- data/manual/text/text.rb +75 -0
- data/manual/text/text_box_excess.rb +32 -0
- data/manual/text/text_box_extensions.rb +45 -0
- data/manual/text/text_box_overflow.rb +44 -0
- data/manual/text/utf8.rb +28 -0
- data/manual/text/win_ansi_charset.rb +59 -0
- data/prawn.gemspec +10 -7
- data/spec/bounding_box_spec.rb +107 -17
- data/spec/cell_spec.rb +66 -40
- data/spec/column_box_spec.rb +33 -0
- data/spec/document_spec.rb +45 -24
- data/spec/extensions/encoding_helpers.rb +6 -0
- data/spec/extensions/mocha.rb +1 -0
- data/spec/font_spec.rb +71 -53
- data/spec/formatted_text_arranger_spec.rb +19 -19
- data/spec/formatted_text_box_spec.rb +16 -16
- data/spec/formatted_text_fragment_spec.rb +6 -6
- data/spec/graphics_spec.rb +96 -31
- data/spec/grid_spec.rb +2 -2
- data/spec/images_spec.rb +18 -10
- data/spec/jpg_spec.rb +1 -1
- data/spec/line_wrap_spec.rb +14 -14
- data/spec/measurement_units_spec.rb +2 -2
- data/spec/name_tree_spec.rb +6 -6
- data/spec/object_store_spec.rb +17 -17
- data/spec/outline_spec.rb +35 -17
- data/spec/pdf_object_spec.rb +3 -1
- data/spec/png_spec.rb +22 -19
- data/spec/reference_spec.rb +24 -1
- data/spec/repeater_spec.rb +9 -9
- data/spec/security_spec.rb +3 -3
- data/spec/snapshot_spec.rb +3 -3
- data/spec/soft_mask_spec.rb +117 -0
- data/spec/span_spec.rb +4 -4
- data/spec/spec_helper.rb +12 -6
- data/spec/stamp_spec.rb +12 -12
- data/spec/stroke_styles_spec.rb +5 -5
- data/spec/table_spec.rb +458 -88
- data/spec/template_spec.rb +108 -54
- data/spec/text_at_spec.rb +17 -17
- data/spec/text_box_spec.rb +76 -45
- data/spec/text_rendering_mode_spec.rb +5 -5
- data/spec/text_spacing_spec.rb +4 -4
- data/spec/text_spec.rb +44 -40
- metadata +419 -250
- data/lib/prawn/graphics/gradient.rb +0 -84
- data/lib/prawn/security/arcfour.rb +0 -51
@@ -1,84 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# gradient.rb : Implements axial gradient
|
4
|
-
#
|
5
|
-
# Contributed by Wojciech Piekutowski. November, 2009
|
6
|
-
#
|
7
|
-
# This is free software. Please see the LICENSE and COPYING files for details.
|
8
|
-
#
|
9
|
-
module Prawn
|
10
|
-
module Graphics
|
11
|
-
module Gradient
|
12
|
-
# Sets the fill gradient from color1 to color2.
|
13
|
-
#
|
14
|
-
# It accepts CMYK and RGB colors, like #fill_color. Both colors must be
|
15
|
-
# of the same type.
|
16
|
-
#
|
17
|
-
# point, width and height define a bounding box in which the gradient
|
18
|
-
# will be rendered. For example, if you want to have page full of text
|
19
|
-
# with gradually changing color:
|
20
|
-
#
|
21
|
-
# pdf.fill_gradient [0, pdf.bounds.height], pdf.bounds.width,
|
22
|
-
# pdf.bounds.height, 'FF0000', '0000FF'
|
23
|
-
# pdf.text 'lots of text'*1000
|
24
|
-
#
|
25
|
-
# <tt>:stroke_bounds</tt> - draw gradient bounds
|
26
|
-
def fill_gradient(point, width, height, color1, color2, options = {})
|
27
|
-
set_gradient(:fill, point, width, height, color1, color2, options)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Sets the stroke gradient from color1 to color2.
|
31
|
-
#
|
32
|
-
# See #fill_gradient for details.
|
33
|
-
def stroke_gradient(point, width, height, color1, color2, options = {})
|
34
|
-
set_gradient(:stroke, point, width, height, color1, color2, options)
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def set_gradient(type, point, width, height, color1, color2, options)
|
40
|
-
if options[:stroke_bounds]
|
41
|
-
stroke_color 0, 0, 0, 100
|
42
|
-
stroke_rectangle point, width, height
|
43
|
-
end
|
44
|
-
|
45
|
-
if color_type(color1) != color_type(color2)
|
46
|
-
raise ArgumentError, 'both colors must be of the same type: RGB or CMYK'
|
47
|
-
end
|
48
|
-
|
49
|
-
process_color color1
|
50
|
-
process_color color2
|
51
|
-
|
52
|
-
shader = ref!({
|
53
|
-
:FunctionType => 2,
|
54
|
-
:Domain => [0.0, 1.0],
|
55
|
-
:C0 => normalize_color(color1),
|
56
|
-
:C1 => normalize_color(color2),
|
57
|
-
:N => 1,
|
58
|
-
})
|
59
|
-
|
60
|
-
shading = ref!({
|
61
|
-
:ShadingType => 2, # axial shading
|
62
|
-
:ColorSpace => color_type(color1) == :RGB ? :DeviceRGB : :DeviceCMYK,
|
63
|
-
:Coords => [0.0, 0.0, 1.0, 0.0],
|
64
|
-
:Function => shader,
|
65
|
-
:Extend => [true, true],
|
66
|
-
})
|
67
|
-
|
68
|
-
x, y = *point
|
69
|
-
shading_pattern = ref!({
|
70
|
-
:PatternType => 2, # shading pattern
|
71
|
-
:Shading => shading,
|
72
|
-
:Matrix => [0,-height, -width, 0, x, y],
|
73
|
-
})
|
74
|
-
|
75
|
-
patterns = page.resources[:Pattern] ||= {}
|
76
|
-
id = patterns.empty? ? 'SP1' : patterns.keys.sort.last.succ
|
77
|
-
patterns[id] = shading_pattern
|
78
|
-
|
79
|
-
set_color type, id, :pattern => true
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# Implementation of the "ARCFOUR" algorithm ("alleged RC4 (tm)"). Implemented
|
2
|
-
# as described at:
|
3
|
-
# http://www.mozilla.org/projects/security/pki/nss/draft-kaukonen-cipher-arcfour-03.txt
|
4
|
-
#
|
5
|
-
# "RC4" is a trademark of RSA Data Security, Inc.
|
6
|
-
#
|
7
|
-
# Copyright August 2009, Brad Ediger. All Rights Reserved.
|
8
|
-
#
|
9
|
-
# This is free software. Please see the LICENSE and COPYING files for details.
|
10
|
-
|
11
|
-
class Arcfour
|
12
|
-
def initialize(key)
|
13
|
-
# Convert string key to Array of integers
|
14
|
-
key = key.unpack('c*') if key.is_a?(String)
|
15
|
-
|
16
|
-
# 1. Allocate an 256 element array of 8 bit bytes to be used as an S-box
|
17
|
-
# 2. Initialize the S-box. Fill each entry first with it's index
|
18
|
-
@sbox = (0..255).to_a
|
19
|
-
|
20
|
-
# 3. Fill another array of the same size (256) with the key, repeating
|
21
|
-
# bytes as necessary.
|
22
|
-
s2 = []
|
23
|
-
while s2.length < 256
|
24
|
-
s2 += key
|
25
|
-
end
|
26
|
-
s2 = s2[0, 256]
|
27
|
-
|
28
|
-
# 4. Set j to zero and initialize the S-box
|
29
|
-
j = 0
|
30
|
-
(0..255).each do |i|
|
31
|
-
j = (j + @sbox[i] + s2[i]) % 256
|
32
|
-
@sbox[i], @sbox[j] = @sbox[j], @sbox[i]
|
33
|
-
end
|
34
|
-
|
35
|
-
@i = @j = 0
|
36
|
-
end
|
37
|
-
|
38
|
-
def encrypt(string)
|
39
|
-
string.unpack('c*').map{|byte| byte ^ key_byte}.pack('c*')
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
# Produces the next byte of key material in the stream (3.2 Stream Generation)
|
45
|
-
def key_byte
|
46
|
-
@i = (@i + 1) % 256
|
47
|
-
@j = (@j + @sbox[@i]) % 256
|
48
|
-
@sbox[@i], @sbox[@j] = @sbox[@j], @sbox[@i]
|
49
|
-
@sbox[(@sbox[@i] + @sbox[@j]) % 256]
|
50
|
-
end
|
51
|
-
end
|