prawn

Add image in pdf using Prawn

China☆狼群 提交于 2019-12-21 03:43:17
问题 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. 回答1: Prawn::DATADIR is new, it has been introduced recently about 2 or 3 months ago. Previously one would have used Prawn::BASEDIR/data

Rails 3 Render Prawn pdf in ActionMailer

↘锁芯ラ 提交于 2019-12-19 02:27:19
问题 How to render prawn pdf as attachment in ActionMailer? I use delayed_job and don't understand, how could I render pdf-file in action mailer (not in controller). What format should I use? 回答1: You just need to tell Prawn to render the PDF to a string, and then add that as an attachment to the email. See the ActionMailer docs for details on attachments. Here's an example: class ReportPdf def initialize(report) @report = report end def render doc = Prawn::Document.new # Draw some stuff... doc

header and footer in Prawn PDF

你离开我真会死。 提交于 2019-12-17 21:49:03
问题 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

Rails, Prawn - PDF show up in browser & etc

三世轮回 提交于 2019-12-17 17:34:58
问题 I'm trying to understand the Prawn pdf gem. I was able to make it generate a pdf. Every gem in the gemfile included: gem 'mysql', '~> 2.8.1' gem 'prawn', '~> 0.12.0' gem 'pdf-reader', '~> 0.10.0' gem 'Ascii85', '~> 1.0.1' In the config/application.rb: config.autoload_paths << "#{Rails.root}/app/reports" Then in the controller: require 'prawn' def index pdf = Prawn::Document.new pdf.text "Hello World" pdf.render_file "x.pdf" end Than I call the index function. A PDF named x.pdf is created in

HTML with Prawn

佐手、 提交于 2019-12-13 15:52:01
问题 Im trying to use prawn to generate a PDF of a log entry, then entries are stored in bbcode ([b]bold[/b] etc...) and is converted to html on display. Is there any way to display the html in prawn? 回答1: It sounds like prawn-format might be what you're looking for, but you'll need to use an older version of prawn if you want to try it out. 回答2: You'll probably get the best results if you use a lexical analyser such as 'Syntax' by Jamis Buck (http://syntax.rubyforge.org/) and parse the

Prawn html formatting

本小妞迷上赌 提交于 2019-12-12 09:41:46
问题 I have some simple lists and bold/italic text to format with prawn. How do I get prawn to pay attention to the html tags instead of just displaying them explicitly. If prawn can't do this, what are my other options? 回答1: Inline formatting has been completely re-instated in the development version of Prawn. You can use the code off of the stable branch (0.9.x) for stability, or track master, where we just merged inline styling support for tables. See notes at: http://wiki.github.com/sandal

RAILS_ROOT not longer valid when loading images with the prawnto_2 gem

廉价感情. 提交于 2019-12-12 09:36:09
问题 I'm in the process of upgrading my app from Rails 3.0 to Rails 3.1. I've binned my old plugins in favour of gems where possible and that includes replacing the old prawnto plugin with this nice shiny new prawnto_2 gem. Most things seem fine, but I can't get images to load as before. The code in my PDF view is pdf.image open("#{RAILS_ROOT}/public/images/logo.png") but I get the following error uninitialized constant ActionView::CompiledTemplates::RAILS_ROOT I realise that the location of the

Change Table Size Prawn

僤鯓⒐⒋嵵緔 提交于 2019-12-11 15:39:45
问题 Hi guys I'm doing a ruby ​​report using prawn! how can I change the size of the table? Code: require "prawn" require "prawn/table" logo=Dir.pwd+"/logo.jpg" arr = ['a', 'aa', 'aaa', 'ddd', 'eee', 'fff'] arr2 = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff'] arr3 = ['a', 'b', 'c', 'd', 'e', 'f'] Prawn::Document.generate("rapportino.pdf") do move_down 10 image logo,:width=>540,:height=>60 move_down 30 text "Ragione Sociale: "+ARGV[0] move_down 30 text "Nome Cantiere: "+ARGV[1] move_down 30 text "Note: "

Replace some text in a PDF template using Prawn in Ruby

穿精又带淫゛_ 提交于 2019-12-11 09:18:41
问题 I am generating a PDF in Prawn using a template using code similar to: Prawn::Document.new(:template => "template.pdf") This works great, and I can add to the document in the normal way - however I would like to search for and replace some text that gets added from the template. Is this possible with Prawn? Looking at the Prawn code it does the following: if options[:template] fresh_content_streams(options) go_to_page(1) else ..... end ..... # adds a new, empty content stream to each page.

Prawn - Move cursor down after text_box expand

怎甘沉沦 提交于 2019-12-11 06:08:37
问题 I'm generating PDF's using the Prawn Gem and I'm unable to find a way to move the cursor down after text_box expands from overflow text, similar to the way a regular text call would. Text_box example pad(5) { text_box payable, :at => [bounds.left, cursor], :width => 540, :height => 15, :overflow => :expand, inline_format: true } move_down(15) pad(5) { text_box address, :at => [bounds.left, cursor], :width => 250, :height => 15, :overflow => :expand, inline_format: true text_box city, :at =>