Quote:
Originally Posted by joblack
Just remembered - perhaps your fonts just doesn't support these characters.
|
OK, out of several PDF metadata editors, only Calibre worked for this purpose. The reason is that all other programs don't write Unicode metadata into the file. But I don't want to install Calibre for just this purpose. So I wrote my own perl script which uses pdftk.
I will just post it here in case someone need it:
Code:
#!/bin/perl
use utf8;
use Encode;
binmode(STDOUT, ":utf8");
$numArgs = $#ARGV + 1;
if ( $numArgs > 1 ) {
open(INFOFILE, "> info.tmp") or die "Cannot open ./info.tmp!\n";
print INFOFILE "InfoKey: Title\n";
print INFOFILE "InfoValue: ";
$title = $ARGV[1];
$title = decode('gb2312', $title);
for $char ( split //, $title ) {
print INFOFILE "&#",ord($char),";";
}
print INFOFILE "\n";
print INFOFILE "InfoKey: Author\n";
print INFOFILE "InfoValue: ";
$author = $ARGV[2];
$author = decode('gb2312', $author);
for $char ( split //, $author ) {
print INFOFILE "&#",ord($char),";";
}
print INFOFILE "\n";
close(INFOFILE);
system("pdftk $ARGV[0] update_info info.tmp output $ARGV[0].update.pdf");
system("rm info.tmp");
} else {
print "Usage: pdfmeta <in.pdf> <title> [author]";
}