Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

Thank you for your time reading this and your possible hints and solutions!

share|improve this question
    
I don't think the meta-data for PDF is used for export. –  rasher Mar 18 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 at 8:45

2 Answers 2

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: enter image description here

share|improve this answer
    
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 at 8:47
up vote 0 down vote accepted

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!

share|improve this answer
    
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 at 14:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.