Method: CombinePDF::PDF#stamp_pages
- Defined in:
- lib/combine_pdf/pdf_public.rb
#stamp_pages(stamp, options = {}) ⇒ Object
This method stamps all (or some) of the pages is the PDF with the requested stamp.
The method accept:
- stamp
-
either a String or a PDF page. If this is a String, you can add formating to add page numbering (i.e. “page number %i”). otherwise remember to escape any percent (‘%’) sign (i.e. “page %number not shown%”).
- options
-
an options Hash.
If the stamp is a PDF page, only :page_range and :underlay (to reverse-stamp) are valid options.
If the stamp is a String, than all the options used by #number_pages or CombinePDF::Page_Methods#textbox can be used.
The default :location option is :center = meaning the stamp will be stamped all across the page unless the :x, :y, :width or :height options are specified.
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
# File 'lib/combine_pdf/pdf_public.rb', line 453 def stamp_pages(stamp, = {}) case stamp when String [:location] ||= [:center] number_pages({ number_format: stamp }.merge()) when Page_Methods # stamp = stamp.copy(true) if [:underlay] ([:page_range] ? pages[[:page_range]] : pages).each { |p| p >> stamp } else ([:page_range] ? pages[[:page_range]] : pages).each { |p| p << stamp } end else raise TypeError, 'expecting a String or a PDF page as the stamp.' end end |