Hello guys,
First I just want to thank you Calibre Team, for the wonderful software you've made.
Now, I discovered that simple changing author and title in the calibre interface doesn't change the PDF metadata. That's a pitty, :whistle: but here it is a simple solution, using pdftk (under Debian/Linux, but the toolkit also run under Windows/Mac).
First download and install PDFTK
http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/
I wrote this simple script. It has the option "-d" if you want to delete the backup.
SCRIPT NAME: pdfmeta.sh
Copy and save the following (without --- begin --- and --- end ---), save in a pdfmeta.sh text file in a place your "PATH" includes, chmod it to +x (executable), and run as
$ pdfmeta.sh myebook.pdf -d
--- Begin ---
#!/bin/bash
#
# Copyright 2012, by Dr. Beco
# Gnu GPL licence.
#
# version 1.0, 05/dec/2012
#
# usage:
# pdfmeta.sh pdffile.pdf [-d]
#
# -d delete old filename.old.pdf
#
# know bugs:
#
# solved bugs:
if [ "$1" == "" ]; then
echo Error: please tell me the pdf filename to open.
else
pdftk "$1" dump_data > metadatapdf.txt
cat metadatapdf.txt
echo "Edit tags? (y/n)"
read Ans
if [ "$Ans" == "y" ]; then
vi metadatapdf.txt
pdftk "$1" update_info metadatapdf.txt output "$1".new.pdf
mv "$1" "$1".old.pdf
mv "$1".new.pdf "$1"
if [ "$2" == "-d" ]; then
echo Deleting filename.old.pdf
rm "$1".old.pdf
fi
fi
fi
# extra tip: find modified files using:
#
# ~/calibrelibrary/$ find . -regextype posix-extended -regex ".*\.epub|.*\.pdf" -newermt "2012-12-08 10:00" -printf "%Ay%Am%Ad%AH%AM%AS %f\n" | sort -n
#
--- End ---
The script will show you the current PDF tags. It will ask if you want to edit it or not. It will edit in vi if you choose "y", just save and quit.
And to include accented characters, use HTML CODE (found in this table:
http://web.forret.com/tools/charmap.asp?show=ascii )
It took me some while to figure out how come "Baçan" was shown as "Baħan", but that's because PDF metadata does not accept UTF8.
Example of metadata for Júlio Verne:
InfoKey: Author
InfoValue: Júlio Verne
Also, I could use hexedit ( http://linux.die.net/man/1/hexedit ) and manually insert the HEX code into the correct position. But that is too low level! :snicker:
é = HEX E9 HTML: é
ç = HEX E7 HTML: ç
ú = HEX FA HTML: ú
ó = HEX F3 HTML: ó
and so on. Take a look at the table above.
I hope this serves to help someone.
:dtw:
Beco
First I just want to thank you Calibre Team, for the wonderful software you've made.
Now, I discovered that simple changing author and title in the calibre interface doesn't change the PDF metadata. That's a pitty, :whistle: but here it is a simple solution, using pdftk (under Debian/Linux, but the toolkit also run under Windows/Mac).
First download and install PDFTK
http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/
I wrote this simple script. It has the option "-d" if you want to delete the backup.
SCRIPT NAME: pdfmeta.sh
Copy and save the following (without --- begin --- and --- end ---), save in a pdfmeta.sh text file in a place your "PATH" includes, chmod it to +x (executable), and run as
$ pdfmeta.sh myebook.pdf -d
--- Begin ---
#!/bin/bash
#
# Copyright 2012, by Dr. Beco
# Gnu GPL licence.
#
# version 1.0, 05/dec/2012
#
# usage:
# pdfmeta.sh pdffile.pdf [-d]
#
# -d delete old filename.old.pdf
#
# know bugs:
#
# solved bugs:
if [ "$1" == "" ]; then
echo Error: please tell me the pdf filename to open.
else
pdftk "$1" dump_data > metadatapdf.txt
cat metadatapdf.txt
echo "Edit tags? (y/n)"
read Ans
if [ "$Ans" == "y" ]; then
vi metadatapdf.txt
pdftk "$1" update_info metadatapdf.txt output "$1".new.pdf
mv "$1" "$1".old.pdf
mv "$1".new.pdf "$1"
if [ "$2" == "-d" ]; then
echo Deleting filename.old.pdf
rm "$1".old.pdf
fi
fi
fi
# extra tip: find modified files using:
#
# ~/calibrelibrary/$ find . -regextype posix-extended -regex ".*\.epub|.*\.pdf" -newermt "2012-12-08 10:00" -printf "%Ay%Am%Ad%AH%AM%AS %f\n" | sort -n
#
--- End ---
The script will show you the current PDF tags. It will ask if you want to edit it or not. It will edit in vi if you choose "y", just save and quit.
And to include accented characters, use HTML CODE (found in this table:
http://web.forret.com/tools/charmap.asp?show=ascii )
It took me some while to figure out how come "Baçan" was shown as "Baħan", but that's because PDF metadata does not accept UTF8.
Example of metadata for Júlio Verne:
InfoKey: Author
InfoValue: Júlio Verne
Also, I could use hexedit ( http://linux.die.net/man/1/hexedit ) and manually insert the HEX code into the correct position. But that is too low level! :snicker:
é = HEX E9 HTML: é
ç = HEX E7 HTML: ç
ú = HEX FA HTML: ú
ó = HEX F3 HTML: ó
and so on. Take a look at the table above.
I hope this serves to help someone.
:dtw:
Beco