ImportEPSFromFile

Vector graphics

Description

Loads an Encapsulated PostScript (.eps or .ps) file from disk and renders its supported vector graphics, text and images onto the selected page within the specified bounding rectangle

Syntax

Delphi

Function TPDFlib.ImportEPSFromFile(Left, Top, Width, Height: Double; Const FileName: WideString; Options: Integer= 0): Integer;

Parameters

LeftHorizontal coordinate of the target bounding box origin
TopVertical coordinate of the target bounding box origin
WidthTarget width in current document units
HeightTarget height in current document units
FileNamePath to the EPS or PostScript file on disk
OptionsReserved option flags; pass 0

Return values

1The EPS file was loaded and rendered onto the selected page
0The file could not be read or contained no valid PostScript drawing operations

Remarks

Validates the offset and length of the PostScript segment in a binary DOS EPS preview wrapper ($C5D0D3C6) and excludes preview bytes from execution; truncated or out-of-range segments are rejected before any page content changes

Input is limited to 4 MiB and must be read completely; Options must be zero and the supported language subset and errors 124, 538 and 539 are the same as DrawPostScript; an unavailable input file reports 402

Bounded data sources and typed operands

The interpreter supports currentfile, string, length, filter, readstring, readhexstring and flushfile against the supplied source or finite string-backed filters; it does not open external files or network resources

ASCIIHexDecode, ASCII85Decode, RunLengthDecode and FlateDecode filters require valid explicit termination or a complete checksummed zlib member; chains are limited to four stages, and decoded bytes remain available through independent file cursors

readhexstring follows the PostScript rule of ignoring nonhexadecimal characters, while ASCIIHexDecode accepts only its defined whitespace and hexadecimal digits before the end marker; an odd final readhexstring nibble at file EOF is outside the qualified read profile

Read operations update named mutable buffers and preserve returned prefix aliases; buffers backing active filters cannot be overwritten, and filtered EOF never consumes following executable source bytes

Arrays evaluate their elements and can contain computed values and variables; typed dictionary operands, booleans, byte strings and file handles can be retained in definitions, and ASCII85 string literals are supported without executing their contents

Data limits are 32 MiB per decoded filter stream, 64 MiB cumulative decoded bytes, 268435456 data-work units, 512 MiB allocation reservation, 512 file handles and 1 MiB for an allocated string buffer; aggregate storage is bounded to 4096 objects, 100000 items, 4096 array elements and 128 dictionary pairs

Bounded images and stencils

Supported imaging includes five-operand image and imagemask, interleaved or planar colorimage, and ImageType 1 dictionaries with Width, Height, BitsPerComponent, ImageMatrix, Decode and DataSource; MultipleDataSources and Interpolate are optional

Old-style image always uses DeviceGray, colorimage selects DeviceGray, DeviceRGB or DeviceCMYK from its component count, dictionary image uses the current supported device color space, and imagemask paints with the current color

Samples support 1, 2, 4, 8 and 12 bits, with byte-padded rows; image matrices preserve top-down, bottom-up, rotated and skewed placement without changing the current path or point

Direct string sources repeat their bytes as needed, procedures return byte strings, and files remain finite; planar procedures run round-robin with equal chunk lengths and distinct buffers, while planar files require independent input streams

Data procedures cannot change graphics state or perform imaging, and cannot overwrite another active component buffer; malformed or unterminated filters fail the whole conversion, while premature finite-source EOF paints only complete available rows

Twelve-bit samples expand to sixteen bits with compensating Decode ranges that preserve normalized values; this requires PDF 1.5 or later and is rejected for archival or print-conformance modes and output versions explicitly locked below 1.5

Images are limited to 64 per import, 8192 pixels per dimension, 4194304 pixels each and 32 MiB of source samples per image; sample processing and allocation share the existing data budgets, and ASCIIHex-encoded inline output must fit the 16 MiB converted-content limit

Converted drawing is flushed before successful return, so an immediate save retains imported vectors, text and images; arbitrary PostScript dictionaries, executable font programs, nondevice color spaces, image types other than 1 and unsupported dictionary keys remain explicit errors

File import preserves original binary sample bytes without converting them through a Unicode text string; DrawPostScript remains a text-source interface, so file import is the suitable path for raw binary EPS data

DSC boundary metadata

BoundingBox and HiResBoundingBox values are read only from actual top-level DSC comment lines, including deferred values in a trailer; high-resolution values take precedence, and matching bytes inside literal strings, procedures or consumed data do not redefine placement

Bounded fonts and text

Text import resolves the exact Standard-14 PostScript font names: Courier, Helvetica and Times families with their standard style names, Symbol and ZapfDingbats; unknown font programs are rejected without environment-dependent substitution

Supported operators include findfont, scalefont, makefont, setfont, currentfont, selectfont, show, stringwidth, ashow, widthshow, awidthshow, xshow, yshow, xyshow and glyphshow for names available in the qualified font encoding

Literal strings decode escaped delimiters, octal bytes and line continuations, and hexadecimal strings support whitespace and odd final nibbles; typed string, array and font definitions retain their values without executing string contents

Font matrices affect glyph orientation, size, translation and natural advances; additional spacing uses current user coordinates, while xshow, yshow and xyshow numeric arrays replace natural advances, including the displacement after the final glyph

Roman fonts preserve PostScript StandardEncoding rather than assuming WinAnsi, and saved resources include matching widths and Unicode maps; Symbol and ZapfDingbats retain their own character mappings

Font resources are collected during private conversion and registered after successful interpretation, leaving the selected library font unchanged; text requiring unembedded Standard-14 resources is rejected in PDF/A, PDF/X, PDF/UA or always-embed mode

Glyph widths, lookups and positioning consume the shared operation budget; unknown encodings, unqualified glyph widths, unencoded named glyphs, encoded numeric displacement strings, arbitrary font dictionaries and executable font programs remain outside this bounded profile

Current path and graphics state

Current paths and points survive gsave/grestore, clipping and rectangle painting according to PostScript semantics; path coordinates retain their original placement when later coordinate transformations change the user coordinate system

currentpoint returns coordinates in the active user space, and relative path operators require a defined current point; singular or numerically unqualified transforms are rejected instead of returning stale coordinates

Path construction is bounded to 100000 cumulative nodes, and replaying saved paths consumes the shared operation and output budgets; bounded path storage does not reset the operation limit across graphics saves or repetition

See also

DrawPostScript, ImportEMFFromFile