pdf-labels 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,8 @@
1
+ == 0.2.0 / 2006-04-25
2
+
3
+ * First published to Rubyforge
4
+
5
+ == 0.3.0 / 2007-06-23
6
+
7
+ * PDFLabels library packed for Ruport and general consumption
8
+
data/LICENCE ADDED
@@ -0,0 +1,38 @@
1
+ PDF::Labels, the compilation and the majority of the works, are copyright � 2006 Rob Kaufman and are released under an MIT-style licence, detailed below. There are other portions of PDF::Labels which are derivative works of others under other licences and Adobe holds several patents related to PDF document creation and reading.
2
+
3
+ PDF::Labels for Ruby Licence
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the *Software*), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ * The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
+
13
+ Works Under Other Licences
14
+ All files in the templates/ directory
15
+
16
+ PDF::Labels includes an XML schema and label discription files from the gLabels project (http://glabels.sourceforge.org). These gLabels templates are released under the LGPL licence.
17
+
18
+ Patents Covering the Adobe PDF Format
19
+ ADOBE PATENTS
20
+
21
+ This software is based on Adobe�s PDF Reference, Third Edition, version 1.6. There may be limitations on the use of this library based on patent restrictions from Adobe. See below for more information.
22
+ UNISYS LZW PATENT
23
+
24
+ This software does not fully conform to the Adobe PDF specification because no support for LZW is included in this software. At the time of original development of this software (2003), the Unisys LZW patent was still in effect outside of the United States. This will be modified in a future version of this software.
25
+ Patent Clarification Notice: Reading and Writing PDF Files
26
+
27
+ Adobe has a number of patents covering technology that is disclosed in the Portable Document Format (PDF) Specification, version 1.6 and later, as documented in PDF Reference and associated Technical Notes (the �Specification�. Adobe desires to promote the use of PDF for information interchange among diverse products and applications.
28
+
29
+ Accordingly, the following patents are licensed on a royalty-free, non-exclusive basis for the term of each patent and for the sole purpose of developing software that produces, consumes, and interprets PDF files that are compliant with the Specification:
30
+
31
+ * U.S. Patent Numbers: 5,634,064; 5,737,599; 5,781,785; 5,819,301; 6,028,583; 6,289,364; 6,421,460
32
+
33
+ In addition, the following patent is licensed on a royalty-free, non-exclusive basis for its term and for the sole purpose of developing software that produces PDF files that are compliant with the Specification (specifically excluding, however, software that consumes and/or interprets PDF files):
34
+
35
+ * U.S. Patent Numbers: 5,860,074
36
+
37
+ The above licenses are limited to only those rights required to implement the Specification and no others. That is to say, Adobe grants only those rights in the above patent(s) necessarily practiced to implement the Specification, and does not grant any rights not required to implement the Specification. The licenses do not grant the right to practice any patent covering other technologies, such as implementation techniques that are not explicitly disclosed in the Specification, nor does it allow the use of any patented feature for any purpose other than as set forth in the applicable license grant. Adobe has other patents in various fields, none of which are hereby licensed.
38
+
@@ -0,0 +1,141 @@
1
+ History.txt
2
+ LICENCE
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ lib/alias.rb
7
+ lib/glabel_template.rb
8
+ lib/label.rb
9
+ lib/layout.rb
10
+ lib/length_node.rb
11
+ lib/markup.rb
12
+ lib/pdf_label_page.rb
13
+ lib/pdf_labels.rb
14
+ lib/template.rb
15
+ templates/avery-iso-templates.xml
16
+ templates/avery-other-templates.xml
17
+ templates/avery-us-templates.xml
18
+ templates/glabels-2.0.dtd
19
+ templates/misc-iso-templates.xml
20
+ templates/misc-other-templates.xml
21
+ templates/misc-us-templates.xml
22
+ templates/paper-sizes.xml
23
+ templates/zweckform-iso-templates.xml
24
+ test/test_pdf_label_page.rb
25
+ vendor/color.rb
26
+ vendor/color/cmyk.rb
27
+ vendor/color/css.rb
28
+ vendor/color/grayscale.rb
29
+ vendor/color/hsl.rb
30
+ vendor/color/palette.rb
31
+ vendor/color/palette/gimp.rb
32
+ vendor/color/palette/monocontrast.rb
33
+ vendor/color/rgb-colors.rb
34
+ vendor/color/rgb.rb
35
+ vendor/color/rgb/metallic.rb
36
+ vendor/color/yiq.rb
37
+ vendor/pdf/charts.rb
38
+ vendor/pdf/charts/stddev.rb
39
+ vendor/pdf/grid.rb
40
+ vendor/pdf/math.rb
41
+ vendor/pdf/pagenumbers.rb
42
+ vendor/pdf/quickref.rb
43
+ vendor/pdf/simpletable.rb
44
+ vendor/pdf/techbook.rb
45
+ vendor/pdf/writer.rb
46
+ vendor/pdf/writer/arc4.rb
47
+ vendor/pdf/writer/fontmetrics.rb
48
+ vendor/pdf/writer/fonts/Courier-Bold.afm
49
+ vendor/pdf/writer/fonts/Courier-BoldOblique.afm
50
+ vendor/pdf/writer/fonts/Courier-Oblique.afm
51
+ vendor/pdf/writer/fonts/Courier.afm
52
+ vendor/pdf/writer/fonts/Helvetica-Bold.afm
53
+ vendor/pdf/writer/fonts/Helvetica-BoldOblique.afm
54
+ vendor/pdf/writer/fonts/Helvetica-Oblique.afm
55
+ vendor/pdf/writer/fonts/Helvetica.afm
56
+ vendor/pdf/writer/fonts/Symbol.afm
57
+ vendor/pdf/writer/fonts/Times-Bold.afm
58
+ vendor/pdf/writer/fonts/Times-BoldItalic.afm
59
+ vendor/pdf/writer/fonts/Times-Italic.afm
60
+ vendor/pdf/writer/fonts/Times-Roman.afm
61
+ vendor/pdf/writer/fonts/ZapfDingbats.afm
62
+ vendor/pdf/writer/graphics.rb
63
+ vendor/pdf/writer/graphics/imageinfo.rb
64
+ vendor/pdf/writer/lang.rb
65
+ vendor/pdf/writer/lang/en.rb
66
+ vendor/pdf/writer/object.rb
67
+ vendor/pdf/writer/object/action.rb
68
+ vendor/pdf/writer/object/annotation.rb
69
+ vendor/pdf/writer/object/catalog.rb
70
+ vendor/pdf/writer/object/contents.rb
71
+ vendor/pdf/writer/object/destination.rb
72
+ vendor/pdf/writer/object/encryption.rb
73
+ vendor/pdf/writer/object/font.rb
74
+ vendor/pdf/writer/object/fontdescriptor.rb
75
+ vendor/pdf/writer/object/fontencoding.rb
76
+ vendor/pdf/writer/object/image.rb
77
+ vendor/pdf/writer/object/info.rb
78
+ vendor/pdf/writer/object/outline.rb
79
+ vendor/pdf/writer/object/outlines.rb
80
+ vendor/pdf/writer/object/page.rb
81
+ vendor/pdf/writer/object/pages.rb
82
+ vendor/pdf/writer/object/procset.rb
83
+ vendor/pdf/writer/object/viewerpreferences.rb
84
+ vendor/pdf/writer/ohash.rb
85
+ vendor/pdf/writer/oreader.rb
86
+ vendor/pdf/writer/state.rb
87
+ vendor/pdf/writer/strokestyle.rb
88
+ vendor/transaction/simple.rb
89
+ vendor/transaction/simple/group.rb
90
+ vendor/transaction/simple/threadsafe.rb
91
+ vendor/transaction/simple/threadsafe/group.rb
92
+ vendor/xml-mapping/ChangeLog
93
+ vendor/xml-mapping/LICENSE
94
+ vendor/xml-mapping/README
95
+ vendor/xml-mapping/README_XPATH
96
+ vendor/xml-mapping/Rakefile
97
+ vendor/xml-mapping/TODO.txt
98
+ vendor/xml-mapping/doc/xpath_impl_notes.txt
99
+ vendor/xml-mapping/examples/company.rb
100
+ vendor/xml-mapping/examples/company.xml
101
+ vendor/xml-mapping/examples/company_usage.intin.rb
102
+ vendor/xml-mapping/examples/company_usage.intout
103
+ vendor/xml-mapping/examples/order.rb
104
+ vendor/xml-mapping/examples/order.xml
105
+ vendor/xml-mapping/examples/order_signature_enhanced.rb
106
+ vendor/xml-mapping/examples/order_signature_enhanced.xml
107
+ vendor/xml-mapping/examples/order_signature_enhanced_usage.intin.rb
108
+ vendor/xml-mapping/examples/order_signature_enhanced_usage.intout
109
+ vendor/xml-mapping/examples/order_usage.intin.rb
110
+ vendor/xml-mapping/examples/order_usage.intout
111
+ vendor/xml-mapping/examples/time_augm.intin.rb
112
+ vendor/xml-mapping/examples/time_augm.intout
113
+ vendor/xml-mapping/examples/time_node.rb
114
+ vendor/xml-mapping/examples/xpath_create_new.intin.rb
115
+ vendor/xml-mapping/examples/xpath_create_new.intout
116
+ vendor/xml-mapping/examples/xpath_docvsroot.intin.rb
117
+ vendor/xml-mapping/examples/xpath_docvsroot.intout
118
+ vendor/xml-mapping/examples/xpath_ensure_created.intin.rb
119
+ vendor/xml-mapping/examples/xpath_ensure_created.intout
120
+ vendor/xml-mapping/examples/xpath_pathological.intin.rb
121
+ vendor/xml-mapping/examples/xpath_pathological.intout
122
+ vendor/xml-mapping/examples/xpath_usage.intin.rb
123
+ vendor/xml-mapping/examples/xpath_usage.intout
124
+ vendor/xml-mapping/install.rb
125
+ vendor/xml-mapping/lib/xml/mapping.rb
126
+ vendor/xml-mapping/lib/xml/mapping/base.rb
127
+ vendor/xml-mapping/lib/xml/mapping/standard_nodes.rb
128
+ vendor/xml-mapping/lib/xml/mapping/version.rb
129
+ vendor/xml-mapping/lib/xml/xxpath.rb
130
+ vendor/xml-mapping/test/all_tests.rb
131
+ vendor/xml-mapping/test/company.rb
132
+ vendor/xml-mapping/test/documents_folders.rb
133
+ vendor/xml-mapping/test/fixtures/bookmarks1.xml
134
+ vendor/xml-mapping/test/fixtures/company1.xml
135
+ vendor/xml-mapping/test/fixtures/documents_folders.xml
136
+ vendor/xml-mapping/test/fixtures/documents_folders2.xml
137
+ vendor/xml-mapping/test/multiple_mappings.rb
138
+ vendor/xml-mapping/test/tests_init.rb
139
+ vendor/xml-mapping/test/xml_mapping_adv_test.rb
140
+ vendor/xml-mapping/test/xml_mapping_test.rb
141
+ vendor/xml-mapping/test/xpath_test.rb
@@ -0,0 +1,72 @@
1
+ PdfLabels
2
+ by Rob Kaufman
3
+ http://www.lightning-tree.net
4
+
5
+ == DESCRIPTION:
6
+
7
+ Welcome to the PDF-Labels project. Our aim is to make creating labels
8
+ programmatically easy in Ruby. This Library builds on top of
9
+ "PDF::Writer":http://ruby-pdf.rubyforge.org/ and uses the templates
10
+ from "gLabels":http://glabels.sourceforge.org. What this means is
11
+ easy, clean Ruby code to create many common label types without
12
+ measuring the labels yourself! All of this in pure Ruby (we use the
13
+ XML templates from gLabels, we do NOT have a dependancy on gLabels,
14
+ nor on Gnome)
15
+
16
+ == FEATURES/PROBLEMS:
17
+
18
+ * Works with all gLabels supported templates for rectangular labels
19
+ * Does not yet work for CD labels (circles)
20
+
21
+ == SYNOPSIS:
22
+
23
+ p = PDFLabelPage.new("Avery 8160") # label is 2 x 10
24
+ #Some examples of adding labels
25
+ p.add_label() # should add to col 1, row 1
26
+ p.add_label(:position => 1) # should add col 1, row 2
27
+ p.add_label(:text => "Positoin 15", :position => 15) # should add col 2, row 1
28
+ p.add_label(:text => 'No Margin', :position => 5, :use_margin => false) #this doesn't use a margin
29
+ p.add_label(:position => 9, :text => "X Offset = 4, Y Offset = -6", :offset_x => 4, :offset_y => -6)
30
+ p.add_label(:text => "Centered", :position => 26, :justification => :center) # should add col 2, row 15
31
+ p.add_label(:text => "[Right justified]", :justification => :right, :position => 28)# col 2, row 14, right justified.
32
+ p.add_label(:position => 29) # should add col 2, row 15
33
+ p.add_label(:position => 8, :text => "This was added last and has a BIG font", :font_size => 18)
34
+
35
+ #If you want to see the boxes around each label (good for printing alignment samples)
36
+ p.draw_boxes(false, true)
37
+
38
+ #Save your PDF when your done
39
+ p.save_as("../label_output.pdf")
40
+
41
+ == REQUIREMENTS:
42
+
43
+ Currently there are no external dependencies, though a version of xml-mapping and pdf-writer (and its dependencies) are provided in vendor
44
+
45
+ == INSTALL:
46
+
47
+ sudo gem install pdf-labels
48
+
49
+ == LICENSE:
50
+
51
+ (The MIT License)
52
+
53
+ Copyright (c) 2007 Rob Kaufman
54
+
55
+ Permission is hereby granted, free of charge, to any person obtaining
56
+ a copy of this software and associated documentation files (the
57
+ 'Software'), to deal in the Software without restriction, including
58
+ without limitation the rights to use, copy, modify, merge, publish,
59
+ distribute, sublicense, and/or sell copies of the Software, and to
60
+ permit persons to whom the Software is furnished to do so, subject to
61
+ the following conditions:
62
+
63
+ The above copyright notice and this permission notice shall be
64
+ included in all copies or substantial portions of the Software.
65
+
66
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
67
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
68
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
69
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
70
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
71
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
72
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,30 @@
1
+ # -*- ruby -*-
2
+
3
+ ENV['RUBY_FLAGS'] = "-I#{%w(lib test vendor).join(File::PATH_SEPARATOR)}"
4
+ require 'rubygems'
5
+ require 'hoe'
6
+ require './lib/pdf_labels.rb'
7
+
8
+ #Ryan, if you want to have strong opinions thats cool, but if you want to be a prick about it, you'd better be right... and your not
9
+ class Hoe
10
+ def extra_deps
11
+ @extra_deps.reject do |x|
12
+ Array(x).first == 'hoe'
13
+ end
14
+ end
15
+ end
16
+
17
+ Hoe.new('pdf-labels', Pdflabels::VERSION) do |p|
18
+ p.rubyforge_name = 'pdf-labels'
19
+ p.author = 'Rob Kaufman'
20
+ p.email = 'rgkaufman@gmail.com'
21
+ p.summary = 'Easy label creation in Ruby through PDF::Writer and using templates from gLabels. Contains the library pdf_labels, the Rails engine LabelPageEngine and an example application FileClerk.'
22
+ p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
23
+ p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
24
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
25
+ end
26
+
27
+ task :clean do
28
+ dir = Dir.new(Dir.pwd)
29
+ dir.grep(/pdf$/) {|file| rm file}
30
+ end
@@ -0,0 +1,8 @@
1
+ require 'xml/mapping'
2
+ require 'length_node'
3
+
4
+ class Alias
5
+ include XML::Mapping
6
+ text_node :name, "@name"
7
+ end
8
+
@@ -0,0 +1,36 @@
1
+ require 'template'
2
+
3
+ class GlabelsTemplate
4
+ include XML::Mapping
5
+
6
+ hash_node :templates, "Template", "@name", :class => Template, :default_value => Hash.new
7
+
8
+ def find_all_templates
9
+ return @t unless @t.nil?
10
+ @t = []
11
+ templates.each {|t|
12
+ @t << "#{t[1].name}"
13
+ t[1].alias.each {|a|
14
+ @t << "#{a[1].name}"
15
+ }
16
+ }
17
+ return @t
18
+ end
19
+
20
+
21
+ def find_template(t_name)
22
+ return find_all_with_templates if t_name == :all
23
+ if t = templates[t_name]
24
+ return t
25
+ else
26
+ templates.each { |t|
27
+ if t[1].alias[t_name]
28
+ return t[1]
29
+ end
30
+ }
31
+ end
32
+ return nil
33
+ end
34
+
35
+ end
36
+
@@ -0,0 +1,52 @@
1
+ require 'length_node'
2
+ require 'layout'
3
+ require 'markup'
4
+
5
+ class Label
6
+ include XML::Mapping
7
+ attr_accessor :shape
8
+ numeric_node :id, "@id"
9
+ array_node :markupMargins, "Markup-margin", :class => MarkupMargin, :default_value => nil
10
+ array_node :markupLines, "Markup-line", :class => MarkupLine, :default_value => nil
11
+ array_node :markupCircles, "Markup-circle", :class => MarkupCircle, :default_value => nil
12
+
13
+ array_node :layouts, "Layout", :class => Layout
14
+
15
+ def markups
16
+ @markups = Hash.new
17
+ @markups = @markups.merge @markupMargins
18
+ @markups = @markups.merge @markupLines
19
+ @markups = @markups.merge @markupCircles
20
+ @markups
21
+ end
22
+
23
+ end
24
+
25
+
26
+
27
+ class LabelRectangle < Label
28
+ length_node :width, "@width"
29
+ length_node :height, "@height"
30
+ length_node :round, "@round", :default_value => "0 pt"
31
+ length_node :waste, "@waste", :default_value => "0 pt"
32
+ length_node :x_waste, "@x_waste", :default_value => "0 pt"
33
+ length_node :y_waste, "@y_waste", :default_value => "0 pt"
34
+ @kind = "Rectangle"
35
+
36
+ end
37
+
38
+ class LabelRound < Label
39
+ length_node :radius, "@radius"
40
+ length_node :waste, "@radius", :default_value => "0 pt"
41
+ @kind = "Round"
42
+ end
43
+
44
+ class LabelCD < Label
45
+ length_node :radius, "@radius"
46
+ length_node :hole, "@hole"
47
+ length_node :width, "@width", :default_value => ""
48
+ length_node :height, "@height", :default_value => ""
49
+ length_node :waste, "@waste", :default_value => ""
50
+ @kind = "CD"
51
+ end
52
+
@@ -0,0 +1,13 @@
1
+ require 'length_node'
2
+
3
+
4
+ class Layout
5
+ include XML::Mapping
6
+ numeric_node :nx, "@nx"
7
+ numeric_node :ny, "@ny"
8
+ length_node :x0, "@x0", :default_value => "0 pt"
9
+ length_node :y0, "@y0", :default_value => "0 pt"
10
+ length_node :dx, "@dx", :default_value => "0 pt"
11
+ length_node :dy, "@dy", :default_value => "0 pt"
12
+ end
13
+
@@ -0,0 +1,47 @@
1
+ require 'xml/mapping/base'
2
+ class Length
3
+ attr_accessor :value, :unit, :number
4
+
5
+ def initialize(value)
6
+ @value = value
7
+ @number = value.match(/[\d\.]*/)[0].to_f
8
+ @unit = value.delete("#{number}").strip
9
+ end
10
+
11
+ #Return the numeric portion as a Points
12
+ def as_pts
13
+ if @unit =~ /pt/
14
+ return @number
15
+ elsif @unit =~ /in/
16
+ return @number * 72 #72.270
17
+ elsif @unit =~ /mm/
18
+ return @number * 2.83464566929134
19
+ elsif @unit =~ /cm/
20
+ return @number * 28.3464566929134
21
+ elsif @unit =~ /pc/
22
+ return 1.0 * @number / 12
23
+ elsif @unit == ''
24
+ return @number
25
+ else
26
+ raise "Unit #{unit} unknown"
27
+ end
28
+ end
29
+ end
30
+
31
+ class LengthNode < XML::Mapping::SingleAttributeNode
32
+ def initialize_impl(path)
33
+ @path = XML::XXPath.new(path)
34
+ end
35
+
36
+ def extract_attr_value(xml)
37
+ @value = default_when_xpath_err{@path.first(xml).text}
38
+ Length.new(@value)
39
+ end
40
+
41
+ def set_attr_value(xml, value)
42
+ raise "Not a Length: #{value}" unless Length===value
43
+ @path.first(xml,:ensure_created=>true).text = value.value
44
+ end
45
+ end
46
+
47
+ XML::Mapping.add_node_class LengthNode