# Change Meta-Information “Title” of PDF file in Export

Whenever I export a PDF file in Mathematica with the Export command, the meta-info of the pdf file will have the title as "Temporary Clipboard 0". I want to change the title. But using:

plot = Plot[Sin[x], {x, 0, 6 Pi}];
Export["test.pdf", plot, "Title" -> "Some title"]


does not change anything.

The Manual, says "Title" is the correct Meta-information element.

Whats wrong?

-
I don't think the meta-data for PDF is used for export. –  rasher Mar 18 '14 at 22:17
my PDF reader (Okular) shows the meta-information as Window Title. And all pdfs exported in Mathematica have the same Title "Temporary Clipboard 0". People that use other PDF viewer maybe do not notice this as most of them show the filename in the windows title. –  Philipp Mar 19 '14 at 8:45
Something similar is been asked again here: mathematica.stackexchange.com/q/59270/10397 –  rhermans Sep 9 '14 at 14:36

I have found a solution that works but it is OS specific. The following code works on Linux with installed exiftools.

A new function is provided (ExportPDF) that takes the same arguments as Export and an optional further argument "title". The PDF is produced with the standard export function and the command line tool exiftool is used to alter the title. If no title is given, then the filename will be used as title.

 ExportPDF[filename_, expr_, title_: 0] := Module[{command, title0},
If[title == 0, title0 = filename, title0 = title];
command = "exiftool -Title='" <> ToString[title0] <> "' -overwrite_original " <> filename;
Export[filename, expr];
Run[command]
];


The same can be done with meta-fields as e.g. author.

Any better solutions or improvements of the given function are very welcome!

-
I would like to add another way to circumvent the problem. At least in my case, as I use the KDE standard pdf viewer okular. There is a hidden option that allows to change okulars behavior. Then by default the filename is shown in the window title. Use the command kwriteconfig --file okularpartrc --group General --key DisplayDocumentTitle --type bool false to change this option. Change it back with bool true. –  Philipp Mar 19 '14 at 14:45

I am not quite sure, if I understood you correctly. If you mean the title of the PDF document that should appear right over the sinus plot, the workaround is below:

    Export[NotebookDirectory[] <> "SinPlot.pdf", CreateDocument[{
TextCell["Plot of a Sinus", "Title"],
ExpressionCell[Plot[Sin[x], {x, 0, 6 Pi}]]
}, WindowTitle -> "Plot of a Sinus"]]


You should, of course first save somewhere the notebook where you are working. Alternatively you can give the full path instead of NotebookDirectory[ ]. The PDF file you get as the result should look like this:

-
No, I am talking about the meta-information of the document. Your example could be easily obtained with the option PlotLabel in the plot function –  Philipp Mar 19 '14 at 8:47