PDF anonymizer/synthesizer for Cradl
Project description
PDF anonymizer/synthesizer for Cradl
Disclaimer
This code does not guarantee that PDFs will be successfully anonymized/synthesized. Use at your own risk.
Installation
$ pip install lucidtech-synthetic
Make sure to have the following software installed on your system before using the CLI:
- ghostscript
Basic Usage
Docker
We recommend disabling networking and setting /path/to/src_dir
to read-only as shown below:
docker run --network none -v /path/to/src_dir:/root/src_dir:ro -v /path/to/dst_dir:/root/dst_dir -it lucidtechai/synthetic pdf /root/src_dir /root/dst_dir
CLI
synthetic pdf /path/to/src_dir /path/to/dst_dir
/path/to/src_dir
is the input directory and should contain your PDFs and JSON ground truths
/path/to/dst_dir
is the output directory where synthesized PDFs and JSON ground truths will be written to
Here is an example of the directory layout for /path/to/src_dir
:
/path/to/src_dir
├── a.pdf
├── a.json
├── b.pdf
└── b.json
The output directory will follow the same layout but with modified PDFs and JSON ground truths:
/path/to/dst_dir
├── a.pdf
├── a.json
├── b.pdf
└── b.json
Using a custom Synthesizer
CLI
synthetic pdf /path/to/src_dir /path/to/dst_dir --synthesizer-class path.to.python.Class
Make sure that parent directory of path.to.python.Class
is in your PYTHONPATH
Example using one of the example Synthesizers in examples
directory
synthetic pdf /path/to/src_dir /path/to/dst_dir --synthesizer-class examples.exclude-words.synthesizer.ExcludeWordsSynthesizer
Docker
docker run --network none -v /path/to/synthesizer:/root/synthesizer -v /path/to/src_dir:/root/src_dir:ro -v /path/to/dst_dir:/root/dst_dir -it lucidtechai/synthetic pdf /root/src_dir /root/dst_dir --synthesizer-class mypythonfile.ExcludeWordsSynthesizer
Note that the python module must be mounted into the docker container to /root/synthesizer
for it to work. In the above example we assume a directory structure of your custom synthesizer to be like below.
/path/to/synthesizer
└── mypythonfile.py
Example using one of the example Synthesizers in examples
directory. The examples
directory should already exist in the image so that we don't need to mount anything additional.
docker run --network none -v /path/to/src_dir:/root/src_dir:ro -v /path/to/dst_dir:/root/dst_dir -it lucidtechai/synthetic pdf /root/src_dir /root/dst_dir --synthesizer-class examples.exclude-words.synthesizer.ExcludeWordsSynthesizer
Help
All methods support the --help
flag which will provide information on the purpose of the method,
and what arguments could be added.
$ synthetic --help
Known Issues
PDF Synthesizer
- Does not synthesize images
- Replaced strings are sometimes not hexadecimal encoded even when expected to be
- Text appearing as single characters with custom spacing in PDF will often yield poor results
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lucidtech-synthetic-0.3.4.tar.gz
.
File metadata
- Download URL: lucidtech-synthetic-0.3.4.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 008fb3797e73ba185c85eb6fa25140a6927c840a7cdd9c8828ef6630bff330be |
|
MD5 | 420b66edf2924de5f3ceff4ef3b2b226 |
|
BLAKE2b-256 | fa06ebb30db2036f100d725c5ecea4442d0c442526ae2ea9f631d17e74b94566 |
File details
Details for the file lucidtech_synthetic-0.3.4-py2.py3-none-any.whl
.
File metadata
- Download URL: lucidtech_synthetic-0.3.4-py2.py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7faa8256c5421c640c68d93e7738c9825f0bae5cfc1d59f3971c4e295c38369f |
|
MD5 | 46c7f07c02cb3769d377e43895490f13 |
|
BLAKE2b-256 | c95c35120e7ae54467fe9d7bdd41d06b1c5585de4e4e316b6f9cbd16a82193b3 |