prawn

Background images using prawn on all pages

安稳与你 提交于 2019-12-09 17:48:42
问题 I have this code in the view prawn_document(:page_size=> "A4", :top_margin => 80, :bottom_margin => 40, :background => "public/uploads/1.png") do |pdf| creation_date = Time.now.strftime('%d-%m-%Y') posts = @posts.each do |post| pdf.pad(10) do pdf.text post.title pdf.text post.text end end pdf.page_count.times do |i| pdf.go_to_page(i + 1) pdf.draw_text "Creation Date : " + creation_date, :at => [200, 780] pdf.draw_text "Page : #{i + 1} / #{pdf.page_count}", :at => [450, -3] end end This gives

prawnto displaying tables that don't break when new page

感情迁移 提交于 2019-12-09 06:29:14
问题 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

How to replace a word in an existing PDF using Ruby Prawn?

[亡魂溺海] 提交于 2019-12-08 19:34:36
问题 -Hello Sandeep here. I am an apprentice to the Jedi Master Yoda. My master believes the force is strong in the Ruby community and has chosen me for a simple task to complete using the Ruby langauge: I need to use the Prawn PDF gem to accomplish the task. I have an existing pdf document called Dooku.pdf - it contains sensitive information on the Evil Count Dooku's activities. In Dooku.pdf there is text called {galaxy}. {galaxy} is always in the same location on every page of the pdf document.

Prawn: Table of content with page numbers

假装没事ソ 提交于 2019-12-08 19:19:09
问题 I need to create a table of contents with Prawn. I have add_dest function calls in my code and the right links in the table of content: add_dest('Komplett', dest_fit(page_count - 1)) and text "* <link anchor='Komplett'> Vollstaendiges Mitgliederverzeichnis </link>", :inline_format = true This works and I get clickable links which forward me to the right pages. However, I need to have page numbers in the table of content. How do I get it printed out? 回答1: you should read the chapter on Outline

Generating a PDF With Images from Base64 with Prawn

情到浓时终转凉″ 提交于 2019-12-07 03:49:47
问题 I am trying to save multiple pngs in one pdf. I'm receiving the PNGs from an API Call to the Endicia Label Server, which is giving me a Base64 Encoded Image as response. Based on this Question: How to convert base64 string to PNG using Prawn without saving on server in Rails def batch_order_labels @orders = Spree::Order.ready_to_ship.limit(1) dt = Date.current.strftime("%d %b %Y ") title = "Labels - #{dt} - #{@orders.count} Orders" Prawn::Document.generate("#{title}.pdf") do |pdf| @orders

Printing prawn generated pdf

こ雲淡風輕ζ 提交于 2019-12-06 08:00:36
Using prawn gem for ruby-on-rails webpage, is it possible to send print request to printer device to print pdf page I've generated using prawn? Looks like you would want to use prawn-print . # Open print dialog, but don't autoprint. pdf = Prawn::Document.new pdf.text "I installed Adobe Reader and all I got was this lousy printout." pdf.print # Autoprint it on the default printer, when opened. pdf = Prawn::Document.new pdf.text "Help! I am trapped in a PDF factory!" pdf.autoprint # Autoprint it on a printer where the name includes "LaserJet". pdf = Prawn::Document.new pdf.text "Help! I am

Start new page automatically when using stacked bounding boxes in Prawn

安稳与你 提交于 2019-12-06 06:59:56
问题 I want to simulate the behaviour of a table in Prawn, but can't use table because of the limitation of things I can draw inside cells. So I am using bounding boxes in order to create contexts for the elements inside each row. The problem I'm having has to do with the rows. I'm trying this: require 'prawn' Prawn::Document.generate("test.pdf") do move_down 50 bounding_box [0, cursor], width: bounds.width do 20.times do |i| stroke_bounds && start_new_page if (i+1) % 11 == 0 bounding_box [0,

My text is written in a bad direction when I use a template

喜夏-厌秋 提交于 2019-12-06 05:30:19
问题 I want to add a text on an existing PDF using Rails, so I did : filename = "#{Rails.root}/app/assets/images/sample.pdf" Prawn::Document.generate("#{Rails.root}/app/assets/images/full_template.pdf", :template => filename) do text "Test", :align => :center end And when I open full_template.pdf, I have my template PDF + my text "Test", but this text is written in a bad direction as if my text was written using a mirror. You can find the two PDF documents here: Original : http://www.sebfie.com/wp

Any font for generating pdf that will handle Chinese, Cyrillic… ?

南笙酒味 提交于 2019-12-06 01:39:54
问题 I'm creating generator of pdf documents in Ruby on Rails with Prawn gem and I came up with issue that when I have Chinese, Japanese and Cyrillic chars they are displayed incorrectly. I googled out that it's because "when I'm generating font I need to specify, what font should pdf text be rendered with" . Now this isn't the issue, but the fact that my documents will include all different possible chars that gTLD supports. Question 1: Do you know any font for generating pdf documents that will

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

只愿长相守 提交于 2019-12-05 21:05:34
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? 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 Erich I had the same problem. I found out that you can use the "stroke_color" function to change this color. http://prawnpdf.org/docs/0.11.1/Prawn/Graphics/Color.html#method-i-stroke_color