0% found this document useful (0 votes)
94 views

How PDF Works: Gary Staas

The document discusses the structure and components of PDF files. It explains that PDF files have four main parts and use dictionary objects extensively to represent document elements like pages and annotations. It also describes how pages are drawn using marking operators and how interactive form fields are built from dictionaries.

Uploaded by

Tanvir Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views

How PDF Works: Gary Staas

The document discusses the structure and components of PDF files. It explains that PDF files have four main parts and use dictionary objects extensively to represent document elements like pages and annotations. It also describes how pages are drawn using marking operators and how interactive form fields are built from dictionaries.

Uploaded by

Tanvir Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

How PDF Works

Gary Staas
ByteSizeBooks.com
www.pdfdream.com

1 of 35

PDF Dream

Outline
How PDF represents a document
File structure4 parts
Document structureelements that build
a document
Painting pagesportray any document
Dictionariesexible data structure used
throughout PDF
Acrobat Formsbuilt from dictionaries
and annotations

2 of 35

PDF Dream

PDF Specication
PDF 1.4
PDF Reference, third edition
Adobe Portable Document Format
Version 1.4
http://partners.adobe.com/asn/
developer/acrosdk/docs/lefmtspecs/
PDFReference.pdf

3 of 35

PDF Dream

Structure levels
File structure
Four parts, one contains most data
Document structure
How document elements represented
Pages, annotations, bookmarks
Cos objects
Building blocks of document elements
Same as PostScript objects
Objects may be used repeatedly
Dictionaryimportant object type

4 of 35

PDF Dream

File structure
Header-version #

Body-most data
Document elements

Xref table-Cos object locs


Trailer-locates rest
May have 1000 bytes before Header

5 of 35

PDF Dream

Incremental update
Header
Body

Original le

Xref
Trailer
Body

Update section
(modied part)

Xref
Trailer

6 of 35

PDF Dream

Incremental update
One update section added for each save
File gets bigger after each save
Can revert to previous versions by
chopping off update sections
Digital signatures uses this feature
Save As... compacts le
Combines update sections and original
le into one Body, Xref, and Trailer

7 of 35

PDF Dream

Observing File structure


Use text editor
Wordpad, MS Word, BBEdit
Dont change line endings!
Modify le
Put data before header

8 of 35

PDF Dream

Document structure
Document comprised of various elements
Catalog/root
Pages
Annotations
Bookmarks
Each document element has its format
dened in PDF Reference
Example: Info dictionary
<<
/CreationDate (D:20010329220824Z)
/ModDate (D:20011006152637-07'00')
/Producer (Acrobat Distiller 5.0)
/Title (Acrobat SDK Release Notes)
/Creator (FrameMaker 5.5.6p145)
/Author (Adobe Developer Support)
>>
9 of 35

PDF Dream

Document structure
Trailer points to 2 things
Info dictionary
Catalog (root) contains document
objects
Page treeall doc pagestypically most of data
Viewer preferencesshow/hide toolbar...
Page labels
Form information
Bookmark (outline) tree
Everything else!

10 of 35

PDF Dream

Page tree
Allows random page access
Pages

Pages

Pages

Pages

Pages

Page
34

Page
35

Pages

Pages

Pages

Page
36

Pages

Page
37

11 of 35

PDF Dream

Page
Each page fully self contained for page
independence
Refer to everything needed for page in
one place
Know where to nd page data
Cos objectsbyte displacements in le from
cross reference table

12 of 35

PDF Dream

Page components
Contentspage descriptionvisible part
Resources
Info needed to render page, e.g., fonts
Thumbnail
Bitmap of page
Crop box
Annotations
Additional data on page
Standard-built-in annots
Custom annots, e.g., Acrobat Form
elds

13 of 35

PDF Dream

Cos objects
Document elements are built from Cos
objects
Types
Numberinteger and real
Stringtext
Arraylist
Dictionarykey-value pairs
Streamcontains data stream

14 of 35

PDF Dream

Cos objectsDictionary
Unordered set of key-value pairs
Database
Inherently extensible
Can represent many data structures
Many things in PDF le are dictionaries
Info dictionary
Pages
Annotations
Much of PDF Ref is dictionary denitions
Undened entries ignored by Acrobat
Can easily add custom data

15 of 35

PDF Dream

Cos objectsDictionary
Example: Text annotation
<<
/Type /Annot
/Subtype /Text
/Rect [266 116 430 204]
/Contents (Data of text annot)
>>

16 of 35

PDF Dream

Cos objectsStream
Two parts:
dictionary describing stream, e.g.,
length
data, which is usually compressed
Streams in PDF le
Page contents
Images

17 of 35

PDF Dream

Examining
Document structure
Annotation dictionary specication
PDF Ref, Section 8.4 Annotations
Provides names of keys
Modify annotations
Flags with annotation attributes
invisible - 32
Add custom data
Acrobat can repair leredundancy
Acrobat cant repair everything!
Cant do this with Touchup tool

18 of 35

PDF Dream

Page contents
Visible part of page
Represents any documents appearance
Appearance created with set of operators
that make marks on page
Descended from PostScript
Types of marks on pages
Text
Paths
Images
Contents is ordered list of drawing
operations
Page drawn in order of list

19 of 35

PDF Dream

Paint characteristics
Pages marked with paint
Objects can hide objects below them
PDF 1.4 transparencycombine layers
Text is font basedvector graphics
Text and lines are not bitmaps/images
Resolution independent
Imagesbitmaps
Page marking operators like
PostScripts and Illustrators
Illustrator 9.0+ native format is PDF 1.4

20 of 35

PDF Dream

Operator format
Prex notation
<operands> operator
operator typically 1 or 2 letters
operands typically numbers, strings
Types of operators
Set painting color
Draw pathslines and curves
Draw text
Draw images
73 drawing operators

21 of 35

PDF Dream

Color
Specify color space and coordinates
Separate colors for path stroke and ll
Basic color spaces
Gray, RGB, CMYK
Can be Device or Calibrated
Other colorspaces
ICC Based
Pattern

22 of 35

PDF Dream

Paths
Draw lines and curves
Can stroke and/or ll path

Example: Draw and ll rectangle


1 0 0 RG
0 1 0 rg
200 100 50 60 re
b

Red stroke in RGB


Green fill in RGB
Draw rectangle
Stroke and fill
23 of 35

PDF Dream

Text
Text is characters in a font
Text outlines can be stroked/lled
Example: Text line
Text PDF sample in 12 point Times
12 /F1 Tf (PDF sample) Tj

/F1 is name of font resource specifying


font attributes, such as Times-Roman
Variety of text operators
Text positioning
Character and word spacing
T- operators from Illustrator

24 of 35

PDF Dream

Text ordering
Text doesnt need to be in any order
1
PDF is a file format used to represent a document in a manner
independent of the application software, hardware, and operating
system used to create it. A5PDF file contains a3PDF document and
other supporting data.
4 PDF document contains one or more pages. Each page in the
A
7
document may contain any6combination
of text, graphics, and
images in a device- and resolution-independent format. This is the
page description. A2PDF document may also contain information
possible only in an electronic representation, such as hypertext links,
sound, and movies.

Page contents could draw all the PDF


words rst
Words can be broken up
Page could be represented in many ways
Tagged PDF enforces reading order
reow
25 of 35

PDF Dream

Resources
Additional information needed to draw
page
Referenced by page contents
Font
Color space
Images

26 of 35

PDF Dream

Font
Font is glyph description plus encoding
Glyphs
Actual character or ligature shapes

abcdefghijklmnopqrstuvwxyz
ZapfDingbats
Symbol

Woodtype 

Parisian

Font contains drawing operators for


glyph description in dened format
Encoding
One glyph for each character code
Most fonts map byte code to glyph
Many encodings close to ASCII
27 of 35

PDF Dream

Data compression and


encryption
Compressed datahuman unreadable
Visible data compressed
Infrastructure not compressed
Dictionaries not compressed
Decoded without password
Encrypted datahuman unreadable
Hide contents
Only data streams and strings
encrypted
Need password to decode
Infrastructure not all encrypted
Dictionary keys not encrypted
data may not be either

28 of 35

PDF Dream

Acrobat Interactive
Forms
Catalog object has AcroForm dictionary
Fields list of root elds
NeedAppearances create appearances
for elds without one
CO calculation order of elds

29 of 35

PDF Dream

Field dictionary
Each form eld is a dictionary
Field can have Kids
Field identied by a name
Fully qualied name from ancestors
applicant.address.city

Field is a Widget annotation if it has


appearance

30 of 35

PDF Dream

Field dictionary attributes


FT Field type
Button, Text, Choice, Signature
T
partial eld name
V
Value
variable format, depending on eld type
DV Default value
Ff
Form ags
Read-only, Required, No-export
Other ags, depending on eld type
Kids Children elds
AP Appearancesdrawn with same
operators that draw page appearance

31 of 35

PDF Dream

Easily examining
PDF internals
Enfocus Browser plug-in
Shows Cos object structure
Mac and Windows
Look at le

32 of 35

PDF Dream

PDF Reference Highlights


Chapter 3 Syntax
3.2 ObjectsCos objects
3.4 File Structure
Chapter 4 Graphics
4.1 Graphics Objectsdrawing
overview
4.4 Path Construction and Painting
4.8 Images
Chapter 5 Text
5.1 Organization and Use of Fonts
5.3 Text Objectshow text is drawn
5.5 Simple Fontsbasic font structure
Chapter 8 Interactive Features
8.4 Annotationsdictionary and types
8.6 Interactive Formseld meanings
33 of 35

PDF Dream

Summary
Three structure levels
File, Document, Cos object
Pages have contents and resources
referenced in one place
Marking operators draw page
Dictionaries are everywhere
Can examine and alter PDF le without
Acrobat
Acrobat form elds are dictionaries
PDF Ref tells you dictionary keys and
structure of document elements

34 of 35

PDF Dream

How PDF Works


Copyright 2001, 2002 Gary Staas
[email protected]
www.pdfdream.com

35 of 35

PDF Dream

You might also like