Packageorg.alivepdf.pdf
Classpublic class PDF
InheritancePDF Inheritance Object
Implements flash.events.IEventDispatcher

The PDF class represents a PDF document.



Public Properties
 PropertyDefined By
  isCompressed : Boolean
Lets you activate zlib compression for the current PDF
PDF
  totalPages : int
[read-only] Lets you retrieve the number of pages in the PDF document
PDF
Protected Properties
 PropertyDefined By
  addTextColor : String
PDF
  aliasNbPages : String
PDF
  angle : Number
PDF
  arrayNotes : Array
PDF
  arrayPages : Array
PDF
  autoPageBreak : Boolean
PDF
  autoPagination : Boolean
PDF
  b2 : String
PDF
  bMargin : Number
PDF
  buffer : ByteArray
PDF
  cMargin : Number
PDF
  colorFlag : Boolean
PDF
  columnNames : Array
PDF
  columns : Array
PDF
  compress : Boolean
PDF
  compressedPages : ByteArray
PDF
  currentFont : Object
PDF
  currentGrid : Grid
PDF
  currentOrientation : String
PDF
  currentPage : Page
PDF
  currentX : Number
PDF
  currentY : Number
PDF
  cw : Object
PDF
  d : Number
PDF
  defaultOrientation : String
PDF
  defaultRotation : int
PDF
  defaultSize : Size
PDF
  defaultUnit : String
PDF
  desc : String
PDF
  diff : Number
PDF
  diffs : Array
PDF
  dispatcher : EventDispatcher
PDF
  documentAuthor : String
PDF
  documentCreator : String
PDF
  documentKeywords : String
PDF
  documentSubject : String
PDF
  documentTitle : String
PDF
  drawingRule : String
PDF
  enc : Number
PDF
  encryptRef : int
PDF
  extgstates : Array
PDF
  file : String
PDF
  fillColor : String
PDF
  filled : Boolean
PDF
  filter : String
PDF
  fontFamily : String
PDF
  fontFiles : Array
PDF
  fontkey : String
PDF
  fonts : Object
PDF
  fontSize : Number
PDF
  fontSizePt : Number
PDF
  fontStyle : String
PDF
  image : PDFImage
PDF
  inFooter : Boolean
PDF
  inHeader : Boolean
PDF
  inited : Boolean
PDF
  isEven : int
PDF
  k : Number
PDF
  lasth : Number
PDF
  layoutMode : String
PDF
  lineWidth : Number
PDF
  links : Array
PDF
  lMargin : Number
PDF
  matrix : Matrix
PDF
  n : int
PDF
  name : String
PDF
  nb : int
PDF
  nbPages : int
PDF
  offsets : Array
PDF
  orientationChanges : Array
PDF
  originalsize : Number
PDF
  outlineRoot : int
PDF
  outlines : Array
PDF
  pageBreakTrigger : Number
PDF
  pageLinks : Array
PDF
  pageMode : String
PDF
  pdfVersion : String
PDF
  reference : String
PDF
  references : String
PDF
  rMargin : Number
PDF
  rotationMatrix : Matrix
PDF
  size1 : Number
PDF
  size2 : Number
PDF
  standardFonts : Object
PDF
  state : int
PDF
  streamDictionary : Dictionary
PDF
  strokeStyle : String
PDF
  textRendering : int
PDF
  tMargin : Number
PDF
  type : String
PDF
  underline : Boolean
PDF
  up : Number
PDF
  ut : Number
PDF
  viewerPreferences : String
PDF
  windingRule : String
PDF
  ws : Number
PDF
  zoomFactor : Number
PDF
  zoomMode : *
PDF
  zoomRectangle : Rectangle
PDF
Public Methods
 MethodDefined By
  
PDF(orientation:String = Portrait, unit:String = Mm, pageSize:Object = null, rotation:int = 0)
The PDF class represents a PDF document.
PDF
  
addBookmark(text:String, level:int, y:Number, color:RGBColor):void
Lets you add a bookmark
PDF
  
addCell(width:Number = 0, height:Number = 0, text:String, border:* = 0, ln:Number = 0, align:String, fill:Number = 0, link:String):void
Add a cell with some text to the current page
PDF
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
PDF
  
addGrid(grid:Grid, x:Number = 0, y:Number = 0, repeatHeader:Boolean = true):void
PDF
  
addImage(displayObject:DisplayObject, x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0, imageFormat:String = PNG, quality:Number = 100, alpha:Number = 1, resizeMode:String = None, blendMode:String = Normal, keepTransformation:Boolean = true, link:String):void
The addImage method takes an incoming DisplayObject.
PDF
  
addImageStream(imageBytes:ByteArray, x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0, alpha:Number = 1, resizeMode:String = None, blendMode:String = Normal, keepTransformation:Boolean = true, link:String, isMask:Boolean = false):void
The addImageStream method takes an incoming image as a ByteArray.
PDF
  
addLink(x:Number, y:Number, width:Number, height:Number, link:*, highlight:String = I):void
Lets you add clickable link to a specific position
PDF
  
addMultiCell(width:Number, height:Number, text:String, border:* = 0, align:String = J, filled:int = 0):void
Add a multicell with some text to the current page
PDF
  
addPage(page:Page = null):Page
Lets you add a page to the current PDF
PDF
  
addStampNote(style:String, x:Number, y:Number, width:Number, height:Number):void
Lets you add a stamp annotation to the current page
PDF
  
addText(text:String, x:Number = 0, y:Number = 0):void
Lets you set some text to any position on the page
PDF
  
addTextNote(x:Number, y:Number, width:Number, height:Number, text:String = A note !):void
Lets you add a text annotation to the current page
PDF
  
addTransition(style:String = R, duration:Number = 1, dimension:String = H, motionDirection:String = I, transitionDirection:int = 0):void
Lets you add a transition between each PDF page Note : PDF must be shown in fullscreen to see the transitions, use the setDisplayMode method with the PageMode.FULL_SCREEN parameter
PDF
  
addVerticalText(text:String, x:Number = 0, y:Number = 0):void
PDF
  
beginFill(color:Color):void
Sets the filling color for different color spaces CMYK/RGB/DEVICEGRAY
PDF
  
curveTo(controlX1:Number, controlY1:Number, controlX2:Number, controlY2:Number, finalX3:Number, finalY3:Number):void
The curveTo method draws a cubic bezier curve
PDF
  
dispatchEvent(event:Event):Boolean
PDF
  
drawCircle(x:Number, y:Number, radius:Number):void
The drawCircle method draws a circle
PDF
  
drawComplexRoundRect(rect:Rectangle, topLeftEllipseWidth:Number, bottomLeftEllipseWidth:Number, topRightEllipseWidth:Number, bottomRightEllipseWidth:Number):void
The drawComplexRoundRect method draws a rounded rectangle shape
PDF
  
drawEllipse(x:Number, y:Number, radiusX:Number, radiusY:Number):void
The drawEllipse method draws an ellipse
PDF
  
drawPolygone(points:Array):void
The drawPolygone method draws a polygone
PDF
  
drawRect(rect:Rectangle):void
The drawRect method draws a rectangle shape
PDF
  
drawRoundRect(rect:Rectangle, ellipseWidth:Number):void
The drawRoundedRect method draws a rounded rectangle shape
PDF
  
end():void
The end method closes the stroke
PDF
  
endFill():void
Ends all previous filling
PDF
  
footer():void
PDF
  
Lets you retrieve the current Page
PDF
  
Returns the default PDF orientation
PDF
  
Returns the default PDF Size
PDF
  
Returns the default PDF unit unit
PDF
  
getMargins():Rectangle
Lets you retrieve the margins dimensions
PDF
  
getPage(page:int):Page
Lets you retrieve a Page object
PDF
  
getPages():Array
Lets you retrieve all the PDF pages
PDF
  
getX():Number
Lets you retrieve the X position for the current page
PDF
  
getY():Number
Lets you retrieve the Y position for the current page
PDF
  
gotoPage(page:int):void
Lets you move to a Page in the PDF
PDF
  
hasEventListener(type:String):Boolean
PDF
  
header():void
PDF
  
lineStyle(color:Color, thickness:Number = 1, flatness:Number = 0, alpha:Number = 1, rule:String = NonZeroWinding, blendMode:String = Normal, style:DashedLine = null, caps:String = null, joints:String = null, miterLimit:Number = 3):void
Sets the stroke style
PDF
  
lineTo(x:Number, y:Number):void
Lets you draw a stroke from the current point to the new point
PDF
  
moveTo(x:Number, y:Number):void
Lets you move the current drawing point to the specified destination
PDF
  
newLine(height:*):void
Lets you insert a line break for text
PDF
  
Lets you remove all the pages from the PDF
PDF
  
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
PDF
  
removePage(page:int):Page
Lets you remove a Page from the PDF
PDF
  
rotate(angle:Number, x:Number = -1, y:Number = -1):void
PDF
  
rotatePage(number:int, rotation:Number):void
Lets you rotate a specific page (between 1 and n-1)
PDF
  
save(method:String, url:String, downloadMethod:String = inline, fileName:String = output.pdf, frame:String = _blank):*
PDF
  
setAliasNbPages(alias:String = {nb}):void
Lets you specify an alias for the total number of pages
PDF
  
setAlpha(alpha:Number, blendMode:String = Normal):void
Lets you specify the opacity for the next drawing operations, from 0 (100% transparent) to 1 (100% opaque)
PDF
  
setAuthor(author:String):void
Sets the specified author for the PDF
PDF
  
setAutoPageBreak(auto:Boolean, margin:Number):void
Lets you enable or disable auto page break mode and triggering margin
PDF
  
setBottomMargin(margin:Number):void
Lets you specify the bottom margin
PDF
  
setCreator(creator:String):void
Sets the specified creator for the PDF
PDF
  
setDisplayMode(zoomStyle:String = FullWidth, layout:String = SinglePage, mode:String = UseNone, zoomValue:Number = 1, rectangle:Rectangle = null):void
Lets you set a specific display mode, the DisplayMode takes care of the general layout of the PDF in the PDF reader
PDF
  
setFont(family:String, style:String, size:int = 0):void
Lets you set a specific font
PDF
  
setFontSize(size:int):void
Lets you set a new size for the current font
PDF
  
setKeywords(keywords:String):void
Sets the specified keywords for the PDF
PDF
  
setLeftMargin(margin:Number):void
Lets you specify the left margin
PDF
  
setMargins(left:Number, top:Number, right:Number = -1, bottom:Number = 20):void
Lets you specify the left, top, and right margins
PDF
  
setRightMargin(margin:Number):void
Lets you specify the right margin
PDF
  
setSubject(subject:String):void
Lets you set a subject for the PDF
PDF
  
setTitle(title:String):void
Lets you set a title for the PDF
PDF
  
setTopMargin(margin:Number):void
Lets you specify the top margin
PDF
  
setUnit(unit:String):String
PDF
  
setViewerPreferences(toolbar:String = false, menubar:String = false, windowUI:String = false, fitWindow:String = false, centeredWindow:String = false, displayTitle:String = false):void
Lets you control the way the document is to be presented on the screen or in print.
PDF
  
setX(x:Number):void
Lets you specify the X position for the current page
PDF
  
setXY(x:Number, y:Number):void
Lets you specify the X and Y position for the current page
PDF
  
setY(y:Number):void
Lets you specify the Y position for the current page
PDF
  
skew(ax:Number, ay:Number, x:Number = -1, y:Number = -1):void
PDF
  
PDF
  
PDF
  
textStyle(color:Color, alpha:Number = 1, rendering:int = 0, wordSpace:Number = 0, characterSpace:Number = 0, scale:Number = 100, leading:Number = 0):void
Sets the text style
PDF
  
toString():String
PDF
  
willTrigger(type:String):Boolean
PDF
  
writeFlashHtmlText(pHeight:Number, pText:String, pLink:String):void
Lets you write some text with basic HTML type formatting
PDF
  
writeText(lineHeight:Number, text:String, link:String):void
Lets you write some text
PDF
Protected Methods
 MethodDefined By
  
acceptPageBreak():Boolean
PDF
  
addExtGState(graphicState:Object):int
PDF
  
close():void
PDF
  
PDF
  
PDF
  
PDF
  
PDF
  
curve(x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number):void
PDF
  
doUnderline(x:Number, y:Number, content:String):String
PDF
  
escape(content:String):String
PDF
  
escapeString(content:String):String
PDF
  
findAndReplace(search:String, replace:String, source:String):String
PDF
  
finish():void
PDF
  
PDF
  
finishPage():void
PDF
  
getChannels(color:Number):String
PDF
  
PDF
  
getFontStyleString(bold:Boolean, italic:Boolean, underline:Boolean):String
PDF
  
getNumImages(object:Object):int
PDF
  
getStringWidth(content:String):Number
PDF
  
PDF
  
PDF
  
PDF
  
PDF
  
PDF
  
lineBreak(pHeight:Number):void
PDF
  
newObj():void
PDF
  
open():void
PDF
  
parseTags(myXML:XML):Array
PDF
  
renderLine(lineArray:Array, align:String):void
PDF
  
setAutoPagination(activate:Boolean):void
Lets you activate the auto pagination mode
PDF
  
setExtGState(graphicState:int):void
PDF
  
startPage(newOrientation:String):Page
PDF
  
strokeColor(color:Color):void
Sets the stroke color for different color spaces CMYK, RGB and DEVICEGRAY
PDF
  
substrCount(content:String, search:String):int
PDF
  
textColor(color:Color):void
Sets the text color for different color spaces CMYK, RGB, and DEVICEGRAY
PDF
  
write(content:*):void
PDF
  
PDF
  
PDF
  
writeStream(stream:String):void
PDF
  
PDF
Events
 Event Summary Defined By
  Dispatched when a page has been added to the PDF.PDF
  Dispatched when PDF has been generated and available.PDF
  Dispatched when the PDF page tree has been generated.PDF
  Dispatched when the required resources (fonts, images, etc.) haven been written into the PDF.PDF
  Dispatched when the PDF generation has been initiated.PDF
Protected Constants
 ConstantDefined By
  ALIVEPDF_VERSION : String = 0.1.4.8
[static]
PDF
  PDF_VERSION : String = 1.3
[static]
PDF
Property Detail
addTextColorproperty
protected var addTextColor:String

aliasNbPagesproperty 
protected var aliasNbPages:String

angleproperty 
protected var angle:Number

arrayNotesproperty 
protected var arrayNotes:Array

arrayPagesproperty 
protected var arrayPages:Array

autoPageBreakproperty 
protected var autoPageBreak:Boolean

autoPaginationproperty 
protected var autoPagination:Boolean

b2property 
protected var b2:String

bMarginproperty 
protected var bMargin:Number

bufferproperty 
protected var buffer:ByteArray

cMarginproperty 
protected var cMargin:Number

colorFlagproperty 
protected var colorFlag:Boolean

columnNamesproperty 
protected var columnNames:Array

columnsproperty 
protected var columns:Array

compressproperty 
protected var compress:Boolean

compressedPagesproperty 
protected var compressedPages:ByteArray

currentFontproperty 
protected var currentFont:Object

currentGridproperty 
protected var currentGrid:Grid

currentOrientationproperty 
protected var currentOrientation:String

currentPageproperty 
protected var currentPage:Page

currentXproperty 
protected var currentX:Number

currentYproperty 
protected var currentY:Number

cwproperty 
protected var cw:Object

dproperty 
protected var d:Number

defaultOrientationproperty 
protected var defaultOrientation:String

defaultRotationproperty 
protected var defaultRotation:int

defaultSizeproperty 
protected var defaultSize:Size

defaultUnitproperty 
protected var defaultUnit:String

descproperty 
protected var desc:String

diffproperty 
protected var diff:Number

diffsproperty 
protected var diffs:Array

dispatcherproperty 
protected var dispatcher:EventDispatcher

documentAuthorproperty 
protected var documentAuthor:String

documentCreatorproperty 
protected var documentCreator:String

documentKeywordsproperty 
protected var documentKeywords:String

documentSubjectproperty 
protected var documentSubject:String

documentTitleproperty 
protected var documentTitle:String

drawingRuleproperty 
protected var drawingRule:String

encproperty 
protected var enc:Number

encryptRefproperty 
protected var encryptRef:int

extgstatesproperty 
protected var extgstates:Array

fileproperty 
protected var file:String

fillColorproperty 
protected var fillColor:String

filledproperty 
protected var filled:Boolean

filterproperty 
protected var filter:String

fontFamilyproperty 
protected var fontFamily:String

fontFilesproperty 
protected var fontFiles:Array

fontkeyproperty 
protected var fontkey:String

fontsproperty 
protected var fonts:Object

fontSizeproperty 
protected var fontSize:Number

fontSizePtproperty 
protected var fontSizePt:Number

fontStyleproperty 
protected var fontStyle:String

imageproperty 
protected var image:PDFImage

inFooterproperty 
protected var inFooter:Boolean

inHeaderproperty 
protected var inHeader:Boolean

initedproperty 
protected var inited:Boolean

isCompressedproperty 
isCompressed:Boolean

Lets you activate zlib compression for the current PDF


Implementation
    public function get isCompressed():Boolean
    public function set isCompressed(value:Boolean):void

Example
This example shows how to activate zlib compression :
isEvenproperty 
protected var isEven:int

kproperty 
protected var k:Number

lasthproperty 
protected var lasth:Number

layoutModeproperty 
protected var layoutMode:String

lineWidthproperty 
protected var lineWidth:Number

linksproperty 
protected var links:Array

lMarginproperty 
protected var lMargin:Number

matrixproperty 
protected var matrix:Matrix

nproperty 
protected var n:int

nameproperty 
protected var name:String

nbproperty 
protected var nb:int

nbPagesproperty 
protected var nbPages:int

offsetsproperty 
protected var offsets:Array

orientationChangesproperty 
protected var orientationChanges:Array

originalsizeproperty 
protected var originalsize:Number

outlineRootproperty 
protected var outlineRoot:int

outlinesproperty 
protected var outlines:Array

pageBreakTriggerproperty 
protected var pageBreakTrigger:Number

pageLinksproperty 
protected var pageLinks:Array

pageModeproperty 
protected var pageMode:String

pdfVersionproperty 
protected var pdfVersion:String

referenceproperty 
protected var reference:String

referencesproperty 
protected var references:String

rMarginproperty 
protected var rMargin:Number

rotationMatrixproperty 
protected var rotationMatrix:Matrix

size1property 
protected var size1:Number

size2property 
protected var size2:Number

standardFontsproperty 
protected var standardFonts:Object

stateproperty 
protected var state:int

streamDictionaryproperty 
protected var streamDictionary:Dictionary

strokeStyleproperty 
protected var strokeStyle:String

textRenderingproperty 
protected var textRendering:int

tMarginproperty 
protected var tMargin:Number

totalPagesproperty 
totalPages:int  [read-only]

Lets you retrieve the number of pages in the PDF document


Implementation
    public function get totalPages():int

Example
This example shows how to retrieve the number of pages :
typeproperty 
protected var type:String

underlineproperty 
protected var underline:Boolean

upproperty 
protected var up:Number

utproperty 
protected var ut:Number

viewerPreferencesproperty 
protected var viewerPreferences:String

windingRuleproperty 
protected var windingRule:String

wsproperty 
protected var ws:Number

zoomFactorproperty 
protected var zoomFactor:Number

zoomModeproperty 
protected var zoomMode:*

zoomRectangleproperty 
protected var zoomRectangle:Rectangle

Constructor Detail
PDF()Constructor
public function PDF(orientation:String = Portrait, unit:String = Mm, pageSize:Object = null, rotation:int = 0)

The PDF class represents a PDF document.

Parameters
orientation:String (default = Portrait)
 
unit:String (default = Mm)
 
pageSize:Object (default = null)
 
rotation:int (default = 0)

Example
This example shows how to create a valid PDF document :
Method Detail
acceptPageBreak()method
protected function acceptPageBreak():Boolean

Returns
Boolean
addBookmark()method 
public function addBookmark(text:String, level:int, y:Number, color:RGBColor):void

Lets you add a bookmark

Parameters

text:String — Text appearing in the outline panel
 
level:int — Specify the bookmark's level
 
y:Number — Position in the current page to go
 
color:RGBColor — Red offset for the text color


Example
This example shows how to add a bookmark for the current page :
addCell()method 
public function addCell(width:Number = 0, height:Number = 0, text:String, border:* = 0, ln:Number = 0, align:String, fill:Number = 0, link:String):void

Add a cell with some text to the current page

Parameters

width:Number (default = 0) — Cell width
 
height:Number (default = 0) — Cell height
 
text:String — Text to add into the cell
 
border:* (default = 0) — Sets the new position after cell is drawn, default value is 0
 
ln:Number (default = 0) — Lets you center or align the text into the cell
 
align:String — Lets you specify if the cell is colored (1) or transparent (0)
 
fill:Number (default = 0) — Any http link, like http://www.mylink.com
 
link:String


Example
This example shows how to write some text within a cell : This example shows how to write some clikable text within a cell :
addEventListener()method 
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

Parameters

type:String
 
listener:Function
 
useCapture:Boolean (default = false)
 
priority:int (default = 0)
 
useWeakReference:Boolean (default = false)

addExtGState()method 
protected function addExtGState(graphicState:Object):int

Parameters

graphicState:Object

Returns
int
addGrid()method 
public function addGrid(grid:Grid, x:Number = 0, y:Number = 0, repeatHeader:Boolean = true):void

Parameters

grid:Grid
 
x:Number (default = 0)
 
y:Number (default = 0)
 
repeatHeader:Boolean (default = true)

addImage()method 
public function addImage(displayObject:DisplayObject, x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0, imageFormat:String = PNG, quality:Number = 100, alpha:Number = 1, resizeMode:String = None, blendMode:String = Normal, keepTransformation:Boolean = true, link:String):void

The addImage method takes an incoming DisplayObject. A JPG or PNG snapshot is done and included in the PDF document

Parameters

displayObject:DisplayObject
 
x:Number (default = 0)
 
y:Number (default = 0)
 
width:Number (default = 0)
 
height:Number (default = 0)
 
imageFormat:String (default = PNG)
 
quality:Number (default = 100)
 
alpha:Number (default = 1)
 
resizeMode:String (default = None)
 
blendMode:String (default = Normal)
 
keepTransformation:Boolean (default = true)
 
link:String


Example
This example shows how to add a 100% compression quality JPG image into the current page at a position of 0,0 with no resizing behavior :
addImageStream()method 
public function addImageStream(imageBytes:ByteArray, x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0, alpha:Number = 1, resizeMode:String = None, blendMode:String = Normal, keepTransformation:Boolean = true, link:String, isMask:Boolean = false):void

The addImageStream method takes an incoming image as a ByteArray. This method can be used to embed high-quality images (300 dpi) to the PDF

Parameters

imageBytes:ByteArray
 
x:Number (default = 0)
 
y:Number (default = 0)
 
width:Number (default = 0)
 
height:Number (default = 0)
 
alpha:Number (default = 1)
 
resizeMode:String (default = None)
 
blendMode:String (default = Normal)
 
keepTransformation:Boolean (default = true)
 
link:String
 
isMask:Boolean (default = false)


Example
This example shows how to add an image as a ByteArray into the current page with a page resize behavior :
addLink()method 
public function addLink(x:Number, y:Number, width:Number, height:Number, link:*, highlight:String = I):void

Lets you add clickable link to a specific position

Parameters

x:Number — Page Format, can be Size.A3, Size.A4, Size.A5, Size.LETTER or Size.LEGAL
 
y:Number
 
width:Number
 
height:Number
 
link:*
 
highlight:String (default = I)


Example
This example shows how to add an invisible clickable link in the current page :
addMultiCell()method 
public function addMultiCell(width:Number, height:Number, text:String, border:* = 0, align:String = J, filled:int = 0):void

Add a multicell with some text to the current page

Parameters

width:Number — Cell width
 
height:Number — Cell height
 
text:String — Text to add into the cell
 
border:* (default = 0) — Lets you specify if a border should be drawn around the cell
 
align:String (default = J) — Lets you center or align the text into the cell, values can be L (left align), C (centered), R (right align), J (justified) default value
 
filled:int (default = 0) — Lets you specify if the cell is colored (1) or transparent (0)


Example
This example shows how to write a table made of text cells :
addPage()method 
public function addPage(page:Page = null):Page

Lets you add a page to the current PDF

Parameters

page:Page (default = null)

Returns
Page

Example
This example shows how to add an A4 page with a landscape orientation : This example shows how to add a page with a custom size :
addStampNote()method 
public function addStampNote(style:String, x:Number, y:Number, width:Number, height:Number):void

Lets you add a stamp annotation to the current page

Parameters

style:String — Stamp style can be StampStyle.CONFIDENTIAL, StampStyle.FOR_PUBLIC_RELEASE, etc.
 
x:Number — Note X position
 
y:Number — Note Y position
 
width:Number — Note width
 
height:Number — Note height


Example
This example shows how to add a stamp annotation in the current page :
addText()method 
public function addText(text:String, x:Number = 0, y:Number = 0):void

Lets you set some text to any position on the page

Parameters

text:String — The text to add
 
x:Number (default = 0) — X position
 
y:Number (default = 0) — Y position


Example
This example shows how to set some text to a specific place :
addTextNote()method 
public function addTextNote(x:Number, y:Number, width:Number, height:Number, text:String = A note !):void

Lets you add a text annotation to the current page

Parameters

x:Number — Note X position
 
y:Number — Note Y position
 
width:Number — Note width
 
height:Number — Note height
 
text:String (default = A note !) — Text for the note


Example
This example shows how to add a note annotation in the current page :
addTransition()method 
public function addTransition(style:String = R, duration:Number = 1, dimension:String = H, motionDirection:String = I, transitionDirection:int = 0):void

Lets you add a transition between each PDF page Note : PDF must be shown in fullscreen to see the transitions, use the setDisplayMode method with the PageMode.FULL_SCREEN parameter

Parameters

style:String (default = R) — Transition style, can be Transition.SPLIT, Transition.BLINDS, BLINDS.BOX, Transition.WIPE, etc.
 
duration:Number (default = 1) — The transition duration
 
dimension:String (default = H) — The dimension in which the the specified transition effect occurs
 
motionDirection:String (default = I) — The motion's direction for the specified transition effect
 
transitionDirection:int (default = 0) — The direction in which the specified transition effect moves


Example
This example shows how to add a 4 seconds "Wipe" transition between the first and second page :
addVerticalText()method 
public function addVerticalText(text:String, x:Number = 0, y:Number = 0):void

Parameters

text:String
 
x:Number (default = 0)
 
y:Number (default = 0)

beginFill()method 
public function beginFill(color:Color):void

Sets the filling color for different color spaces CMYK/RGB/DEVICEGRAY

Parameters

color:Color — Color object, can be CMYKColor, GrayColor, or RGBColor


Example
This example shows how to create a red rectangle in the current page :
close()method 
protected function close():void

createCatalog()method 
protected function createCatalog():void

createHeader()method 
protected function createHeader():void

createPageTree()method 
protected function createPageTree():void

createTrailer()method 
protected function createTrailer():void

curve()method 
protected function curve(x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number):void

Parameters

x1:Number
 
y1:Number
 
x2:Number
 
y2:Number
 
x3:Number
 
y3:Number

curveTo()method 
public function curveTo(controlX1:Number, controlY1:Number, controlX2:Number, controlY2:Number, finalX3:Number, finalY3:Number):void

The curveTo method draws a cubic bezier curve

Parameters

controlX1:Number
 
controlY1:Number
 
controlX2:Number
 
controlY2:Number
 
finalX3:Number
 
finalY3:Number


Example
This example shows how to draw some curves lines in the current page : Important : Always call the end() method when you're done
dispatchEvent()method 
public function dispatchEvent(event:Event):Boolean

Parameters

event:Event

Returns
Boolean
doUnderline()method 
protected function doUnderline(x:Number, y:Number, content:String):String

Parameters

x:Number
 
y:Number
 
content:String

Returns
String
drawCircle()method 
public function drawCircle(x:Number, y:Number, radius:Number):void

The drawCircle method draws a circle

Parameters

x:Number — X Position
 
y:Number — Y Position
 
radius:Number — Circle Radius


Example
This example shows how to create a rounded red ellipse in the current page :
drawComplexRoundRect()method 
public function drawComplexRoundRect(rect:Rectangle, topLeftEllipseWidth:Number, bottomLeftEllipseWidth:Number, topRightEllipseWidth:Number, bottomRightEllipseWidth:Number):void

The drawComplexRoundRect method draws a rounded rectangle shape

Parameters

rect:Rectangle — A flash.geom.Rectange object
 
topLeftEllipseWidth:Number — Angle radius
 
bottomLeftEllipseWidth:Number — Angle radius
 
topRightEllipseWidth:Number — Angle radius
 
bottomRightEllipseWidth:Number — Angle radius


Example
This example shows how to create a complex rounded green rectangle (different angles radius) in the current page :
drawEllipse()method 
public function drawEllipse(x:Number, y:Number, radiusX:Number, radiusY:Number):void

The drawEllipse method draws an ellipse

Parameters

x:Number — X Position
 
y:Number — Y Position
 
radiusX:Number — X Radius
 
radiusY:Number — Y Radius


Example
This example shows how to create a rounded red ellipse in the current page :
drawPolygone()method 
public function drawPolygone(points:Array):void

The drawPolygone method draws a polygone

Parameters

points:Array — Array of points


Example
This example shows how to create a polygone with a few points :
drawRect()method 
public function drawRect(rect:Rectangle):void

The drawRect method draws a rectangle shape

Parameters

rect:Rectangle — A flash.geom.Rectange object


Example
This example shows how to create a blue rectangle in the current page :
drawRoundRect()method 
public function drawRoundRect(rect:Rectangle, ellipseWidth:Number):void

The drawRoundedRect method draws a rounded rectangle shape

Parameters

rect:Rectangle — A flash.geom.Rectange object
 
ellipseWidth:Number — Angle radius


Example
This example shows how to create a rounded green rectangle in the current page :
end()method 
public function end():void

The end method closes the stroke


Example
This example shows how to draw some dashed lines in the current page with specific caps style and joint style : Important : Always call the end() method when you're done
endFill()method 
public function endFill():void

Ends all previous filling


Example
This example shows how to create a red rectangle in the current page :
escape()method 
protected function escape(content:String):String

Parameters

content:String

Returns
String
escapeString()method 
protected function escapeString(content:String):String

Parameters

content:String

Returns
String
findAndReplace()method 
protected function findAndReplace(search:String, replace:String, source:String):String

Parameters

search:String
 
replace:String
 
source:String

Returns
String
finish()method 
protected function finish():void

finishDocument()method 
protected function finishDocument():void

finishPage()method 
protected function finishPage():void

footer()method 
public function footer():void

getChannels()method 
protected function getChannels(color:Number):String

Parameters

color:Number

Returns
String
getCurrentDate()method 
protected function getCurrentDate():String

Returns
String
getCurrentPage()method 
public function getCurrentPage():Page

Lets you retrieve the current Page

Returns
Page — Page A Page object

Example
This example shows how to retrieve the current page :
getDefaultOrientation()method 
public function getDefaultOrientation():String

Returns the default PDF orientation

Returns
String — String
getDefaultSize()method 
public function getDefaultSize():Size

Returns the default PDF Size

Returns
Size — Size
getDefaultUnit()method 
public function getDefaultUnit():String

Returns the default PDF unit unit

Returns
String — String
getFontStyleString()method 
protected function getFontStyleString(bold:Boolean, italic:Boolean, underline:Boolean):String

Parameters

bold:Boolean
 
italic:Boolean
 
underline:Boolean

Returns
String
getMargins()method 
public function getMargins():Rectangle

Lets you retrieve the margins dimensions

Returns
Rectangle — Rectangle

Example
This example shows how to get the margins dimensions :
getNumImages()method 
protected function getNumImages(object:Object):int

Parameters

object:Object

Returns
int
getPage()method 
public function getPage(page:int):Page

Lets you retrieve a Page object

Parameters

page:int — page number, from 1 to total numbers of pages

Returns
Page — Page

Example
This example shows how to retrieve the first page :
getPages()method 
public function getPages():Array

Lets you retrieve all the PDF pages

Returns
Array — Array

Example
This example shows how to retrieve all the PDF pages :
getStringWidth()method 
protected function getStringWidth(content:String):Number

Parameters

content:String

Returns
Number
getX()method 
public function getX():Number

Lets you retrieve the X position for the current page

Returns
Number — Number the X position
getY()method 
public function getY():Number

Lets you retrieve the Y position for the current page

Returns
Number — Number the Y position
gotoPage()method 
public function gotoPage(page:int):void

Lets you move to a Page in the PDF

Parameters

page:int — page number, from 1 to total numbers of pages


Example
This example shows how to move to the first page :
hasEventListener()method 
public function hasEventListener(type:String):Boolean

Parameters

type:String

Returns
Boolean
header()method 
public function header():void

insertBookmarks()method 
protected function insertBookmarks():void

insertExtGState()method 
protected function insertExtGState():void

insertFonts()method 
protected function insertFonts():void

insertImages()method 
protected function insertImages():void

insertInfos()method 
protected function insertInfos():void

lineBreak()method 
protected function lineBreak(pHeight:Number):void

Parameters

pHeight:Number

lineStyle()method 
public function lineStyle(color:Color, thickness:Number = 1, flatness:Number = 0, alpha:Number = 1, rule:String = NonZeroWinding, blendMode:String = Normal, style:DashedLine = null, caps:String = null, joints:String = null, miterLimit:Number = 3):void

Sets the stroke style

Parameters

color:Color
 
thickness:Number (default = 1)
 
flatness:Number (default = 0)
 
alpha:Number (default = 1)
 
rule:String (default = NonZeroWinding)
 
blendMode:String (default = Normal)
 
style:DashedLine (default = null)
 
caps:String (default = null)
 
joints:String (default = null)
 
miterLimit:Number (default = 3)


Example
This example shows how to draw a star with an "even odd" rule : This example shows how to draw a star with an "non-zero" winding rule :
lineTo()method 
public function lineTo(x:Number, y:Number):void

Lets you draw a stroke from the current point to the new point

Parameters

x:Number — X position
 
y:Number — Y position


Example
This example shows how to draw some dashed lines in the current page with specific caps style and joint style : Important : Always call the end() method when you're done
moveTo()method 
public function moveTo(x:Number, y:Number):void

Lets you move the current drawing point to the specified destination

Parameters

x:Number — X position
 
y:Number — Y position


Example
This example shows how to move the pen to 120,200 :
newLine()method 
public function newLine(height:*):void

Lets you insert a line break for text

Parameters

height:* — Line break height


Example
This example shows how to add a line break :
newObj()method 
protected function newObj():void

open()method 
protected function open():void

parseTags()method 
protected function parseTags(myXML:XML):Array

Parameters

myXML:XML

Returns
Array
removeAllPages()method 
public function removeAllPages():void

Lets you remove all the pages from the PDF


Example
This example shows how to remove all the pages :
removeEventListener()method 
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void

Parameters

type:String
 
listener:Function
 
useCapture:Boolean (default = false)

removePage()method 
public function removePage(page:int):Page

Lets you remove a Page from the PDF

Parameters

page:int — page number, from 1 to total numbers of pages

Returns
Page — Page

Example
This example shows how to remove the first page :
renderLine()method 
protected function renderLine(lineArray:Array, align:String):void

Parameters

lineArray:Array
 
align:String

rotate()method 
public function rotate(angle:Number, x:Number = -1, y:Number = -1):void

Parameters

angle:Number
 
x:Number (default = -1)
 
y:Number (default = -1)

rotatePage()method 
public function rotatePage(number:int, rotation:Number):void

Lets you rotate a specific page (between 1 and n-1)

Parameters

number:int — Page number
 
rotation:Number — Page rotation (must be a multiple of 90)


Throws
RangeError

Example
This example shows how to rotate the first page 90 clock wise : This example shows how to rotate the first page 90 counter clock wise :
save()method 
public function save(method:String, url:String, downloadMethod:String = inline, fileName:String = output.pdf, frame:String = _blank):*

Parameters

method:String — Can be se to Method.LOCAL, the savePDF will return the PDF ByteArray. When Method.REMOTE is passed, just specify the path to the create.php file
 
url:String — The url of the create.php file
 
downloadMethod:String (default = inline) — Lets you specify the way the PDF is going to be available. Use Download.INLINE if you want the PDF to be opened in the browser, use Download.ATTACHMENT if you want to make it available with a save-as dialog box
 
fileName:String (default = output.pdf) — The name of the PDF, only available when Method.REMOTE is used
 
frame:String (default = _blank)

Returns
* — The ByteArray PDF when Method.LOCAL is used, otherwise the method returns null

Example
This example shows how to save the PDF on the desktop with the AIR runtime : This example shows how to save the PDF through a download dialog-box with Flash or Flex : This example shows how to view the PDF in the browser with Flash or Flex :
setAliasNbPages()method 
public function setAliasNbPages(alias:String = {nb}):void

Lets you specify an alias for the total number of pages

Parameters

alias:String (default = {nb}) — Alias to use


Example
This example shows how to show the total number of pages :
setAlpha()method 
public function setAlpha(alpha:Number, blendMode:String = Normal):void

Lets you specify the opacity for the next drawing operations, from 0 (100% transparent) to 1 (100% opaque)

Parameters

alpha:Number — Opacity
 
blendMode:String (default = Normal) — Blend mode, can be Blend.DIFFERENCE, BLEND.HARDLIGHT, etc.


Example
This example shows how to set the transparency to 50% for any following drawing, image or text operation :
setAuthor()method 
public function setAuthor(author:String):void

Sets the specified author for the PDF

Parameters

author:String — The author


Example
This example shows how to add a specific author to the PDF tags :
setAutoPageBreak()method 
public function setAutoPageBreak(auto:Boolean, margin:Number):void

Lets you enable or disable auto page break mode and triggering margin

Parameters

auto:Boolean — Page break mode
 
margin:Number — Bottom margin

setAutoPagination()method 
protected function setAutoPagination(activate:Boolean):void

Lets you activate the auto pagination mode

Parameters

activate:Boolean — Activate the auto pagination mode


Example
This example shows how to activate the auto pagination mode :
setBottomMargin()method 
public function setBottomMargin(margin:Number):void

Lets you specify the bottom margin

Parameters

margin:Number — Bottom margin


Example
This example shows how set bottom margin for the PDF document :
setCreator()method 
public function setCreator(creator:String):void

Sets the specified creator for the PDF

Parameters

creator:String — Name of the PDF creator


Example
This example shows how to set a creator name to the PDF tags :
setDisplayMode()method 
public function setDisplayMode(zoomStyle:String = FullWidth, layout:String = SinglePage, mode:String = UseNone, zoomValue:Number = 1, rectangle:Rectangle = null):void

Lets you set a specific display mode, the DisplayMode takes care of the general layout of the PDF in the PDF reader

Parameters

zoomStyle:String (default = FullWidth) — Zoom mode, can be Display.FULL_PAGE, Display.FULL_WIDTH, Display.REAL, Display.DEFAULT
 
layout:String (default = SinglePage) — Layout of the PDF document, can be Layout.SINGLE_PAGE, Layout.ONE_COLUMN, Layout.TWO_COLUMN_LEFT, Layout.TWO_COLUMN_RIGHT
 
mode:String (default = UseNone) — PageMode can be pageMode.USE_NONE, PageMode.USE_OUTLINES, PageMode.USE_THUMBS, PageMode.FULL_SCREEN
 
zoomValue:Number (default = 1)
 
rectangle:Rectangle (default = null)


Example
This example creates a PDF which opens at full page scaling, one page at a time : To create a full screen PDF you would write :
setExtGState()method 
protected function setExtGState(graphicState:int):void

Parameters

graphicState:int

setFont()method 
public function setFont(family:String, style:String, size:int = 0):void

Lets you set a specific font

Parameters

family:String — Font family, can be any of FontFamily.COURIER, FontFamily.HELVETICA, FontFamily.ARIAL, FontFamily.TIMES, FontFamily.SYMBOL, FontFamily.ZAPFDINGBATS.
 
style:String — Any font style, can be Style.BOLD, Style.ITALIC, Style.BOLD_ITALIC, Style.NORMAL
 
size:int (default = 0)


Example
This example shows how to set the Helvetica font, with a bold style :
setFontSize()method 
public function setFontSize(size:int):void

Lets you set a new size for the current font

Parameters

size:int — Font size


Example
This example shows how to se the current font to 18 :
setKeywords()method 
public function setKeywords(keywords:String):void

Sets the specified keywords for the PDF

Parameters

keywords:String — The keywords


Example
This example shows how to add some keywords to the PDF tags :
setLeftMargin()method 
public function setLeftMargin(margin:Number):void

Lets you specify the left margin

Parameters

margin:Number — Left margin


Example
This example shows how set left margin for the PDF document :
setMargins()method 
public function setMargins(left:Number, top:Number, right:Number = -1, bottom:Number = 20):void

Lets you specify the left, top, and right margins

Parameters

left:Number — Left margin
 
top:Number — Right number
 
right:Number (default = -1) — Top number
 
bottom:Number (default = 20) — Bottom number


Example
This example shows how to set margins for the PDF document :
setRightMargin()method 
public function setRightMargin(margin:Number):void

Lets you specify the right margin

Parameters

margin:Number — Right margin


Example
This example shows how set right margin for the PDF document :
setSubject()method 
public function setSubject(subject:String):void

Lets you set a subject for the PDF

Parameters

subject:String — The subject


Example
This example shows how to set a specific subject to the PDF tags :
setTitle()method 
public function setTitle(title:String):void

Lets you set a title for the PDF

Parameters

title:String — The title


Example
This example shows how to set a specific title to the PDF tags :
setTopMargin()method 
public function setTopMargin(margin:Number):void

Lets you specify the top margin

Parameters

margin:Number — Top margin


Example
This example shows how set top margin for the PDF document :
setUnit()method 
public function setUnit(unit:String):String

Parameters

unit:String

Returns
String
setViewerPreferences()method 
public function setViewerPreferences(toolbar:String = false, menubar:String = false, windowUI:String = false, fitWindow:String = false, centeredWindow:String = false, displayTitle:String = false):void

Lets you control the way the document is to be presented on the screen or in print.

Parameters

toolbar:String (default = false) — Toolbar behavior
 
menubar:String (default = false) — Menubar behavior
 
windowUI:String (default = false) — WindowUI behavior
 
fitWindow:String (default = false) — Specify whether to resize the document's window to fit the size of the first displayed page.
 
centeredWindow:String (default = false) — Specify whether to position the document's window in the center of the screen.
 
displayTitle:String (default = false) — Specify whether the window's title bar should display the document title taken from the value passed to the setTitle method


Example
This example shows how to present the document centered on the screen with no toolbars :
setX()method 
public function setX(x:Number):void

Lets you specify the X position for the current page

Parameters

x:Number — The X position

setXY()method 
public function setXY(x:Number, y:Number):void

Lets you specify the X and Y position for the current page

Parameters

x:Number — The X position
 
y:Number — The Y position

setY()method 
public function setY(y:Number):void

Lets you specify the Y position for the current page

Parameters

y:Number — The Y position

skew()method 
public function skew(ax:Number, ay:Number, x:Number = -1, y:Number = -1):void

Parameters

ax:Number
 
ay:Number
 
x:Number (default = -1)
 
y:Number (default = -1)

startPage()method 
protected function startPage(newOrientation:String):Page

Parameters

newOrientation:String

Returns
Page
startTransform()method 
public function startTransform():void

stopTransform()method 
public function stopTransform():void

strokeColor()method 
protected function strokeColor(color:Color):void

Sets the stroke color for different color spaces CMYK, RGB and DEVICEGRAY

Parameters

color:Color

substrCount()method 
protected function substrCount(content:String, search:String):int

Parameters

content:String
 
search:String

Returns
int
textColor()method 
protected function textColor(color:Color):void

Sets the text color for different color spaces CMYK, RGB, and DEVICEGRAY

Parameters

color:Color

textStyle()method 
public function textStyle(color:Color, alpha:Number = 1, rendering:int = 0, wordSpace:Number = 0, characterSpace:Number = 0, scale:Number = 100, leading:Number = 0):void

Sets the text style

Parameters

color:Color — Color object, can be CMYKColor, GrayColor, or RGBColor
 
alpha:Number (default = 1) — Text opacity
 
rendering:int (default = 0) — pRendering Specify the text rendering mode
 
wordSpace:Number (default = 0) — Spaces between each words
 
characterSpace:Number (default = 0) — Spaces between each characters
 
scale:Number (default = 100) — Text scaling
 
leading:Number (default = 0) — Text leading


Example
This example shows how to set a specific black text style with full opacity :
toString()method 
public function toString():String

Returns
String
willTrigger()method 
public function willTrigger(type:String):Boolean

Parameters

type:String

Returns
Boolean
write()method 
protected function write(content:*):void

Parameters

content:*

writeFlashHtmlText()method 
public function writeFlashHtmlText(pHeight:Number, pText:String, pLink:String):void

Lets you write some text with basic HTML type formatting

Parameters

pHeight:Number — Line height, lets you specify height between each lines
 
pText:String — Text to write, to put a line break just add a \n in the text string
 
pLink:String — Any link, like http://www.mylink.com, will open te browser when clicked


Example
Only a limited subset of tags are currently supported used to create a new line This example shows how to add some basic HTML text to the current page :
writeResources()method 
protected function writeResources():void

writeResourcesDictionary()method 
protected function writeResourcesDictionary():void

writeStream()method 
protected function writeStream(stream:String):void

Parameters

stream:String

writeText()method 
public function writeText(lineHeight:Number, text:String, link:String):void

Lets you write some text

Parameters

lineHeight:Number — Line height, lets you specify height between each lines
 
text:String — Text to write, to put a line break just add a \n in the text string
 
link:String — Any link, like http://www.mylink.com, will open te browser when clicked


Example
This example shows how to add some text to the current page : This example shows how to add some text with a clickable link :
writeXObjectDictionary()method 
protected function writeXObjectDictionary():void

Event Detail
added Event
Event Object Type: org.alivepdf.events.PageEvent
PageEvent.type property = org.alivepdf.events.PageEvent.ADDED

Dispatched when a page has been added to the PDF. The addPage() method generate this event

complete Event  
Event Object Type: org.alivepdf.events.ProcessingEvent
ProcessingEvent.type property = org.alivepdf.events.ProcessingEvent.COMPLETE

Dispatched when PDF has been generated and available. The save() method generate this event

pageTree Event  
Event Object Type: org.alivepdf.events.ProcessingEvent
ProcessingEvent.type property = org.alivepdf.events.ProcessingEvent.PAGE_TREE

Dispatched when the PDF page tree has been generated. The save() method generate this event

resources Event  
Event Object Type: org.alivepdf.events.ProcessingEvent
ProcessingEvent.type property = org.alivepdf.events.ProcessingEvent.RESOURCES

Dispatched when the required resources (fonts, images, etc.) haven been written into the PDF. The save() method generate this event

started Event  
Event Object Type: org.alivepdf.events.ProcessingEvent
ProcessingEvent.type property = org.alivepdf.events.ProcessingEvent.STARTED

Dispatched when the PDF generation has been initiated. The save() method generate this event

Constant Detail
ALIVEPDF_VERSIONConstant
protected static const ALIVEPDF_VERSION:String = 0.1.4.8

PDF_VERSIONConstant 
protected static const PDF_VERSION:String = 1.3