0.0
No commit activity in last 3 years
No release in over 3 years
Simple library to checks whether the margins are clear in a PDF
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.14.0
>= 0

Runtime

~> 1.2.8
~> 1.1.0
 Project Readme

pdf/margins

Build Status

Simple Ruby library to check a PDF for clear margin areas, by rendering to a bitmap, ensuring that the pixel area defined by each margin is empty.

This is a bit of a clumsy technique, but it's faster than parsing and understanding all the permutations of the PDF format that may result in an object being visible in the margins.

It shells out to mudraw, part of [mupdf] 1, for rastering the PDF to PNGs, and then uses [Chunky PNG] 2 to examine each page's margins.

On Ubuntu, you may wish to install mupdf from the [PPA] 3.

Written by [Tom Taylor] 3, [Newspaper Club] 4.

Example

# Accepts a `spreads` option which assumes margin dimensions refer to
# spreads, and so alternates which pages we check left and right margins
# on. Measurements are in mm, defaulting to 0 unless specified.
checker = PDF::Margins::Checker.new('example.pdf', top_margin: 10, 
                                                   right_margin: 10, 
                                                   bottom_margin: 10, 
                                                   left_margin: 10, 
                                                   spreads: true)
puts checker.issues.inspect