Class PDF::Writer::Object::Pages
In: lib/pdf/writer/object/pages.rb
Parent: PDF::Writer::Object
TechBook Transaction::Simple SimpleTable Complex Action FontDescriptor Procset Catalog FontEncoding Pages Destination Info Encryption Annotation Contents Outline Page Outlines Font ViewerPreferences Image Hash OHash QuickRef StdDev FontMetrics StrokeStyle ARC4 PolygonPoint ImageInfo lib/pdf/simpletable.rb lib/pdf/writer.rb lib/pdf/techbook.rb lib/pdf/quickref.rb lib/pdf/charts/stddev.rb Charts Math lib/pdf/writer/ohash.rb lib/pdf/writer/fontmetrics.rb lib/pdf/writer/strokestyle.rb lib/pdf/writer/arc4.rb lib/pdf/writer/graphics.rb lib/pdf/writer/object.rb lib/pdf/writer/object/image.rb External lib/pdf/writer/object/font.rb lib/pdf/writer/object/outlines.rb lib/pdf/writer/object/contents.rb lib/pdf/writer/object/annotation.rb lib/pdf/writer/object/destination.rb lib/pdf/writer/object/viewerpreferences.rb lib/pdf/writer/object/info.rb lib/pdf/writer/object/fontencoding.rb lib/pdf/writer/object/page.rb lib/pdf/writer/object/catalog.rb lib/pdf/writer/object/outline.rb lib/pdf/writer/object/encryption.rb lib/pdf/writer/object/procset.rb lib/pdf/writer/object/action.rb lib/pdf/writer/object/pages.rb lib/pdf/writer/object/fontdescriptor.rb Object OffsetReader EN Lang lib/pdf/writer/graphics/imageinfo.rb Graphics Writer PDF dot/m_33_0.png

object which is a parent to the pages in the document

Methods

<<   add   first_page   new   size   to_s  

Attributes

bleed_box  [RW] 
media_box  [RW]  Each of the following should be an array of 4 numbers, the x and y coordinates of the lower left and upper right bounds of the box.
procset  [RW] 
trim_box  [RW] 

Public Class methods

[Source]

    # File lib/pdf/writer/object/pages.rb, line 13
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

Public Instance methods

Add the page ID to the end of the page list.

[Source]

    # File lib/pdf/writer/object/pages.rb, line 36
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

Add a page to the page list. If p is just a Page, then it will be added to the page list. Otherwise, it will be treated as a Hash with keys :page, :pos, and :rpage. :page is the Page to be added to the list; :pos is :before or :after; :rpage is the Page to which the new Page will be added relative to.

[Source]

    # File lib/pdf/writer/object/pages.rb, line 53
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

[Source]

    # File lib/pdf/writer/object/pages.rb, line 31
31:   def first_page
32:     @pages[0]
33:   end

[Source]

    # File lib/pdf/writer/object/pages.rb, line 27
27:   def size
28:     @pages.size
29:   end

[Source]

     # File lib/pdf/writer/object/pages.rb, line 86
 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

[Validate]