prawn

Sinatra: Template engine not found: prawn

会有一股神秘感。 提交于 2019-12-11 05:57:10
问题 I'm a newbie with Sinatra and prawn. I succeeded with erb and xmm/builder templates. Now trying to get pdf generation with prawn working. Error received: Template engine not found: prawn Code: require 'rubygems' require 'sinatra' require 'sinatra/prawn' set :prawn, { :page_layout => :portrait } get '/pdf' do content_type 'application/pdf' prawn :pdf1 end Thanks. 回答1: Found it: The gem from sbfaulkner doesn't work with current version of Sinatra. Fix: install the forked gem from

Does Prawn gem support Arabic Language?

与世无争的帅哥 提交于 2019-12-11 04:36:11
问题 I'll create a pdf report in Arabic Language, but the letters is separated and in reverse order, I use the following code to generate a pdf file class InstitutesPdf < Prawn::Document def initialize(institute) super() font(Rails.root.join("app/assets/fonts/arial.ttf")) @institute = institute text "Institute ID : #{@institute.id}" move_down(30) text "Institute name : #{@institute.name.mb_chars.to_s}" end end when I change the last line to text "Institute name : #{@institute.name.mb_chars.reverse

ruby prawn how to wrap text around an aligned right image?

こ雲淡風輕ζ 提交于 2019-12-11 02:12:30
问题 s it posible to align an image to the right and wrap text around the image like it is in html and css using the float:right property ? If so how do you do this ? I can align an image but dont't know how to wrap the text around it. The text is dynamic text therefore varies alot in length. Thanks alot Rick 回答1: One suggestion is to try nested bounding boxes. The main bounding box would have the text inside it. with at some point another bounding box for the image. Something along the lines of

Prawn Tables: Block is not executing

霸气de小男生 提交于 2019-12-11 00:59:57
问题 I've run into a really strange issue with my rails/prawn code. I'm generating a table and trying to change the font style of the first row with the following code: pdf.table(data) do rows.first.style(:font_style => :bold) end The table is generated, but nothing inside the block is executed. I've tried putting a debugger statement in the block, but it doesn't even hit that. As per suggestions found by Googling, I've tried adding a block argument, eg: pdf.table(data) do |t| t.rows.first.style(

prawn-table set header's row background color

自作多情 提交于 2019-12-11 00:53:50
问题 pdf.table([header, row1, row2], width: 490, cell_style: { size: 7, align: :center }) do style(row(0), padding: [4,2], font: "#{Prawn::BASEDIR}/data/fonts/DejaVuSans-Bold.ttf") # style(row(0).columns(2..3), width: 10 ) # style(row(0), cell_style: {background_color: "#f5f5dc"} ) style(row(1), padding: [16,10]) style(row(1).columns(-2..-1), align: :right) style(row(2).column(0), borders: []) style(row(2).column(-2..-1), padding: [6,10], align: :right) end I want row(0) to have a background color

How to generate table of contents with prawn?

谁说胖子不能爱 提交于 2019-12-10 21:14:28
问题 Is there an easy way to generate table of contents with links to corresponding pages? 回答1: In recent-ish versions of prawn, yes. Check out the examples/general/outlines.rb example for API samples. See http://prawnpdf.org/manual.pdf p. 96 来源: https://stackoverflow.com/questions/2687833/how-to-generate-table-of-contents-with-prawn

Can I use highcharts in a pdf generate with prawn in Rails?

有些话、适合烂在心里 提交于 2019-12-10 17:43:06
问题 In my rails application, I use highcharts to display some charts. And now, I need to generate a pdf with charts (I will use prawn). I want to know if I can use highcharts in my pdf. Maybe with ExecJS ? Or with an alternative to prawn ? Thanks! 回答1: You can use wkhtmltopdf (http://code.google.com/p/wkhtmltopdf/) to render the javascript charts as a PDF This blog post is helpful: http://www.claytonlz.com/index.php/2011/02/broken-highcharts-wkhtmltopdf/ 来源: https://stackoverflow.com/questions

Set dynamically height for entire Prawn PDF Document

我的梦境 提交于 2019-12-10 16:54:40
问题 I'm stuck with a problem when trying to generate a document using Prawn gem for Rails What I'm trying to do is to set a variable height for my pdf, so depending on some queries in the database, the PDF height will change. I'm doing this because I need a single page PDF document. Currently, my code looks like this: pdf = Prawn::Document.new(page_size: [297.64, 419.53], margin: 0) .... data = [ ["Header1", "Header2", "Header3", "Header4", "Header5", "Header6"] ] // here is the variable data

generating pdf using prawn in background with resque

安稳与你 提交于 2019-12-10 09:34:28
问题 I am trying to create a PDF document in the background via Resque background job. My code for creating the PDF is in a Rails helper method that I want to use in the Resque worker like: class DocumentCreator @queue = :document_creator_queue require "prawn" def self.perform(id) @doc = Document.find(id) Prawn::Document.generate('test.pdf') do |pdf| include ActionView::Helpers::DocumentHelper create_pdf(pdf) end end end The create_pdf method is from the DocumentHelper but I am getting this error:

How to handle a file_as_string (generated by Prawn) so that it is accepted by Carrierwave?

让人想犯罪 __ 提交于 2019-12-10 01:23:32
问题 I'm using Prawn to generate a PDF from the controller of a Rails app, ... respond_to do |format| format.pdf do pdf = GenerateReportPdf.new(@object, view_context) send_data pdf.render, filename: "Report", type: "application/pdf", disposition: "inline" end end This works fine, but I now want to move GenerateReportPdf into a background task, and pass the resulting object to Carrierwave to upload directly to S3. The worker looks like this def perform pdf = GenerateReportPdf.new(@object)