Sha256: 84812808839bf105bc20186dcc450b067e338992a51402e223219717d398ab06

Contents?: true

Size: 746 Bytes

Versions: 145

Compression:

Stored size: 746 Bytes

Contents

#!/usr/bin/env ruby

require "poppler"

if ARGV.size != 2
  puts "usage: #{$0} input.pdf output.pdf"
  exit(-1)
end

input, output = ARGV

doc = Poppler::Document.new(input)

width, height = doc.pages[0].size
Cairo::PDFSurface.new(output, width / 2, height) do |surface|
  context = Cairo::Context.new(surface)

  doc.each do |page|
    width, height = page.size
    half_width = width / 2
    context.save do
      context.rectangle(0, 0, half_width, height)
      context.clip
      page.render(context)
      context.show_page
    end

    context.save do
      context.translate(-half_width, 0)
      context.rectangle(half_width, 0, half_width, height)
      context.clip
      page.render(context)
      context.show_page
    end
  end
end

Version data entries

145 entries across 145 versions & 1 rubygems

Version Path
poppler-3.1.8-x64-mingw32 sample/pdfdiv.rb
poppler-3.1.8-x86-mingw32 sample/pdfdiv.rb
poppler-3.1.8 sample/pdfdiv.rb
poppler-3.1.7-x64-mingw32 sample/pdfdiv.rb
poppler-3.1.7-x86-mingw32 sample/pdfdiv.rb
poppler-3.1.7 sample/pdfdiv.rb
poppler-3.1.6-x64-mingw32 sample/pdfdiv.rb
poppler-3.1.6-x86-mingw32 sample/pdfdiv.rb
poppler-3.1.6 sample/pdfdiv.rb
poppler-3.1.5-x64-mingw32 sample/pdfdiv.rb
poppler-3.1.5-x86-mingw32 sample/pdfdiv.rb
poppler-3.1.4-x64-mingw32 sample/pdfdiv.rb
poppler-3.1.4-x86-mingw32 sample/pdfdiv.rb
poppler-3.1.4 sample/pdfdiv.rb
poppler-3.1.3-x64-mingw32 sample/pdfdiv.rb
poppler-3.1.3-x86-mingw32 sample/pdfdiv.rb
poppler-3.1.3 sample/pdfdiv.rb
poppler-3.1.2-x64-mingw32 sample/pdfdiv.rb
poppler-3.1.2-x86-mingw32 sample/pdfdiv.rb
poppler-3.1.2 sample/pdfdiv.rb