Canvas Size on Paper

Hi, I need to make a sheet with lines at precise angles in order to line up a physical detector using lasers. I figured ROOT would be a good way to produce the sheet, especially if I need to do other angles later. Here is my code which produces a figure:

[code]#include “TLine.h”
#include
#include “TCanvas.h”
#include “TMath.h”
#include “TPad.h”
#include “TLatex.h”
#include "TString.h"
void angledrawing()
{
std::vector<Double_t> angles;
angles.push_back(0);
angles.push_back(10);
angles.push_back(20);
angles.push_back(30);
angles.push_back(40);

std::vector lines;
Double_t ypos = 0;
TCanvas c1(“c1”,“Angle Drawing”,200,200);
TLine * thisline = 0;
TLatex label;
label.SetTextSize(0.03);
for( auto angle:angles) // Hurray for C++11
{
// Positive angles.
ypos = 0.5TMath::Tan(TMath::DegToRad()(angle));
thisline = new TLine(0,0.5+ypos,1,0.5-ypos);
lines.push_back(*thisline);
thisline->Draw();
label.DrawLatex(0,0.5+ypos,TString::Format("%3.1f",angle));

  // Negative angles.
  ypos = 0.5*TMath::Tan(TMath::DegToRad()*(-1.0*(angle)));
  thisline = new TLine(0,0.5+ypos,1,0.5-ypos);
  lines.push_back(*thisline);
  thisline->Draw();

  label.DrawLatex(0.9,0.5+ypos,TString::Format("%3.1f",-1.0*angle));
}

gPad->Modified();
gPad->Update();
c1.SaveAs(“angledrawing.pdf”);
}
[/code]

Unfortunately when I print this, the angles are slightly off, noticeable with a protractor. The 40’ angle is really ~38’. I tried producing a .ps file instead, with the same result. I tried using one of the TCanvas constructors with a “Form” parameter that gives a square canvas (5). They all give the same result.

Can anyone advise whether this is a problem in how I am using the TCanvas, or a problem with pdf/ps files, or maybe I am just doing something dumb when printing?

Jean-François

I tried measuring the angles with a protractor on my screen, and there the angles are worse. I guess maybe my pixels are not in a square grid, but a rectangular one? The problem remains, how to create a canvas such that the printed thing ends up square?

Jean-François

Try:
gStyle->SetPaperSize(TStyle::kA4); // TStyle::kA4 or TStyle::kUSLetter
See also:
TPad::Print(const char* filename, Option_t* option)
TStyle::SetPaperSize(TStyle::EPaperSize size)
TStyle::SetPaperSize(Float_t xsize = 20, Float_t ysize = 26)
TCanvas::Size(Float_t xsizeuser = 0, Float_t ysizeuser = 0)