mirror of
https://codeberg.org/privacy1st/pdf-replace
synced 2024-12-23 02:36:06 +01:00
About replacing text and links on PDF files
pdf_replace | ||
tests | ||
.gitignore | ||
pdf-replace.iml | ||
poetry.lock | ||
pyproject.toml | ||
README.md | ||
shell.nix |
PDF Replace
About replacing text and links on PDF files.
PDF - Print all links
See pdf_replace/print_links.py
PDF - Print text from all pages
PDF - Replace text or links
Source: https://gist.github.com/Nezteb/e761bb85ced6ce965e37d54ceb04635d
- Uncompress the PDF file
nix-shell -p qpdf
qpdf --qdf --object-streams=disable input.pdf uncompressed.pdf
or
nix-shell -p pdftk
pdftk input.pdf output uncompressed.pdf uncompress
- Edit the PDF as "plain text" file
Works:
- With
LC_ALL=C sed
LC_ALL=C sed -e 's|some text||g' uncompressed.pdf > uncompressed-output.pdf
Does not work:
- With
nano
by pressingALT
+r
(search and replace). The resulting PDF is distorted - some text is missing or misaligned.
Untested:
- With a text editor using "search and replace". Warning, on large files this might be laggy.
- Compress the PDF
qpdf uncompressed-output.pdf output.pdf
or
pdftk uncompressed-output.pdf output output.pdf compress