gROOT->GetListOfCanvases()->Print() to print PDF

Hi rooters,

I would like to print all the Canvases in memory to PDF files.

gROOT->GetListOfCanvases()->Print() almost gets my what I want … but theses are PS files, not PDF.

I thought gROOT->GetListOfCanvases()->Print(“pdf”) would do the job but it doesn’t (options are said to be passed recursively in TCollection, which is the Print method for TSeqCollection).

Any suggestion?

Thanks

Karolos

Hi Karolos,

what about something like this:

TCanvas *c = 0; TIter next(gROOT->GetListOfCanvases()); while ((c = (TCanvas *)next())) { c->Print("pdf"); }Cheers,
Bertrand.

1 Like

Hi Bertrand,

Thank you very for your reply.

I had indeed done something similar (but with at TIter* because I have more files to process) but the purpose of my mail was to understand this option passing process, which I haven’t yet (since I cannot make this work with one line).

Since it is possible to make a PS from all the files, isn’t the whole purpose of having simple commands defeated when one has to make loops to achieve what could be done in one line of code (and is implemented for the PS case)?

Of course I got the job done now and I’m fine with it. But either I am not understanding the options passing, or there is a bug. It’s probably the former, but in case it isn’t I wanted to report it/ask for the feature, since PDF is the native format for many applications now and pdflatex is being used more and more.

Thanks again.

Karolos

Hi Karolos,

You’re most welcome! :slight_smile:
Did you try:gROOT->GetListOfCanvases()->Print("pdf", 1);
See documentation of TCollection::Print() at:
http://root.cern.ch/root/html/TCollection.html#TCollection:Print

Cheers,
Bertrand.

Hi Bertrand,

This was actually the second thing I tried, after passing numerical parameter -1 for infinite recursion (but then I read that variables were passed recursively anyhow).

In that same page you are quoting, it is said that the default value for the second parameter is 1.

Anyhow when I try it out, after opening a file with Canvases, I get the following

root [1] gROOT->GetListOfCanvases()->Print("pdf", 1); Error: Can't call TSeqCollection::Print("pdf",1) in current scope (tmpfile):1: Possible candidates are... public: virtual void TCollection::Print(Option_t* wildcard="") const; public: virtual void TCollection::Print(Option_t* wildcard,Option_t* option) const; public: virtual void TObject::Print(Option_t* option="") const; Error: non class,struct,union object GetListOfCanvases() used with . or -> (tmpfile):1: *** Interpreter error recovered ***

Note that performing a loop-style (using TIter) script works perfectly fine for that same file.

Any ideas ?

The thing I don’t understand here is that

gROOT->GetListOfCanvases()->Print(“pdf”); yiels nothing (no output on the standard output nor as file) while gROOT->GetListOfCanvases()->Print(“pdf”, 1); (with the default value for the parameter) yields the above error.

Thanks for your help.

Karolos