TPad::Print() for PDF files

Hi all,

According the reference manual of TPad::Print http://root.cern.ch/root/html/TPad.html#TPad:Print for version 5.23/02, the “[” can be used to open a PostScript file without actual printing:

    c1.Print("file.ps[");   // No actual print, just open file.ps
    for (int i=0; i<10; ++i) {
      // fill canvas for context i
      // ...

      c1.Print("file.ps");  // actually print canvas to file
    }// end loop
    c1.Print("file.ps]");   // No actual print, just close.

This works for PostScript but NOT for PDF: even with “[” TPad::Print() does print. The attached is a sample script which opens, reads and displays a 1D histogram “hpx” from the hsimple.root file produced by running $ROOTSYS/tutorials/hsimple.C, and then print/save the canvas to a PostScript and a PDF file.

Yours,
Kazuyoshi
hsimplePrint.C (335 Bytes)

example:

{
   TFile f("hsimple.root","READ");
   c1 = new TCanvas("c1","sub data",200,10,700,500);
   hpx->Draw();
   c1->Print("h1.pdf(","pdf");
   hpx->Draw();
   c1->Print("h1.pdf","pdf");
   hpx->Draw();
   c1->Print("h1.pdf)","pdf");
}

Hi Olivier,

I sometimes want to open a pdf file without actual printing before doing something. How can I do so in the case of pdf files?

Yours,
Kazuyoshi

That was not what your macro was showing.
To do that you will have to use TPDF etc … but that is more complex than simply using the macro I sent you. If you do not want to print anything why opening a PDF file ? and then if you want to cumulate pictures into the same file simply use the macro I sent you.

Dear Olivier,

Sorry to make you confuse, but I’ve just tried to show that the opening angle bracket character doesn’t work as I expected (it DOES actual printing) for pdf files.

[quote=“couet”]
To do that you will have to use TPDF etc … but that is more complex than simply using the macro I sent you.[/quote]
I see. I’ll consult it.

[quote=“couet”]
If you do not want to print anything why opening a PDF file ? and then if you want to cumulate pictures into the same file simply use the macro I sent you.[/quote]
As in my previous post I sometimes do not want to print anything before doing something and just want to open an output file; main reason is that actual printing is done in loops that follow the opening.

Yours,
Kazuyoshi

With PDF only the normal brackets work () not the square ones []