|12-09-2012, 05:51 PM||#1|
Join Date: Dec 2012
Device: Kobo Touch
Script to change pdf metadata (accented)
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, 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
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 ---
# Copyright 2012, by Dr. Beco
# Gnu GPL licence.
# version 1.0, 05/dec/2012
# 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.
pdftk "$1" dump_data > metadatapdf.txt
echo "Edit tags? (y/n)"
if [ "$Ans" == "y" ]; then
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
# 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:
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:
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!
Ú = 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.
|Thread Tools||Search this Thread|
|Thread||Thread Starter||Forum||Replies||Last Post|
|ePUB + PDF creation script||Trouhel||ePub||30||07-28-2012 09:02 AM|
|PDF to EPUB batch/script conversion ?||smallhagrid||Conversion||5||06-14-2011 06:33 PM|
|Script to download pdf-newspapers like ftd?||ganymede||Recipes||1||03-11-2011 09:04 AM|
|JetBook PDF antialiasing script||syrex314||Ectaco jetBook||7||05-18-2010 07:23 PM|
|A script to make iLiad show mobi metadata.||Format C:||iRex||4||09-23-2008 10:45 AM|