prawn

Using lists in prawn

岁酱吖の 提交于 2019-12-03 11:09:23
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? Prawn was a good PDF library but the problem is its own view system. There is Prawn-format but is not maintained anymore. I suggest to use WickedPDF , it allows you to include

Save a Prawn PDF as a Paperclip attachment?

无人久伴 提交于 2019-12-03 08:32:20
问题 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! 回答1: When using prawnto you will need to eval the variables in the .pdf.prawn template. Second step is to mimic a real file for paperclip. Generating the PDF: #find the prawwnto template you want template = File.read("#

prawnto displaying tables that don't break when new page

夙愿已清 提交于 2019-12-03 08:08:46
I have a variable number of tables with variable number of rows and I want to have them displaying one after the other but if a table doesn't fit on the current page put it on the next then continue on. I have put the table in a transaction so I can roll back then print it if the height will fit on curent page but how do I get the table height? I have this code at the moment pdf.transaction do pdf.table @data, :font_size => 12, :border_style => :grid, :horizontal_padding => 10, :vertical_padding => 3, :border_width => 2, :position => :left, :row_colors => ["FFFFFF","DDDDDD"] pdf.move_down 20

Prawn pdf attachments in the email

≯℡__Kan透↙ 提交于 2019-12-03 07:28:33
问题 In my Rails application, I'm trying to attach the invoice to the email: def invoice(invoice) attachment :content_disposition => "attachment", :body => InvoicePdf.new(invoice), :content_type => "application/pdf", :filename => 'invoice.pdf' mail(:to => @user.email, :subject => "Your Invoice") end The InvoicePdf is a Prawn PDF document: class InvoicePdf < Prawn::Document def initialize(order, view) draw_pdf end def draw_pdf # pdf stuff end end I get no attachments in the email. What am I doing

Unable to render PDF to browser using Prawn PDF for Ruby on Rails

落爺英雄遲暮 提交于 2019-12-03 06:05:03
问题 I am creating a pdf file in the latest version of the Prawn library (v1.0.1rc) in Rails (3.1.1) and when I run my code it generates the PDF into the root of the application. I don't want this. I want it to render the output into user's browser window, without saving it locally to the server. Please tell me how I can achieve this. Here are my files: views/foo/show.pdf.erb : <%= require 'prawn' pdf = Prawn::Document.new(:page_size => 'LETTER', :page_layout => :landscape, :margin => 50, :top

Watermark in existing PDF in Ruby

混江龙づ霸主 提交于 2019-12-03 05:12:26
I would like to add a dynamically generated text. Is there a way to watermark an existing PDF in Ruby? This will do it: PDF::Reader to count the number of pages in the file. Prawn to create a new PDF document using each page of the input pdf as a template. require 'prawn' require 'pdf-reader' input_filename = 'input.pdf' output_filename = 'output.pdf' page_count = PDF::Reader.new(input_filename).page_count Prawn::Document.generate(output_filename, :skip_page_creation => true) do |pdf| page_count.times do |num| pdf.start_new_page(:template => input_filename, :template_page => num+1) pdf.text(

Unable to render PDF to browser using Prawn PDF for Ruby on Rails

空扰寡人 提交于 2019-12-02 19:33:13
I am creating a pdf file in the latest version of the Prawn library (v1.0.1rc) in Rails (3.1.1) and when I run my code it generates the PDF into the root of the application. I don't want this. I want it to render the output into user's browser window, without saving it locally to the server. Please tell me how I can achieve this. Here are my files: views/foo/show.pdf.erb : <%= require 'prawn' pdf = Prawn::Document.new(:page_size => 'LETTER', :page_layout => :landscape, :margin => 50, :top_margin => 20, :bottom_margin => 50) ..... render_file("foo.pdf") %> controllers/foo_controller : class

prawn PDF: I need to generate nested tables

浪子不回头ぞ 提交于 2019-12-01 03:53:10
问题 I need a table where rows are actually 2 rows tables, a nested table that is.. How can I do that in prawn? Maybe I need an extension.. but which one? 回答1: No support for this exists in released versions, but in the master branch of http://github.com/sandal/prawn you'll find our revamped table support which has nested tables. Take a look at the examples/ dir. 回答2: Subtables are now supported: Prawn::Document.generate("subtable.pdf") do |pdf| subtable = pdf.make_table([["sub"], ["table"]]) pdf

Rails PDF Generation with Prawn in IE7

拟墨画扇 提交于 2019-11-30 10:31:28
I'm using Prawn and Prawnto to generate a PDF in a Ruby on Rails app (Rails version 2.2.2) which works great and generates PDFs happily and sends them to the user to download in Firefox. The problem is in IE7. I have a route set up like so: map.invoice_pdf '/invoices.pdf', :controller => 'invoices', :action => 'index', :format => 'pdf' Which I then have a link like so to call: invoice_pdf_path(:year => params[:year], :month => params[:month], :unpaid_only => params[:unpaid_only]) And the following in my controller: def index params[:year] = default params[:year] params[:month] = default params

Rails PDF Generation with Prawn in IE7

跟風遠走 提交于 2019-11-29 15:43:53
问题 I'm using Prawn and Prawnto to generate a PDF in a Ruby on Rails app (Rails version 2.2.2) which works great and generates PDFs happily and sends them to the user to download in Firefox. The problem is in IE7. I have a route set up like so: map.invoice_pdf '/invoices.pdf', :controller => 'invoices', :action => 'index', :format => 'pdf' Which I then have a link like so to call: invoice_pdf_path(:year => params[:year], :month => params[:month], :unpaid_only => params[:unpaid_only]) And the