Output path included as meta-data to some PDF files by SaveAS

Hey there,

We utilise pyROOT-based scripts to provide plots for our analysis. We have noticed a peculiar behaviour of some of our scripts, namely sometimes SaveAs seems to add the full output path as meta-data to a PDF file, sometimes not. This is an unwanted feature, given the PDF files are published online and a full eos path will be visible when a PDF file is opened. Reproducing the issue is difficult, as some plots produced with the script have this problem, some not.

The canvas is created as

    canvas = ROOT.TCanvas("c", "c", 800, 600)
    canvas.cd()
    if options.log:
      pad = canvas.SetLogz(1)
    ROOT.gStyle.SetOptStat(0);
    ROOT.gStyle.SetPaintTextFormat("4.2f")
    ROOT.gStyle.SetOptTitle(0)
    ROOT.gPad.Update()
    canvas.SetTickx(1)
    canvas.SetTicky(1)
    canvas.SetRightMargin (0.19)
    canvas.SetTopMargin   (0.08)
    canvas.SetLeftMargin  (0.14)
    canvas.SetBottomMargin(0.14)

where as the saving is done as

    for ext in exts:
      canvas.SaveAs(self.outpath + ext)

and outpath is somebody’s EOS webpage path.

What could possible cause this?

ROOT Version: /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.22.00/x86_64-centos7-gcc48-opt/bin/thisroot.sh

1 Like

Welcome to the ROOT forum

Yes, the header of a ROOT pdf files contains the file name as Title with its path.

/Title (./c1.pdf)

It that what you are talking about ?

It is like that for at least 14 years. Nobody complained about that.

Hi couet,

Many thanks for your prompt reply!

I think yes, this is exactly what I am talking about. I guess I feel confused as some files keep this title information as a header when I rename and publish these plots, some don’t. Why does the outcome vary? While I would love to have all the fame for making the plots for one of the analysis of a big collaboration, I guess sharing my EOS paths publicly is not how one would hope it to happen.

I would like to send you an example to an existing plot privately if that is OK?

yes sure

1 Like

Reached out through CERN-channels, given I don’t have a permission to send a private message yet. :slight_smile:

I examined the details. The file name you provide to the SaveAs or Print methods is used as the global Title for the PDF file, and there is no way to change it. If you provide a full path name to the SaveAs or Print methods, the entire path will appear in the PDF file’s Title metadata. To avoid this, generate the PDF file in the current working directory and then move it to your preferred folder.

1 Like

I also created a small sed script that allows you to change the Title metadata of an existing PDF file.

File ChangePDFTitle.sh

#!/bin/sh
# ChangePDFTitle.sh
#
# Usage: ChangePDFTitle.sh filename new_Title

sed -i "s/\/Title (.*$/\/Title ($2)/" $1

Create the file ChangePDFTitle.sh containing the above lines and make it executable with:

$ chmod +x ChangePDFTitle.sh

Then, if you place it in a directory that is part of your $PATH , you can execute the following command to change the Title metadata of any PDF file generated by ROOT:

$ ChangePDFTitle.sh filename.pdf New_Title
1 Like

Thank you for your help @couet, this clarifies and solves it !

1 Like