postscript

package
v1.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package postscript reads the comments of PostScript documents, and of Encapsulated PostScript (EPS) files, which follow Adobe's Document Structuring Conventions (DSC), such as their title, the application which made them, who they were made for, when, and their pages and bounding box, and the preview of an EPS file with a DOS EPS header

Index

Constants

View Source
const ContentType = "application/postscript"

ContentType is the content type of PostScript documents and EPS files

Variables

View Source
var (
	// ErrNotPostScript is returned for a document which isn't PostScript
	ErrNotPostScript = errors.New("not a PostScript document")
)

Functions

This section is empty.

Types

type BoundingBox

type BoundingBox struct {
	LLX, LLY, URX, URY float64
}

BoundingBox is a box on a page, by its lower left and upper right corners, in points

func (BoundingBox) Height

func (b BoundingBox) Height() float64

Height returns the height of the box, in points

func (BoundingBox) Width

func (b BoundingBox) Width() float64

Width returns the width of the box, in points

type Document

type Document struct {
	// The version of the conventions it follows, such as 3.0, from its first
	// line, %!PS-Adobe-3.0, and the version of EPS, such as 3.0, when it's an
	// EPS file, from %!PS-Adobe-3.0 EPSF-3.0
	Version, EPS string

	// Its title, the application which made it, and who it was made for,
	// such as a person and their company
	Title, Creator, For string

	// When it was made, as it's written, such as "Fri Oct 24 07:32:48 1997",
	// and as a time, in UTC, when it can be read
	CreationDate string
	Created      time.Time

	// How many pages it has, from its %%Pages comment, or else its %%Page
	// comments, and its PostScript language level, such as 2
	Pages, LanguageLevel int

	// The size of paper it's for, as it says, such as A4, or empty (see
	// Paper)
	PaperSize string

	// The names of the fonts it uses, such as Times-Roman
	Fonts []string

	// The box which its marks are within, in points, a 72nd of an inch,
	// which is its high resolution bounding box, when it has one, or nil
	BoundingBox *BoundingBox

	// The preview of an EPS file with a DOS EPS header, which is a TIFF
	// image, or nil
	Preview []byte
}

Document is what a PostScript document's comments say about it, each of which is empty, or zero, when it doesn't have it

func Parse

func Parse(r io.ReaderAt, size int64) (*Document, error)

Parse returns what the comments of the PostScript document of the size say about it, from its header, and its trailer, for a value which is (atend) in its header, or ErrNotPostScript when it isn't a PostScript document. An EPS file with a DOS EPS header is read from its PostScript section, and its TIFF preview is read too.

func (*Document) Paper

func (doc *Document) Paper() string

Paper returns the size of paper the document is for: the size it says, with the case of a known size, such as A4 for a4, or else the size its bounding box is, in either orientation, when it's a page, which starts at the corner of the page, such as dvips gives a document, or an empty string when it isn't known, as an EPS file's bounding box is its drawing's

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL