pdf - Ruby: gem Prawn: print wraps and goes upside down -
i tried example in watermark existing pdf ruby, when printed generated document, "watermark" printed upside down, if got end of paper, folded on , printed on (but showed through front). in fact, happened because added few more lines of text "pdf.text".
i tried playing page size of new document, :page_size=>"legal", didn't change anything. tried "letter", , "executive", didn't work either.
is there way print without folding over?
it's possible pdf trying watermark has been rotated.
you can use combinepdf gem both fix rotation , add watermarks existing pdf so:
require 'combine_pdf' watermark = combinepdf.load("watermark.pdf").pages[0] pdf = combinepdf.load "content_file.pdf" pdf.pages.each {|page| page.fix_rotation << watermark} pdf.save "content_with_watermark.pdf"
or, can watermark using own text:
require 'combine_pdf' pdf = combinepdf.load "content_file.pdf" pdf.pages.each {|page| page.fix_rotation.textbox 'watermark', opacity: 0.3} pdf.save "content_with_watermark.pdf"
notice #fix_rotation
returns self
- is, page object - allows chain methods have done in demo code.
as pdf::reader ... have no idea how move 'rotate: 180' actual page's content stream. if insist on using pdf_reader gem, might able find data in it's documentation.
good luck!
p.s.
as far know, prawn dropped it's template support... example referenced shouldn't work newer versions of prawn.
Comments
Post a Comment