Using PDFtk Server, I want to rotate a PDF file 90˚ and save it in-place, to overwrite the input file. I tried the following, but it fails, probably because it starts writing before the file is finished reading.
pdftk in.pdf cat 1-endright output - > in.pdf
in your operation bash overwrite in.pdf file before call pdftk. You can't do it that way. I would recommend something like
This command also protect you when converting fail - file would not be overwriten.
Use
moreutils
sponge
for this:One bug I've found is that
pdftk
doesn't always return non-zero on error, meaning thatin.pdf
may be wiped (sponge
doesn't wipe if zero exit status).