10. Printing Trees

TrEd is able to render trees to PostScript, Encapsulated PostScript (EPS), and Portable Document Format (PDF). Should the trees contain non-latin (iso-8859-1, iso-8859-2, windows-1250, etc.) characters, such as Arabic, the PDF might be the only option, because of its support for TrueType fonts.

If ImageMagick toolkit is installed, TrEd can also automatically convert the result into one of many bitmap image formats supported by this toolkit.

While PostScript is the default printing format on most Unix/Linux systems (and can be printed using the standard lpr command), Windows users may use for example Adobe Acrobat Reader to preview and print trees rendered into PDF. There are also some free PostScript interpreters for Windows (see GhostView).

Figure 6. Print dialog

print dialog

Encapsulated PostScript files (EPS) are especially useful for preparation of other printed materials e.g. PDF of LaTeX documents. Compared to bitmapped images, EPS images have the advantage of being scalable. Most office suits (such as Microsoft Office and OpenOffice.org) have at least limited support for EPS. Similar results can be obtained by using PDF with BBox media size.

Note

TrEd's ability to render PostScript and EPS is limitted to Eastern European character sets. For other charsets and unicode (especially when TrEd runs on a unicode aware versions of Perl and Tk, i.e. at least Perl 5.8 and Tk804), PDF print format is recommended.

Printing into PDF requires a TrueType font containing at least the glyphs used in the tree. For most languages, the usual fonts such as Arial (arial.ttf), Times New Roman (times.ttf) or Bitstream Vera (vera.ttf) are sufficient while other languages, such as Arabic, require a fully featured Unicode font such as Arial Unicode MS. The TrueType font can be specified either directly from the Print dialog or by setting TTFont configuration option. If TTFont is not given, it defaults to Arial. TrEd searches for TrueType fonts in directories listed in TTFontPath configuration option. If this option is not explicitly specified, TrEd uses directories listed in fontconfig library configuration file /etc/fonts/fonts.conf on Unix and Windows system font directory on Windows. If no usable font is found, PDF printing is disabled.

For PostScript printing, TrEd uses a Type1 font. The file containing the font may be specified using the PsFontFile (and optionally PsFontAFMFile) configuration option.

Note

Printing trees can also be automated by writing a suitable macro. For this purpose, TrEd API offers the function Print (see Section 14.8, “Public API: pre-defined macros”). This function however requires TrEd GUI, i.e. it cannot be run in btred.

Example 1. Printing trees from a user-defined macro

	  
# bind key p to CreateImages menu Create bitmap images of all trees
sub CreateImages {
   GotoTree(1);
   my $tree_no = 1;
   my $name = FileName();
   $name =~ s/\..*//; # strip filename suffix
   do {{
      TredMacro::Print(
	 -toFile => 1,
	 -format => 'ImageMagick',
	 -imageMagickResolution => 90,
	 -colors => 1,
	 -sentenceInfo => 1,
	 -filename => "${name}_${tree_no}.png"
       );
      $tree_no++;
   }} while NextTree();
}