Very often you want to read comfortably on screen or on eBook reader, the PDFs created for printing: two side or slides of presentations (2 or more slides per page), without zooming or scrolling from side to side. After several fruitless searching I have found a great solution: LaTeX. With the help of 2 different types of PDFs, I show you how to automatically crop them.

Speaking of *LaTeX* to friends or colleagues, I make them smile and sometimes I obtain malicious comments, but don't worry: pronounced /ˈleɪtɛk/, /ˈleɪtɛx/, /ˈlɑːtɛx/, or /ˈlɑːtɛk/, this is a document markup language and document preparation system for the TeX typesetting program, as reported on Wikipedia. I suggest you an excellent introductory guide: L'arte di scrivere con LaTeX written by Lorenzo Pantieri and Tommaso Gordini.

Well, after this necessary introduction, I found on the Net the solution to my necessities: the two2one.tex file written by J.S. Milne, at this link. At first I did more attempts to get acceptable results, I made some mistakes in taking the measures of the pages and many times new edges appeared in the final PDF (when selected areas don't respect the A4 size proportion). Even for the last problem, I found solution by reading this article: LaTeX - how do I force PDF page height/width?.

## The requirements

*LaTeX* with the following packages: geometry to define the new page size, pdfpages to include PDF pages in TeX documents and ifthen for conditional commands. Or using WriteLatex online without installing anything.

## Typical procedure in 4 steps

- You have to know:
- Page size in points (pt width x pt height), page layout (portrait or landscape) and exact number of pages to cut out;
- The two coordinates measured in points that contain the cutting selection: x
_{0},y_{0}at the bottom left side (rounding-down) e x_{1},y_{1}at the top right side(rounding-up);

- If you have more selections, you must use the bigger size cutting in order to having an uniform PDF, i.e. you subtract the coordinates (x
_{1}-x_{0}=width, y_{1}-y_{0}=height) for every cuttings and will use the bigger dimensions to define new page size; - Rewrite the measures in a
*LaTeX*file, the layout orientation and total number of pages; - Run
*pdflatex*.

## Example 1: two-side document

This is a PDF with two different margins: the first for the right page (odd pages) and second for the left one (even pages).

Find size of the page (595x841 pt) | Highlight the interest areas | Find the coordinates (x,y), remember that (0,0) is in the bottom left of the page |

Using these data, you type the following LateX file (**da_two_side.tex**):

%%Original version by J.S.Milne 25.09.05 (two2one.tex - http://www.jmilne.org/math/Books/scan.html) %%Updated by Nicola Rainiero (http://rainnic.altervista.org/it/tag/latex) %%Correct this file for the number of pages in your document %%Correct this file for the size of your document in postscript points %%To do this, you need to find the size of your input document in points (Inkscape, Gimp or PDF Reader) %%Run pdflatex on this file: pdflatex "name of this file" % letterpaper, landscape or portrait \documentclass[portrait]{minimal} %%force the final dimension of PDF, put the maximum difference among the coordinates of the cropped areas %%(x direction: width, y direction: height) \usepackage[paperwidth=383pt,paperheight=696pt]{geometry} \usepackage{pdfpages} \usepackage{ifthen} \newcounter{pg} %counter of pages \begin{document} \setcounter{pg}{1} %fix the first page %% my pdf file has 10 pages %% my pdf file has size 595 x 841 points (width X height) \whiledo{\value{pg}<10}{% default pages + 1, pages +0 if there are two increments of pg %%x0,y0 at the bottom left -- x1,y1 at the top right of the selection \includepdf[pages=\thepg,viewport=80 87 463 783]{two_side.pdf} %pages on the right side, (odd pages) \addtocounter{pg}{1} %page increment \includepdf[pages=\thepg,viewport=128 87 511 783]{two_side.pdf} %pages on the left side, (even pages) \addtocounter{pg}{1} %page increment }% \end{document}

Summary:

input file | output file |

two_side.pdf | da_two_side.pdf |

## Example 2: landscape presentations with 4 slides every page

I chose this type, to highlight the versatility and simplicity of this method.

Find size of the page (841x594 pt) | Highlight the interest areas | Find the coordinates (x,y) |

Using these data, you type the following LateX file (**da_4_slide_orizzontali.tex**):

%%Original version by J.S.Milne 25.09.05 (two2one.tex - http://www.jmilne.org/math/Books/scan.html) %%Updated by Nicola Rainiero (http://rainnic.altervista.org/it/tag/latex) %%Correct this file for the number of pages in your document %%Correct this file for the size of your document in postscript points %%To do this, you need to find the size of your input document in points (Inkscape, Gimp or PDF Reader) %%Run pdflatex on this file: pdflatex "name of this file" %%letterpaper, landscape or portrait \documentclass[landscape]{minimal} %%force the final dimension of PDF, put the maximum difference among the coordinates of the cropped areas %%(x direction: width, y direction: height) \usepackage[paperwidth=285pt,paperheight=199pt]{geometry} \usepackage{pdfpages} \usepackage{ifthen} \newcounter{pg} %counter of pages \begin{document} \setcounter{pg}{1} %fix the first page %% my pdf file has 1 page %% my pdf file has size 841 x 594 points \whiledo{\value{pg}<2}{% default pages + 1, pages +0 if there are two increments of pg %%x0,y0 at the bottom left -- x1,y1 at the top right of the selection \includepdf[pages=\thepg,viewport=68 347 353 546]{4_slide_orizzontali.pdf} %first slide \includepdf[pages=\thepg,viewport=488 347 773 546]{4_slide_orizzontali.pdf} %second slide \includepdf[pages=\thepg,viewport=68 49 353 248]{4_slide_orizzontali.pdf} %third slide \includepdf[pages=\thepg,viewport=488 49 773 248]{4_slide_orizzontali.pdf} %fourth slide \addtocounter{pg}{1} %page increment } \end{document}

Summary:

input file | output file |

4_slide_orizzontali.pdf | da_4_slide_orizzontali.pdf |

All PDF of this guide and the corresponding TEX files have been compressed here: Esempi_su_come_ritagliare_un_PDF.zip

## Add new comment