Class: Origami::Page
- Inherits:
-
Dictionary
- Object
- Hash
- Dictionary
- Origami::Page
- Includes:
- ResourcesHolder, StandardObject
- Defined in:
- lib/origami/page.rb,
lib/origami/graphics/xobject.rb
Overview
class ContentStream
Defined Under Namespace
Modules: Format
Constant Summary
Constants included from StandardObject
StandardObject::DEFAULT_ATTRIBUTES
Constants inherited from Dictionary
Constants included from Object
Instance Attribute Summary
Attributes inherited from Dictionary
#names_cache, #strings_cache, #xref_cache
Attributes included from Object
#file_offset, #generation, #no, #objstm_offset, #parent
Instance Method Summary collapse
-
#add_annot(*annotations) ⇒ Object
Add an Annotation to the Page.
-
#add_flash_application(swfspec, params = {}) ⇒ Object
Embed a SWF Flash application in the page.
-
#annotations ⇒ Object
Returns the array of Annotation objects of the Page.
-
#draw_image ⇒ Object
TODO :nodoc:.
-
#draw_line(from, to, attr = {}) ⇒ Object
See ContentStream#draw_line.
-
#draw_polygon(coords = [], attr = {}) ⇒ Object
See ContentStream#draw_polygon.
-
#draw_rectangle(x, y, width, height, attr = {}) ⇒ Object
See ContentStream#draw_rectangle.
-
#each_annot(&b) ⇒ Object
Iterate through each Annotation of the Page.
-
#initialize(hash = {}) ⇒ Page
constructor
A new instance of Page.
-
#onClose(action) ⇒ Object
Will execute an action when the page is closed.
-
#onNavigateBackward(action) ⇒ Object
Will execute an action when navigating backward from this page.
-
#onNavigateForward(action) ⇒ Object
Will execute an action when navigating forward from this page.
-
#onOpen(action) ⇒ Object
Will execute an action when the page is opened.
-
#paint_shading(shade) ⇒ Object
TODO :nodoc:.
- #pre_build ⇒ Object
-
#render(engine) ⇒ Object
:nodoc:.
-
#set_dash_pattern(pattern) ⇒ Object
See ContentStream#set_dash_pattern.
-
#set_fill_color(color) ⇒ Object
See ContentStream#set_fill_color.
-
#set_line_cap(cap) ⇒ Object
See ContentStream#set_line_cap.
-
#set_line_join(join) ⇒ Object
See ContentStream#set_line_join.
-
#set_line_width(width) ⇒ Object
See ContentStream#set_line_width.
-
#set_stroke_color(color) ⇒ Object
See ContentStream#set_stroke_color.
-
#set_text_char_spacing(char_spacing) ⇒ Object
See ContentStream#set_text_char_spacing.
-
#set_text_font(font, size) ⇒ Object
TODO :nodoc:.
-
#set_text_leading(leading) ⇒ Object
See ContentStream#set_text_leading.
-
#set_text_pos(tx, ty) ⇒ Object
See ContentStream#set_text_pos.
-
#set_text_rendering(rendering) ⇒ Object
See ContentStream#set_text_rendering.
-
#set_text_rise(rise) ⇒ Object
See ContentStream#set_text_rise.
-
#set_text_scale(scaling) ⇒ Object
See ContentStream#set_text_scale.
-
#set_text_word_spacing(word_spacing) ⇒ Object
See ContentStream#set_text_word_spacing.
-
#write(text, attr = {}) ⇒ Object
See ContentStream#write.
Methods included from ResourcesHolder
#add_colorspace, #add_extgstate, #add_font, #add_pattern, #add_properties, #add_resource, #add_shading, #add_xobject, #colorspaces, #extgstates, #fonts, #ls_resources, #patterns, #properties, #resources, #shadings, #xobjects
Methods included from StandardObject
#do_type_check, #has_field?, included, #pdf_version_required, #set_default_value, #set_default_values
Methods inherited from Dictionary
#[], #[]=, add_type_info, #cast_to, #copy, #delete, guess_type, #has_key?, hint_type, #map!, #merge, #method_missing, native_type, parse, #to_obfuscated_str, #to_s
Methods included from Object
#<=>, #cast_to, #copy, #export, #indirect_parent, #is_indirect?, #logicalize, #logicalize!, native_type, #native_type, parse, #pdf, #pdf_version_required, #post_build, #reference, #resolve_all_references, #set_indirect, #set_pdf, #size, skip_until_next_obj, #solve, #to_o, #to_s, #type, typeof, #xrefs
Methods inherited from Hash
Constructor Details
#initialize(hash = {}) ⇒ Page
Returns a new instance of Page.
464 465 466 467 468 |
# File 'lib/origami/page.rb', line 464 def initialize(hash = {}) super(hash) set_indirect(true) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Origami::Dictionary
Instance Method Details
#add_annot(*annotations) ⇒ Object
Add an Annotation to the Page.
479 480 481 482 483 484 485 486 487 488 489 490 |
# File 'lib/origami/page.rb', line 479 def add_annot(*annotations) unless annotations.all?{|annot| annot.is_a?(Annotation) or annot.is_a?(Reference)} raise TypeError, "Only Annotation objects must be passed." end self.Annots ||= [] annotations.each do |annot| annot.solve[:P] = self if is_indirect? self.Annots << annot end end |
#add_flash_application(swfspec, params = {}) ⇒ Object
Embed a SWF Flash application in the page.
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
# File 'lib/origami/page.rb', line 517 def add_flash_application(swfspec, params = {}) = { :windowed => false, :transparent => false, :navigation_pane => false, :toolbar => false, :pass_context_click => false, :activation => Annotation::RichMedia::Activation::PAGE_OPEN, :deactivation => Annotation::RichMedia::Deactivation::PAGE_CLOSE, :flash_vars => nil } .update(params) annot = create_richmedia(:Flash, swfspec, ) add_annot(annot) annot end |
#annotations ⇒ Object
Returns the array of Annotation objects of the Page.
507 508 509 510 511 512 |
# File 'lib/origami/page.rb', line 507 def annotations annots = self.Annots return [] unless annots.is_a?(Array) annots.map{|annot| annot.solve} end |
#draw_image ⇒ Object
TODO :nodoc:
458 459 460 |
# File 'lib/origami/graphics/xobject.rb', line 458 def draw_image raise NotImplementedError end |
#draw_line(from, to, attr = {}) ⇒ Object
See ContentStream#draw_line.
463 464 465 |
# File 'lib/origami/graphics/xobject.rb', line 463 def draw_line(from, to, attr = {}) last_content_stream.draw_line(from, to, attr); self end |
#draw_polygon(coords = [], attr = {}) ⇒ Object
See ContentStream#draw_polygon.
468 469 470 |
# File 'lib/origami/graphics/xobject.rb', line 468 def draw_polygon(coords = [], attr = {}) last_content_stream.draw_polygon(coords, attr); self end |
#draw_rectangle(x, y, width, height, attr = {}) ⇒ Object
See ContentStream#draw_rectangle.
473 474 475 |
# File 'lib/origami/graphics/xobject.rb', line 473 def draw_rectangle(x, y, width, height, attr = {}) last_content_stream.draw_rectangle(x, y, width, height, attr); self end |
#each_annot(&b) ⇒ Object
Iterate through each Annotation of the Page.
495 496 497 498 499 500 501 502 |
# File 'lib/origami/page.rb', line 495 def each_annot(&b) annots = self.Annots return unless annots.is_a?(Array) annots.each do |annot| b.call(annot.solve) end end |
#onClose(action) ⇒ Object
Will execute an action when the page is closed.
554 555 556 557 558 559 560 561 562 563 |
# File 'lib/origami/page.rb', line 554 def onClose(action) unless action.is_a?(Action) or action.is_a?(Reference) raise TypeError, "An Action object must be passed." end self.AA ||= PageAdditionalActions.new self.AA.C = action self end |
#onNavigateBackward(action) ⇒ Object
Will execute an action when navigating backward from this page.
582 583 584 585 586 587 588 589 590 591 |
# File 'lib/origami/page.rb', line 582 def onNavigateBackward(action) #:nodoc: unless action.is_a?(Action) or action.is_a?(Reference) raise TypeError, "An Action object must be passed." end self.PresSteps ||= NavigationNode.new self.PresSteps.PA = action self end |
#onNavigateForward(action) ⇒ Object
Will execute an action when navigating forward from this page.
568 569 570 571 572 573 574 575 576 577 |
# File 'lib/origami/page.rb', line 568 def onNavigateForward(action) #:nodoc: unless action.is_a?(Action) or action.is_a?(Reference) raise TypeError, "An Action object must be passed." end self.PresSteps ||= NavigationNode.new self.PresSteps.NA = action self end |
#onOpen(action) ⇒ Object
Will execute an action when the page is opened.
540 541 542 543 544 545 546 547 548 549 |
# File 'lib/origami/page.rb', line 540 def onOpen(action) unless action.is_a?(Action) or action.is_a?(Reference) raise TypeError, "An Action object must be passed." end self.AA ||= PageAdditionalActions.new self.AA.O = action self end |
#paint_shading(shade) ⇒ Object
TODO :nodoc:
483 484 485 |
# File 'lib/origami/graphics/xobject.rb', line 483 def paint_shading(shade) raise NotImplementedError end |
#pre_build ⇒ Object
470 471 472 473 474 |
# File 'lib/origami/page.rb', line 470 def pre_build self.Resources = Resources.new.pre_build unless self.has_key?(:Resources) super end |
#render(engine) ⇒ Object
:nodoc:
446 447 448 449 450 451 452 453 454 455 |
# File 'lib/origami/graphics/xobject.rb', line 446 def render(engine) #:nodoc: contents = self.Contents contents = [ contents ] unless contents.is_a? Array contents.each do |stream| stream = stream.cast_to(ContentStream) unless stream.is_a? ContentStream stream.render(engine) end end |
#set_dash_pattern(pattern) ⇒ Object
See ContentStream#set_dash_pattern.
538 539 540 |
# File 'lib/origami/graphics/xobject.rb', line 538 def set_dash_pattern(pattern) last_content_stream.set_dash_pattern(pattern); self end |
#set_fill_color(color) ⇒ Object
See ContentStream#set_fill_color.
528 529 530 |
# File 'lib/origami/graphics/xobject.rb', line 528 def set_fill_color(color) last_content_stream.set_fill_color(color); self end |
#set_line_cap(cap) ⇒ Object
See ContentStream#set_line_cap.
548 549 550 |
# File 'lib/origami/graphics/xobject.rb', line 548 def set_line_cap(cap) last_content_stream.set_line_cap(cap); self end |
#set_line_join(join) ⇒ Object
See ContentStream#set_line_join.
553 554 555 |
# File 'lib/origami/graphics/xobject.rb', line 553 def set_line_join(join) last_content_stream.set_line_join(join); self end |
#set_line_width(width) ⇒ Object
See ContentStream#set_line_width.
543 544 545 |
# File 'lib/origami/graphics/xobject.rb', line 543 def set_line_width(width) last_content_stream.set_line_width(width); self end |
#set_stroke_color(color) ⇒ Object
See ContentStream#set_stroke_color.
533 534 535 |
# File 'lib/origami/graphics/xobject.rb', line 533 def set_stroke_color(color) last_content_stream.set_stroke_color(color); self end |
#set_text_char_spacing(char_spacing) ⇒ Object
See ContentStream#set_text_char_spacing.
523 524 525 |
# File 'lib/origami/graphics/xobject.rb', line 523 def set_text_char_spacing(char_spacing) last_content_stream.set_text_char_spacing(char_spacing); self end |
#set_text_font(font, size) ⇒ Object
TODO :nodoc:
488 489 490 |
# File 'lib/origami/graphics/xobject.rb', line 488 def set_text_font(font, size) raise NotImplementedError end |
#set_text_leading(leading) ⇒ Object
See ContentStream#set_text_leading.
498 499 500 |
# File 'lib/origami/graphics/xobject.rb', line 498 def set_text_leading(leading) last_content_stream.set_text_leading(leading); self end |
#set_text_pos(tx, ty) ⇒ Object
See ContentStream#set_text_pos.
493 494 495 |
# File 'lib/origami/graphics/xobject.rb', line 493 def set_text_pos(tx, ty) last_content_stream.set_text_pos(tx, ty); self end |
#set_text_rendering(rendering) ⇒ Object
See ContentStream#set_text_rendering.
503 504 505 |
# File 'lib/origami/graphics/xobject.rb', line 503 def set_text_rendering(rendering) last_content_stream.set_text_rendering(rendering); self end |
#set_text_rise(rise) ⇒ Object
See ContentStream#set_text_rise.
508 509 510 |
# File 'lib/origami/graphics/xobject.rb', line 508 def set_text_rise(rise) last_content_stream.set_text_rise(rise); self end |
#set_text_scale(scaling) ⇒ Object
See ContentStream#set_text_scale.
513 514 515 |
# File 'lib/origami/graphics/xobject.rb', line 513 def set_text_scale(scaling) last_content_stream.set_text_scale(scaling); self end |
#set_text_word_spacing(word_spacing) ⇒ Object
See ContentStream#set_text_word_spacing.
518 519 520 |
# File 'lib/origami/graphics/xobject.rb', line 518 def set_text_word_spacing(word_spacing) last_content_stream.set_text_word_spacing(word_spacing); self end |
#write(text, attr = {}) ⇒ Object
See ContentStream#write.
478 479 480 |
# File 'lib/origami/graphics/xobject.rb', line 478 def write(text, attr = {}) last_content_stream.write(text, attr); self end |