Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre


Thread Tools Search this Thread
Old 12-09-2012, 05:51 PM   #1
Junior Member
beco began at the beginning.
beco's Avatar
Posts: 1
Karma: 10
Join Date: Dec 2012
Device: Kobo Touch
Script to change pdf metadata (accented)

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, 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.

Copy and save the following (without --- begin --- and --- end ---), save in a text file in a place your "PATH" includes, chmod it to +x (executable), and run as

$ myebook.pdf -d

--- Begin ---

# Copyright 2012, by Dr. Beco
# Gnu GPL licence.
# version 1.0, 05/dec/2012
# usage:
# 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
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

# 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:

InfoKey: Author
InfoValue: J˙lio Verne

Also, I could use hexedit ( ) and manually insert the HEX code into the correct position. But that is too low level!

š = 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.

beco is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
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

All times are GMT -4. The time now is 12:54 AM. is a privately owned, operated and funded community.