mack-pdf_writer 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/lib/gems/archive-tar-minitar-0.5.2/bin/minitar +27 -0
  2. data/lib/gems/archive-tar-minitar-0.5.2/lib/archive/tar/minitar/command.rb +814 -0
  3. data/lib/gems/archive-tar-minitar-0.5.2/lib/archive/tar/minitar.rb +979 -0
  4. data/lib/gems/color-1.4.0/lib/color/cmyk.rb +281 -0
  5. data/lib/gems/color-1.4.0/lib/color/css.rb +30 -0
  6. data/lib/gems/color-1.4.0/lib/color/grayscale.rb +214 -0
  7. data/lib/gems/color-1.4.0/lib/color/hsl.rb +223 -0
  8. data/lib/gems/color-1.4.0/lib/color/palette/adobecolor.rb +274 -0
  9. data/lib/gems/color-1.4.0/lib/color/palette/gimp.rb +118 -0
  10. data/lib/gems/color-1.4.0/lib/color/palette/monocontrast.rb +182 -0
  11. data/lib/gems/color-1.4.0/lib/color/palette.rb +18 -0
  12. data/lib/gems/color-1.4.0/lib/color/rgb/metallic.rb +45 -0
  13. data/lib/gems/color-1.4.0/lib/color/rgb-colors.rb +357 -0
  14. data/lib/gems/color-1.4.0/lib/color/rgb.rb +455 -0
  15. data/lib/gems/color-1.4.0/lib/color/yiq.rb +86 -0
  16. data/lib/gems/color-1.4.0/lib/color.rb +147 -0
  17. data/lib/gems/pdf-writer-1.1.8/bin/techbook +24 -0
  18. data/lib/gems/pdf-writer-1.1.8/lib/pdf/charts/stddev.rb +430 -0
  19. data/lib/gems/pdf-writer-1.1.8/lib/pdf/charts.rb +13 -0
  20. data/lib/gems/pdf-writer-1.1.8/lib/pdf/math.rb +108 -0
  21. data/lib/gems/pdf-writer-1.1.8/lib/pdf/quickref.rb +332 -0
  22. data/lib/gems/pdf-writer-1.1.8/lib/pdf/simpletable.rb +947 -0
  23. data/lib/gems/pdf-writer-1.1.8/lib/pdf/techbook.rb +901 -0
  24. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/arc4.rb +63 -0
  25. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fontmetrics.rb +203 -0
  26. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fonts/Courier-Bold.afm +342 -0
  27. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fonts/Courier-BoldOblique.afm +342 -0
  28. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fonts/Courier-Oblique.afm +342 -0
  29. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fonts/Courier.afm +342 -0
  30. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fonts/Helvetica-Bold.afm +2827 -0
  31. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fonts/Helvetica-BoldOblique.afm +2827 -0
  32. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fonts/Helvetica-Oblique.afm +3051 -0
  33. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fonts/Helvetica.afm +3051 -0
  34. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fonts/MustRead.html +19 -0
  35. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fonts/Symbol.afm +213 -0
  36. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fonts/Times-Bold.afm +2588 -0
  37. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fonts/Times-BoldItalic.afm +2384 -0
  38. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fonts/Times-Italic.afm +2667 -0
  39. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fonts/Times-Roman.afm +2419 -0
  40. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/fonts/ZapfDingbats.afm +225 -0
  41. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/graphics/imageinfo.rb +365 -0
  42. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/graphics.rb +813 -0
  43. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/lang/en.rb +99 -0
  44. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/lang.rb +43 -0
  45. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/action.rb +35 -0
  46. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/annotation.rb +42 -0
  47. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/catalog.rb +39 -0
  48. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/contents.rb +65 -0
  49. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/destination.rb +40 -0
  50. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/encryption.rb +53 -0
  51. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/font.rb +72 -0
  52. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/fontdescriptor.rb +34 -0
  53. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/fontencoding.rb +40 -0
  54. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/image.rb +304 -0
  55. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/info.rb +51 -0
  56. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/outline.rb +30 -0
  57. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/outlines.rb +30 -0
  58. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/page.rb +195 -0
  59. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/pages.rb +115 -0
  60. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/procset.rb +46 -0
  61. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/viewerpreferences.rb +74 -0
  62. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object.rb +23 -0
  63. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb +58 -0
  64. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/oreader.rb +25 -0
  65. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/state.rb +48 -0
  66. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer/strokestyle.rb +138 -0
  67. data/lib/gems/pdf-writer-1.1.8/lib/pdf/writer.rb +2729 -0
  68. data/lib/gems/transaction-simple-1.4.0/lib/transaction/simple/group.rb +146 -0
  69. data/lib/gems/transaction-simple-1.4.0/lib/transaction/simple/threadsafe/group.rb +36 -0
  70. data/lib/gems/transaction-simple-1.4.0/lib/transaction/simple/threadsafe.rb +68 -0
  71. data/lib/gems/transaction-simple-1.4.0/lib/transaction/simple.rb +486 -0
  72. data/lib/gems.rb +13 -0
  73. data/lib/mack-pdf_writer.rb +2 -0
  74. metadata +111 -16
@@ -0,0 +1,99 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
+ # for full licensing information.
8
+ #
9
+ # $Id: en.rb 134 2005-08-25 03:38:06Z austin $
10
+ #++
11
+ # PDF::Writer::Lang::EN is the English-language output module. It contains a
12
+ # hash, @message, that contains the messages that may be reported by any
13
+ # method in the PDF library. The messages are identified by a Symbol.
14
+ #
15
+ # <b>Symbol</b>:: <b>Meaning</b>
16
+ # <b>:uri_09x</b>:: URIs must be HTTP or FTP URIs in this version of RSS.
17
+ module PDF::Writer::Lang::EN
18
+ @message = {
19
+ :invalid_pos => ":pos must be either :before or :after.",
20
+ :req_FPXO => "Pages#<< requires a PDF::Writer::Page, PDF::Writer::Font, or PDF::Writer::ExternalObject.",
21
+ :req_FPXOH => "Pages#add requires a PDF::Writer::Page, PDF::Writer::Font, PDF::Writer::ExternalObject, or Hash.",
22
+ :text_width_parameters_reversed => <<-EOS,
23
+ %s
24
+ As of PDF::Writer 1.1, the signature for #text_width and #text_line_width
25
+ is (text, size), not (size, text). It appears that the old version is still
26
+ in use in your code. Please change it.
27
+ EOS
28
+ :add_text_parameters_reversed => <<-EOS,
29
+ %s
30
+ As of PDF::Writer 1.1, the signature for #add_text is (x, y, text, size,
31
+ angle, word_space_adjust), not (x, y, size, text, angle, word_space_adjust).
32
+ It appears that the old version is still in use in your code. Please change
33
+ it.
34
+ EOS
35
+ :add_textw_parameters_reversed => <<-EOS,
36
+ %s
37
+ As of PDF::Writer 1.1, the signature for #add_text_wrap is (x, y, text,
38
+ size, justification, angle, test), not (x, y, size, text, justification,
39
+ angle, test). It appears that the old version is still in use in your
40
+ code. Please change it.
41
+ EOS
42
+ :png_invalid_header => "Invalid PNG header.",
43
+ :png_unsupp_compres => "Unsupported PNG compression method.",
44
+ :png_unsupp_filter => "Unsupported PNG filter method.",
45
+ :png_header_missing => "PNG information header is missing.",
46
+ :png_8bit_colour => "Only PNG colour depths of 8 bits or less are supported.",
47
+ :png_interlace => "Interlaced PNG images are not currently supported.",
48
+ :png_alpha_trans => "PNG alpha channel transparency is not supported; only palette transparency is supported.",
49
+ :data_must_be_array => "The table data is not an Array. (Temporary limitation.)",
50
+ :columns_unspecified => "Columns are unspecified. They must be data[0] and be an array.",
51
+ :no_zlib_no_compress => "Could not load Zlib. PDF compression is disabled.",
52
+ :ttf_licence_no_embedding => "The TrueType font %1s has a licence that does not allow for embedding.",
53
+ :simpletable_columns_undefined => "Columns are undefined for table.",
54
+ :simpletable_data_empty => "Table data is empty.",
55
+ :techbook_eval_exception => <<-EOS,
56
+
57
+ Error in document around line %d:
58
+ %s
59
+ Backtrace:
60
+ %s
61
+ EOS
62
+ :techbook_bad_columns_directive => "Invalid argument to directive .columns: %s",
63
+ :techbook_cannot_find_document => "Error: cannot find a document.",
64
+ :techbook_using_default_doc => "Using default document '%s'.",
65
+ :techbook_using_cached_doc => "Using cached document '%s'...",
66
+ :techbook_regenerating => "Cached document is older than source document. Regenerating.",
67
+ :techbook_ignoring_cache => "Ignoring cached document.",
68
+ :techbook_unknown_xref => "Unknown cross-reference %s.",
69
+ :techbook_code_not_empty => "Code is not empty:",
70
+ :techbook_usage_banner => "Usage: %s [options] [INPUT FILE]",
71
+ :techbook_usage_banner_1 => [
72
+ "INPUT FILE, if not specified, will be 'manual.pwd', either in the",
73
+ "current directory or relative to this file.",
74
+ ""
75
+ ],
76
+ :techbook_help_force_regen => [
77
+ "Forces the regeneration of the document,",
78
+ "ignoring the cached document version."
79
+ ],
80
+ :techbook_help_no_cache => [
81
+ "Disables generated document caching.",
82
+ ],
83
+ :techbook_help_compress => [
84
+ "Compresses the resulting PDF.",
85
+ ],
86
+ :techbook_help_help => [
87
+ "Shows this text.",
88
+ ],
89
+ :techbook_exception => "Exception %1s around line %2d.",
90
+ :C_callback_form_error => "Stand-alone callbacks must be of the form <C:callback />.",
91
+ :c_callback_form_error => "Paired callbacks must be of the form <c:callback>...</c:callback>.",
92
+ :callback_warning => "Unknown %1s callback: '%2s'. Ignoring.",
93
+ :charts_stddev_data_empty => "Charts::StdDev data is empty.",
94
+ :charts_stddev_scale_norange => "Charts::StdDev::Scale has no range.",
95
+ :charts_stddev_scale_nostep => "Charts::StdDev::Scale has no step.",
96
+ }
97
+
98
+ PDF::Writer::Lang.language = self
99
+ end
@@ -0,0 +1,43 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
+ # for full licensing information.
8
+ #
9
+ # $Id: lang.rb 57 2005-05-18 11:57:58Z austin $
10
+ #++
11
+
12
+ module PDF::Writer::Lang
13
+ @message = {}
14
+
15
+ class << self
16
+ # PDF::Writer is fully internationalized. This module method sets the
17
+ # error messages to the specified language Module. The language Module
18
+ # must have a constant Hash called +Message+ containing a set of
19
+ # symbols and localized versions of the messages associated with them.
20
+ #
21
+ # If the file 'pdf/writer/lang/es' contains the module
22
+ # <tt>PDF::Writer::Lang::ES</tt>, the error messages for PDF could be
23
+ # localized to Espa�ol thus:
24
+ #
25
+ # require 'pdf/writer'
26
+ # require 'pdf/writer/lang/es'
27
+ #
28
+ # Localization is module-global; in a multithreaded program, all
29
+ # threads will use the current language's messages.
30
+ #
31
+ # See PDF::Writer::Lang::EN for more information.
32
+ attr_accessor :language
33
+ def language=(ll) #:nodoc:
34
+ @language = ll
35
+ @message.replace ll.instance_variable_get('@message')
36
+ end
37
+
38
+ # Looks up the mesasge
39
+ def [](message_id)
40
+ @message[message_id]
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,35 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
+ # for full licensing information.
8
+ #
9
+ # $Id: action.rb 188 2007-12-11 07:14:58Z sandal $
10
+ #++
11
+ # An action object, used to link to URLS initially
12
+ class PDF::Writer::Object::Action < PDF::Writer::Object
13
+ def initialize(parent, label, type = "URI")
14
+ super(parent)
15
+
16
+ @type = type
17
+ @label = label
18
+ raise TypeError if @label.nil?
19
+ end
20
+
21
+ attr_accessor :type
22
+ attr_accessor :label
23
+
24
+ def to_s
25
+ res = "\n#{@oid} 0 obj\n<< /Type /Action"
26
+ if @type == :ilink
27
+ res << "\n/S /GoTo\n/D #{@parent.destinations[@label].oid} 0 R"
28
+ elsif @type == 'URI'
29
+ res << "\n/S /URI\n/URI ("
30
+ res << PDF::Writer.escape(@label)
31
+ res << ")\n"
32
+ end
33
+ res << ">>\nendobj"
34
+ end
35
+ end
@@ -0,0 +1,42 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
+ # for full licensing information.
8
+ #
9
+ # $Id: annotation.rb 50 2005-05-16 03:59:21Z austin $
10
+ #++
11
+ # An annotation object, this will add an annotation to the current page.
12
+ # initially will support just link annotations.
13
+ class PDF::Writer::Object::Annotation < PDF::Writer::Object
14
+ TYPES = [:link, :ilink]
15
+
16
+ def initialize(parent, type, rect, label)
17
+ super(parent)
18
+
19
+ @type = type
20
+ @rect = rect
21
+
22
+ case @type
23
+ when :link
24
+ @action = PDF::Writer::Object::Action.new(parent, label)
25
+ when :ilink
26
+ @action = PDF::Writer::Object::Action.new(parent, label, type)
27
+ end
28
+ parent.current_page.add_annotation(self)
29
+ end
30
+
31
+ attr_accessor :type
32
+ attr_accessor :action
33
+ attr_accessor :rect
34
+
35
+ def to_s
36
+ res = "\n#{@oid} 0 obj\n<< /Type /Annot"
37
+ res << "\n/Subtype /Link" if TYPES.include?(@type)
38
+ res << "\n/A #{@action.oid} 0 R\n/Border [0 0 0]\n/H /I\n/Rect ["
39
+ @rect.each { |v| res << "%.4f " % v }
40
+ res << "]\n>>\nendobj"
41
+ end
42
+ end
@@ -0,0 +1,39 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
+ # for full licensing information.
8
+ #
9
+ # $Id: catalog.rb 50 2005-05-16 03:59:21Z austin $
10
+ #++
11
+ # Define the document catalog, the overall controller for the document
12
+ class PDF::Writer::Object::Catalog < PDF::Writer::Object
13
+ def initialize(parent)
14
+ super(parent)
15
+
16
+ @outlines = nil
17
+ @pages = nil
18
+ @open_here = nil
19
+ @viewer_preferences = nil
20
+ @page_mode = nil
21
+ end
22
+
23
+ attr_accessor :outlines
24
+ attr_accessor :pages
25
+ attr_accessor :open_here
26
+ attr_accessor :viewer_preferences
27
+ attr_accessor :page_mode
28
+
29
+ def to_s
30
+ res = "\n#{@oid} 0 obj\n<< /Type /Catalog"
31
+ res << "\n/Outlines #{@outlines.oid} 0 R" unless @outlines.nil?
32
+ res << "\n/Pages #{@pages.oid} 0 R" unless @pages.nil?
33
+ res << "\n/ViewerPreferences #{@viewer_preferences.oid} 0 R" if @viewer_preferences and @parent.version >= '1.2'
34
+ res << "\n/OpenAction #{@open_here.oid} 0 R" unless @open_here.nil?
35
+ res << "\n/PageMode /#{@page_mode}" unless @page_mode.nil?
36
+ res << "\n/Version /#{@parent.version}" if @parent.version >= '1.4'
37
+ res << ">>\nendobj"
38
+ end
39
+ end
@@ -0,0 +1,65 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
+ # for full licensing information.
8
+ #
9
+ # $Id: contents.rb 177 2007-11-26 16:06:58Z sandal $
10
+ #++
11
+ # The contents objects hold all of the content which appears on pages
12
+ class PDF::Writer::Object::Contents < PDF::Writer::Object
13
+ def initialize(parent, page = nil)
14
+ super(parent)
15
+
16
+ @data = ""
17
+ @info = {}
18
+ @raw = false
19
+ @on_page = nil
20
+
21
+ if page.kind_of?(PDF::Writer::Object::Page)
22
+ @on_page = page
23
+ elsif page == :raw
24
+ @raw = true
25
+ end
26
+ end
27
+
28
+ attr_reader :on_page
29
+ attr_accessor :data
30
+
31
+ def size
32
+ @data.size
33
+ end
34
+
35
+ def each
36
+ @contents.each { |c| yield c }
37
+ end
38
+
39
+ def <<(v)
40
+ raise TypeError unless v.kind_of?(PDF::Writer::Object) or v.kind_of?(String)
41
+ @data << v
42
+ end
43
+
44
+ def add(a)
45
+ a.each { |k, v| @info[k] = v }
46
+ end
47
+
48
+ def to_s
49
+ tmp = @data.dup
50
+ res = "\n#{@oid} 0 obj\n"
51
+ if @raw
52
+ res << tmp
53
+ else
54
+ res << "<<"
55
+ if PDF::Writer::Compression and @parent.compressed?
56
+ res << " /Filter /FlateDecode"
57
+ tmp = Zlib::Deflate.deflate(tmp)
58
+ end
59
+ @info.each { |k, v| res << "\n/#{k} #{v}" }
60
+ res << "\n/Length #{tmp.size} >>\nstream\n#{tmp}\nendstream"
61
+ end
62
+ res << "\nendobj\n"
63
+ res
64
+ end
65
+ end
@@ -0,0 +1,40 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
+ # for full licensing information.
8
+ #
9
+ # $Id: destination.rb 50 2005-05-16 03:59:21Z austin $
10
+ #++
11
+ # Destination object, used to specify the location for the user to jump
12
+ # to; presently, only on opening.
13
+ class PDF::Writer::Object::Destination < PDF::Writer::Object
14
+ def initialize(parent, page, type, *params)
15
+ super(parent)
16
+
17
+ case type
18
+ when "FitR"
19
+ raise TypeError if params.size < 4
20
+ @string = "/#{type} #{params[0..3].join(' ')}"
21
+ when "XYZ"
22
+ params = (params + [ "null" ] * 4).first(4)
23
+ @string = "/#{type} #{params[0..2].join(' ')}"
24
+ when "FitH", "FitV", "FitBH", "FitBV"
25
+ raise TypeError if params.empty?
26
+ @string = "/#{type} #{params[0]}"
27
+ when "Fit", "FitB"
28
+ @string = "/#{type}"
29
+ end
30
+
31
+ @page = page
32
+ end
33
+
34
+ attr_accessor :string
35
+ attr_accessor :page
36
+
37
+ def to_s
38
+ "\n#{@oid} 0 obj\n[#{@page.oid} 0 R #{@string}]\nendobj\n"
39
+ end
40
+ end
@@ -0,0 +1,53 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
+ # for full licensing information.
8
+ #
9
+ # $Id: encryption.rb 50 2005-05-16 03:59:21Z austin $
10
+ #++
11
+ # Encryption object
12
+ class PDF::Writer::Object::Encryption < PDF::Writer::Object
13
+ PAD = [ 0x28, 0xBF, 0x4E, 0x5E, 0x4E, 0x75, 0x8A, 0x41,
14
+ 0x64, 0x00, 0x4E, 0x56, 0xFF, 0xFA, 0x01, 0x08,
15
+ 0x2E, 0x2E, 0x00, 0xB6, 0xD0, 0x68, 0x3E, 0x80,
16
+ 0x2F, 0x0C, 0xA9, 0xFE, 0x64, 0x53, 0x69, 0x7A ].pack("C*")
17
+
18
+ def initialize(parent, options)
19
+ super(parent)
20
+
21
+ @parent.encrypt_obj = self
22
+
23
+ # Figure out the additional parameters required.
24
+ @owner = "#{options[:owner_pass]}#{PAD}"[0...32]
25
+ @user = "#{options[:user_pass]}#{PAD}"[0...32]
26
+ @perms = options[:permissions]
27
+
28
+ @parent.arc4.prepare(Digest::MD5.hexdigest(@owner)[0...5])
29
+
30
+ # Get the 'O' value.
31
+ @owner_info = ARC4.encrypt(@user)
32
+ # Get the 'U' value.
33
+ ukey = @user.dup
34
+ ukey << @owner_info
35
+ ukey << [ @perms, 0xFF, 0xFF, 0xFF ].pack("C*")
36
+ ukey << @parent.file_identifier
37
+ @parent.encryption_key = Digest::MD5.hexdigest(ukey)[0...5]
38
+
39
+ @parent.arc4.prepare(@parent.encryption_key)
40
+
41
+ @user_info = @parent.arc4.encrypt(PAD)
42
+ end
43
+
44
+ def to_s
45
+ res = "\n#{@oid} 0 obj\n<<\n/Filter /Standard\n"
46
+ res << "/V 1\n/R 2\n"
47
+ res << "/O (#{PDF::Writer.escape(@owner_info)})\n"
48
+ res << "/U (#{PDF::Writer.escape(@user_info)})\n"
49
+ res << "/P #{(((@perms ^ 255) + 1) * -1)}\n"
50
+ res << ">>\nendobj\n"
51
+ res
52
+ end
53
+ end
@@ -0,0 +1,72 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
+ # for full licensing information.
8
+ #
9
+ # $Id: font.rb 198 2008-03-03 15:26:31Z jh $
10
+ #++
11
+ # An object to hold the font description
12
+ class PDF::Writer::Object::Font < PDF::Writer::Object
13
+ Details = %w{FirstChar LastChar Widths FontDescriptor SubType}
14
+
15
+ def initialize(parent, name, encoding = 'WinAnsiEncoding', subtype = 'Type1')
16
+ super(parent)
17
+
18
+ @name = name
19
+ @subtype = subtype
20
+ @font_id = @parent.__send__(:generate_font_id)
21
+
22
+ if encoding.kind_of?(PDF::Writer::Object::FontEncoding)
23
+ @encoding = encoding
24
+ elsif encoding == 'none' or encoding.nil?
25
+ @encoding = nil
26
+ else
27
+ @encoding = encoding
28
+ end
29
+
30
+ @parent.pages << self
31
+
32
+ @firstchar = nil
33
+ @lastchar = nil
34
+ @widths = nil
35
+ @fontdescriptor = nil
36
+ end
37
+
38
+ attr_reader :font_id
39
+ # The type of the font: Type1 and TrueType are the only values supported
40
+ # by
41
+ attr_reader :subtype
42
+ # Valid values: WinAnsiEncoding, MacRomanEncoding, MacExpertEncoding,
43
+ # none, +nil+, or an instance of PDF::Writer::Object::FontEncoding.
44
+ attr_reader :encoding
45
+
46
+ def basefont #:nodoc:
47
+ @name
48
+ end
49
+
50
+ def basefont=(val) #:nodoc:
51
+ @name = val
52
+ end
53
+
54
+ Details.each do |d|
55
+ attr_accessor d.downcase.intern
56
+ end
57
+
58
+ def to_s
59
+ res = "\n#{@oid} 0 obj\n<< /Type /Font\n/Subtype /#{@subtype}\n"
60
+ res << "/Name /F#{@font_id}\n/BaseFont /#{@name}\n"
61
+ if @encoding.kind_of?(PDF::Writer::Object::FontEncoding)
62
+ res << "/Encoding #{@encoding.oid} 0 R\n"
63
+ elsif @encoding
64
+ res << "/Encoding /#{@encoding}\n" if @encoding
65
+ end
66
+ res << "/FirstChar #{@firstchar}\n" unless @firstchar.nil?
67
+ res << "/LastChar #{@lastchar}\n" unless @lastchar.nil?
68
+ res << "/Widths #{@widths} 0 R\n" unless @widths.nil?
69
+ res << "/FontDescriptor #{@fontdescriptor} 0 R\n" unless @fontdescriptor.nil?
70
+ res << ">>\nendobj"
71
+ end
72
+ end
@@ -0,0 +1,34 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
+ # for full licensing information.
8
+ #
9
+ # $Id: fontdescriptor.rb 198 2008-03-03 15:26:31Z jh $
10
+ #++
11
+ # A font descriptor, needed for including additional fonts. +options+ is a
12
+ # Hash with one of the following keys: Ascent, CapHeight, Descent, Flags,
13
+ # ItalicAngle, StemV, AvgWidth, Leading, MaxWidth, MissingWidth, StemH,
14
+ # XHeight, CharSet, FontFile, FontFile2, FontFile3, FontBBox, or FontName.
15
+ class PDF::Writer::Object::FontDescriptor < PDF::Writer::Object
16
+ def initialize(parent, options = nil)
17
+ super(parent)
18
+
19
+ @options = options
20
+ end
21
+
22
+ attr_accessor :options
23
+
24
+ def to_s
25
+ res = "\n#{@oid} 0 obj\n<< /Type /FontDescriptor\n"
26
+ @options.each do |k, v|
27
+ res << "/#{k} #{v}\n" if %w{Ascent CapHeight Descent Flags ItalicAngle StemV AvgWidth Leading MaxWidth MissingWidth StemH XHeight CharSet}.include?(k)
28
+ res << "/#{k} #{v} 0 R\n" if %w{FontFile FontFile2 FontFile3}.include?(k)
29
+ res << "/#{k} [#{v.join(' ')}]\n" if k == "FontBBox"
30
+ res << "/#{k} /#{v}\n" if k == "FontName"
31
+ end
32
+ res << ">>\nendobj"
33
+ end
34
+ end
@@ -0,0 +1,40 @@
1
+ #--
2
+ # PDF::Writer for Ruby.
3
+ # http://rubyforge.org/projects/ruby-pdf/
4
+ # Copyright 2003 - 2005 Austin Ziegler.
5
+ #
6
+ # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
+ # for full licensing information.
8
+ #
9
+ # $Id: fontencoding.rb 101 2005-06-28 21:32:17Z austin $
10
+ #++
11
+ # The font encoding
12
+ class PDF::Writer::Object::FontEncoding < PDF::Writer::Object
13
+ def initialize(parent, encoding, differences)
14
+ super(parent)
15
+
16
+ @differences = differences
17
+ @encoding = encoding
18
+ end
19
+
20
+ attr_accessor :differences
21
+ attr_accessor :encoding
22
+
23
+ def to_s
24
+ res = "\n#{@oid} 0 obj\n<< /Type /Encoding\n"
25
+ enc = @encoding || 'WinAnsiEncoding'
26
+ res << "/BaseEncoding /#{enc}\n" unless enc == 'none'
27
+ unless @differences.nil? or @differences.empty?
28
+ res << "/Differences \n["
29
+ n = nil
30
+ @differences.keys.sort.each do |k|
31
+ # Cannot make use of consecutive numbering
32
+ res << "\n#{k} " if n.nil? or k != (n + 1)
33
+ res << " /#{@differences[k]}"
34
+ n = k
35
+ end
36
+ res << "\n]"
37
+ end
38
+ res << "\n>>\nendobj"
39
+ end
40
+ end