pdf-labels 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/LICENCE +38 -0
- data/Manifest.txt +141 -0
- data/README.txt +72 -0
- data/Rakefile +30 -0
- data/lib/alias.rb +8 -0
- data/lib/glabel_template.rb +36 -0
- data/lib/label.rb +52 -0
- data/lib/layout.rb +13 -0
- data/lib/length_node.rb +47 -0
- data/lib/markup.rb +25 -0
- data/lib/pdf_label_page.rb +171 -0
- data/lib/pdf_labels.rb +6 -0
- data/lib/template.rb +37 -0
- data/templates/avery-iso-templates.xml +222 -0
- data/templates/avery-other-templates.xml +21 -0
- data/templates/avery-us-templates.xml +599 -0
- data/templates/glabels-2.0.dtd +329 -0
- data/templates/misc-iso-templates.xml +434 -0
- data/templates/misc-other-templates.xml +21 -0
- data/templates/misc-us-templates.xml +183 -0
- data/templates/paper-sizes.xml +37 -0
- data/templates/zweckform-iso-templates.xml +197 -0
- data/test/test_pdf_label_page.rb +91 -0
- data/vendor/color.rb +87 -0
- data/vendor/color/cmyk.rb +182 -0
- data/vendor/color/css.rb +27 -0
- data/vendor/color/grayscale.rb +135 -0
- data/vendor/color/hsl.rb +130 -0
- data/vendor/color/palette.rb +15 -0
- data/vendor/color/palette/gimp.rb +107 -0
- data/vendor/color/palette/monocontrast.rb +180 -0
- data/vendor/color/rgb-colors.rb +189 -0
- data/vendor/color/rgb.rb +311 -0
- data/vendor/color/rgb/metallic.rb +28 -0
- data/vendor/color/yiq.rb +78 -0
- data/vendor/pdf/charts.rb +13 -0
- data/vendor/pdf/charts/stddev.rb +433 -0
- data/vendor/pdf/grid.rb +135 -0
- data/vendor/pdf/math.rb +108 -0
- data/vendor/pdf/pagenumbers.rb +288 -0
- data/vendor/pdf/quickref.rb +331 -0
- data/vendor/pdf/simpletable.rb +947 -0
- data/vendor/pdf/techbook.rb +901 -0
- data/vendor/pdf/writer.rb +2801 -0
- data/vendor/pdf/writer/arc4.rb +63 -0
- data/vendor/pdf/writer/fontmetrics.rb +202 -0
- data/vendor/pdf/writer/fonts/Courier-Bold.afm +342 -0
- data/vendor/pdf/writer/fonts/Courier-BoldOblique.afm +342 -0
- data/vendor/pdf/writer/fonts/Courier-Oblique.afm +342 -0
- data/vendor/pdf/writer/fonts/Courier.afm +342 -0
- data/vendor/pdf/writer/fonts/Helvetica-Bold.afm +2827 -0
- data/vendor/pdf/writer/fonts/Helvetica-BoldOblique.afm +2827 -0
- data/vendor/pdf/writer/fonts/Helvetica-Oblique.afm +3051 -0
- data/vendor/pdf/writer/fonts/Helvetica.afm +3051 -0
- data/vendor/pdf/writer/fonts/Symbol.afm +213 -0
- data/vendor/pdf/writer/fonts/Times-Bold.afm +2588 -0
- data/vendor/pdf/writer/fonts/Times-BoldItalic.afm +2384 -0
- data/vendor/pdf/writer/fonts/Times-Italic.afm +2667 -0
- data/vendor/pdf/writer/fonts/Times-Roman.afm +2419 -0
- data/vendor/pdf/writer/fonts/ZapfDingbats.afm +225 -0
- data/vendor/pdf/writer/graphics.rb +813 -0
- data/vendor/pdf/writer/graphics/imageinfo.rb +365 -0
- data/vendor/pdf/writer/lang.rb +44 -0
- data/vendor/pdf/writer/lang/en.rb +104 -0
- data/vendor/pdf/writer/object.rb +23 -0
- data/vendor/pdf/writer/object/action.rb +40 -0
- data/vendor/pdf/writer/object/annotation.rb +42 -0
- data/vendor/pdf/writer/object/catalog.rb +39 -0
- data/vendor/pdf/writer/object/contents.rb +69 -0
- data/vendor/pdf/writer/object/destination.rb +40 -0
- data/vendor/pdf/writer/object/encryption.rb +53 -0
- data/vendor/pdf/writer/object/font.rb +68 -0
- data/vendor/pdf/writer/object/fontdescriptor.rb +34 -0
- data/vendor/pdf/writer/object/fontencoding.rb +40 -0
- data/vendor/pdf/writer/object/image.rb +308 -0
- data/vendor/pdf/writer/object/info.rb +79 -0
- data/vendor/pdf/writer/object/outline.rb +30 -0
- data/vendor/pdf/writer/object/outlines.rb +30 -0
- data/vendor/pdf/writer/object/page.rb +195 -0
- data/vendor/pdf/writer/object/pages.rb +115 -0
- data/vendor/pdf/writer/object/procset.rb +46 -0
- data/vendor/pdf/writer/object/viewerpreferences.rb +74 -0
- data/vendor/pdf/writer/ohash.rb +58 -0
- data/vendor/pdf/writer/oreader.rb +25 -0
- data/vendor/pdf/writer/state.rb +48 -0
- data/vendor/pdf/writer/strokestyle.rb +140 -0
- data/vendor/transaction/simple.rb +693 -0
- data/vendor/transaction/simple/group.rb +133 -0
- data/vendor/transaction/simple/threadsafe.rb +52 -0
- data/vendor/transaction/simple/threadsafe/group.rb +23 -0
- data/vendor/xml-mapping/ChangeLog +128 -0
- data/vendor/xml-mapping/LICENSE +56 -0
- data/vendor/xml-mapping/README +386 -0
- data/vendor/xml-mapping/README_XPATH +175 -0
- data/vendor/xml-mapping/Rakefile +214 -0
- data/vendor/xml-mapping/TODO.txt +32 -0
- data/vendor/xml-mapping/doc/xpath_impl_notes.txt +119 -0
- data/vendor/xml-mapping/examples/company.rb +34 -0
- data/vendor/xml-mapping/examples/company.xml +26 -0
- data/vendor/xml-mapping/examples/company_usage.intin.rb +19 -0
- data/vendor/xml-mapping/examples/company_usage.intout +39 -0
- data/vendor/xml-mapping/examples/order.rb +61 -0
- data/vendor/xml-mapping/examples/order.xml +54 -0
- data/vendor/xml-mapping/examples/order_signature_enhanced.rb +7 -0
- data/vendor/xml-mapping/examples/order_signature_enhanced.xml +9 -0
- data/vendor/xml-mapping/examples/order_signature_enhanced_usage.intin.rb +12 -0
- data/vendor/xml-mapping/examples/order_signature_enhanced_usage.intout +16 -0
- data/vendor/xml-mapping/examples/order_usage.intin.rb +73 -0
- data/vendor/xml-mapping/examples/order_usage.intout +147 -0
- data/vendor/xml-mapping/examples/time_augm.intin.rb +19 -0
- data/vendor/xml-mapping/examples/time_augm.intout +23 -0
- data/vendor/xml-mapping/examples/time_node.rb +27 -0
- data/vendor/xml-mapping/examples/xpath_create_new.intin.rb +85 -0
- data/vendor/xml-mapping/examples/xpath_create_new.intout +181 -0
- data/vendor/xml-mapping/examples/xpath_docvsroot.intin.rb +30 -0
- data/vendor/xml-mapping/examples/xpath_docvsroot.intout +34 -0
- data/vendor/xml-mapping/examples/xpath_ensure_created.intin.rb +62 -0
- data/vendor/xml-mapping/examples/xpath_ensure_created.intout +114 -0
- data/vendor/xml-mapping/examples/xpath_pathological.intin.rb +42 -0
- data/vendor/xml-mapping/examples/xpath_pathological.intout +56 -0
- data/vendor/xml-mapping/examples/xpath_usage.intin.rb +51 -0
- data/vendor/xml-mapping/examples/xpath_usage.intout +57 -0
- data/vendor/xml-mapping/install.rb +40 -0
- data/vendor/xml-mapping/lib/xml/mapping.rb +14 -0
- data/vendor/xml-mapping/lib/xml/mapping/base.rb +571 -0
- data/vendor/xml-mapping/lib/xml/mapping/standard_nodes.rb +343 -0
- data/vendor/xml-mapping/lib/xml/mapping/version.rb +8 -0
- data/vendor/xml-mapping/lib/xml/xxpath.rb +354 -0
- data/vendor/xml-mapping/test/all_tests.rb +6 -0
- data/vendor/xml-mapping/test/company.rb +56 -0
- data/vendor/xml-mapping/test/documents_folders.rb +33 -0
- data/vendor/xml-mapping/test/fixtures/bookmarks1.xml +24 -0
- data/vendor/xml-mapping/test/fixtures/company1.xml +85 -0
- data/vendor/xml-mapping/test/fixtures/documents_folders.xml +71 -0
- data/vendor/xml-mapping/test/fixtures/documents_folders2.xml +30 -0
- data/vendor/xml-mapping/test/multiple_mappings.rb +80 -0
- data/vendor/xml-mapping/test/tests_init.rb +2 -0
- data/vendor/xml-mapping/test/xml_mapping_adv_test.rb +84 -0
- data/vendor/xml-mapping/test/xml_mapping_test.rb +201 -0
- data/vendor/xml-mapping/test/xpath_test.rb +273 -0
- metadata +191 -0
@@ -0,0 +1,195 @@
|
|
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: page.rb,v 1.3 2005/06/02 21:20:35 austin Exp $
|
10
|
+
#++
|
11
|
+
# A page object, it also creates a contents object to hold its contents
|
12
|
+
class PDF::Writer::Object::Page < PDF::Writer::Object
|
13
|
+
# Create a page. The optional +relative+ is a Hash with keys :pos =>
|
14
|
+
# :before|:after and :rpage, the page to which this new page will be
|
15
|
+
# added relative.
|
16
|
+
def initialize(parent, relative = nil)
|
17
|
+
super(parent)
|
18
|
+
|
19
|
+
@parent.current_page = self
|
20
|
+
@owner = @parent.instance_variable_get('@current_node')
|
21
|
+
@page_number = @parent.pages.size
|
22
|
+
@contents = []
|
23
|
+
|
24
|
+
if relative.nil?
|
25
|
+
@parent.pages << self
|
26
|
+
else
|
27
|
+
relative[:page] = self
|
28
|
+
@parent.pages.add(relative)
|
29
|
+
end
|
30
|
+
|
31
|
+
# make a contents object to go with this page
|
32
|
+
@contents << PDF::Writer::Object::Contents.new(@parent, self)
|
33
|
+
@parent.instance_variable_set('@current_contents', @contents[-1])
|
34
|
+
match = (@parent.pages.size % 2 == 0 ? :even_pages : :odd_pages)
|
35
|
+
# Cheat here. I don't want to add an unnecessary attribute.
|
36
|
+
@parent.instance_variable_get('@add_loose_objects').each do |obj, target|
|
37
|
+
@contents << obj if target == :all_pages or match == target
|
38
|
+
end
|
39
|
+
|
40
|
+
@annotations = []
|
41
|
+
|
42
|
+
@media_box = nil
|
43
|
+
@crop_box = nil
|
44
|
+
@bleed_box = nil
|
45
|
+
@trim_box = nil
|
46
|
+
@art_box = nil
|
47
|
+
end
|
48
|
+
|
49
|
+
attr_accessor :contents
|
50
|
+
attr_reader :page_number
|
51
|
+
|
52
|
+
def add_annotation(a)
|
53
|
+
@annotations << a
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_s
|
57
|
+
res = "\n#{@oid} 0 obj\n<< /Type /Page\n/Parent #{@owner.oid} 0 R"
|
58
|
+
unless @annotations.empty?
|
59
|
+
res << "\n/Annots ["
|
60
|
+
@annotations.each { |e| res << " #{e.oid} 0 R"}
|
61
|
+
res << "]"
|
62
|
+
end
|
63
|
+
|
64
|
+
if @contents.size == 1
|
65
|
+
res << "\n/Contents #{@contents[0].oid} 0 R"
|
66
|
+
else
|
67
|
+
res << "\n/Contents [\n"
|
68
|
+
@contents.each { |c| res << "#{c.oid} 0 R\n" }
|
69
|
+
res << "]"
|
70
|
+
end
|
71
|
+
|
72
|
+
# MediaBox:: rectangle (Required; inheritable). A rectangle (see
|
73
|
+
# Section 3.8.4, �Rectangles�), expressed in default user
|
74
|
+
# space units, defining the boundaries of the physical
|
75
|
+
# medium on which the page is intended to be displayed or
|
76
|
+
# printed (see Section 10.10.1, �Page Boundaries�).
|
77
|
+
res << "\n/MediaBox [#{@media_box.join(' ')}]" unless @media_box.nil? or @media_box.empty?
|
78
|
+
# CropBox:: rectangle (Optional; inheritable) A rectangle, expressed
|
79
|
+
# in default user space units, defining the visible region
|
80
|
+
# of default user space. When the page is displayed or
|
81
|
+
# printed, its contents are to be clipped (cropped) to
|
82
|
+
# this rectangle and then imposed on the output medium in
|
83
|
+
# some implementation-defined manner (see Section 10.10.1,
|
84
|
+
# �Page Boundaries�). Default value: the value of MediaBox.
|
85
|
+
res << "\n/CropBox [#{@crop_box.join(' ')}]" unless @crop_box.nil? or @crop_box.empty?
|
86
|
+
# BleedBox:: rectangle (Optional; PDF 1.3) A rectangle, expressed in
|
87
|
+
# default user space units, defining the region to which
|
88
|
+
# the contents of the page should be clipped when output
|
89
|
+
# in a production environment (see Section 10.10.1, �Page
|
90
|
+
# Boundaries�). Default value: the value of CropBox.
|
91
|
+
res << "\n/BleedBox [#{@bleed_box.join(' ')}]" unless @bleed_box.nil? or @bleed_box.empty?
|
92
|
+
# TrimBox:: rectangle (Optional; PDF 1.3) A rectangle, expressed in
|
93
|
+
# default user space units, defining the intended
|
94
|
+
# dimensions of the finished page after trimming (see
|
95
|
+
# Section 10.10.1, �Page Boundaries�). Default value: the
|
96
|
+
# value of CropBox.
|
97
|
+
res << "\n/TrimBox [#{@trim_box.join(' ')}]" unless @trim_box.nil? or @trim_box.empty?
|
98
|
+
# ArtBox:: rectangle (Optional; PDF 1.3) A rectangle, expressed in
|
99
|
+
# default user space units, defining the extent of the
|
100
|
+
# page�s meaningful content (including potential white
|
101
|
+
# space) as intended by the page�s creator (see Section
|
102
|
+
# 10.10.1, �Page Boundaries�). Default value: the value of
|
103
|
+
# CropBox.
|
104
|
+
res << "\n/ArtBox [#{@art_box.join(' ')}]" unless @art_box.nil? or @art_box.empty?
|
105
|
+
|
106
|
+
res << "\n>>\nendobj"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# BoxColorInfo:: dictionary (Optional; PDF 1.4) A box color information
|
111
|
+
# dictionary specifying the colors and other visual
|
112
|
+
# characteristics to be used in displaying guidelines on
|
113
|
+
# the screen for the various page boundaries (see �Display
|
114
|
+
# of Page Boundaries� on page 893). If this entry is
|
115
|
+
# absent, the application should use its own current
|
116
|
+
# default settings.
|
117
|
+
#
|
118
|
+
# Rotate:: integer (Optional; inheritable) The number of degrees by
|
119
|
+
# which the page should be rotated clockwise when
|
120
|
+
# displayed or printed. The value must be a multiple of
|
121
|
+
# 90. Default value: 0.
|
122
|
+
# Group:: dictionary (Optional; PDF 1.4) A group attributes
|
123
|
+
# dictionary specifying the attributes of the page�s page
|
124
|
+
# group for use in the transparent imaging model (see
|
125
|
+
# Sections 7.3.6, �Page Group,� and 7.5.5, �Transparency
|
126
|
+
# Group XObjects�).
|
127
|
+
# Thumb:: stream (Optional) A stream object defining the page�s
|
128
|
+
# thumbnail image (see Section 8.2.3, �Thumbnail Images�).
|
129
|
+
# B:: array (Optional; PDF 1.1; recommended if the page
|
130
|
+
# contains article beads) An array of indirect references
|
131
|
+
# to article beads appearing on the page (see Section
|
132
|
+
# 8.3.2, �Articles�; see also implementation note 37 in
|
133
|
+
# Appendix H). The beads are listed in the array in
|
134
|
+
# natural reading order.
|
135
|
+
# Dur:: number (Optional; PDF 1.1) The page�s display duration
|
136
|
+
# (also called its advance timing): the maximum length of
|
137
|
+
# time, in seconds, that the page is displayed during
|
138
|
+
# presentations before the viewer application
|
139
|
+
# automatically advances to the next page (see Section
|
140
|
+
# 8.3.3, �Presentations�). By default, the viewer does not
|
141
|
+
# advance automatically.
|
142
|
+
# Trans:: dictionary (Optional; PDF 1.1) A transition dictionary
|
143
|
+
# describing the transition effect to be used when
|
144
|
+
# displaying the page during presentations (see Section
|
145
|
+
# 8.3.3, �Presentations�).
|
146
|
+
# Annots:: array (Optional) An array of annotation dictionaries
|
147
|
+
# representing annotations associated with the page (see
|
148
|
+
# Section 8.4, �Annotations�).
|
149
|
+
# AA:: dictionary (Optional; PDF 1.2) An additional-actions
|
150
|
+
# dictionary defining actions to be performed when the
|
151
|
+
# page is opened or closed (see Section 8.5.2, �Trigger
|
152
|
+
# Events�; see also implementation note 38 in Appendix H).
|
153
|
+
# Metadata:: stream (Optional; PDF 1.4) A metadata stream containing
|
154
|
+
# metadata for the page (see Section 10.2.2, �Metadata
|
155
|
+
# Streams�).
|
156
|
+
# PieceInfo:: dictionary (Optional; PDF 1.3) A page-piece dictionary
|
157
|
+
# associated with the page (see Section 10.4, �Page-Piece
|
158
|
+
# Dictionaries�).
|
159
|
+
# StructParents:: integer (Required if the page contains structural
|
160
|
+
# content items; PDF 1.3) The integer key of the page�s
|
161
|
+
# entry in the structural parent tree (see �Finding
|
162
|
+
# Structure Elements from Content Items� on page 797).
|
163
|
+
# ID:: string (Optional; PDF 1.3; indirect reference preferred)
|
164
|
+
# The digital identifier of the page�s parent Web Capture
|
165
|
+
# content set (see Section 10.9.5, �Object Attributes
|
166
|
+
# Related to Web Capture�).
|
167
|
+
# PZ:: number (Optional; PDF 1.3) The page�s preferred zoom
|
168
|
+
# (magnification) factor: the factor by which it should be
|
169
|
+
# scaled to achieve the natural display magnification (see
|
170
|
+
# Section 10.9.5, �Object Attributes Related to Web
|
171
|
+
# Capture�).
|
172
|
+
# SeparationInfo:: dictionary (Optional; PDF 1.3) A separation dictionary
|
173
|
+
# containing information needed to generate color
|
174
|
+
# separations for the page (see Section 10.10.3,
|
175
|
+
# �Separation Dictionaries�).
|
176
|
+
# Tabs:: name (Optional; PDF 1.5) A name specifying the tab order
|
177
|
+
# to be used for annotations on the page. The possible
|
178
|
+
# values are R (row order), C (column order), and S
|
179
|
+
# (structure order). See Section 8.4, �Annotations,� for
|
180
|
+
# details.
|
181
|
+
# TemplateInstantiated:: name (Required if this page was created from a
|
182
|
+
# named page object; PDF 1.5) The name of the
|
183
|
+
# originating page object (see Section 8.6.5,
|
184
|
+
# �Named Pages�).
|
185
|
+
# PresSteps:: dictionary (Optional; PDF 1.5) A navigation node
|
186
|
+
# dictionary representing the first node on the page (see
|
187
|
+
# �Sub-page Navigation� on page 566).
|
188
|
+
# UserUnit:: number (Optional; PDF 1.6) A positive number giving the
|
189
|
+
# size of default user space units, in multiples of 1/72
|
190
|
+
# inch. The range of supported values is
|
191
|
+
# implementation-dependent; see implementation note 171 in
|
192
|
+
# Appendix H. Default value: 1.0 (user unit is 1/72 inch).
|
193
|
+
# VP:: dictionary (Optional; PDF 1.6) An array of viewport
|
194
|
+
# dictionaries (see Table 8.105) specifying rectangular
|
195
|
+
# regions of the page.
|
@@ -0,0 +1,115 @@
|
|
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: pages.rb,v 1.2 2005/05/16 03:59:21 austin Exp $
|
10
|
+
#++
|
11
|
+
# object which is a parent to the pages in the document
|
12
|
+
class PDF::Writer::Object::Pages < PDF::Writer::Object
|
13
|
+
def initialize(parent)
|
14
|
+
super(parent)
|
15
|
+
|
16
|
+
@parent.catalog.pages = self
|
17
|
+
|
18
|
+
@pages = []
|
19
|
+
@procset = nil
|
20
|
+
@media_box = nil
|
21
|
+
@fonts = []
|
22
|
+
@xObjects = []
|
23
|
+
@bleed_box = nil
|
24
|
+
@trim_box = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def size
|
28
|
+
@pages.size
|
29
|
+
end
|
30
|
+
|
31
|
+
def first_page
|
32
|
+
@pages[0]
|
33
|
+
end
|
34
|
+
|
35
|
+
# Add the page ID to the end of the page list.
|
36
|
+
def <<(p)
|
37
|
+
if p.kind_of?(PDF::Writer::Object::Page)
|
38
|
+
@pages << p
|
39
|
+
elsif p.kind_of?(PDF::Writer::Object::Font)
|
40
|
+
@fonts << p
|
41
|
+
elsif p.kind_of?(PDF::Writer::External)
|
42
|
+
@xObjects << p
|
43
|
+
else
|
44
|
+
raise ArgumentError, PDF::Message[:req_FPXO]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Add a page to the page list. If p is just a Page, then it will be
|
49
|
+
# added to the page list. Otherwise, it will be treated as a Hash with
|
50
|
+
# keys :page, :pos, and :rpage. :page is the Page to be added to the
|
51
|
+
# list; :pos is :before or :after; :rpage is the Page to which the
|
52
|
+
# new Page will be added relative to.
|
53
|
+
def add(p)
|
54
|
+
if p.kind_of?(PDF::Writer::Object::Page)
|
55
|
+
@pages << p
|
56
|
+
elsif p.kind_of?(PDF::Writer::FontMetrics)
|
57
|
+
@fonts << p
|
58
|
+
elsif p.kind_of?(PDF::Writer::External)
|
59
|
+
@xObjects << p
|
60
|
+
elsif p.kind_of?(Hash)
|
61
|
+
# Find a match.
|
62
|
+
i = @pages.index(p[:rpage])
|
63
|
+
unless i.nil?
|
64
|
+
# There is a match; insert the page.
|
65
|
+
case p[:pos]
|
66
|
+
when :before
|
67
|
+
@pages[i, 0] = p[:page]
|
68
|
+
when :after
|
69
|
+
@pages[i + 1, 0] = p[:page]
|
70
|
+
else
|
71
|
+
raise ArgumentError, PDF::Message[:invalid_pos]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
else
|
75
|
+
raise ArgumentError, PDF::Message[:req_FPXOH]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
attr_accessor :procset
|
80
|
+
# Each of the following should be an array of 4 numbers, the x and y
|
81
|
+
# coordinates of the lower left and upper right bounds of the box.
|
82
|
+
attr_accessor :media_box
|
83
|
+
attr_accessor :bleed_box
|
84
|
+
attr_accessor :trim_box
|
85
|
+
|
86
|
+
def to_s
|
87
|
+
unless @pages.empty?
|
88
|
+
res = "\n#{@oid} 0 obj\n<< /Type /Pages\n/Kids ["
|
89
|
+
@pages.uniq! # uniqify the data...
|
90
|
+
@pages.each { |p| res << "#{p.oid} 0 R\n" }
|
91
|
+
res << "]\n/Count #{@pages.size}"
|
92
|
+
unless @fonts.empty? and @procset.nil?
|
93
|
+
res << "\n/Resources <<"
|
94
|
+
res << "\n/ProcSet #{@procset.oid} 0 R" unless @procset.nil?
|
95
|
+
unless @fonts.empty?
|
96
|
+
res << "\n/Font << "
|
97
|
+
@fonts.each { |f| res << "\n/F#{f.font_id} #{f.oid} 0 R" }
|
98
|
+
res << " >>"
|
99
|
+
end
|
100
|
+
unless @xObjects.empty?
|
101
|
+
res << "\n/XObject << "
|
102
|
+
@xObjects.each { |x| res << "\n/#{x.label} #{x.oid} 0 R" }
|
103
|
+
res << " >>"
|
104
|
+
end
|
105
|
+
res << "\n>>"
|
106
|
+
res << "\n/MediaBox [#{@media_box.join(' ')}]" unless @media_box.nil? or @media_box.empty?
|
107
|
+
res << "\n/BleedBox [#{@bleed_box.join(' ')}]" unless @bleed_box.nil? or @bleed_box.empty?
|
108
|
+
res << "\n/TrimBox [#{@trim_box.join(' ')}]" unless @trim_box.nil? or @trim_box.empty?
|
109
|
+
end
|
110
|
+
res << "\n >>\nendobj"
|
111
|
+
else
|
112
|
+
"\n#{@oid} 0 obj\n<< /Type /Pages\n/Count 0\n>>\nendobj"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,46 @@
|
|
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: procset.rb,v 1.2 2005/05/16 03:59:21 austin Exp $
|
10
|
+
#++
|
11
|
+
# The document Procedure Set. Not necessary in PDF 1.4 or later, but
|
12
|
+
# producing applications are recommended to provide the /ProcSet /Resource
|
13
|
+
# in any case for older viewers. Viewing applications are *not*
|
14
|
+
# recommended to rely on this information being correct.
|
15
|
+
#
|
16
|
+
# These procedure sets are used only when the content stream is printed to
|
17
|
+
# a PostScript output device; the names identify PostScript procedure sets
|
18
|
+
# that must be sent to the device to interpret the PDF operators in the
|
19
|
+
# content stream. Each element of this array must be one of the following
|
20
|
+
# predefined names: 'PDF', 'Text', 'ImageB', 'ImageC', and 'ImageI'. See
|
21
|
+
# also Appendix H note 102.
|
22
|
+
class PDF::Writer::Object::Procset < PDF::Writer::Object
|
23
|
+
def initialize(parent)
|
24
|
+
super
|
25
|
+
|
26
|
+
@info = ["PDF", "Text"]
|
27
|
+
@parent.pages.procset = self
|
28
|
+
@parent.procset = self
|
29
|
+
end
|
30
|
+
|
31
|
+
# This is to add new items to the procset list, despite the fact that
|
32
|
+
# this is considered obselete, the items are required for printing to
|
33
|
+
# some PostsCript printers.
|
34
|
+
#
|
35
|
+
# +p+ may be 'ImageB', 'ImageC', or 'ImageI'.
|
36
|
+
def <<(p)
|
37
|
+
@info << p
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_s
|
41
|
+
info = @info.uniq
|
42
|
+
res = "\n#{@oid} 0 obj\n["
|
43
|
+
@info.each { |k| res << "/#{k} " }
|
44
|
+
res << "]\nendobj"
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,74 @@
|
|
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: viewerpreferences.rb,v 1.2 2005/05/16 03:59:21 austin Exp $
|
10
|
+
#++
|
11
|
+
# Set the viewer preferences.
|
12
|
+
#
|
13
|
+
# HideToolbar:: boolean (Optional) A flag specifying whether to hide the
|
14
|
+
# viewer application? tool bars when the document is
|
15
|
+
# active. Default value: false.
|
16
|
+
# HideMenubar:: boolean (Optional) A flag specifying whether to hide the
|
17
|
+
# viewer application? menu bar when the document is
|
18
|
+
# active. Default value: false.
|
19
|
+
# HideWindowUI:: boolean (Optional) A flag specifying whether to hide
|
20
|
+
# user interface elements in the document? window (such as
|
21
|
+
# scroll bars and navigation controls), leaving only the
|
22
|
+
# document? contents displayed. Default value: false.
|
23
|
+
# FitWindow:: boolean (Optional) A flag specifying whether to resize
|
24
|
+
# the document? window to fit the size of the first
|
25
|
+
# displayed page. Default value: false.
|
26
|
+
# CenterWindow:: boolean (Optional) A flag specifying whether to position
|
27
|
+
# the document? window in the center of the screen.
|
28
|
+
# Default value: false.
|
29
|
+
# NonFullScreenPageMode:: name (Optional) The document? page mode,
|
30
|
+
# specifying how to display the document on
|
31
|
+
# exiting full-screen mode. This entry is
|
32
|
+
# meaningful only if the value of the PageMode
|
33
|
+
# entry in the catalog dictionary is FullScreen;
|
34
|
+
# it is ignored otherwise. Default value: UseNone.
|
35
|
+
# Direction:: name (Optional; PDF 1.3) The predominant reading
|
36
|
+
# order for text: L2R Left to right R2L Right to
|
37
|
+
# left (including vertical writing systems such as
|
38
|
+
# Chinese, Japanese, and Korean) This entry has no
|
39
|
+
# direct effect on the document? contents or page
|
40
|
+
# numbering, but can be used to determine the
|
41
|
+
# relative positioning of pages when displayed
|
42
|
+
# side by side or printed n-up. Default value:
|
43
|
+
# L2R.
|
44
|
+
#
|
45
|
+
# NonFullScreenPageMode Names
|
46
|
+
# UseNone:: Neither document outline nor thumbnail images visible
|
47
|
+
# UseOutlines:: Document outline visible
|
48
|
+
# UseThumbs:: Thumbnail images visible
|
49
|
+
#
|
50
|
+
# Note that boolean values are represented by the values 'true' and
|
51
|
+
# 'false'. Also note that I have not done much testing on changing these
|
52
|
+
# values and am not sure how responsive the various viewers and browsers
|
53
|
+
# are to them (and setting the direction would be fairly meaningless as
|
54
|
+
# none of these character sets are avaliable yet.
|
55
|
+
class PDF::Writer::Object::ViewerPreferences < PDF::Writer::Object
|
56
|
+
Preferences = %w{HideToolbar HideMenubar HideWindowUI FitWindow CenterWindow NonFullScreenPageMode Direction}
|
57
|
+
|
58
|
+
def initialize(parent)
|
59
|
+
super(parent)
|
60
|
+
end
|
61
|
+
|
62
|
+
Preferences.each do |s|
|
63
|
+
attr_accessor s.downcase.intern
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_s
|
67
|
+
res = "\n#{@id} 0 obj\n<< "
|
68
|
+
Preferences.each do |s|
|
69
|
+
v = __send__("#{s.downcase}".intern)
|
70
|
+
res << "\n/#{s} /#{v}" unless v.nil?
|
71
|
+
end
|
72
|
+
res << "\n>>\n"
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,58 @@
|
|
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: ohash.rb,v 1.2 2005/05/16 03:59:21 austin Exp $
|
10
|
+
#++
|
11
|
+
# Based on [ruby-talk:20551]. Updated to (hopefully) be 1.8 friendly.
|
12
|
+
class PDF::Writer::OHash < Hash
|
13
|
+
alias_method :store, :[]=
|
14
|
+
alias_method :each_pair, :each
|
15
|
+
|
16
|
+
def initialize(*args)
|
17
|
+
@keys = []
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def []=(key, val)
|
22
|
+
@keys << key unless has_key?(key)
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete(key)
|
27
|
+
@keys.delete(key) if has_key?(key)
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
def each
|
32
|
+
@keys.each { |k| yield k, self[k] }
|
33
|
+
end
|
34
|
+
|
35
|
+
def each_key
|
36
|
+
@keys.each { |k| yield k }
|
37
|
+
end
|
38
|
+
|
39
|
+
def each_value
|
40
|
+
@keys.each { |k| yield self[k] }
|
41
|
+
end
|
42
|
+
|
43
|
+
def first
|
44
|
+
self[@keys[0]]
|
45
|
+
end
|
46
|
+
|
47
|
+
def last
|
48
|
+
self[@keys[-1]]
|
49
|
+
end
|
50
|
+
|
51
|
+
def first?(item)
|
52
|
+
self[@keys[0]] == item
|
53
|
+
end
|
54
|
+
|
55
|
+
def last?(item)
|
56
|
+
self[@keys[-1]] == item
|
57
|
+
end
|
58
|
+
end
|