Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
Ruby PDF libraries generate, read, and modify PDF documents from Ruby code. A generator either draws pages with its own layout commands or converts HTML through an external renderer such as wkhtmltopdf. These libraries let Rails apps, billing systems, and reporting jobs produce invoices, reports, and forms as PDF files.
Popularity
PDF::Reader has the most monthly downloads in this comparison, at 119574974.
def generate_invoice(order)
renderer_data = if OpenFoodNetwork::FeatureToggle.enabled?(:invoices, current_user)
Orders::GenerateInvoiceService.new(order).generate_or_update_latest_invoice
order.invoices.first.presenter
else
order
end
invoice = renderer.render_to_string(renderer_data, current_user)
pdf << CombinePDF.parse(invoice)
end
def pdf(name)
@slides = get_slides_html(:static=>true, :toc=>true, :print=>true)
@inline = true
html = erb :onepage
# Process inline css and js for included images # The css uses relative paths for images and we prepend the file url html.gsub!(/url\([\"\']?(?!https?:\/\/)(.*?)[\"\']?\)/) do |s|
"url(file://#{settings.pres_dir}/#{$1})"
end
# remove the weird /files component, since that doesn't exist on the filesystem # replace it for file://<PATH> for correct use with wkhtmltopdf (exactly with qt-webkit) html.gsub!(/<img src=".\/file\/([^"]*)/) do |s|
"<img src=\"file:\/\/#{settings.pres_dir}\/#{$1}"
end
# PDFKit.new takes the HTML and any options for wkhtmltopdf # run `wkhtmltopdf --extended-help` for a full list of options kit = PDFKit.new(html, ShowoffUtils.showoff_pdf_options(settings.pres_dir))
# Save the PDF to a file kit.to_file(name)
end
pdf-inspector
Inspects PDF output with analysis classes based on PDF::Reader, mainly for testing Prawn.
def signed_pdf
signed_file = Tempfile.new("signed_pdf")
doc = HexaPDF::Document.new(io: StringIO.new(pdf))
# Prepare the document for embedding of the digital signature data = nil # Used for storing the to-be-signed data
signing_mechanism = lambda do |io, byte_range|
# Store the to-be-signed data in the local variable data io.pos = byte_range[0]
data = io.read(byte_range[1])
io.pos = byte_range[2]
data << io.read(byte_range[3])
""
end
doc.sign(signed_file.path, signature: signature_widget(doc), reason: caption, signature_size: 10_000, external_signing: signing_mechanism)
signature = OpenSSL::PKCS7.sign(certificate, key, data,
# [HexaPDF.demo_cert.sub_ca, HexaPDF.demo_cert.root_ca], [],
OpenSSL::PKCS7::DETACHED | OpenSSL::PKCS7::BINARY).to_der
# Embed the signature HexaPDF::DigitalSignature::Signing.embed_signature(File.open(signed_file.path, "rb+"), signature)
File.binread(signed_file.path)
ensure
signed_file.close
signed_file.unlink
end
pdf-forms
Fills PDF templates from a data hash through the pdftk binary, with FDF and XFDF creation.
def exporta
configuracao_pdf = "configuracao.pdf"
configuracao_yaml = "configuracao.yaml"
Dir.chdir(options[:input_dir]) do
raise IOError, "Arquivo não encontrado: #{options[:input_dir]}/" + configuracao_pdf unless File.exist? (configuracao_pdf)
pdf = PdfForms::Pdf.new configuracao_pdf, (PdfForms.new 'pdftk'), utf8_fields: true
pdfconf = Limarka::Pdfconf.new(pdf: pdf)
# exporta sem validação h = pdfconf.exporta(false)
target_file = options[:output_dir]+'/'+configuracao_yaml
puts "Sobrescrevendo #{target_file}".green if File.exist?(target_file)
Limarka::Trabalho.save_yaml(h, target_file)
end
end
FAQ
Prawn suits PDFs drawn from Ruby with vector shapes, flowing text, and embedded fonts. Wicked PDF suits PDFs rendered from HTML through wkhtmltopdf. PDF::Reader suits reading text and metadata from existing PDFs.
Wicked PDF uses the wkhtmltopdf shell utility to serve a PDF file generated from HTML.
No. Prawn cannot convert full HTML pages. Those need a browser renderer or an HTML-based tool such as Wicked PDF.
combine_pdf appends complete PDFs or selected pages. Its original maintenance has stopped.
HexaPDF assigns values to AcroForm fields from a data hash. pdf-forms fills templates through the pdftk binary.
For coding agents
Found your PDF library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.