prawn
Fast, Nimble PDF Writer for Ruby
Is there a way to watermark an existing pdf in ruby ?
I want to add a dynamically generated text,
Thanks,
Source: (StackOverflow)
I need to embed a link into a generated pdf in a ruby on rails app. Is there a way to do this with prawn?
Reading about this it turns out that prawn-format was the answer for awhile, but 0.7.x broke this.
prawn-format uses the link_annotate(rect, options={})
function to create links. What options need to be passed into this to get it to create a link in the PDF?
edit:
I would like to see a code example of this being done if anyone has one.
Source: (StackOverflow)
I can't seem to figure out how to import an image from an url
To import the images from my localhost I use:
image"./assets/images/img.png"
When I replace the path with an URL it says
`image' : URL not found
Is there a solution for this, or should I create a def that downloads the image and to use the path it returns?
Source: (StackOverflow)
I've been randomly trying fonts in Prawn, for Ruby.
For Example:
Times New Roman - Yes
Palatino Linotype - No
Is there a list of which fonts are available and which aren't?
Source: (StackOverflow)
Can you tell me how to insert image which will be a link to for example page 20? I know how to make with normal text:
text "<link anchor='page20'>Go to page 20</link>", :inline_format=>true
and then on page 20 I have
add_dest('page20', dest_fit(page.dictionary))
but how to do this with image ?
Source: (StackOverflow)
I have read through all relevant posts on Prawn but found no mentioning (even in Prawn's own documentation) of headers and footers.
However, I did see a demo on Prawnto's own website about headers and footers. I copied the entire source of that demo just to see if it works but an error of undefined method "header" is complained about. Am I to understand that Prawn took out header and footer recently in the gem or is there something else I need to do first to use header and footer?
The demo page:
http://cracklabs.com/prawnto/code/prawn_demos/source/text/flowing_text_with_header_and_footer
the part of code of concern:
Prawn::Document.generate("flow_with_headers_and_footers.pdf") do
header margin_box.top_left do
text "Here's My Fancy Header", :size => 25, :align => :center
end
text "hello world!"
end
And by header, just in case, I mean the snippets of words that appear usually at a corner of every page of a document. Like your account number in your bills pages.
thanks!
Source: (StackOverflow)
I'm creating a pdf book where I need to put a background image for each page.
The size of the page is (576 x 576) and the size of the background image is 2700 x 2700 (300 dpi.) (These sizes are the requirements so cannot be adjusted).
My problem is - the background image appears out of proportion in the page. How can I fix this ?
Here's my code:
Prawn::Document.generate("#{Rails.root.to_s}/public/#{filename}.pdf", :page_size => [576,576], :left_margin => 50,
:right_margin => 50, :page_layout => :portrait, :skip_page_creation => true, :skip_encoding => true,
:background => "#{Rails.root.to_s}/public/images/pdf/bg_blank_low.jpg" ) do |pdf|
....
....
....
)
Is there any other way by which I can place the image of 300 dpi as a background image.
I even tried adding pdf template as a background, but still no luck.
Any suggestion or hint will be much appreciated.
Thanks.
Source: (StackOverflow)
I'm using Prawn and Prawnto to display a PDF-based reports to the user, but in some circumstances, I'd also like to save the PDF as an attachment to one of my models. I'm using Paperclip for all of my attachments. Does anyone have any suggestions on how to do this?
Thanks!
Source: (StackOverflow)
I need to be able to render some views as PDFs from a Rails 3 project. I've never before used PDF generation techniques with ruby/rails, so I researched a few popular approaches such as Prawn and PDF::Writer, but all the examples and articles I found so far seem outdated and only applicable for rails 2.x. I haven't yet seen a working Rails3 example; tried myself installing prawn and the prawnto gems and reproducing the example described in this Railscasts episode, but I'm getting error of prawnto method not being recognized. I'm uncertain of whether this was an implementation error or just a sign of incompatibility, but seeing other people share on the web that prawn is no longer working for them in Rails3 I didn't bother tracing the code further.
Has anyone found a working reliable solution for pdf generation in Rails3? Could you possibly share it or point me to external resources and documentation?
Big thanks!
Source: (StackOverflow)
This is what I have so far, but I need to set margins:
def send_fax
contact = Contact.find_by_id(self.contact_id)
pdf = Prawn::Document.new
pdf.font "Times-Roman"
pdf.move_down(20)
pdf.text "ATTN: #{contact.first_name} #{contact.last_name}", :size => , :style => :bold
pdf.text "RE: #{self.subject}"
pdf.move_down(20)
pdf.text "#{self.body}"
OutboundMailer.deliver_fax_email(contact, self, pdf)
end
Source: (StackOverflow)
I've a problem for adding images into a PDF using Prawn as pdf generator. I'm trying to add image using the following code:
def header
text "something"
image "#{Prawn::DATADIR}/images/logo_small.png"
end
But app replies to me with the following error:
uninitialized constant Prawn::DATADIR
Where is the mistake?
P.S. My app is running on Rails 3.1 & Ruby 1.9.2.
Source: (StackOverflow)
Im using prawn to create pdfs that contain much data in table format and some lists. The problem with the lists is that Im just using text as lists because there is no semantic equivalent to ul > li lists like I use them in the webfrointend. So the lists arent justified. A list point that uses more than one line looks creapy because I doesnt fit the list icon. How can I implement lists in prawn that dont look like crap?
Source: (StackOverflow)
Im using prawn to generate a PDF output in a rails app. How do i change the color of the outputted text?
Source: (StackOverflow)
I'm using ruby, prawn, and prawnto to dynamically generate pdf's containing text in other languages. I can't seem to get any text in languages with non-english characters to show up. It doesn't throw any errors...just shows a bunch of dashes instead of characters. Prawn brags on its homepage about UTF-8 support so I don't see why this is a problem. I'm using ruby 1.8.6 (engineyard).
Source: (StackOverflow)