File: README.md

package info (click to toggle)
scantpaper 3.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,936 kB
  • sloc: python: 46,241; xml: 81; makefile: 11
file content (389 lines) | stat: -rw-r--r-- 10,824 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
# ScantPaper

A GUI to produce PDFs or DjVus from scanned documents.

<p align="center">
    <img width="1254" height="656" alt="Image" src="https://github.com/user-attachments/assets/14078f4b-9cde-404e-aaab-958c77f90c5a" />
    <em>Screenshot: Main page v3.0.0</em>
</p>

---

## Usage

1. Start the application with `python3 scantpaper/app.py`.
   Add `--debug|info|warn|error|fatal` to enable logging at the required level.
1. Scan one or several pages with **File → Scan**.
1. Create a PDF of selected pages with **File → Save**.

---

## Command-line Options

scantpaper supports the following options:

- `--device=<device>`  
    Specifies the device to use, instead of getting the list from the SANE API. Useful for remote scanners.

- `--help`  
    Displays help and exits.

- `--log=<log-file>`  
    Specifies a file to store logging messages.

- `--debug`, `--info`, `--warn`, `--error`, `--fatal`  
    Defines the log level. Defaults to `--debug` if a log file is specified, otherwise `--error`.

- `--import=<PDF|DjVu|images>`  
    Imports the specified file(s). For multi-page documents, a window is displayed to select required pages.

- `--import-all=<PDF|DjVu|images>`  
    Imports all pages of the specified file(s).

- `--version`  
    Displays the program version and exits.

Scanning is handled with SANE. PDF conversion uses `img2pdf` and `ocrmypdf`. TIFF export uses `libtiff`.

---

## Diagnostics

To diagnose errors, start scantpaper from the command line with logging enabled:

```sh
python3 scantpaper/app.py --debug
```

---

## Configuration

scantpaper creates a config file at `~/.config/scantpaperrc`. The directory can be changed by setting `$XDG_CONFIG_HOME`. Preferences are usually set via **Edit → Preferences**.

---

## Dependencies

### Required

- gir1.2-gdkpixbuf-2.0
- gir1.2-gtk-3.0
- gir1.2-goocanvas-2.0
- imagemagick
- img2pdf
- libtiff-tools
- ocrmypdf
- poppler-utils
- python3-gi
- python3-gi-cairo
- python3-iso639
- python3-pil
- python3-sane
- python3-tesserocr

### Optional

- djvulibre-bin
- pdftk
- unpaper
- xdg-utils

### Development

- pytest-black
- python3-pytest-mock
- python3-pytest-cov
- python3-pytest-pylint
- python3-pytest-timeout
- python3-pytest-xvfb

---

## Download & Installation

**Github:**  
[scantpaper downloads](https://github.com/carygravel/scantpaper/releases/)

### Debian-based

- Debian `sid` will have the latest version as soon as it has cleared the new
  queue.
- Ubuntu users can use the PPA:

    ```sh
    sudo apt-add-repository ppa:jeffreyratcliffe/ppa
    sudo apt update
    sudo apt install scantpaper
    ```

### From Source

Download from [Github](https://github.com/carygravel/scantpaper/releases/).

### From the Repository

Browse the code at [Github](https://github.com/carygravel/scantpaper):

```sh
git clone https://github.com/carygravel/scantpaper.git
```

### Building from Source

Run the app straight from the source directory:
```sh
tar xvfz scantpaper-x.x.x.tar.gz
cd scantpaper-x.x.x
# optionally run the tests
pytest
# before starting the app
python3 scantpaper/app.py
```

Or build a wheel to install via `pip`:
```sh
# if necessary install build
pip install build
python3 -m build --wheel
# which you can install with pip
pip install scantpaper
# and then start the app
scantpaper
```

Or build a package for debian:
```sh
make debdist
```

---

## Support

- **Mailing lists:**
    - [gscan2pdf-announce](https://lists.sourceforge.net/lists/listinfo/gscan2pdf-announce) (announcements)
    - [gscan2pdf-help](https://lists.sourceforge.net/lists/listinfo/gscan2pdf-help) (general support)

---

## Reporting Bugs

- Please read the [FAQs](#faqs) first.
- Report bugs preferably against the [Debian package](https://packages.debian.org/sid/gscan2pdf) or [Debian Bugs](https://www.debian.org/Bugs/).
- Alternatively, use the [Github issue tracker](https://github.com/carygravel/scantpaper/issues).
- Include the log file created by `scantpaper --log=log` with your report.

---

## Translations

gscan2pdf is partly translated into several languages. Contribute via [Launchpad Rosetta](https://translations.launchpad.net/gscan2pdf).

- Scanner option translations come from sane-backends. Contribute via the [sane-devel mailing list](mailto:sane-devel@lists.alioth.debian.org) or [SANE project](http://www.sane-project.org/cvs.html).
- Ubuntu translation project: [Jaunty SANE backends](https://translations.launchpad.net/ubuntu/jaunty/+source/sane-backends/+pots/sane-backends)

To test updated `.po` files:

```sh
perl Makefile.PL LOCALEDIR=./locale
perl -I lib bin/gscan2pdf --log=log --locale=locale
```

Set locale variables as needed (e.g., for Russian):

```sh
LC_ALL=ru_RU.utf8 LC_MESSAGES=ru_RU.utf8 LC_CTYPE=ru_RU.utf8 LANG=ru_RU.utf8 LANGUAGE=ru_RU.utf8 python3 scantpaper/app.py --log=log --locale=locale
```

---

## Description

scantpaper provides a GUI for scanning, editing, and saving documents as PDF, DjVu, TIFF, PNG, JPEG, PNM, or GIF. It supports batch scanning, metadata, OCR, and various editing tools.

### Main Features

- **Scan:** Options for device, page count, source document, side to scan, and device-dependent options (page size, mode, resolution, batch-scan, etc.).
- **Save:** Save selected/all pages in multiple formats. Supports metadata.
- **Email as PDF:** Attach pages as PDF to a blank email (requires xdg-email).
- **Print:** Print selected/all pages.
- **Compress temporary files:** Compress images to save space.

### Edit Menu

- **Delete:** Remove selected page.
- **Renumber:** Renumber pages.
- **Select:** Select all, even, odd, blank, dark, or modified pages.
- **Properties:** Edit image metadata.
- **Preferences:** Configure default behaviors and frontends.

### View Menu

- Zoom, rotate, and fit options.

### Tools

- **Threshold:** Binarize images.
- **Unsharp mask:** Sharpen images.
- **Crop**
- **unpaper:** Clean up scans.
- **OCR:** Use gocr, tesseract, or cuneiform to extract text.

#### User-defined Tool Variables

- `%i` - input filename
- `%o` - output filename
- `%r` - resolution

---

## FAQs

### Why isn't option xyz available in the scan window?

It may not be supported by SANE or your scanner. If you see it in `scanimage --help` but not in scantpaper, send the output to the maintainer.

### How do I scan a multipage document with a flatbed scanner?

Enable "Allow batch scanning from flatbed" in Preferences. Some scanners require additional settings.

### Why is option xyz ghosted out?

The required package may not be installed (e.g., xdg-email, unpaper, imagemagick).

### Why can I not scan from the flatbed of my HP scanner?

Set "# Pages" to "1" and "Batch scan" to "No".

### Why is the list of changes not displayed when updating in Ubuntu?

Only changelogs from official Ubuntu builds are shown.

### Why can't scantpaper find my scanner?

If the scanner is remote and not found automatically, specify the device:

```sh
scantpaper --device <device>
```

### How can I search for text in the OCR layer?

Use `pdftotext` or `djvutxt` to extract text. Many viewers support searching the embedded text layer.

### How can I change the colour of the selection box or OCR output?

Create or edit `~/.config/gtk-3.0/gtk.css`:

```css
.rubberband,
rubberband,
flowbox rubberband,
treeview.view rubberband,
.content-view rubberband,
.content-view .rubberband {
    border: 1px solid #2a76c6;
    background-color: rgba(42, 118, 198, 0.2);
}

#scantpaper-ocr-output {
    color: black;
}
```

### What's in a name?

"scant" (https://en.wiktionary.org/wiki/scant) in this sense means "short (of)", as I am trying to digitalise my paperwork, and I liked the play on "scan".

---

## See Also

- [XSane](http://xsane.org/)
- [Scan Tailor](http://scantailor.org/)

---

## History

I started writing `gscan2pdf` as a Perl & Gtk2 project in 2006.
Version 2 switched to Gtk3, but kept the basic software architecture.
This stored the pages as temporary files with hashed names, which had a couple
of major disadvantages:

- Difficult to support PDF/A directly
- It was impossible to create documents with more than a few hundred pages, as
it ran out of open file handles.
- In the event of a crash, it was tedious to recreate the document from the image files.
- AFAIK, Perl's support for Gtk4 never extended beyond that provided by introspection.

Therefore I decided in 2022 to completely rewrite `gscan2pdf` in Python and
renamed it for v3 `scantpaper`. The rewrite:

- Supports PDF/A by using `ocrmypdf` to write PDFs
- Stores all session data in a single Sqlite database
- Should be simple to migrate to Gtk4

---

## Author

Jeffrey Ratcliffe (jffry at posteo dot net)

---

## Thanks To

- All contributors (patches, translations, bugs, feedback)
- The SANE project
- The authors of `img2pdf` and `ocrmypdf`, without which this would have been much harder.

---

## Contributing
Contributions are welcome. Please submit pull requests, ensuring that all the
tests pass, that new code is covered by new tests, and that the `pylint` does
not drop.

To run all the tests, just run `pytest`. To run all the tests in a particular
file, `pytest scantpaper/tests/test_app.py`. To run just one test in a file
`pytest scantpaper/tests/test_app.py::test_application_init`.

Note that the test suite also tests that the code is formatted with `black`.
To fix the formatting `black scantpaper`.

Similarly to check the linting for one or more files
`pylint scantpaper/app.py scantpaper/text_layer_control.py`

---

## Donate

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="GYQGXYD5UZS6S">
<input type="image" src="https://www.paypalobjects.com/en_US/DE/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

---

## License

Copyright © 2006–2026 Jeffrey Ratcliffe <jffry@posteo.net>

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free Software
Foundation.

This program is distributed in the hope that it will be useful, but **WITHOUT
ANY WARRANTY**; without even the implied warranty of **MERCHANTABILITY** or
**FITNESS FOR A PARTICULAR PURPOSE**. See the
[GNU General Public License](https://www.gnu.org/licenses/) for more details.

## Badges
On some READMEs, you may see small images that convey metadata, such as whether
or not all the tests are passing for the project. You can use Shields to add
some to your README. Many services also have instructions for adding a badge.