Project

mupdf

0.0
The project is in a healthy, maintained state
Integrate with MuPDF for analyzing and converting PDFs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

 Project Readme

MuPDF

LICENSE RubyGems GitHub Yard CircleCI

Installation

gem install mupdf

This project requires mutool be installed on your system. To verify ensure the following works:

mutool

To install mutool on MacOS use:

brew install mupdf

To install mutool on Ubuntu use:

apt-get install mupdf

Usage

Document

A MuPDF::Document wraps a PDF file:

document = MuPDF::Document.new('./file.pdf')

Info

The info command displays information about the document such as the number of pages:

info = document.info
info.pages # e.g. 2

Pages

The pages command finds sizing information about the pages within a document:

pages = document.pages
pages.count # e.g. 2
pages.each do |page|
  page.number # e.g. 1, 2, ...
  page.width # 612
  page.height # 792
end

Draw

The draw command is useful for converting a document between formats:

document.pages.each do |page|
  document.draw(page: page.number, format: "png", path: "./file-#{page.number}.png")
end