A simple tool to hide ads in pdfs.
Go to file
Fabrice Mouhartem 0b8755d9ec Add sanity check for input file existence 2023-10-25 10:33:12 +02:00
data Updating SNCF presets 2023-10-25 10:06:20 +02:00
src Add sanity check for input file existence 2023-10-25 10:33:12 +02:00
.gitignore .gitignore 2019-04-23 12:06:30 +05:30
LICENSE First commit 2019-04-23 12:05:27 +05:30
Makefile First commit 2019-04-23 12:05:27 +05:30
hidepdfads Add sanity check for input file existence 2023-10-25 10:33:12 +02:00
readme.md url update 2019-04-25 22:12:12 +05:30



A small tool to hide a recurrent part of a PDF file such as ads on plane tickets for instance.

It is a scripted version of this blog post.


The project comprises two main files: scr/script.sh and data/presets.json

These two files are used to generate the pdf-adblocker standalone file.

Build and run

To build, simply run the make command in this directory.

The following commands are available:

Usage: hidepdfads <command> [<args>]

This tool uses latex to cover a specific region of a PDF file on every page.

<command> can be:
	help:	display this help message
	list:	list the different presets
	preset:	use an existing preset
		arguments: <preset> <infile> <outfile>
	manual:	set coordinates and dimension of the rectangle
		arguments: <infile> <outfile> X Y L H [color=white] [unit=cm] [format=a4paper]


$ hidepdfads preset AF plane-ticket.pdf plane-ticket-adfree.pdf


To build the PDF, you may need jq to parse the json database.

The script relies on latex to run. You can specify your favorite latex compiler in the environment variable LATEXCC.

Add presets

Presets are compiled in a json file with the following signature:

    "name"   : "preset-name",
    "X"      : "0",
    "Y"      : "0",
    "L"      : "0",
    "H"      : "0",
    "unit"   : "mm/cm/in/pt or any LaTeX-compatible unit",
    "format" : "a4/letter",
    "color"  : "white or any LaTeX-compatible color"

This data can be filled using for instance inkscape to find the location and size of the area to hide.

inkscape dimensions

Instructions: After opening your pdf file, start by selecting the ad (purple), you may have to ungroup elements (ctrl+shift+g), then set the dimensions in cm or your favourite length unit (blue) and finally note the dimensions of the ad (red).

Feel free to contribute to this (so far small) database of PDF cleaner presets 😉


The basecode and principles of the code are highly inspired from dmenu-emoji.


  • Simplify the way to fill the database