11. Printing Trees
Prev |  | Next

## 11. 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 8. 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.

- In the Print dialog you can specify a printing command to be used or (if Print to file is checked) a filename of the destination file.

- You can also specify a media-type (paper format) in the Media roll-out menu, page width and height (in case of `User` media-type), and horizontal and vertical margins. If the printed tree exceeds specified page boundaries, it is automatically shrunk and (unless Disable landscape rotation of wide trees is selected) rotated to fit on the page. See `PSMedia` configuration option for a list of supported media formats.

- The output format is specified by selecting one of Create PostScript, Create EPS, Create PDF and Convert according to ImageMagick buttons.

- If ImageMagick utilities are installed on the system, then automatic conversion to one of many image formats is supported. To use it, first check the Convert according to file extension button, then select a desired pixel resolution for conversion to bitmap, and finally edit the output filename extension to that of the desired output file-format such as `.png` or `.jpg`. When converting to a bitmap, Resolution may be specified to adjust the mapping between PostScript coordinate system units (given in 1/72 inch) to raster pixels.

- If you also want the “sentence” of the tree (i.e. the usual annotation mode of the text window above the tree) to be printed under the tree, check the Print sentence button.

- It is possible to print more than one tree (each tree then appears either on a separate page or in a separate file). To do so, a comma-separated list of tree numbers or ranges of tree numbers that correspond to the desired trees in the active file, must be entered into the Page range field. The button is be used to automatically insert a page range corresponding to sentences selected via View → List of Sentences.... A different selection based on “sentences” can be made by pressing the button .

- If entered manually, the page range must be specified according to the following rules: Trees in the file are numbered starting from 1. Ranges are pairs of numbers of the form “`3-20`” (which in this case covers all trees starting from the tree no. 3 to no. 20). If the first number in the range is omitted, 1 is assumed. If the second number in the range is ommited, the number of the last tree in the active file is assumed. The order of the tree numbers given in the list is strictly reflected in the output file, which also means that ceratin tree can be printed more than once.

  ### Example:

  To print trees from 1 to 5, then trees no. 7, 11, 12 and 5 again, use e.g. one of the following lists:

  `1-5,7,11,12,5`
  `1-5,7,11-12,5`
  `-5,7,11-12,5`

### Note

Printing trees can also be automated by writing a suitable macro. For this purpose, TrEd API offers the function `Print` (see Section 15.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();
    }

Prev |  | Next
10. Customizing Tree Appearance: Stylesheets | Home | ToC | 12. Using File Lists