class Rabbit::ImageManipulable::PDF
Public Class Methods
Source
# File lib/rabbit/image/pdf.rb, line 30 def match?(filename) return true if File.extname(filename) == ".pdf" File.open(filename, "rb") do |file| data = file.read(10) return false if data.nil? data.start_with?("%PDF-1.") end end
Public Instance Methods
Source
# File lib/rabbit/image/pdf.rb, line 42 def draw(canvas, x, y, params={}) if @document default_params = default_draw_params(x, y) canvas.draw_poppler_page(page, x, y, default_params.merge(params)) else super end end
Calls superclass method
Rabbit::ImageManipulable::Base#draw
Source
# File lib/rabbit/image/pdf.rb, line 55 def update_size @document = Poppler::Document.new(uri) @width, @height = page.size end
Private Instance Methods
Source
# File lib/rabbit/image/pdf.rb, line 77 def filename File.expand_path(@filename) end
Source
# File lib/rabbit/image/pdf.rb, line 61 def page index = self["page"] || 1 begin index = Integer(index) rescue ArgumentError message = _("invalid PDF page number: <%s>") % index.inspect raise ImageLoadError.new("#{@filename}: #{message}") end _page = @document[index - 1] if _page.nil? message = _("%s page doesn't exist in PDF") % index raise ImageLoadError.new("#{@filename}: #{message}") end _page end
Source
# File lib/rabbit/image/pdf.rb, line 85 def to_pixbuf w = original_width h = original_height pixbuf = GdkPixbuf::Pixbuf.new(:rgb, true, 8, w, h) page.render(0, 0, w, h, 1.0, 0, pixbuf) pixbuf end