prawn

Prawn + Prawnto Issue

做~自己de王妃 提交于 2019-12-25 03:23:06
问题 I know prawn is working because I have a show action that if I add .pdf on to the end of it loads show.pdf.prawn. However, I have a form: <%= form_tag(:controller => "/holders", :action=> "generate", format: "pdf") do %> <%= label_tag(:count, "How Many Students?") %> <%= text_field_tag(:count) %> <%= hidden_field_tag :holder_id, value: @holder%> <%= submit_tag("Generate Course Lesson") %> <% end %> That submits count to the the generate action. Inside my generate action I have the following:

Prawn: float text automatically to a new page

强颜欢笑 提交于 2019-12-24 06:47:46
问题 I have following simple code to generate a pdf. def employe_details y = cursor bounding_box([0, y], :width => 16.cm) do @employe.each do |pr| txt = pr.week.to_s + ' ' txt += "work hours" text_box txt, size: 11, :at => [0.5.cm, cursor] move_down 0.4.cm end .#more similar texts . . end Problem is, this doesn't create a new page automatically. When the text exceeds first page, rest of the text doesn't show at all or those texts does not show up in a new page. How to float the texts automatically

Attach Prawn pdf to email

一世执手 提交于 2019-12-24 00:15:13
问题 I have been searching for ages and I still cant seem to figure this out, I am currently using the prawn gem and I want to be able to attach a pdf to an email in my invoice controllers create action . I am currently able to link to a generated pdf from my invoices/show page through http://localhost:3000/invoices/297.pdf but I cant figure out how to attach this pdf to an email. Currently I am not storing the generated PDF anywhere and my mailer looks like this Mailer class InvoiceMailer <

Ruby: Prawn PDF out of memory when using the group method

妖精的绣舞 提交于 2019-12-23 18:05:24
问题 I have a large number of products I want to display in a pdf, with category headers. If a category doesn't fit on the current page I want to move it to the next. For this I'm using Prawn's group method. Product.all.group_by(&:category).each do |category, products| pdf.group do # Simplified the data a bit for this example pdf.text category pdf.table products.map{ |p| [p.title, p.price] } end end This works very well for small amounts of products, but when I add more than 100 or so it takes a

How to convert base64 string to PNG using Prawn without saving on server in Rails

懵懂的女人 提交于 2019-12-23 12:15:09
问题 So I am trying to embed a PNG image of canvas to PDF using Prawn gem. Base64 string is generated by using canvas' toDataURL() function. As the image is only needed in PDF I'm trying to avoid saving it on the server. Params[:base64string] is correctly passed to the server. However, I am trying to use image = Prawn::Images::PNG.new(base64string) to create the image but I get NoMethodError: undefined method `unpack' for nil:NilClass. Any ideas what I'm doing wrong or how this should be done

How can I do inline formatting (bold and underline) for PDF generated by Prawnto in Rails?

删除回忆录丶 提交于 2019-12-23 07:40:12
问题 I generate a PDF file using Prawn and the Prawnto plugin in my rails application. I create a standard form with a standard textarea, and submit that as the body of the PDF file. However, I need to be able to format words and sentences with: bold underline maybe different type sizes I want to be able to do it from within the textarea input box. Right now, because I use prawnto, I basically am genering a view which outputs what is in the textarea. But if I put, say, bold in the text area, it

Is there any options to customize stroke_bounds? (Rails Prawn)

流过昼夜 提交于 2019-12-22 10:36:19
问题 I want to draw borders for all the pages in my PDF. But while using stroke_bounds , I can only draw single dark lined borders alone. I couldn't customize anything? Does anybody have any idea on how to change the style of my stroke_bounds borders? 回答1: Use dash in Prawn::Graphics::Dash http://prawn.majesticseacreature.com/docs/0.11.1/Prawn/Graphics/Dash.html example: pdf.dash 10, :space => 4 pdf.stroke_bounds 回答2: I had the same problem. I found out that you can use the "stroke_color" function

Ruby - How to use different fonts in Prawn?

风流意气都作罢 提交于 2019-12-21 12:24:39
问题 I have a small Ruby program where I'm printing some text out to a PDF using Prawn, but a small portion of the text is non-English characters. (Some of that text is Chinese, some is Greek, etc.). When I run my program, I of course get an error saying Your document includes text that's not compatible with the Windows-1252 character set. (Prawn::Errors::IncompatibleStringEncoding) If you need full UTF-8 support, use TTF fonts instead of PDF's built-in fonts . I know that I need to use a TTF font

Prawn & Prawnto Rails PDF generation - UTF-8?

不想你离开。 提交于 2019-12-21 04:21:43
问题 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). 回答1: For Unicode to work you need to load a TTF font that has the characters you require. The default Helvetica

Prawn & Prawnto Rails PDF generation - UTF-8?

允我心安 提交于 2019-12-21 04:21:14
问题 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). 回答1: For Unicode to work you need to load a TTF font that has the characters you require. The default Helvetica