PDF Manipulation with HexaPDF

I’m Thomas

a.k.a

github @gettalong
twitter @_gettalong

You may know me from kramdown…

Motivation

Features of HexaPDF

Goal: One library for creating, manipulating, merging, extracting data from, securing and optimizing PDF files.

Examples

  1. Read, compress and write a PDF:

    HexaPDF::PDF::Document.open(ARGV.shift) do |doc|
      doc.task(:optimize, compact: true, object_streams: :generate)
      doc.write(ARGV.shift, validate: true)
    end
    
  2. Merge two (or more) PDFs:

    target = HexaPDF::PDF::Document.new
    output_name = ARGV.shift
    ARGV.each do |file|
      pdf = HexaPDF::PDF::Document.new(io: File.open(file, 'rb'))
      pdf.pages.each_page {|page| target.pages.add_page(target.import(page))}
    end
    target.write(output_name)
    
  3. Graphics support (https://gist.github.com/gettalong/7c72149ee84ea9d01b61)

Performance

Future

Caveat: Code of HexaPDF not released yet but soon

Thanks!

For questions regarding HexaPDF

t_leitner@gmx.at
https://gitter.im/gettalong/hexapdf