pdf-labels 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. data/History.txt +8 -0
  2. data/LICENCE +38 -0
  3. data/Manifest.txt +141 -0
  4. data/README.txt +72 -0
  5. data/Rakefile +30 -0
  6. data/lib/alias.rb +8 -0
  7. data/lib/glabel_template.rb +36 -0
  8. data/lib/label.rb +52 -0
  9. data/lib/layout.rb +13 -0
  10. data/lib/length_node.rb +47 -0
  11. data/lib/markup.rb +25 -0
  12. data/lib/pdf_label_page.rb +171 -0
  13. data/lib/pdf_labels.rb +6 -0
  14. data/lib/template.rb +37 -0
  15. data/templates/avery-iso-templates.xml +222 -0
  16. data/templates/avery-other-templates.xml +21 -0
  17. data/templates/avery-us-templates.xml +599 -0
  18. data/templates/glabels-2.0.dtd +329 -0
  19. data/templates/misc-iso-templates.xml +434 -0
  20. data/templates/misc-other-templates.xml +21 -0
  21. data/templates/misc-us-templates.xml +183 -0
  22. data/templates/paper-sizes.xml +37 -0
  23. data/templates/zweckform-iso-templates.xml +197 -0
  24. data/test/test_pdf_label_page.rb +91 -0
  25. data/vendor/color.rb +87 -0
  26. data/vendor/color/cmyk.rb +182 -0
  27. data/vendor/color/css.rb +27 -0
  28. data/vendor/color/grayscale.rb +135 -0
  29. data/vendor/color/hsl.rb +130 -0
  30. data/vendor/color/palette.rb +15 -0
  31. data/vendor/color/palette/gimp.rb +107 -0
  32. data/vendor/color/palette/monocontrast.rb +180 -0
  33. data/vendor/color/rgb-colors.rb +189 -0
  34. data/vendor/color/rgb.rb +311 -0
  35. data/vendor/color/rgb/metallic.rb +28 -0
  36. data/vendor/color/yiq.rb +78 -0
  37. data/vendor/pdf/charts.rb +13 -0
  38. data/vendor/pdf/charts/stddev.rb +433 -0
  39. data/vendor/pdf/grid.rb +135 -0
  40. data/vendor/pdf/math.rb +108 -0
  41. data/vendor/pdf/pagenumbers.rb +288 -0
  42. data/vendor/pdf/quickref.rb +331 -0
  43. data/vendor/pdf/simpletable.rb +947 -0
  44. data/vendor/pdf/techbook.rb +901 -0
  45. data/vendor/pdf/writer.rb +2801 -0
  46. data/vendor/pdf/writer/arc4.rb +63 -0
  47. data/vendor/pdf/writer/fontmetrics.rb +202 -0
  48. data/vendor/pdf/writer/fonts/Courier-Bold.afm +342 -0
  49. data/vendor/pdf/writer/fonts/Courier-BoldOblique.afm +342 -0
  50. data/vendor/pdf/writer/fonts/Courier-Oblique.afm +342 -0
  51. data/vendor/pdf/writer/fonts/Courier.afm +342 -0
  52. data/vendor/pdf/writer/fonts/Helvetica-Bold.afm +2827 -0
  53. data/vendor/pdf/writer/fonts/Helvetica-BoldOblique.afm +2827 -0
  54. data/vendor/pdf/writer/fonts/Helvetica-Oblique.afm +3051 -0
  55. data/vendor/pdf/writer/fonts/Helvetica.afm +3051 -0
  56. data/vendor/pdf/writer/fonts/Symbol.afm +213 -0
  57. data/vendor/pdf/writer/fonts/Times-Bold.afm +2588 -0
  58. data/vendor/pdf/writer/fonts/Times-BoldItalic.afm +2384 -0
  59. data/vendor/pdf/writer/fonts/Times-Italic.afm +2667 -0
  60. data/vendor/pdf/writer/fonts/Times-Roman.afm +2419 -0
  61. data/vendor/pdf/writer/fonts/ZapfDingbats.afm +225 -0
  62. data/vendor/pdf/writer/graphics.rb +813 -0
  63. data/vendor/pdf/writer/graphics/imageinfo.rb +365 -0
  64. data/vendor/pdf/writer/lang.rb +44 -0
  65. data/vendor/pdf/writer/lang/en.rb +104 -0
  66. data/vendor/pdf/writer/object.rb +23 -0
  67. data/vendor/pdf/writer/object/action.rb +40 -0
  68. data/vendor/pdf/writer/object/annotation.rb +42 -0
  69. data/vendor/pdf/writer/object/catalog.rb +39 -0
  70. data/vendor/pdf/writer/object/contents.rb +69 -0
  71. data/vendor/pdf/writer/object/destination.rb +40 -0
  72. data/vendor/pdf/writer/object/encryption.rb +53 -0
  73. data/vendor/pdf/writer/object/font.rb +68 -0
  74. data/vendor/pdf/writer/object/fontdescriptor.rb +34 -0
  75. data/vendor/pdf/writer/object/fontencoding.rb +40 -0
  76. data/vendor/pdf/writer/object/image.rb +308 -0
  77. data/vendor/pdf/writer/object/info.rb +79 -0
  78. data/vendor/pdf/writer/object/outline.rb +30 -0
  79. data/vendor/pdf/writer/object/outlines.rb +30 -0
  80. data/vendor/pdf/writer/object/page.rb +195 -0
  81. data/vendor/pdf/writer/object/pages.rb +115 -0
  82. data/vendor/pdf/writer/object/procset.rb +46 -0
  83. data/vendor/pdf/writer/object/viewerpreferences.rb +74 -0
  84. data/vendor/pdf/writer/ohash.rb +58 -0
  85. data/vendor/pdf/writer/oreader.rb +25 -0
  86. data/vendor/pdf/writer/state.rb +48 -0
  87. data/vendor/pdf/writer/strokestyle.rb +140 -0
  88. data/vendor/transaction/simple.rb +693 -0
  89. data/vendor/transaction/simple/group.rb +133 -0
  90. data/vendor/transaction/simple/threadsafe.rb +52 -0
  91. data/vendor/transaction/simple/threadsafe/group.rb +23 -0
  92. data/vendor/xml-mapping/ChangeLog +128 -0
  93. data/vendor/xml-mapping/LICENSE +56 -0
  94. data/vendor/xml-mapping/README +386 -0
  95. data/vendor/xml-mapping/README_XPATH +175 -0
  96. data/vendor/xml-mapping/Rakefile +214 -0
  97. data/vendor/xml-mapping/TODO.txt +32 -0
  98. data/vendor/xml-mapping/doc/xpath_impl_notes.txt +119 -0
  99. data/vendor/xml-mapping/examples/company.rb +34 -0
  100. data/vendor/xml-mapping/examples/company.xml +26 -0
  101. data/vendor/xml-mapping/examples/company_usage.intin.rb +19 -0
  102. data/vendor/xml-mapping/examples/company_usage.intout +39 -0
  103. data/vendor/xml-mapping/examples/order.rb +61 -0
  104. data/vendor/xml-mapping/examples/order.xml +54 -0
  105. data/vendor/xml-mapping/examples/order_signature_enhanced.rb +7 -0
  106. data/vendor/xml-mapping/examples/order_signature_enhanced.xml +9 -0
  107. data/vendor/xml-mapping/examples/order_signature_enhanced_usage.intin.rb +12 -0
  108. data/vendor/xml-mapping/examples/order_signature_enhanced_usage.intout +16 -0
  109. data/vendor/xml-mapping/examples/order_usage.intin.rb +73 -0
  110. data/vendor/xml-mapping/examples/order_usage.intout +147 -0
  111. data/vendor/xml-mapping/examples/time_augm.intin.rb +19 -0
  112. data/vendor/xml-mapping/examples/time_augm.intout +23 -0
  113. data/vendor/xml-mapping/examples/time_node.rb +27 -0
  114. data/vendor/xml-mapping/examples/xpath_create_new.intin.rb +85 -0
  115. data/vendor/xml-mapping/examples/xpath_create_new.intout +181 -0
  116. data/vendor/xml-mapping/examples/xpath_docvsroot.intin.rb +30 -0
  117. data/vendor/xml-mapping/examples/xpath_docvsroot.intout +34 -0
  118. data/vendor/xml-mapping/examples/xpath_ensure_created.intin.rb +62 -0
  119. data/vendor/xml-mapping/examples/xpath_ensure_created.intout +114 -0
  120. data/vendor/xml-mapping/examples/xpath_pathological.intin.rb +42 -0
  121. data/vendor/xml-mapping/examples/xpath_pathological.intout +56 -0
  122. data/vendor/xml-mapping/examples/xpath_usage.intin.rb +51 -0
  123. data/vendor/xml-mapping/examples/xpath_usage.intout +57 -0
  124. data/vendor/xml-mapping/install.rb +40 -0
  125. data/vendor/xml-mapping/lib/xml/mapping.rb +14 -0
  126. data/vendor/xml-mapping/lib/xml/mapping/base.rb +571 -0
  127. data/vendor/xml-mapping/lib/xml/mapping/standard_nodes.rb +343 -0
  128. data/vendor/xml-mapping/lib/xml/mapping/version.rb +8 -0
  129. data/vendor/xml-mapping/lib/xml/xxpath.rb +354 -0
  130. data/vendor/xml-mapping/test/all_tests.rb +6 -0
  131. data/vendor/xml-mapping/test/company.rb +56 -0
  132. data/vendor/xml-mapping/test/documents_folders.rb +33 -0
  133. data/vendor/xml-mapping/test/fixtures/bookmarks1.xml +24 -0
  134. data/vendor/xml-mapping/test/fixtures/company1.xml +85 -0
  135. data/vendor/xml-mapping/test/fixtures/documents_folders.xml +71 -0
  136. data/vendor/xml-mapping/test/fixtures/documents_folders2.xml +30 -0
  137. data/vendor/xml-mapping/test/multiple_mappings.rb +80 -0
  138. data/vendor/xml-mapping/test/tests_init.rb +2 -0
  139. data/vendor/xml-mapping/test/xml_mapping_adv_test.rb +84 -0
  140. data/vendor/xml-mapping/test/xml_mapping_test.rb +201 -0
  141. data/vendor/xml-mapping/test/xpath_test.rb +273 -0
  142. metadata +191 -0
@@ -0,0 +1,23 @@
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: object.rb,v 1.3 2005/05/25 11:19:50 austin Exp $
10
+ #++
11
+ class PDF::Writer::Object
12
+ def initialize(parent)
13
+ @parent = parent
14
+ @oid = @parent.__send__(:generate_id)
15
+ @parent.objects << self
16
+ end
17
+
18
+ attr_reader :oid
19
+ end
20
+
21
+ class PDF::Writer::External < PDF::Writer::Object; end
22
+
23
+ class PDF::Writer::Complex < PDF::Writer::Object; 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: action.rb,v 1.5 2005/05/24 22:19:42 austin Exp $
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
+ @parent.arc4.prepare(self) if @parent.encrypted?
26
+ res = "\n#{@oid} 0 obj\n<< /Type /Action"
27
+ if @type == :ilink
28
+ res << "\n/S /GoTo\n/D #{@parent.destinations[@label].oid} 0 R"
29
+ elsif @type == 'URI'
30
+ res << "\n/S /URI\n/URI ("
31
+ if @parent.encrypted?
32
+ res << PDF::Writer.escape(@parent.arc4.encrypt(@label))
33
+ else
34
+ res << PDF::Writer.escape(@label)
35
+ end
36
+ res << ")\n"
37
+ end
38
+ res << ">>\nendobj"
39
+ end
40
+ 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,v 1.2 2005/05/16 03:59:21 austin Exp $
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,v 1.2 2005/05/16 03:59:21 austin Exp $
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,69 @@
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,v 1.3 2005/08/26 03:13:24 austin Exp $
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
+ if (@parent.encrypted?)
60
+ @parent.arc4.prepare(self)
61
+ tmp = @parent.arc4.encrypt(tmp)
62
+ end
63
+ @info.each { |k, v| res << "\n/#{k} #{v}" }
64
+ res << "\n/Length #{tmp.size} >>\nstream\n#{tmp}\nendstream"
65
+ end
66
+ res << "\nendobj\n"
67
+ res
68
+ end
69
+ 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,v 1.2 2005/05/16 03:59:21 austin Exp $
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,v 1.2 2005/05/16 03:59:21 austin Exp $
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,68 @@
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,v 1.5 2005/06/28 21:32:17 austin Exp $
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
+ attr_reader :basefont
46
+ def basefont #:nodoc:
47
+ @name
48
+ end
49
+
50
+ Details.each do |d|
51
+ attr_accessor d.downcase.intern
52
+ end
53
+
54
+ def to_s
55
+ res = "\n#{@oid} 0 obj\n<< /Type /Font\n/Subtype /#{@subtype}\n"
56
+ res << "/Name /F#{@font_id}\n/BaseFont /#{@name}\n"
57
+ if @encoding.kind_of?(PDF::Writer::Object::FontEncoding)
58
+ res << "/Encoding #{@encoding.oid} 0 R\n"
59
+ elsif @encoding
60
+ res << "/Encoding /#{@encoding}\n" if @encoding
61
+ end
62
+ res << "/FirstChar #{@firstchar}\n" unless @firstchar.nil?
63
+ res << "/LastChar #{@lastchar}\n" unless @lastchar.nil?
64
+ res << "/Widths #{@widths} 0 R\n" unless @widths.nil?
65
+ res << "/FontDescriptor #{@fontdescriptor} 0 R\n" unless @fontdescriptor.nil?
66
+ res << ">>\nendobj"
67
+ end
68
+ 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,v 1.2 2005/05/16 03:59:21 austin Exp $
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 << "\n>>\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,v 1.4 2005/06/28 21:32:17 austin Exp $
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