Re: TCanvas creates PDFs with extra blank page ?

From: Chris Jones <jonesc_at_hep.phy.cam.ac.uk>
Date: Mon, 6 Sep 2010 16:28:30 +0100


H8i,

Ahhh. But the PDF you sent me has 5 pages in it. Which means that your lines

c1->Print("h1.pdf(");
c1->Print("h1.pdf)");

add to the file. I *specially* do not want this. I want to completely decouple the actions of opening and closing the file from filling it. This is why I am using the "[" and "]" syntax. I.e.

c1->Print("h1.pdf["); // Open the file without adding a page
c1->Print("h1.pdf");  // add a page
c1->Print("h1.pdf");  // add a page
c1->Print("h1.pdf");  // add a page
c1->Print("h1.pdf]"); // close the file without adding a page

so I end up with a PDF with only 3 pages.

Am I misreading the documentation for how the "[" and "]" syntax is supposed to work ?

cheers Chris

Olivier Couet wrote:
> It is fine for me.
>
> {
>
> TFile f("hsimple.root","READ");
> c1 = new TCanvas("c1","sub data",200,10,700,500);
>
> hpx->Draw();
> c1->Print("h1.pdf(");
> c1->Print("h1.pdf");
> c1->Print("h1.pdf");
> c1->Print("h1.pdf");
> c1->Print("h1.pdf)");
>
> }
>
> -----Original Message-----
> From: Chris Jones [mailto:jonesc_at_hep.phy.cam.ac.uk]
> Sent: Monday, September 06, 2010 5:15 PM
> To: Olivier Couet
> Cc: roottalk_at_root.cern.ch
> Subject: Re: [ROOT] TCanvas creates PDFs with extra blank page ?
>
> Olivier Couet wrote:

>> c.Print("test.pdf(");
>> ...
>> c.Print("test.pdf)");

>
> Thats even worse though ;) The first blank page is still there, but in
> addition I get a second unwanted page which half contains the histogram
> (from the script below) but is messed up. The third is OK ...
>
> See attached PDF
>
> Chris
>
>> -----Original Message-----
>> From: Chris Jones [mailto:jonesc_at_hep.phy.cam.ac.uk]
>> Sent: Monday, September 06, 2010 5:09 PM
>> To: Olivier Couet
>> Cc: roottalk_at_root.cern.ch
>> Subject: Re: [ROOT] TCanvas creates PDFs with extra blank page ?
>>
>> Hi,
>>
>> Sorry, I don't follow you when you say I should use parenthesis ?
>>
>> Chris
>>
>> Olivier Couet wrote:
>>> You should use parenthesis instead of square brackets and the fixed I

>
>>> mentioned is about the PS and PDF mixing.
>>>
>>> -----Original Message-----
>>> From: Chris Jones [mailto:jonesc_at_hep.phy.cam.ac.uk]
>>> Sent: Monday, September 06, 2010 4:54 PM
>>> To: Olivier Couet
>>> Cc: roottalk_at_root.cern.ch
>>> Subject: Re: [ROOT] TCanvas creates PDFs with extra blank page ?
>>>
>>> Hi,
>>>
>>> Sorry, just to be 100% clear. Are you saying just the PS and PDF bug 
>>> is fixed in v5.27, or is the empty first page fixed there as well ?
>>>
>>> cheers Chris
>>>
>>> Chris Jones wrote:
>>>> Hi,
>>>>
>>>> OK thanks. I cannot use a DEV version of ROOT though, so will have 
>>>> to
>>>> wait until this comes into production ...
>>>>
>>>> cheers Chris
>>>>
>>>> Olivier Couet wrote:
>>>>>> One thing. To properly create a PDF you have to do
>>>>>> c.Print("test.pdf[","pdf")
>>>>> This was fixed on May 26th this year. I am using 5.27 on linux
>>>>>
>>>>> -----Original Message-----
>>>>> From: Chris Jones [mailto:jonesc_at_hep.phy.cam.ac.uk] Sent: Monday, 
>>>>> September 06, 2010 2:27 PM
>>>>> To: Olivier Couet
>>>>> Cc: roottalk_at_root.cern.ch
>>>>> Subject: Re: [ROOT] TCanvas creates PDFs with extra blank page ?
>>>>>
>>>>> Hi,
>>>>>
>>>>> One thing. To properly create a PDF you have to do
>>>>>
>>>>> c.Print("test.pdf[","pdf")
>>>>>
>>>>> If you just do
>>>>>
>>>>> c.Print("test.pdf[")
>>>>>
>>>>> Then there is another bug (which I reported before but seems never 
>>>>> got
>>>>> fixed) in that ROOT actually creates a PS file. If you then load 
>>>>> this "PDF" file with say gv, then it might seem to have worked OK, 
>>>>> but that is only because you don't actually have a PDF file, but a 
>>>>> PS
>>> one...
>>>>> cheers Chris
>>>>>
>>>>> Chris Jones wrote:
>>>>>> Hi,
>>>>>>
>>>>>> It is nothing to do with PyRoot, I think, as the follow test CINT 
>>>>>> script shows the same bug for me. Switch to PS from PDF for the 
>>>>>> file type, and the empty page disappears.
>>>>>>
>>>>>> cheers Chris
>>>>>>
>>>>>> {
>>>>>>
>>>>>>   std::string fileType = "pdf";
>>>>>>
>>>>>>   TCanvas * c = new TCanvas();
>>>>>>
>>>>>>   c->Print( ("test."+fileType+"[").c_str(), fileType.c_str() );
>>>>>>
>>>>>>   TH1F * h = new TH1F("test","test",100,0.0,1.0);
>>>>>>
>>>>>>   h->Draw();
>>>>>>   c->Update();
>>>>>>   c->Print( ("test."+fileType).c_str(), fileType.c_str() );
>>>>>>
>>>>>>   c->Print( ("test."+fileType+"]").c_str(), fileType.c_str() );
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>> Chris Jones wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> OK, I'll try with CINT.
>>>>>>>
>>>>>>> Could you also try with PyRoot ?
>>>>>>>
>>>>>>> Exactly which root version did you use yourself, and what 
>>>>>>> platform
>>> ?
>>>>>>> cheers Chris
>>>>>>>
>>>>>>> Olivier Couet wrote:
>>>>>>>> Hi,
>>>>>>>> I just tried with the last ROOT version on my Linux machine and 
>>>>>>>> it is fine for me.
>>>>>>>> (with CINT of course :-) ).
>>>>>>>> Cheers,
>>>>>>>> O.Couet
>>>>>>>>
>>>>>>>> -----Original Message-----
>>>>>>>> From: Chris Jones [mailto:jonesc_at_hep.phy.cam.ac.uk] Sent: 
>>>>>>>> Monday,
>>>>>>>> September 06, 2010 1:07 PM
>>>>>>>> To: Olivier Couet
>>>>>>>> Cc: roottalk_at_root.cern.ch
>>>>>>>> Subject: Re: [ROOT] TCanvas creates PDFs with extra blank page ?
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>>> Do you get the same with the CINT macro ?
>>>>>>>> No idea. I try and stay away from CINT as much as possible... I 
>>>>>>>> could try if you insist ;)
>>>>>>>>
>>>>>>>>> Which root version are you using ?
>>>>>>>> Sorry, should have said. A very recent version -
>>>>>>>> 5.26.00cp1_python2.5 from /afs/cern.ch/sw/lcg/app/releases/ROOT
>>>>>>>>
>>>>>>>>> On which platform ?
>>>>>>>> SLC5.
>>>>>>>>
>>>>>>>> cheers Chris
>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>> O. Couet
>>>>>>>>>
>>>>>>>>> -----Original Message-----
>>>>>>>>> From: owner-roottalk_at_root.cern.ch 
>>>>>>>>> [mailto:owner-roottalk_at_root.cern.ch]
>>>>>>>>> On Behalf Of Chris Jones
>>>>>>>>> Sent: Monday, September 06, 2010 12:43 PM
>>>>>>>>> To: roottalk_at_root.cern.ch
>>>>>>>>> Subject: [ROOT] TCanvas creates PDFs with extra blank page ?
>>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> I use the TCanvas.Print method with the "[" and "]" syntax to 
>>>>>>>>> full multipage PDF and PS files from a PyRoot script. i.e.
>>>>>>>>>
>>>>>>>>> canvas = TCanvas()
>>>>>>>>>
>>>>>>>>> # Open the file
>>>>>>>>> canvas.Print("File.pdf[")
>>>>>>>>>
>>>>>>>>> # print some pages (after plotting histograms etc.)
>>>>>>>>> canvas.Print("File.pdf")
>>>>>>>>>
>>>>>>>>> # Close the file
>>>>>>>>> canvas.Print("File.pdf]")
>>>>>>>>>
>>>>>>>>> I've noticed that if I create a PDF, my preferred format, I 
>>>>>>>>> always seem to get an unwanted extra blank page at the start of

>
>>>>>>>>> the
>>>>> document.
>>>>>>>>> If, on the other hand I create PS files instead, I don't. See 
>>>>>>>>> as
>>>>>>>>> examples
>>>>>>>>>
>>>>>>>>>

> <http://www.hep.phy.cam.ac.uk/~jonesc/HPDImageCalibrationByFill.
>>>>>>>>> p
>>>>>>>>> s> 
>>>>>>>>>

> <http://www.hep.phy.cam.ac.uk/~jonesc/HPDImageCalibrationByFill.
>>>>>>>>> p
>>>>>>>>> df
>>>>>>>>> Any ideas why ?
>>>>>>>>>
>>>>>>>>> cheers Chris
>>>>>>>>>
Received on Mon Sep 06 2010 - 17:28:36 CEST

This archive was generated by hypermail 2.2.0 : Mon Sep 06 2010 - 17:50:01 CEST