[PYTHON] [auto-ohin] Introducing auto-ohin, a command line tool that can automatically stamp all at once [electronic stamp]

Introducing auto-ohin, a command line tool that can be electronically stamped

0. Introduction

At the end of every month, I made a move to print a pdf file, stamp it, and then scan it. Therefore, I made a command line tool that electronically stamps because I don't want to stamp it too much.

Click here for the repository GitHub

1. Installation method

it's simple.

$ pip install auto-ohin

2. File preparation

Prepare the following items.

--The pdf file you want to stamp --Electronic seal (transparent image (png)) --config file (described later)

2.1 Preparing the config file

Prepare the config file required for stamping. It is possible to write in Json format, but it also supports Jsonnet. For example, create the following file with a text editor and save it in a suitable location with a suitable name.

This time, let's assume that it was saved as path / to / config.jsonnet.

local root = "path/to/root/"; #Parent directory for storing various files
local pathgen(path) = root + path;
{
    "input_path": pathgen("input.pdf"), #The pdf file name you want to imprint
    "save_path": pathgen("output.pdf"), #Output file name(Note that it will be rewritten if it exists)
    "img_path": pathgen("inkan.png "), #File name of electronic seal stamp
    "obj_pages": [1, 3], #An array of page numbers to be stamped. It starts from 1.
    "position": [147, 225], #With the lower left as the origin[x, y]Fill in the format. The unit is mm.
    "img_size": [20, 20], # [Width height]Enter as. The unit is pixels.
    "pdf_size": "A4" #For now, A0~It corresponds to A5.

}

3. Imprint

If you execute the following on the command line, the pdf after stamping will be created in the location specified in the config file.

$ auto-ohin path/to/config.jsonnet

4. Finally

Future prospects: Since there are many arguments, I made it a format to prepare config, but it is difficult for people who are not familiar with Json to use it, so I would like to do something about it. We are looking for ideas.

It can also be used to put a watermark on each page of P.S.pdf, or put a specific icon in the footer position of even-numbered pages.

Recommended Posts

[auto-ohin] Introducing auto-ohin, a command line tool that can automatically stamp all at once [electronic stamp]
Introduced "Glances" command, a monitoring tool that can be understood at a glance, on Mac
[Python] I made a function that can also use regular expressions that replace character strings all at once.
Introducing youtube-dl, a video download tool that runs on the command line, and its zsh completion function.
Command to automatically update pip library at once
Limits that can be analyzed at once with MeCab
I made a tool to get the answer links of OpenAI Gym all at once