Prev: png.html Up Next: multi-page-terminals.html
The printer terminal

Practical Guide: To print the current canvas directly to a printer say:
printer::print();
And to specify the printing command (%f is replaced by the filename)
printer::print("lpr -h -Pprintername %f","-w 10cm -h 5cm");

The class printer is a terminal class to support direct printing to a printer. This is done via the eps terminal: a temporary eps file is created, printed to the printer, and then removed. The static printer::print() function accepts two arguments:

The default command can be set for example in $HOME/.blop/bloprc.C. In my institute I usually have to work at different places, at different PCs. There are many printers, and I want to send print jobs to the nearest one. So I have put this into my ~/.blop/bloprc.C (BLOP_USER_INIT is the function which is automatically called at program startup)

void BLOP_USER_INIT()
{
  const char *hn = getenv("HOST");
  if(hn == 0) { cerr<<"Could not getenv HOST, no default printer set"<<endl; }
  else
  {
     var host = hn;
     if(hn.find("machine1") != var::npos) {printer::default_command("lpr -h -Pprinter1");
     else if(hn.find("machine2") != var::npos)  {printer::default_command("lpr -h -Pprinter2");
     ...
     else
     {
        cerr<<"Don't know where is this machine: "<<host<<endl;
        cerr<<"No default printer is set"<<endl;
     }
  }
}

Source files:
   terminal.h
   terminal.cc

Prev: png.html Up Next: multi-page-terminals.html