All Projects → cortiz → Prawn Rails

cortiz / Prawn Rails

Licence: mit
Prawn Handler for Rails. Handles and registers pdf formats.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Prawn Rails

Fbpdf
A small framebuffer pdf, djvu, epub, xps, and cbz viewer
Stars: ✭ 103 (-7.21%)
Mutual labels:  pdf
Lancia
网页转PDF渲染服务。提供收据、发票、报告或任何网页内容转PDF的微服务
Stars: ✭ 108 (-2.7%)
Mutual labels:  pdf
Pandiff
Prose diffs for any document format supported by Pandoc
Stars: ✭ 110 (-0.9%)
Mutual labels:  pdf
Electron Render Service
Microservice for rendering PDF/PNG/JPEG from HTML with Electron
Stars: ✭ 104 (-6.31%)
Mutual labels:  pdf
Pdfscribe
A PDF virtual printer for 64-bit Windows 7 / 2008R2 or later.
Stars: ✭ 106 (-4.5%)
Mutual labels:  pdf
Analyzer
🔍 Offline Analyzer for extracting features, artifacts and IoCs from Windows, Linux, Android, iPhone, Blackberry, macOS binaries, emails and more
Stars: ✭ 108 (-2.7%)
Mutual labels:  pdf
Pdflayouttextstripper
Converts a pdf file into a text file while keeping the layout of the original pdf. Useful to extract the content from a table in a pdf file for instance. This is a subclass of PDFTextStripper class (from the Apache PDFBox library).
Stars: ✭ 1,369 (+1133.33%)
Mutual labels:  pdf
Email To Pdf Converter
Converts email files (eml, msg) to pdf
Stars: ✭ 110 (-0.9%)
Mutual labels:  pdf
Pypdftk
Python module to drive the awesome pdftk binary.
Stars: ✭ 107 (-3.6%)
Mutual labels:  pdf
Pdf Generator
PDF Generator library, easy way to create PDF from String Content or Any HTML Content.
Stars: ✭ 110 (-0.9%)
Mutual labels:  pdf
Pdfviewpager
Android widget that can render PDF documents stored on SD card, linked as assets, or downloaded from a remote URL.
Stars: ✭ 1,508 (+1258.56%)
Mutual labels:  pdf
Invoice As A Service
💰 Simple invoicing service (REST API): from JSON to PDF
Stars: ✭ 106 (-4.5%)
Mutual labels:  pdf
Pdfalto
PDF to XML ALTO file converter
Stars: ✭ 109 (-1.8%)
Mutual labels:  pdf
I7j Pdfhtml
pdfHTML is an iText 7 add-on for Java that allows you to easily convert HTML and CSS into standards compliant PDFs that are accessible, searchable and usable for indexing.
Stars: ✭ 104 (-6.31%)
Mutual labels:  pdf
Docbleach
🚿 Sanitising your documents, one threat at a time. — Content Disarm & Reconstruction Software
Stars: ✭ 110 (-0.9%)
Mutual labels:  pdf
Quad
document processor in Racket
Stars: ✭ 100 (-9.91%)
Mutual labels:  pdf
Play Pdf
A PDF module for the Play framework
Stars: ✭ 108 (-2.7%)
Mutual labels:  pdf
Bepasty Server
binary pastebin server
Stars: ✭ 111 (+0%)
Mutual labels:  pdf
Pdfsam
PDFsam, a desktop application to extract pages, split, merge, mix and rotate PDF files
Stars: ✭ 1,829 (+1547.75%)
Mutual labels:  pdf
Nb pdf template
A more accurate representation of jupyter notebooks when converting to pdfs.
Stars: ✭ 109 (-1.8%)
Mutual labels:  pdf

Prawn-Rails

Gem Version CI Status RubyGems Downloads

Install

gem 'prawn-rails'

Note: prawn and prawn-table are dependencies of prawn-rails so there is no need to mention it in the projects Gemfile unless you want to use a specific version of either of those libraries.

Usage

Create a view with pdf as format and prawn as handler so filename should look like example.pdf.prawn.

It provides a helper called prawn_document which builds a PrawnRails::Document with default options. You can override any options as you please. Example:

prawn_document do |pdf|
  pdf.text "Hello World"
end

No need to call pdf.render, it is called by prawn_document.

You can customize the name of the generated PDF and the file's delivery format with the :filename and :disposition keys:

prawn_document(filename: "my-file.pdf", disposition: "attachment") do |pdf|
  pdf.text "Direct download incoming!"
end

You can also override the content disposition using the Content-Disposition HTTP header. If you've already set this, prawn-rails will not override it. Here's an example of setting the header directly:

def download
  respond_to do |format|
    format.pdf do
      headers["Content-Disposition"] = "attachment; filename=\"charts-#{Time.now.to_i}.pdf\""
    end
  end
end

You can also override the file's name from the controller via @filename:

def show
  @filename = "my_report.pdf"
end

If no options are given, the file's name will match to your browser's default and the delivery format will default to inline.

Default configuration

Add a prawn-rails.rb config to your Rails app under config/initializers like this:

PrawnRails.config do |config|
  config.page_layout = :portrait
  config.page_size   = "A4"
  config.skip_page_creation = false
end

Please note that these are the defaults.

For a list of all available options: http://www.rubydoc.info/gems/prawn/Prawn%2FDocument:initialize.

For a list of all metadata the the :info option supports, please see https://github.com/prawnpdf/prawn/blob/master/manual/document_and_page_options/metadata.rb.

If skip_page_creation is set to true then you have to create the first page yourself. Example:

pdf.start_new_page
# OR
pdf.start_new_page size: "A4", page_layout: :portrait

Examples

Hello World

# hello.pdf.prawn

prawn_document do |pdf|
  pdf.text 'Hello World!'
end

Using Active Record

# myproducts.pdf.prawn

prawn_document do |pdf|
  pdf.text 'Current Products are:'
  pdf.move_down 20
  pdf.table @products.collect{|p| [p.name,p.price]}
end

Using Custom options

# landscape.pdf.prawn

prawn_document(page_layout: :landscape) do |pdf|
  pdf.text 'Landscape Page!'
end

Credits

Maintained by Weston Ganger - @westonganger

Created by Carlos Ortiz - @cortiz

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].