From 3c5edea2a4b9199a2bf47c2fa88472f1cc2f8ed1 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Fri, 2 Sep 2022 13:27:24 +0200 Subject: [PATCH] fix pdf --- README.md | 8 ++++---- setup.cfg | 2 +- src/paper_secret/enpaper.py | 5 ++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b2660a1..8d83ba2 100644 --- a/README.md +++ b/README.md @@ -24,11 +24,11 @@ One can set the according parameters of `split_encode` to `False` to skip this s sudo pacman -S --needed qrencode imagemagick ``` -`enscript` is required to create a PDF containing the split secret in text form. +`enscript` and `ghostscript` (`ps2pdf`) are required to create a PDF containing the split secret in text form. One can set the according parameters of `split_encode` to `False` to skip this step. ```shell -sudo pacman -S --needed enscript +sudo pacman -S --needed enscript ghostscript ``` ## Usage @@ -42,7 +42,7 @@ cat > secret.txt Split the secret into 5 lines: ```shell -./enpaper.py secret.txt +enpaper secret.txt ``` Manually delete up to 2 of the 5 lines in `secret.txt_txt.txt`. @@ -50,7 +50,7 @@ Manually delete up to 2 of the 5 lines in `secret.txt_txt.txt`. Then recreate the secret: ```shell -./depaper.py secret.txt.split-text.txt +depaper secret.txt.split-text.txt ``` Print the secret: diff --git a/setup.cfg b/setup.cfg index dd048a0..7fd4e63 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,7 @@ [metadata] name = paper-secret -version = 0.1.0 +version = 0.1.1 author = Daniel Langbein author_email = daniel@systemli.org description = Shamir Secret Sharing on paper using gfshare diff --git a/src/paper_secret/enpaper.py b/src/paper_secret/enpaper.py index dce7e34..bca74d0 100755 --- a/src/paper_secret/enpaper.py +++ b/src/paper_secret/enpaper.py @@ -73,9 +73,12 @@ def split_encode( txt_file.write_text(lines) if create_text_pdf: - command = ['enscript', '-B', '--margins=24:24:', '-o', str(txt_pdf), '-f', 'Courier@12/12'] + txt_ps = tmpdir / 'txt.ps' + command = ['enscript', '-B', '--margins=24:24:', '-o', str(txt_ps), '-f', 'Courier@12/12'] util.execute_stdin_capture(command, lines.replace('\n', '\n\n\n').encode('UTF-8')) + util.execute_stdin_capture(['ps2pdf', str(txt_ps), str(txt_pdf)]) + if create_qr_codes and merge_qr_codes: command = ['convert'] + [str(qrcode) for qrcode in qrcodes] + [str(qr_pdf)] util.execute_stdin_capture(command)