Add git repository and thumbnail
This commit is contained in:
parent
f803b1cf5a
commit
a39b7891da
content
BIN
content/images/thumb_stop-pub.png
Normal file
BIN
content/images/thumb_stop-pub.png
Normal file
Binary file not shown.
After (image error) Size: 17 KiB |
@ -1,22 +1,29 @@
|
|||||||
---
|
---
|
||||||
Title: Block ads using LaTeX
|
Title: Block ads using LaTeX
|
||||||
Date: 2019-04-23 08:00
|
Date: 2019-04-23 12:00
|
||||||
Author: Fabrice
|
Author: Fabrice
|
||||||
Category: tips
|
Category: tips
|
||||||
Tags: LaTeX, inkscape, ads
|
Tags: LaTeX, inkscape, ads, git
|
||||||
Slug: latex-ad-block
|
Slug: latex-ad-block
|
||||||
|
og_image: images/thumb_stop-pub.png
|
||||||
|
twitter_image: images/thumb_stop-pub.png
|
||||||
Header_Cover: images/cover_velov.jpg
|
Header_Cover: images/cover_velov.jpg
|
||||||
|
Summary: How to block advertisement using LaTeX
|
||||||
---
|
---
|
||||||
|
|
||||||
I'm quite annoyed with ads. As of many, I'm using an adblocker on my computer, but there is one kind of ads that annoys me the most: ads on printable ticket. Not only it poisons our eyes, but it consumes ink to print it.
|
I'm quite annoyed with ads. As of many, I'm using an adblocker on my computer, but there is one kind of ads that annoys me the most: ads on printable ticket. Not only it poisons our eyes, but it consumes ink to print it.
|
||||||
|
|
||||||
I'm aware that we can just open the QR/barcode on your smartphone, but still, isn't it better if we can get rid of the ad directly?
|
I'm aware that we can just open the QR/barcode on your smartphone, but still, isn't it better if we can get rid of the ad directly?
|
||||||
|
|
||||||
To do this, I tried the most obvious solution: open it with inkscape, and remove the image.
|
A first obvious solution could be to import your pdf in any [image editing software](https://www.gimp.org/) and simply use any rectangle shape selection tool to remove the ad.
|
||||||
However, this approach has a serious drawback, it breaks the fonts, and some of them (such as Air France's “_Excellence in Motion_” font) are proprietary and cannot be found easily/legally for free.
|
However, this produces a new pdf file (or image file) that does not contain any more information about the text, and which may grow in size.
|
||||||
|
|
||||||
|
A simple workaround is then to use a vector graphic editor to keep this information: for instance, opening the PDF with [inkscape](https://inkscape.org/), and remove the image corresponding to the ads.
|
||||||
|
Yet more elegant, this approach still has a serious drawback: it breaks the fonts. Also, some of them (such as Air France's “_Excellence in Motion_” font) are proprietary and cannot be found easily/legally for free.
|
||||||
|
|
||||||
But inkscape can still be of use in order to remove those ads.
|
But inkscape can still be of use in order to remove those ads.
|
||||||
Indeed, it allows finding the coordinates and the dimensions of those ads as illustrated in the following (click to zoom):
|
Indeed, it allows finding the coordinates and the dimensions of those ads as illustrated in the following (click to zoom):
|
||||||
|
|
||||||
[![Inkscape ad dimensions](/examples/inkscape-adblock.png)](/examples/inkscape-adblock.png)
|
[![Inkscape ad dimensions](/examples/inkscape-adblock.png)](/examples/inkscape-adblock.png)
|
||||||
|
|
||||||
**Explanations:** After opening your pdf file, start by selecting the ad (<span style="color:#8b0074">purple</span>), you may have to ungroup elements (`ctrl+shift+g`), then set the dimensions in cm or your favourite length unit (<span style="color:#0000ff">blue</span>) and finally note the dimensions of the ad (<span style="color:#ff0000">red</span>).
|
**Explanations:** After opening your pdf file, start by selecting the ad (<span style="color:#8b0074">purple</span>), you may have to ungroup elements (`ctrl+shift+g`), then set the dimensions in cm or your favourite length unit (<span style="color:#0000ff">blue</span>) and finally note the dimensions of the ad (<span style="color:#ff0000">red</span>).
|
||||||
@ -26,7 +33,7 @@ I already used the [wallpaper](https://www.ctan.org/pkg/wallpaper) package in [a
|
|||||||
|
|
||||||
Thus, I used this [answer on stackexchange](https://tex.stackexchange.com/questions/12838/can-i-add-tikzpictures-to-pages-included-with-pdfpages).
|
Thus, I used this [answer on stackexchange](https://tex.stackexchange.com/questions/12838/can-i-add-tikzpictures-to-pages-included-with-pdfpages).
|
||||||
To put it short, we use the package [pdfpages](https://ctan.org/pkg/pdfpages) with its options `pages={-}` to include every page, and the option `pagecommand` to include the rectangle overlay with the right dimensions `X`, `Y`, `L`, `H`.
|
To put it short, we use the package [pdfpages](https://ctan.org/pkg/pdfpages) with its options `pages={-}` to include every page, and the option `pagecommand` to include the rectangle overlay with the right dimensions `X`, `Y`, `L`, `H`.
|
||||||
That gives us the following `.tex`.
|
That gives us the following `.tex` file which can simply be compiled with your favorite latex typesetter (for instance `pdflatex file.tex` twice).
|
||||||
|
|
||||||
```tex
|
```tex
|
||||||
\documentclass[a4paper]{article}
|
\documentclass[a4paper]{article}
|
||||||
@ -44,7 +51,7 @@ That gives us the following `.tex`.
|
|||||||
(X, -Y)$) rectangle ++ (L, -H);%
|
(X, -Y)$) rectangle ++ (L, -H);%
|
||||||
\end{tikzpicture}%
|
\end{tikzpicture}%
|
||||||
}]%
|
}]%
|
||||||
{af.pdf}
|
{original file.pdf}
|
||||||
\end{document}
|
\end{document}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -64,7 +71,9 @@ You may have noticed that the dimensions are larger than in the above picture, t
|
|||||||
However, if you plan to use your smartphone, these companies also attach an ad-free `png` with minimal information.
|
However, if you plan to use your smartphone, these companies also attach an ad-free `png` with minimal information.
|
||||||
|
|
||||||
|
|
||||||
As I don't buy a plane ticket every day, I didn't feel the need to script it, and I don't have enough examples to make an interesting enough database of ad locations. However, if you are interested in it, feel free to send me dimensions and type of pdf (for instance a brand name) by email at <img style="height:2em" src="/images/mel.png" alt="courriel"/>.
|
As I don't buy a plane ticket every day, I didn't feel the need to script it, and I don't have enough examples to make an interesting enough database of ad locations.
|
||||||
|
However, it is a great opportunity to get some more data about it, therefore there you can `git clone` the script from [here](https://git.epheme.re/fmouhart/hidepdfads).
|
||||||
|
As it is a self-hosted private repository, if you are eager to contribute, you may want to do a pull request on its [github repository](https://github.com/Chouhartem/hidepdfads) or send me an email on <img style="height:2em" src="/images/mel.png" alt="courriel"/>. In any case, feel free to contact me for any further remarks, comments or questions.
|
||||||
|
|
||||||
<center>
|
<center>
|
||||||
![xkcd 1319 Randall Munroe](https://imgs.xkcd.com/comics/automation.png)]
|
![xkcd 1319 Randall Munroe](https://imgs.xkcd.com/comics/automation.png)]
|
||||||
|
Loading…
Reference in New Issue
Block a user