# scan-reflow **Repository Path**: ssb22/scan-reflow ## Basic Information - **Project Name**: scan-reflow - **Description**: Unix scripts for large-print handouts etc - **Primary Language**: C - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: http://ssb22.user.srcf.net/notes - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-27 - **Last Updated**: 2026-01-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # scan-reflow Unix scripts for large-print handouts etc, from https://ssb22.user.srcf.net/notes (also [mirrored on GitLab Pages](https://ssb22.gitlab.io/notes) just in case) Enlarging material in LaTeX --------------------------- Simply adding instructions such as `\Large` is not enough, as it doesn’t enlarge everything, and it may be difficult to achieve exactly the desired size. It’s more effective to change the LaTeX paper size and margin settings to simulate small paper, then magnify this up to the real paper size. The exact settings can be adjusted to achieve virtually any desired font size, and everything is enlarged to that size. You can generate the settings using my Python script `latex-papersize.py` (works in both Python 2 and Python 3). See the `--help` text or the comments at the beginning of the script for how to use it. latex-papersize is also on CTAN and in the TeX Live distribution, usually packaged in `texlive-extra-utils` or `texlive-latex-extra` by GNU/Linux distributions. It was previously called `LatexPaper.py` and older versions are Python 2 only. It is also available as a PyPI module: you can use `pip install latex-papersize` or `pipx run latex-papersize` Enlarging material using The GIMP --------------------------------- In some cases you will not have the files that produced the original handout. If obtaining these is out of the question, and if you do not have the resources to reproduce them, then you may still be able to produce an enlarged handout with the aid of an image manipulation program such as The GIMP. Here are some scripts to speed up this process. For each page, you can select areas that will be printed larger on pages of their own. If the printout has one column then you will be able to print the top half on one page and the bottom half on another page. If the printout has two columns then you will normally be able to select four areas (top half of left column, bottom half of left column, top half of right column, bottom half of right column). More complex layouts may need more complex selections. When selecting areas, try to put the boundaries in sensible places. The areas should roughly match the proportions of the paper that you will be printing on (either portrait or landscape) but slight irregularities in their size don’t matter (the script will adjust the scale accordingly). `savearea.scm` is a GIMP plugin to save the selection quickly (it will go to a temporary file without any further prompting). Installation instructions are in the comments at the top of the file (you will need to read these). Once you have done the selecting, run `areas2pdf.sh` to put the selections in order. It should write the result to a file called handout.pdf in your home directory, and clean up the temporary files. Requires pdflatex and netpbm (already present on most installations). Sometimes the handout.pdf file has a blank page at the start; I think this is a pdflatex bug (you can work around it by printing from page 2 onward). An image reflow utility ----------------------- The program `reflow.c` takes an arbitrary document (perhaps scanned) and magnifies it, re-flowing the words to fit the paper. This can be used when very large magnification is needed and the original files are not available. The program also facilitates highlighting, re-ordering and editing (see below) and it has a function for processing documents with interlinear annotations such as pinyin. It does not always work, but it works often enough to be useful. See the comments at the start for details. For highlighting and other editing, you may also need the Python 2 script `edit-reflow.py`. If using a scanner, you will need the images in PNG format, one per page, 600dpi greyscale. (Some scanning software says PPI instead of DPI; it’s the same thing.) If you are working from a typeset PDF, convert it into a series of PNG images like this: `gs -sDEVICE=pngmono -sOutputFile=myfile%03d.png -r600 -q -dNOPAUSE - < myfile.pdf` which will create myfile001.png, myfile002.png etc. (If your PDF is from a greyscale scan, use `pnggray` instead of `pngmono`. You can also add `-dFirstPage=3 -dLastPage=17` or whatever to limit the page range.) (If gs fails, you might get somewhere by first using the `pdftops` utility that comes with `xpdf`, or by using `acroread -toPostScript`, and then repeating the above on the resulting .ps file. If acroread reports “Segmentation fault” then it might still have converted all the pages, and if not then try running acroread in graphical mode and print to a `.ps` file.) If a fast computer will be in use, then it may be best to use the `--html` option which will create an HTML page that can be zoomed dynamically in most modern browsers (changing the browser’s text size will scale and reflow the images). The HTML can also be edited in SeaMonkey etc, in which case `edit-reflow.py` can still be used to colour the images but don’t follow its instruction to re-run reflow.c afterwards. (However note that Seamonkey has been known to delete the spacing between the images, which you then need to restore by replacing `>