LinuxCommandLibrary

pbmtextps

Convert portable bitmap (PBM) to PostScript

TLDR

Render a single line of text as a PBM image

$ pbmtextps "[Hello World!]" > [path/to/output.pbm]
copy

Specify the font and font size
$ pbmtextps -font [Times-Roman] -fontsize [30] "[Hello World!]" > [path/to/output.pbm]
copy

Specify the desired left and top margins
$ pbmtextps [[-l|-leftmargin]] [70] [[-t|-topmargin]] [162] "[Hello World!]" > [path/to/output.pbm]
copy

Do not output the rendered text as a PBM image, but a PostScript program that would create this image
$ pbmtextps [[-du|-dump-ps]] "[Hello World!]" > [path/to/output.ps]
copy

SYNOPSIS

pbmtextps [options] [pbmfile]

PARAMETERS

-font <fontname>
    Specifies the PostScript font to use for rendering the text. E.g., 'Courier'.

-fontsize <points>
    Sets the font size in PostScript points (1/72 inch).

-linewidth <width>
    Sets the width of lines drawn in the PostScript output, in PostScript points.

-linespacing <points>
    Specifies the spacing between lines of text in PostScript points.

-bottomspace <points>
    Sets the bottom margin in PostScript points.

-topspace <points>
    Sets the top margin in PostScript points.

-leftspace <points>
    Sets the left margin in PostScript points.

-rightspace <points>
    Sets the right margin in PostScript points.

-width <inches>
    Sets the width of the output PostScript page in inches.

-height <inches>
    Sets the height of the output PostScript page in inches.

-x <inches>
    Sets the X coordinate of the output text's lower-left corner, in inches relative to the page's lower-left. Overrides horizontal centering.

-y <inches>
    Sets the Y coordinate of the output text's lower-left corner, in inches relative to the page's lower-left. Overrides vertical centering.

-rotate
    Rotates the entire output content 90 degrees clockwise within the PostScript page. Useful for changing the content orientation without altering page dimensions.

-nomargin
    Suppresses all default margins, making the text fill the entire output area if -x and -y are not used.

-setmargins
    Forces margins to be set even if -x or -y are used, which typically override default margin behavior.

-landscape
    Sets the output page orientation to landscape. This implies a 90-degree rotation of the coordinate system relative to portrait.

-portrait
    Sets the output page orientation to portrait (this is the default).

-level <level>
    Specifies the PostScript language level (e.g., 2, 3) for the output. Default is typically 2.

-inverted
    Inverts the PostScript output, rendering black pixels white and white pixels black.

-nocenter
    Prevents the text from being horizontally centered on the page. By default, text is centered horizontally if -x is not used.

-debug
    Enables debug output for troubleshooting command execution.

-version
    Displays the version information of pbmtextps and exits.

DESCRIPTION

pbmtextps is a utility from the Netpbm package designed to convert Portable Bitmap (PBM) images, specifically those generated to represent text, into PostScript format. It interprets the black pixels in the PBM image as characters and generates PostScript commands to render these characters using specified fonts and formatting.

This command is often used in conjunction with pbmtext, which creates PBM images from plain text. pbmtextps allows for extensive control over the output PostScript, including font selection, font size, line spacing, page margins, precise positioning (X/Y coordinates), rotation, and output page dimensions. It's particularly useful for embedding text-based graphical elements into PostScript documents or for printing text that has been manipulated at the pixel level. The output is typically PostScript Level 2 or higher compatible.

CAVEATS

pbmtextps generates PostScript Level 2 or higher compatible output. The specified PostScript fonts must be available to the interpreter or printer that processes the generated file; otherwise, a default font might be substituted, or an error could occur. The command is primarily designed for input PBM files where black pixels are intended to represent textual content.

COORDINATE SYSTEM AND UNITS

The PostScript output uses a coordinate system where the origin (0,0) is typically at the lower-left corner of the page. Units for dimensions and positions are primarily PostScript points (1/72 inch) for internal spacing options (e.g., -fontsize, -linespacing, margins), and inches for overall page dimensions and explicit X/Y coordinates (e.g., -width, -height, -x, -y). This mix requires careful attention when precisely positioning elements and calculating layouts.

STANDARD INPUT USAGE

If no pbmfile argument is provided, pbmtextps reads the PBM image data from standard input. This feature makes it highly adaptable for use in pipelines, allowing the output of other Netpbm commands (such as pbmtext) to be directly fed into pbmtextps for conversion to PostScript.

HISTORY

pbmtextps is an integral part of the Netpbm package, a versatile toolkit for manipulating graphic images. Netpbm originated from Jef Poskanzer's Portable Pixmap (PPM) format and related tools developed in the late 1980s. It has since evolved into a comprehensive suite maintained by Bryan Henderson. pbmtextps leverages the core PBM format to convert pixel-based text into a scalable, vector-based PostScript representation. Its development has been driven by the need for flexible image and text manipulation capabilities in various Unix-like environments, providing a robust solution for integrating bitmap text into PostScript documents.

SEE ALSO

pbmtext(1), pbm(5), netpbm(1), gs(1)

Copied to clipboard