prawn

Prawn PDF Compression, compress content streams, what does it do

空扰寡人 提交于 2021-02-10 05:59:57
问题 The prawn gem has an initialize option :compress , which is described here. Apparently it "Compresses content streams before rendering them" . With and without compress: true I generated the same 14 page pdf twice. Each page has 2 photos and all sorts of text. The resulting file size was the exact same. So my question is: in production with larger quantities of photos will I see a difference in file sizes? Or maybe compress: true eats more or less RAM during processing? What is its purpose?

Prawn PDF Compression, compress content streams, what does it do

∥☆過路亽.° 提交于 2021-02-10 05:59:06
问题 The prawn gem has an initialize option :compress , which is described here. Apparently it "Compresses content streams before rendering them" . With and without compress: true I generated the same 14 page pdf twice. Each page has 2 photos and all sorts of text. The resulting file size was the exact same. So my question is: in production with larger quantities of photos will I see a difference in file sizes? Or maybe compress: true eats more or less RAM during processing? What is its purpose?

Is it possible to render blob images in a prawn document?

依然范特西╮ 提交于 2021-02-07 03:37:40
问题 I´m willing to use Gruff to render some graphics inside prawn documents. I want to avoid the delay of writing images to the disk only for them to be read by Prawn. Gruff offers the to_blob method that renders the graph image as a blob in memory, but looking at the prawn manual image section, it only gives us a way to render images directly from files. Am I missing something? Is there a way to render it from memory? 回答1: You should be able pass the image data as a StringIO require 'stringio'

Create a table in Prawn by its html representation

﹥>﹥吖頭↗ 提交于 2020-01-07 09:34:51
问题 Earlier Prawn gem allowed to create a table by its html representation (having an html table string as an input argument like <table class="abc"> .... </table> ). Now I didn't find this facility in the manual. So is it possible now? If not, is there any other option then? 回答1: TL;DR: if your use-case is 1) generating both HTML and PDF data (like online invoices etc.), and 2) making sure both look the same, then Prawn is not really the best solution (which is the same suggestion in the Prawn

Create a table in Prawn by its html representation

谁都会走 提交于 2020-01-07 09:34:37
问题 Earlier Prawn gem allowed to create a table by its html representation (having an html table string as an input argument like <table class="abc"> .... </table> ). Now I didn't find this facility in the manual. So is it possible now? If not, is there any other option then? 回答1: TL;DR: if your use-case is 1) generating both HTML and PDF data (like online invoices etc.), and 2) making sure both look the same, then Prawn is not really the best solution (which is the same suggestion in the Prawn

can't write unknown attribute `info' PrawnPDF

徘徊边缘 提交于 2020-01-06 18:44:22
问题 I'm using Prawn PDF to generate an invoice PDF on the fly and I keep getting the error "can't write unknown attribute 'info'" but I don't have an attribute 'info' anywhere in any of the concerned database tables (or my entire database for that matter). I don't know if it's something in the gem that I'm missing. Here is the tutorial I'm following: http://www.idyllic-software.com/blog/creating-pdf-using-prawn-in-ruby-on-rails/ and http://www.sitepoint.com/pdf-generation-rails/ I did register

Prawn: Print unicode string in PDF

余生长醉 提交于 2020-01-04 13:34:10
问题 I'm using Prawn to generate PDFs in a Rails 3 app. Is it possible to print a Unicode string into a PDF like in a HTML view? For example, <%= raw "unicode_for_ཀ" %> in show.html.erb results in the glyph ཀ while pdf.text raw "unicode_for_ཀ" in show.pdf.prawn results in the string "unicode_for_ཀ" Tried in show.pdf.prawn : pdf.font "#{Prawn::BASEDIR}/data/fonts/TibMachUni-1.901b.ttf" do pdf.text raw "unicode_for_ཀ" end and pdf.font_families.update("TibMachUni" => {:normal => "#{Prawn::BASEDIR}

Adding metadata to PDF

这一生的挚爱 提交于 2020-01-03 08:35:33
问题 I need to add metadata to a PDF which I am creating using prawn. That meta-data will be extracted later by, probably, pdf-reader. This metadata will contain internal document numbers and other information needed by downstream tools. It would be convenient to associate meta-data with each page of the PDF. The PDF specification claims that I can store per-page private data in a "Page-Piece Dictionary". Section 14.5 states: A page-piece dictionary (PDF 1.3) may be used to hold private conforming

Using lists in prawn

混江龙づ霸主 提交于 2020-01-01 04:35:08
问题 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? 回答1: Prawn was a good PDF library but the problem is its own view system.

How many fonts are available in Prawn?

别来无恙 提交于 2020-01-01 02:35:06
问题 I've been randomly trying fonts in Prawn, for Ruby. For Example: Times New Roman - Yes Palatino Linotype - No Is there a list of which fonts are available and which aren't? 回答1: There's a list of default fonts in the code, at lib/prawn/font/afm.rb (version 1.0.0.rc1): module Prawn class Font class AFM < Font BUILT_INS = %w[ Courier Helvetica Times-Roman Symbol ZapfDingbats Courier-Bold Courier-Oblique Courier-BoldOblique Times-Bold Times-Italic Times-BoldItalic Helvetica-Bold Helvetica