Class: PDFWalker::Walker::ObjectView
- Inherits:
-
Notebook
- Object
- Notebook
- PDFWalker::Walker::ObjectView
- Defined in:
- lib/pdfwalker/textview.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#pdfpanel ⇒ Object
readonly
Returns the value of attribute pdfpanel.
-
#valuepanel ⇒ Object
readonly
Returns the value of attribute valuepanel.
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize(parent) ⇒ ObjectView
constructor
A new instance of ObjectView.
- #load(object) ⇒ Object
Constructor Details
#initialize(parent) ⇒ ObjectView
Returns a new instance of ObjectView.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pdfwalker/textview.rb', line 35 def initialize(parent) @parent = parent super() @pdfbuffer = TextBuffer.new @pdfview = TextView.new(@pdfbuffer).set_editable(false).set_cursor_visible(false).set_left_margin(5) @pdfpanel = ScrolledWindow.new.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) @pdfpanel. @pdfview append_page(@pdfpanel, Label.new("PDF Code")) @pdfbuffer.create_tag("Default", weight: Pango::Weight::BOLD, family: "monospace", scale: Pango::Scale::LARGE ) end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
32 33 34 |
# File 'lib/pdfwalker/textview.rb', line 32 def parent @parent end |
#pdfpanel ⇒ Object (readonly)
Returns the value of attribute pdfpanel.
33 34 35 |
# File 'lib/pdfwalker/textview.rb', line 33 def pdfpanel @pdfpanel end |
#valuepanel ⇒ Object (readonly)
Returns the value of attribute valuepanel.
33 34 35 |
# File 'lib/pdfwalker/textview.rb', line 33 def valuepanel @valuepanel end |
Instance Method Details
#clear ⇒ Object
82 83 84 |
# File 'lib/pdfwalker/textview.rb', line 82 def clear @pdfbuffer.set_text("") end |
#load(object) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/pdfwalker/textview.rb', line 53 def load(object) begin self.clear case object when Origami::PDF::Header, Origami::FDF::Header, Origami::PPKLite::Header text = object.to_s @pdfbuffer.set_text(text) @pdfbuffer.apply_tag("Default", @pdfbuffer.start_iter, @pdfbuffer.end_iter) when Origami::Object if object.is_a?(Origami::Stream) text = [ "#{object.no} #{object.generation} obj", object.dictionary ].join($/) else text = object.to_s end text.encode!("UTF-8", replace: '.') .tr!("\x00", '.') @pdfbuffer.set_text(text) @pdfbuffer.apply_tag("Default", @pdfbuffer.start_iter, @pdfbuffer.end_iter) end rescue @parent.error("An error occured while loading this object.\n#{$!} (#{$!.class})") end end |