Pdf Output in US Letter Size

I am trying to use ROOT to create pdf output with a total page size of 8.5 x 11 inches. Unfortunately no matter how I change the various parameters I am unable to get that page size. Here’s the script I run…

{
//Set Paper Size to 8.5" x 11"
gStyle->SetPaperSize(8.5*2.54, 11*2.54);

//Make canvas with arbritrary size but use correct aspect ratio to be sure
TCanvas c1("c1","title",850,1100);

//Make something to print
TF1 func("func","sin(x)^2",0,10);

//Draw the function
func.Draw();

//Print to pdf
c1.Print("letter.pdf");
}

After I run the macro I get a pdf file but Adobe Reader’s Document Properties states that the document has a page size of 7.99 x 10.76 in. Is there anyway to have ROOT generate an actual 8.5 x 11 in document?

John Estrada

Hi John,

You can usegStyle->SetPaperSize(kUSLetter); // or gStyle->SetPaperSize(20,24);kUSLetter is defined in the enum EPaperSize in TStyle.h. The numbers above take into account some margins and are in centimeters.

Cheers, Ilka

Ilka - I changed the paper size as suggested. When I run the following code…

{
  gStyle->SetPaperSize(20,24);
  TCanvas c1("c1","title",850,1100);
  TF1 func("func","sin(x)^2",0,10);
  func.Draw();
  c1.Print("letter.pdf");
}

the resulting pdf is 7.46 x 9.44 inch (as measured in Acrobat Reader). What I’m hoping to make is a true 8.5 x 11 inch document. I’ve attached the output file in case it is helpful.

John Estrada
letter.pdf (13.2 KB)

Hi John,

As documentation says the numbers for US Letter (20, 24) take into account some margins. My colleague Olivier can provide more details what is the meaning of that on Monday. Meanwhile you can use the Acrobat reader PostScript Options in the Print menu to get what you want. Please select the check button ‘Expand small pages to paper size’ and print your file. When I printed the above file ‘letter.pdf’ this way, I got (20,26) cm image on the paper, i.e. A4 format in use here.

Cheers, Ilka

PS: Please read “Print dialog”, not “Print menu” in my previous post.

Thanks, Ilka

When you open a PS or PDF file, the file type parameter is used to define to orientation (landscape or portrait) and the format.

   // The page orientation is last digit of PDF workstation type
   //  orientation = 1 for portrait
   //  orientation = 2 for landscape
   fPageOrientation = fType%10;
                                                                                
   // format = 0-99 is the European page format (A4,A3 ...)
   // format = 100 is the US format  8.5x11.0 inch
   // format = 200 is the US format  8.5x14.0 inch
   // format = 300 is the US format 11.0x17.0 inch
   fPageFormat = fType/1000;

so you can specify 1000001.
For PDF files, the format is used to dfined the PDF “MediaBox”

Thanks for all the information. PDFs generated with SetPaperSize can be printed onto US letter paper but the screen size is still smaller than US letter. This is a problem when I generate a PDF document with pages from ROOT (at less than US letter) and with other programs like Word (with US letter).

As for the fType I’m more than happy to try this out. Unfortunately I can’t figure out how. I searched for the code fragment and found it in TPDF. I’m guessing that TPDF is used when I call…

c1.Print(“letter.pdf”)

where c1 is an instance of TCanvas but since the call to TPDF is not explicit I don’t know how to change the fType.

John Estrada

Example:

{
   c = new TCanvas("c","c",400,600);
   TPDF pdf("pdf.pdf",-100111);
   TLine l(0.5,0.5,.75,.75);
   l.Draw();
   TText t(.3,.5,"Hello");
   t.Draw();
   pdf.Close();
}

Running the script above produces the attached pdf file which Adobe Reader 7.0 measures as 7.08 inches by 10.24 inches. US letter is 8.5 inches by 11 inches.

I’ve also attached a 2-page document which shows why I’m trying to get US letter as opposed to reduced US letter.

John Estrada
combined.pdf (29.3 KB)
pdf.pdf (11.4 KB)