PSTOEDIT

Dr. Wolfgang Glunz

2001/12/30

Version 3.31

pstoedit - a tool converting PostScript and PDF files into various vector graphic formats

Table of Contents

Synopsis

From the command shell

pstoedit [ -v -help ]

pstoedit [ -adt ] [ -df fontname ] [ -dis ] [ -dt ] [ -flat number ] [ -fontmap file ] [ -include includefile ] [ -merge ] [ -nb ] [ -nfr ] [ -nomaptoisolatin1 ] [ -nq ] [ -page number ] [ -pagesize string ] [ -psarg string ] [ -pti or -pta ] [ -rgb ] [ -rotate angle (0-360) ] [ -scale factor ] [ -sclip ] [ -ssp ] [ -split ] [ -t2fontsast1 ] [ -uchar character ] [ -v ] -f "format[:options]" [inputfile [ outputfile ]]

pstoedit [ -scale factor ] -f "format[:options]" -bo input-file [ output-file ]

From Gsview

From within gsview pstoedit can be called via "Edit | Convert to vector format"

From programs that support the ALDUS graphic import filter interface

pstoedit can also be used as PostScript and PDF graphic import filter for several programs including MS-Office 95/97,2000, PaintShop-Pro and PhotoLine. See http://www.pstoedit.net/importps/ for more details.

Description

RELEASE LEVEL

This manpage documents release 3.31 of pstoedit.

USE

pstoedit converts PostScript and PDF files to various vector graphic formats. The resulting files can be edited or imported into various drawing packages. Type

pstoedit -help

to get a list of supported output formats. Pstoedit comes with a large set of format drivers integrated in the binary. Additional drivers can be installed as plugins and are available via http://www.pstoedit.net/plugins/. Just copy the plugins to the same directory where the pstoedit binary is installed. However, unless you also get a license key for the plugins, the additional drivers will slightly distort the resulting graphics. See the documentation provided with the plugins for further details.

PRINCIPLE OF CONVERSION

pstoedit works by redefining the two basic painting operators of PostScript, stroke and show (bitmaps drawn by the image operator are not supported by all backends.) After redefining these operators, the PostScript or PDF file that needs to be converted is processed by a PostScript interpreter, e.g., Ghostscript (gs(1)). You normally need to have a PostScript interpreter installed in order to use this program. However, you can perform some "back end" processing of prepared files by specifying the -bo option for debugging or limited filtering. See "BACK END-SPECIFIC OPTIONS" below.

The output that is written by the interpreter due to the redefinition of the drawing operators is a sort of 'flat' PostScript file that contains only simple operations like moveto, lineto, show, etc. You can look at this file using the -f debug option.

This output is read by end-processing functions of pstoedit and triggers the drawing functions in the selected back end driver, or backend.

NOTES

If you want to process PDF files directly, your PostScript interpreter must provide this feature, as does Ghostscript. Aladdin Ghostscript 4.03 or later is recommended for processing PDF (and PostScript Level 2) files.

Options

-dt
Draw text - Text is drawn as polygons. This might produce a large output file. This option is automatically switched on if the selected backend does not support this, e.g. gnuplot(1).

-adt
Automatic Draw text - This option turns on the -dt option selectively for fonts that seem to be no normal text fonts, e.g. Symbol..

-t2fontsast1
Handle type 2 fonts same as type 1. Type 2 fonts sometimes occur as embedded fonts within PDF files. In the default mode, text using such fonts is drawn as polygons since pstoedit assumes that such a font is not available on the users machine. If this option is set, pstoedit assumes that the internal encoding follows the same as for a standard font and generates normal text output. This assumption may not be true in all cases. But it is nearly impossible for pstoedit to verify this assumption - it would have to do a sort of OCR.

-pti or -pta
Precision text - With -pta, each character of a text string is placed separately. With -pti, this is done only in cases when there is a non zero inter-letter spacing. Normally a text string is drawn as it occurs in the input file. However, in some situations, this might produce wrongly positioned characters. This is due to limitiations in most backends of pstoedit. They cannot represent text with arbitray inter-letter spacing which is easily possible in PDF and PostScript. The downside of "precision text" is a bigger file size and hard to edit text.

-nfr
In normal mode pstoedit replaces bitmap fonts with a font as defined by the -df option. This is done, because most backends can't handle such fonts. This behavior can be switched off using the -nfr option but then it strongly depends on the application reading the the generated file whether the file is usable and correctly interpreted or not. Any problems are then out of control of pstoedit.

-dis
Open a display during processing by Ghostscript. Some files only work correctly this way.

-psarg string
The string given with this option is passed directly to Ghostscript when Ghostscript is called to process the PostScript file for pstoedit. For example: -psarg "-r300x300" This causes the resolution to be changed to 300x300 dpi. (With older versions of GhostScript, changing the resolution this way has an effect only if -display is set.)

You can switch Ghostscript into PostScript Level 1 only mode by -psarg "level1.ps". This can be useful for example if the PostScript file to be converted uses some Level 2 specific custom color models that are not supported by pstoedit. However, this requires that the PostScript program checks for the PostScript level supported by the interpreter and "acts" accordingly.

If you want to pass multiple options to Ghostscript you must can use multiple -psarg options -psarg opt1 -psarg opt2 -psarg opt2. See the GhostScript manual for other possible options.

-merge
Some output formats permit the representation of filled polygons with edges that are in a different color than the fill color. Since PostScript does not support this, drawing programs typically generate two objects (the outline and the filled polygon) into the PostScript output. pstoedit is able to recombine these, if they follow each other directly and you specify -merge.

-page page number
Select a single page from a multi page PostScript or PDF file.

-rotate angle (0-360)
Rotage image by angle.

-rgb
Since version 3.30 pstoedit uses the CMYK colors internally. The -rgb option turns on the old behavior to use RGB values.

-split
Create a new file for each page of the input. For this the output filename must contain a %d which is replaced with the current page number. This option is automatically switched on for backends that don't support multiple pages within one file, e.g. fig or gnuplot.

-uchar character
Sometimes pstoedit cannot map a character from the encoding used by the PostScript file to the font encoding of the target format. In this case pstoedit replaces the input character by a special character in order to show all the places that couldn't be mapped correctly. The default for this is a "#". Using the -uchar option it is possible to specify another character to be used instead. If you want to use a space, use -uchar " ".

-df fontname
Sometimes fonts embedded in a PostScript programs do not have a fontname. For example, this happens in PostScript files generated by dvips(1). In such a case pstoedit uses a replacement font. The default for this is Courier. Another font can be specified using the -df option. -df Helvetica causes all unnamed fonts to be replaced by Helvetica.

-include name of a PostScript file to be included
This options allows to specify an additional PostScript file that will be executed just before the normal input is read. This is helpful for including specific page settings or for disabling potentially unsafe PostScript operators, e.g., file, renamefile, or deletefile.

-fontmap name of font map file for pstoedit
The font map is a simple text file containing lines in the following format:

document_font_name target_font_name
% lines beginning with % are comments
% if a font name contains spaces, use
% the "font name with spaces" notation.

Each font name found in the document is checked agains this mapping and if there is a corresponding entry, the new name is used for the output.

If the -fontmap option is not specified, pstoedit automatically looks for the file drivername.fmp in the installation directory and uses that file as a default fontmap file if available. The installation directory is:

The mpost.fmp in the misc directory of the pstoedit distibution is a sample map file with mappings from over 5000 PostScript font names to their TeX equivalents. This is useful because MetaPost is frequently used with TeX/LaTeX and those programs don't use standard font names. This file and the MetaPost backend are provided by Scott Pakin (pakin@cs.uiuc.edu).

Another example is wemf.fmp to be used under Windows. See the misc directory of the pstoedit distribution.

-f format
target output format recognized by pstoedit. Since other format drivers can be loaded dynamically, type pstoedit -help to get a full list of formats. See "BACK END-SPECIFIC OPTIONS" below for an explanation of the [ :options ] to -f format.

-scale factor
scale by the specified factor. (Currently used with -f tgif backend only.)

-ssp
simulate sub paths
Several backend don't support PostScript pathes containing sub pathes, i.e. pathes with intermediate movetos. In the normal case, each subpath is treated as an independent path for such backends. This can lead to bad looking results. The most common case where this happens is if you use the -dt option and show some text with letters like e, o, or b, i.e. letter that have a "hole". When the -ssp option is set, pstoedit tries to eliminate these problems. However, this option is CPU time intensive!

-sclip
simulate clipping
Most backends of pstoedit don't have native support for clipping. For that pstoedit offers an option to perform the clipping of the graphics directly without passing the clippath to the backends. However, this results in curves being replaces by a lot of line segments and thus larger output files. So use this option only if your output looks different from the input due to clipping. In addition, this "simulated clipping" is not exactly the same as defined in PostScript. There might be lines drawn at the double size. Also clipping of text is not supported unless you also use the -dt option.

-pagesizestring
set page size for output medium
This option sets the page size for the output medium. Currently this is just used by the libplot backend, but might be used by other backends in future. The page size is specified in terms of the usual page size names, e.g. letter or a4.

-bo
You can run backend processing only (without the PostScript interpreter frontend) by first running pstoedit -f dump infile dumpfile and then running pstoedit -f format -bo dumpfile outfile.

-flat number
If the backend does not support curves in the way PostScript does or if the -nc option is specified, all curves are approximated by lines. Using the -flat option one can control this approximation. This parameter is directly converted to a PostScript setflat command. Higher numbers, e.g. 10 give rougher, lower numbers, e.g. 0.1 finer approximations.

-nb
Since version 3.10 pstoedit uses the -dDELAYBIND option when calling GhostScript. Previously the -dNOBIND option was used instead but that sometimes caused problems if a user's PostScript file overloaded standard PostScript operator with totally new semantic, e.g. lt for lineto. Using -nb the old style can be activated again in case the -dDELAYBIND gives different results as before. In such a case please also contact the author.

-nc
no curves
Normally pstoedit tries to keep curves from the input and transfers them to the output if the output format supports curves. If the backend does not support curves, then pstoedit replaces curves by a series of lines (see also -flat option). However, in some cases the user might wish to have this behavior also for backends that originally support curves. This can be forced via the -nc option.

-nq
No exit from the PostScript interpreter. Normally Ghostscript exits after processing the pstoedit input-file. For debugging it can be useful to avoid this. If you do, you will have to type quit at the GS> prompt to exit from Ghostscript.

-v
Switch on verbose mode. Some additional information is shown during processing.

-nomaptoisolatin1
Normally pstoedit maps all character codes to the ones defined by the ISO-Latin1 encoding. If you specify -nomaptoisolatin1 then the encoding from the input PostScript is passed unchanged to the output.

input-file
input file. If a "-" is given, standard input is used.

output-file
output file. If no output file or "-" is given as argument, pstoedit writes the result to standard output.

If neither an input nor an output file is given as argument, pstoedit works as filter reading from standard input and writing to standard output.

BACK END-SPECIFIC OPTIONS

pstoedit allows you to pass individual options to a backend. This is done by appending all options to the format specified after the -f option. The format specifier and its options must be separated by a colon (:). If more than one option needs to be passed to the backend, the whole argument to -f must be enclosed within double-quote characters, thus:

-f "format[:option option ...]"

To see which options are supported by a specific format, type: pstoedit -f format:-help

The following description is it not up to date at the moment. Sorry! Please use the above command to get a current list of options supported by the specific format.

Currently met, java, dxf, pic, fig, metapost, LaTeX2e, mif, emf, and wmf are the only drivers accepting specific options. Other options may be asserted through environment variables. See "ENVIRONMENT VARIABLES" below.

The wmf and the emf driver supports the following backend specific options:

-f wmf:m
Maps all fonts in the document to Arial (should be available on every Windows installation)
-f wmf:n
Emulate narrow fonts by shrinking fonts horizontally (sometimes does not look that good, but it's the only chance, when requested font weight is not available. And this is quite common for off-the-shelf Windows installations)
-f wmf:b
DON'T draw two white border pixel (upper left and lower right corner). They are normally drawn to keep content always within bounding box (is sometimes clipped otherwise, i.e. Windows doesn't respect pen thickness or rotated text extents). This could be done more smarter for EMF, have to figure out...

The java backend allows to specify the class name of the class that is generated by pstoedit. The default is PSJava. You can change this using

-f java:anothername

The dxf backend accepts the option -lines which forces all polygons and lines to be represented as LINEs in the generated DXF file. The default is to use POLYLINEs.

Example: -f "dxf:-lines"

The met backend allows the following single character options (without a leading -)

p
Draw no geometric linewidths, all lines have a width of zero.
l
No filling of polygon interiors.
c
No colors, just greyscales.
t
Omit all text.
g
Omit all graphics.
v
Put verbose output to STDERR.

Example: -f "met:lc"

The pic backend accepts the options:

-troff
-groff
which forces output to be compatible with troff and groff, respectively. Groff mode is default, troff mode severely limiting the choice of supported text fonts.

BUG: these options really does not belong in a backend

-keep
makes the pic backend emit the full font name of fonts that does not map to built-in groff fonts.

-text
makes the pic backend attempt to recognize running text, and treat it accordingly.

-landscape
-portrait
to compensate for the postscript orientation. Portrait mode is default.

Example: -f "pic:-troff -text -landscape"

The fig driver accepts the following options:

-startdepth
Fig knows about 999 layers (0 is the topmost, 999 the backmost). Per default, pstoedit starts with layer 999 and then places all subsequent objects on lower layers (on top of the previous objects). This can result in problems if you want to put something "below" all the objects that were created by pstoedit. In such a case you should define a lower number to leave some space behind.

-depth
depth in inches. Sets the paper width to the specified size in inches.

The ps2ai driver provides an option to select to old AI-88 format instead of the default AI-3

-88
selects the AI-88 format.

Example: -f ps2ai:-88

The tgif driver provides option to control the conversion of text strings into hyperlink attributes.

-ta
enables the conversion of text into boxes with hyperlink attributes. More options allowing finer control about this new feature will follow in future versions.

The tk driver supports the following backend specific options:

-f tk:I
Disables ImPress specific formatting. Only canvas objects will be output.
-f tk:N tagname
Adds a specific tag to all objects. If ImPress formatting is enabled, the items will be grouped.
-f tk:n tagname
Deprecated option. Behaves like N.
-f tk:R
If ImPress formatting is enabled, swap the Width and Height associated with the pagesize.

The mif backend allows the following options:

-f mif:-nopage
Generates an anchored frame instead of a full page. This is useful, if you want to insert a figure into an existing document.

-f mif:-imagesaspng
Bitmap images are written as PNG files instead of EPS. This is still experimental but should work for non rotated bitmaps.

The GNU libplot driver (gmfa, gmfb, plot) provides a huge set of options. All these are described in the header of the drvlplot.cpp file.

NOTES

autotrace:

pstoedit cooperates with autotrace. Autotrace can now produce a dump file for further processing by pstoedit using the -bo (backend only) option. Autotrace is a program written by a group around Martin Weber and can be found at http://sourceforge.net/projects/autotrace/.

Ps2ai:

The ps2ai backend is not a native pstoedit backend. It does not use the pstoedit postcript flattener, instead it uses the PostScript program ps2ai.ps which is installed in the GhostScript distribution directory. It is included to provide the same "look-and-feel" for the conversion to AI. The additional benefit is that this conversion is now available also via the "convert-to-vector" menu of Gsview. However, lot's of files don't convert nicely or at all using ps2ai.ps. So a native pstoedit driver would be much better. Anyone out there to take this ? The AI format is usable for example by Mayura Draw (http://www.mayura.com). Also a driver to the Mayura native format would be nice.

If you have a version of GhostScript older than 5.60, then you have to apply the following simple patch to the ps2ai.ps file in order to make this driver work. This patch is already included in newer versions of GhostScript.

After the line "/vers {2.13} def" insert:

/cdef { 1 index where { pop pop pop } { def } ifelse } def

Replace the lines:

"/jout false def"

with

"/jout false cdef"

(notice the cdef instead of def)

"/joutput (ps2ai.out.aips) def"

with

"/joutput (ps2ai.out.aips) cdef"

"/joutln false def"

with

"/joutln false cdef"

and the line

"/jtxt3 true def"

with

"/jtxt3 true cdef"

Note: If you already patched ps2ai for pstoedit version 3.02. you have to change to the patch above. This version is different but it better fits the ideas of Peter L. Deutsch. Sorry for the confusion, but this way chances are better that this version will go into the GhostScript distribution.

MetaPost:

Note that, as far as Scott knows, MetaPost does not support PostScript's eofill. My backend just converts eofill to fill, and issues a warning if verbose is set. Fortunately, very few PostScript programs rely on the even-odd fill rule, even though many specify it.

For more on MetaPost see:

http://cm.bell-labs.com/who/hobby/MetaPost.html

LaTeX2e:

creating a new backend:

To implement a new backend you can start from drvsampl.cpp and drvsampl.h. See also comments in drvbase.h and drvfuncs.h for an explanation of methods that should be implemented for a new backend.

ENVIRONMENT VARIABLES

A default PostScript interpreter to be called by pstoedit is specified at compile time. You can overwrite the default by setting the GS environment variable to the name of a suitable PostScript interpreter.

You can check which name of a PostScript interpreter was compiled into pstoedit using: pstoedit -help -v.

See the GhostScript manual for descriptions of environment variables used by Ghostscript most importantly GS_FONTPATH and GS_LIB; other environment variables also affect output to display, print, and additional filtering and processing. See the related documentation.

pstoedit allocates temporary files using the function tempnam(3). Thus the location for temporary files might be controllable by other environment variables used by this function. See the tempnam(3) manpage for descriptions of environment variables used. On UNIX like system this is probably the TMPDIR variable, on DOS/WINDOWS either TMP or TEMP.

SYSTEM SPECIFIC NOTES

DOS/WINDOWS

pstoedit compiled with MS-Visual C++ or Borland C++ runs under 32-bit only. It might run under WIN32s, but certainly does not run under plain 16-bit DOS.

pstoedit works best if you installed at least version 5.50 of GhostScript and version 2.72 of gsview. Using older version of GhostScript is possible but requires the setting of some environment variables.

TROUBLE SHOOTING

If you have problems with pstoedit first try whether Ghostscript successfully displays your file. If yes try pstoedit -f ps infile.ps testfile.ps and check whether testfile.ps still displays correctly using Ghostscript. If this file doesn't look correctly then there seems to be a problem with pstoedit's PostScript frontend. If this file looks good but the output for a specific format is wrong, the problem is probably in the backend for the specific format. In either case send bug fixes and reports to the author.

A common problem with PostScript files is that the PostScript file redefines one of the standard PostScript operators inconsistently. There is no effect of this if you just print the file since the original PostScript "program" uses these new operator in the new meaning and does not use the original ones anymoew. However, when run under the control of pstoedit, these operators are expected to work with the original semantics.

So far I've seen redefinitions for:

I've included work-arounds for the ones mentioned above, but some others could show up in addition to those.

RESTRICTIONS

Non-standard fonts (e.g. TeXbitmap fonts) are mapped to a default font which can be changed using the -df option. pstoedit chooses the size of the replacement font such that the width of the string in the original font is the same as in the replacement font. This is done for each text fragment displayed. Special character encoding support is limited in this case. If a character cannot be mapped into the target format, pstoedit displays a '#' instead. See also the -uchar option.

pstoedit supports bitmap graphics only for some backends.

The Gnuplot backend and the 3D backends (rpl, lwo, rib) do not support text.

Generally, pstoedit does not support clipping. You can try to use the -sclip option to simulate clipping. However, this doesn't work in all cases as expected.

Special note about the Java backends (java1 and java2)

The java backends generate a java source file that needs other files in order to be compiled and usable. These other files are Java classes (one applet and support classes) that allow to step through the individual pages of a converted PostScript document. This applet can easily be activated from a html-document. See the java/java1/readme_java1.txt or java/java2/readme_java2.htm file for more details.

FAQs

Why do letters like O or B get strange if converted to tgif/xfig using the -dt option?

This is because most backends don't support composite paths with intermediate gaps (moveto's) and second don't support very well the (eo)fill operators of PostScript (winding rule). For such objects pstoedit breaks them into smaller objects whenever such a gap is found. This results in the "hole" beeing filled with black color instead of beeing transparent. Since version 3.11 you can try the -ssp option in combination with the xfig backend.

Why does pstoedit produce ugly results from PostScript files generated by dvips?

TeX documents usually use bitmap fonts. Such fonts cannot be used as native font in other format. So pstoedit replaces the TeX font with another native font. Of course, the replacement font will in most cases produce another look, especially if mathematical symbols are used.

NOTICES

AUTHOR

Wolfgang Glunz, wglunz@pstoedit.net

CANONICAL ARCHIVE SITE

http://www.pstoedit.net/pstoedit/

At this site you also find more information about pstoedit and related programs and hints how to subscribe to a mailing list in order to get informed about new releases and bug-fixes.

ACKNOWLEDGEMENTS

LEGAL NOTICES

Trademarks mentioned are the property of their respective owners.

Some code incorporated in the pstoedit package is subject to copyright or other intellectual property rights or restrictions including attribution rights. See the notes in individual files.

pstoedit is controlled under the Free Software Foundation GNU Public License (GPL). However, this does not apply to importps and the additional plugins.

Aladdin Ghostscript is a redistributable software package with copyright restrictions controlled by Aladdin Software.

pstoedit has no other relation to Ghostscript besides calling it in a subprocess.

The authors, contributors, and distributors of pstoedit are not responsible for its use for any purpose, or for the results generated thereby.

Restrictions such as the foregoing may apply in other countries according to international conventions and agreements.