📜 ⬆️ ⬇️

How to cheap print a book in Linux

I think almost everyone faced the problem of printing large pdf files. Recently, I had to print a 600 page manual. Since the document consists entirely of text, I didn’t really want to print all 300 sheets of a4. In search of a solution, I came across an article from rapkasta .

That's how I came across a wonderful psutils package, only the method of binding it did not make me happy. Too much work. And I want to lazy automation, suddenly in the future come in handy.

Then I remembered that at the university I had to flash my graduation drafts and it turned out pretty cheap. It was worth 79 rubles to flash 300 sheets with a plastic spring. The problem remained in the script, how to remake it so that it was convenient to type with a minimum of human influence in the future.

First you need to install 2 packages:
1. texlive-core
2. psutils
They are put simply, if you have Ubuntu then sudo apt-get install texlive texlive-extra psutils
In my case, pacman -S texlive-core psutils
Use your package manager.
')

I will sign step by step:


We crop the fields to get maximum working coverage with text.

1) pdfcrop yourFile.pdf book.pdf

Convert pdf to ps file

2) pdftops book.pdf book.ps
There are two ways to convert pdf to psutils. pdf2ps and pdftops. The difference between them is that the first one rasterizes the fonts in good resolution and the second one tries to keep as much information as possible o pdf

Sort pages

We will re-sort the pages so that the first two and the last two pages alternate, so that with double-sided printing and subsequent cutting of a4 in two, sorted pages will turn out that could be folded together and flashed.

3) psbook book.ps > sorted_book.ps
This command adds blank pages to the file so that the total number of pages is a multiple of four, and also sorts the pages in two at first and two at the end. By default, the entire file is one brochure, but you can set a different number of pages for the brochure.

Redoing the file, 2 pages each centered

4) Open the resulting file in Evince (the program for viewing documents by default in Ubuntu) choose printing to a file as the resulting file will be called result.ps, printing in Postscript, in the Page Setup tab select 2 pages per side, paper size a4, portrait orientation go to the Page Handling tab and select Page Scaling: Fit to Printable Area, and tick off the autorotation and centering, click on the seal.
The same result can be achieved using the command psnup -p a4 -l -2 > result.ps , but I could not get a result that would suit me.

Sort files

5) psselect -e -r result.ps book-even-reverse.ps && psselect -o result.ps book-odd.ps
As a result, we get two files for printing, in one of which the pages go backwards. The same could be obtained from evince by selecting the seal and acc. options.

Delete rudimentary files

6) rm book.pdf book.ps sorted_book.ps result.ps

We print files

7) lpr book-odd.ps turn over the printed and re-type lpr book-even-reverse.ps

So, finally, a small cost estimate:
  1. Refill printer 236 rubles.
  2. A printer resource on one gas station of 1500 passes
  3. Xerox paper 500 sheets 118 rub.
  4. Stitching more than 200 sheets - 79 rubles.

Total 150 sheets = 35.4 rubles were used. + 300 passes of the printer = 47.2 rubles. + 79 rub. binding.
35.4 + 47.20 + 79 = 161.6 rubles.
In your area, the amount may be somewhat different.

PS Ideally, I would like to get a ready-made bash script to almost completely take the human factor out of this routine operation. I would appreciate any comments on improving the scripts. Especially the moment that concerns the use of Evince for centering and scaling images.

Source: https://habr.com/ru/post/196922/


All Articles