Questions tagged [prawn]

Prawn is a fast, nimble Ruby library for creating PDF files.

Prawn is a fast, nimble Ruby library for creating PDF files.

More information on the library can be found here. There is a wiki and the source is available on GitHub.

For support requests, you can use the Prawn mailing list or #prawn on Freenode.

692 questions
31
votes
7 answers

header and footer in Prawn PDF

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…
Nik So
  • 15,873
  • 20
  • 69
  • 104
25
votes
3 answers

Prawn::Errors::IncompatibleStringEncoding: Your document includes text that's not compatible with the Windows-1252 character set

Below is my Prawn PDF file to generate a name on the PDF - def initialize(opportunity_application) pdf = Prawn::Document.new(:page_size => [1536, 2048], :page_layout => :landscape) cell_1 = pdf.make_cell(content: "Eylül…
Michael Victor
  • 781
  • 2
  • 11
  • 39
22
votes
5 answers

Save a Prawn PDF as a Paperclip attachment?

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…
Adam Albrecht
  • 6,282
  • 4
  • 27
  • 35
19
votes
5 answers

Watermark in existing PDF in Ruby

I would like to add a dynamically generated text. Is there a way to watermark an existing PDF in Ruby?
Mike
  • 5,005
  • 6
  • 32
  • 49
18
votes
2 answers

how do I set margins in Prawn in ruby?

This is what I have so far, but I need to set margins: def send_fax contact = Contact.find_by_id(self.contact_id) pdf = Prawn::Document.new pdf.font "Times-Roman" pdf.move_down(20) pdf.text "ATTN: #{contact.first_name}…
Satchel
  • 15,436
  • 22
  • 100
  • 180
18
votes
4 answers

Can prawn generate PDFs with links?

I need to embed a link into a generated pdf in a ruby on rails app. Is there a way to do this with prawn? Reading about this it turns out that prawn-format was the answer for awhile, but 0.7.x broke this. prawn-format uses the link_annotate(rect,…
lillq
  • 13,102
  • 20
  • 50
  • 58
17
votes
2 answers

Rails + Prawn: undefined method `table' for #:

I'm using Rails 4 + prawn_rails + the latest version of prawn (v 1.1.0) and I noticed in the changelog here: https://github.com/prawnpdf/prawn/wiki/CHANGELOG that tables are now separated. I followed the instructions to require "prawn/tables". I did…
bigpotato
  • 22,922
  • 46
  • 147
  • 286
16
votes
5 answers

How to add background/fill color to a bounding_box in Prawn

Is it possible to add a background color to a bounding_box in Prawn? bounding_box([100, cursor], width: 80, height: 20) do pad_top(7) { text "THIS IS TEXT", size: 8, align: :center } stroke_bounds end Ive tried adding this to the…
hellion
  • 4,044
  • 3
  • 32
  • 63
15
votes
3 answers

Rails, Prawn - PDF show up in browser & etc

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…
Kael
  • 555
  • 2
  • 7
  • 18
15
votes
1 answer

How do I define line height with Prawn when generating a pdf in rails app?

I am using prawn to generate a pdf. So far everything has been rather straight forward. I am having a problem defining the leading between lines of text. For example: when using a text_box pdf.text_box "Ipsum dolor sit amet consectetue?", :width…
user187678
14
votes
2 answers

Prawn : adding background image of larger resolution

I'm creating a pdf book where I need to put a background image for each page. The size of the page is (576 x 576) and the size of the background image is 2700 x 2700 (300 dpi.) (These sizes are the requirements so cannot be adjusted). My problem is…
safalmj
  • 692
  • 1
  • 5
  • 16
14
votes
3 answers

Set the font color in prawn

Im using prawn to generate a PDF output in a rails app. How do i change the color of the outputted text?
Arcath
  • 4,083
  • 8
  • 36
  • 69
14
votes
2 answers

Prawn image on amazon image not found

I am using Prawn 0.12.0 in a Rails 3.2.12 app. If I have an image on my local server it can show in a standard rails view, and I can also have it shown in a Prawn PDF using the following code @logo = company.logo_url(:large).to_s image @logo,…
Michael Moulsdale
  • 1,408
  • 13
  • 32
14
votes
3 answers

How do I use the Arial font with Prawn on OS X?

I'm trying to use ruby to generate a PDF using Prawn on OS X. I have the following: font 'Arial' Arial is installed on my Mac. But when I try to generate the PDF, I get the following error: Prawn::Errors::UnknownFont in…
croceldon
  • 4,211
  • 9
  • 51
  • 86
13
votes
4 answers

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

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",…
Andy Harvey
  • 11,339
  • 14
  • 76
  • 166
1
2 3
46 47