pdf-toolbox-content-0.0.5.0: A collection of tools for processing PDF files

Safe HaskellNone
LanguageHaskell98

Pdf.Toolbox.Content.Processor

Description

Process content stream operators maintaining graphics state

It is pretty experimental

Synopsis

Documentation

data Processor Source

Processor maintains graphics state

Constructors

Processor 

Fields

prState :: GraphicsState
 
prStateStack :: [GraphicsState]
 
prGlyphDecoder :: GlyphDecoder
 
prGlyphs :: [[Glyph]]

Each element is a list of glyphs, drawn in one shot

data GraphicsState Source

Graphics state

Constructors

GraphicsState 

Fields

gsInText :: Bool

Indicates that we are inside text object

gsCurrentTransformMatrix :: Transform Double
 
gsFont :: Maybe Name
 
gsFontSize :: Maybe Double
 
gsTextMatrix :: Transform Double

Defined only inside text object

gsTextLineMatrix :: Transform Double

Defined only inside text object

gsTextLeading :: Double
 
gsTextCharSpacing :: Double
 
gsTextWordSpacing :: Double
 

type GlyphDecoder = Name -> Str -> [(Glyph, Double)] Source

Given font name and string, it should return list of glyphs and their widths.

Note: it should not try to position or scale glyphs to user space, bounding boxes should be defined in glyph space.

Note: glyph width is a distance between the glyph's origin and the next glyph's origin, so it generally can't be calculated from bounding box

Note: the Processor actually doesn't cares about glyph's bounding box, so you can return anything you want

data Glyph Source

Glyph

Constructors

Glyph 

Fields

glyphCode :: Int

The code as read from content stream

glyphTopLeft :: Vector Double

Top-left corner of glyph's bounding box

glyphBottomRight :: Vector Double

Bottom-right corner of glyph's bounding box

glyphText :: Maybe Text

Text ectracted from the glyph

Instances

mkProcessor :: Processor Source

Create processor in initial state

processOp :: Monad m => Operator -> Processor -> PdfE m Processor Source

Process one operation