Packageorg.alivepdf.pdf
Classpublic final class PDF
Implementsflash.events.IEventDispatcher

The PDF class represents a PDF document.



Public Methods
 MethodDefined by
  
PDF(pOrientation:String = "Portrait", pUnit:String = "Mm", pageSize:Object = null)
The PDF class represents a PDF document.
PDF
  
addBookmark(pText:String, pLevel:int = 0, pY:Number = 0, pRed:Number = 0, pGreen:Number = 0, pBlue:Number = 0):void
Lets you add a bookmark
PDF
  
addCell(pWidth:Number = 0, pHeight:Number = 0, pText:String = "", pBorder:Number = 0, pLn:String = "0", pAlign:Number, pFill:String = "0", pLink:*):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
  
addImage(pDisplayObject:DisplayObject, pAlpha:Number = 1, pBlend:String = "Normal", pMatrix:Matrix = null, pResizePage:Boolean = false, pEncoding:String = "JPG", pQuality:Number = 100, pX:Number = 0, pY:Number = 0, pWidth:Number = 0, pHeight:Number = 0, pLink:String = ""):void
The addImage method takes an incoming DisplayObject object, take a snapshot from it in JPG and add it to the PDF document
PDF
  
addLink(pX:Number, pY:Number, pWidth:Number, pHeight:Number, pLink:String, pHighlight:* = I):void
Lets you add clickable link at a specific position
PDF
  
addMultiCell(pWidth:Number, pHeight:Number, pText:String, pBorder:String = "0", pAlign:int = J, pFill:* = 0):void
Add a multicell with some text to the current page
PDF
  
addPage(pOrientation:String = "", pUnit:String = "Mm", pSize:Object = null, pRotation:Number = 0):void
Lets you add a page to the current PDF
PDF
  
addText(pTxt:String, pX:Number = 0, pY:Number = 0):void
Lets you set some text to any position on the page
PDF
  
addTextNote(pX:Number, pY:Number, pWidth:Number, pHeight:Number, pText:String = "A note !"):void
Lets you add a text annotation to the current page
PDF
  
addTransition(pStyle:String = "R", pDuration:Number = 1, pDimension:String = "H", pMotionDirection:String = "I", pTransitionDirection:int = 0):void
Lets you add a transition between each PDF page
PDF
  
aliasNbPagesMethodMethod(alias:String = "{nb}"):void
Lets you rotate a specific page (between 1 and last one)
PDF
  
beginFill(pColor:Color):void
Sets the filling color for differents color spaces CMYK/RGB/DEVICEGRAY
PDF
  
curveTo(pControlX1:Number, pControlY1:Number, pControlX2:Number, pControlY2:Number, pFinalX3:Number, pFinalY3:Number):void
The curveTo method draws a cubic bezier curve
PDF
  
dispatchEvent(event:Event):Boolean
PDF
  
drawCircle(pX:Number, pY:Number, pRadius:Number):void
The drawCircle method draws a circle
PDF
  
drawEllipse(pX:Number, pY:Number, pRx:Number, pRy:Number):void
The drawEllipse method draws an ellipse
PDF
  
drawPolygone(pPoints:Array):void
The drawPolygone method draws a polygone
PDF
  
drawRect(pRect:Rectangle):void
The drawRect method draws a rectangle shape
PDF
  
drawRoundRect(pRect:Rectangle, pR:*):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
  
Lets you retrieve the current Page
PDF
  
getMargins():Rectangle
Lets you retrieve the margins dimensions
PDF
  
getPage(pPage:int):Page
Lets you retrieve a Page object
PDF
  
Lets you retrieve the number of pages in the PDF document
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
  
hasEventListener(type:String):Boolean
PDF
  
lineStyle(pColor:Color, pThickness:Number = 1, pAlpha:Number = 1.0, pBlend:String = "Normal", pStyle:DashedLine = null, pCaps:String = null, pJoints:String = null, pMiterLimit:Number = 3, pMatrix:Matrix = null):void
Sets the stroke style
PDF
  
lineTo(pX:Number, pY:Number):void
Lets you draw a stroke from the current point to the new point
PDF
  
moveTo(pX:Number, pY:Number):void
Lets you move the current drawing point to the specified destination
PDF
  
newLine(pHeight:*):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(pPage:int):Page
Lets you remove a Page from the PDF
PDF
  
rotatePage(pPage:int, pRotation:Number):void
Lets you rotate a specific page (between 1 and last one)
PDF
  
savePDF(pMethod:String, pURL:String = "", pDownload:String = "inline", pName:String = "generated.pdf"):*
Lets you finalize and save the PDF document and make it available for download
PDF
  
setAlpha(pAlpha:Number, pBlendMode:String = "Normal"):void
Lets you move the current drawing point to the specified destination
PDF
  
setAuthor(pAuthor:String):void
Sets the specified author for the PDF tags
PDF
  
setBottomMargin(pMargin:Number):void
Lets you specify the bottom margin
PDF
  
setCreator(pCreator:String):void
Sets the specified creator for the PDF tags
PDF
  
setDisplayMode(pZoom:String = "FullWidth", pLayout:String = "SinglePage", pPageMode:String = "UseNone"):void
Lets you set a specific display mode, the DisplayMode takes care of the general layout of the PDF in Acrobat Reader
PDF
  
setFont(pFamily:String, pStyle:String = "", pSize:int = 0):void
Lets you set a specific font
PDF
  
setFontSize(size:int):void
Lets you retrieve a Page object
PDF
  
setKeywords(pKeywords:String):void
Sets the specified keywords for the PDF tags
PDF
  
setLeftMargin(pMargin:Number):void
Lets you specify the left margin
PDF
  
setMargins(pLeft:Number, pTop:Number, pRight:Number = -1, pBottom:Number = 20):void
Lets you specify the left, top, and right margins
PDF
  
setPagination(pActive:Boolean):void
Lets you activate the auto pagination mode
PDF
  
setRightMargin(pMargin:Number):void
Lets you specify the right margin
PDF
  
setSubject(pSubject:String):void
Lets you set a subject for the PDF tags
PDF
  
setTitle(pTitle:String):void
Lets you set a subject for the PDF tags
PDF
  
setTopMargin(pMargin:Number):void
Lets you specify the top margin
PDF
  
setViewerPreferences(pToolBar:String = "false", pMenuBar:String = "false", pWindowUI:String = "false", pFitWindow:String = "false", pCenteredWindow:String = "false", pDisplayTitle:String = "false"):void
Lets you control the way the document is to be presented on the screen or in print.
PDF
  
setX(pX:Number):void
Lets you specify the X position for the current page
PDF
  
setXY(pX:Number, pY:Number):void
Lets you specify the X and Y position for the current page
PDF
  
setY(pY:Number):void
Lets you specify the Y position for the current page
PDF
  
textStyle(pColor:Color, pAlpha:int = 1, pRendering:int = 0, pWordSpace:Number = 0, pCharSpace:Number = 0, pScale:Number = 100, pLeading:Number = 0):void
Sets the text style
PDF
  
willTrigger(type:String):Boolean
PDF
  
writeText(pHeight:Number, pText:String, pLink:String = ""):void
Lets you write some text
PDF
Events
 EventSummaryDefined by
   Dispatched when PDF is generated.PDF
Constructor detail
PDF()constructor
public function PDF(pOrientation:String = "Portrait", pUnit:String = "Mm", pageSize:Object = null)

The PDF class represents a PDF document.

Parameters
pOrientation:String (default = "Portrait")
 
pUnit:String (default = "Mm")
 
pageSize:Object (default = null)

Example
This example shows how to create a valid PDF document :
    var myPDF:PDF = new PDF ( Orientation.PORTRAIT, Unit.MM, Size.A4 );
  

Method detail
addBookmark()method
public function addBookmark(pText:String, pLevel:int = 0, pY:Number = 0, pRed:Number = 0, pGreen:Number = 0, pBlue:Number = 0):void

Lets you add a bookmark

Parameters
pText:String — Text appearing in the outline panel
 
pLevel:int (default = 0) — Specify the bookmark's level
 
pY:Number (default = 0) — Position in the current page to go
 
pRed:Number (default = 0) — Red offset for the text color
 
pGreen:Number (default = 0) — Green offset for the text color
 
pBlue:Number (default = 0) — Blue offset for the text color

Example
This example shows how to add a bookmark for the current page :
    myPDF.addBookmark("A bookmark", 0, 0, 0, .9, 0);
  myPDF.addPage();
  myPDF.addBookmark("Another bookmark", 0, 60, .9, .9, 0);
  

addCell()method 
public function addCell(pWidth:Number = 0, pHeight:Number = 0, pText:String = "", pBorder:Number = 0, pLn:String = "0", pAlign:Number, pFill:String = "0", pLink:*):void

Add a cell with some text to the current page

Parameters
pWidth:Number (default = 0) — Cell width
 
pHeight:Number (default = 0) — Cell height
 
pText:String (default = "") — Text to add into the cell
 
pBorder:Number (default = 0) — Sets the new position after cell is drawn, default value is 0
 
pLn:String (default = "0") — Lets you center or align the text into the cell
 
pAlign:Number — Lets you specify if the cell is colored (1) or transparent (0)
 
pFill:String (default = "0") — Any http link, like http://www.mylink.com
 
pLink:*

Example
This example shows how to write some text within a cell :
    myPDF.setFont(FontFamily.HELVETICA, 'B', 12);
  myPDF.textStyle ( new RGBColor ( 255, 0, 0 ) );
  myPDF.addCell(50,10,'Some text into a cell !',1,1);
  
This example shows how to write some clikable text within a cell :
    myPDF.setFont(FontFamily.HELVETICA, 'B', 12);
  myPDF.textStyle ( new RGBColor ( 200, 50, 50 ) );
  myPDF.addCell(50,10,'A clikable cell !',1,1, null, 0, "http://www.alivepdf.org");
  

addEventListener()method 
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):voidParameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
 
priority:int (default = 0)
 
useWeakReference:Boolean (default = false)
addImage()method 
public function addImage(pDisplayObject:DisplayObject, pAlpha:Number = 1, pBlend:String = "Normal", pMatrix:Matrix = null, pResizePage:Boolean = false, pEncoding:String = "JPG", pQuality:Number = 100, pX:Number = 0, pY:Number = 0, pWidth:Number = 0, pHeight:Number = 0, pLink:String = ""):void

The addImage method takes an incoming DisplayObject object, take a snapshot from it in JPG and add it to the PDF document

Parameters
pDisplayObject:DisplayObject — Any DisplayObject
 
pAlpha:Number (default = 1) — Image transparency
 
pBlend:String (default = "Normal") — Blend mode, can be Blend.DIFFERENCE, BLEND.HARDLIGHT, etc.
 
pMatrix:Matrix (default = null) — A transformation matrix to apply to the picture
 
pResizePage:Boolean (default = false) — Automatically resize the page so that the full picture fits in the page
 
pEncoding:String (default = "JPG") — Image format, can be ImageFormat.JPG
 
pQuality:Number (default = 100) — Compression quality
 
pX:Number (default = 0) — Image X position
 
pY:Number (default = 0) — Image Y position
 
pWidth:Number (default = 0) — Image width
 
pHeight:Number (default = 0) — Image height
 
pLink:String (default = "") — If pLink is specified, the image is clickable and reaches the http link specified when clicked

Example
This example shows how to add a 100% compression quality JPG image into the current page, and make the image fits :
    myPDF.addImage (myDisplayObject, 1 , null, null, false, ImageFormat.JPG, 100, 160, 120, 0, 0);
  

addLink()method 
public function addLink(pX:Number, pY:Number, pWidth:Number, pHeight:Number, pLink:String, pHighlight:* = I):void

Lets you add clickable link at a specific position

Parameters
pX:Number — Page Format, can be Size.A3, Size.A4, Size.A5, Size.LETTER or Size.LEGAL
 
pY:Number
 
pWidth:Number
 
pHeight:Number
 
pLink:String
 
pHighlight:* (default = I)

Example
This example shows how to add an invisible clickable link in the current page :
    myPDF.addLink ( 70, 4, 60, 16, "http://www.alivepdf.org");
  

addMultiCell()method 
public function addMultiCell(pWidth:Number, pHeight:Number, pText:String, pBorder:String = "0", pAlign:int = J, pFill:* = 0):void

Add a multicell with some text to the current page

Parameters
pWidth:Number — Cell width
 
pHeight:Number — Cell height
 
pText:String — Text to add into the cell
 
pBorder:String (default = "0") — Lets you specify if a border should be drawn around the cell
 
pAlign:int (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
 
pFill:* (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 :
    myPDF.setFont('helvetica', 'B', 12);
  myPDF.textStyle ( new RGBColor ( 0, 0, 0 ) );
  myPDF.addMultiCell ( 70, 24, "A multicell :)", 1);
  myPDF.addMultiCell ( 70, 24, "A multicell :)", 1);
  

addPage()method 
public function addPage(pOrientation:String = "", pUnit:String = "Mm", pSize:Object = null, pRotation:Number = 0):void

Lets you add a page to the current PDF

Parameters
pOrientation:String (default = "") — Page orientation can be Orientation.PORTRAIT or Orientation.LANDSCAPE
 
pUnit:String (default = "Mm") — Page Unit, can be Unit.MM, Unit.CM, Unit.POINT, Unit.INCHES
 
pSize:Object (default = null) — Format, can be a custom Size object, or any of the following : Size.A3, Size.A4, Size.A5, Size.LETTER, Size.LEGAL
 
pRotation:Number (default = 0) — Page rotation (must be a multiple of 90)

Example
This example shows how to add an A4 page with a landscape orientation
    myPDF.addPage( Size.A4, 0, Orientation.LANDSCAPE );
  
This example shows how to add an custom page size :
    myPDF.addPage( Orientation.LANDSCAPE, Unit.MM,  new Size ([500, 500], "myFavoriteSize", [11.7, 16.5],[297, 420] ));
  

addText()method 
public function addText(pTxt:String, pX:Number = 0, pY:Number = 0):void

Lets you set some text to any position on the page

Parameters
pTxt:String — The text to add
 
pX:Number (default = 0) — X position
 
pY:Number (default = 0) — Y position

Example
This example shows how to set some text to a specific place :
    myPDF.addText ('Cubic Bezier curve with curveTo', 14, 110);
  

addTextNote()method 
public function addTextNote(pX:Number, pY:Number, pWidth:Number, pHeight:Number, pText:String = "A note !"):void

Lets you add a text annotation to the current page

Parameters
pX:Number — Note X position
 
pY:Number — Note Y position
 
pWidth:Number — Note width
 
pHeight:Number — Note height
 
pText:String (default = "A note !") — Text for the note

Example
This example shows how to add a note annotation in the current page :
    myPDF.addNote (100, 75, 50, 50, "A note !");
  

addTransition()method 
public function addTransition(pStyle:String = "R", pDuration:Number = 1, pDimension:String = "H", pMotionDirection:String = "I", pTransitionDirection:int = 0):void

Lets you add a transition between each PDF page

Parameters
pStyle:String (default = "R") — Transition style, can be Transition.SPLIT, Transition.BLINDS, BLINDS.BOX, Transition.WIPE, etc.
 
pDuration:Number (default = 1) — The transition duration
 
pDimension:String (default = "H") — The dimension in which the the specified transition effect occurs
 
pMotionDirection:String (default = "I") — The motion's direction for the specified transition effect
 
pTransitionDirection: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 :
    myPDF.addPage();
  myPDF.addTransition (Transition.WIPE, 4, Dimension.VERTICAL);
  myPDF.addPage();
  

aliasNbPagesMethodMethod()method 
public function aliasNbPagesMethodMethod(alias:String = "{nb}"):void

Lets you rotate a specific page (between 1 and last one)

Parameters
alias:String (default = "{nb}") — Page number

Example
This example shows how to rotate the first page 90 cw
    myPDF.rotatePage ( 1, 90 );
  

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

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

Parameters
pColor:Color — Color object, can be CMYKColor, GrayColor, or RGBColor

Example
This example shows how to create a red rectangle in the current page :
    myPDF.beginFill ( new RGBColor ( 255, 0, 0 ) );
  myPDF.drawRect ( new Rectangle ( 10, 26, 50, 25 ) );
  

curveTo()method 
public function curveTo(pControlX1:Number, pControlY1:Number, pControlX2:Number, pControlY2:Number, pFinalX3:Number, pFinalY3:Number):void

The curveTo method draws a cubic bezier curve

Parameters
pControlX1:Number
 
pControlY1:Number
 
pControlX2:Number
 
pControlY2:Number
 
pFinalX3:Number
 
pFinalY3: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
    yPDF.lineStyle ( new RGBColor ( 255, 0, 255 ), 1, 1, null, CapsStyle.NONE, JointStyle.MITER);
  myPDF.moveTo ( 10, 200 );
  myPDF.curveTo ( 120, 210, 196, 280, 139, 195 );
  myPDF.curveTo ( 190, 110, 206, 190, 179, 205 );
  myPDF.end();
  

dispatchEvent()method 
public function dispatchEvent(event:Event):BooleanParameters
event:Event

Returns
Boolean
drawCircle()method 
public function drawCircle(pX:Number, pY:Number, pRadius:Number):void

The drawCircle method draws a circle

Parameters
pX:Number — X Position
 
pY:Number — Y Position
 
pRadius:Number — Circle Radius

Example
This example shows how to create a rounded red ellipse in the current page :
    myPDF.beginFill ( new RGBColor ( 0, 0, 255 ) );
  myPDF.drawCircle( 30, 180, 20 );
  

drawEllipse()method 
public function drawEllipse(pX:Number, pY:Number, pRx:Number, pRy:Number):void

The drawEllipse method draws an ellipse

Parameters
pX:Number — X Position
 
pY:Number — Y Position
 
pRx:Number — X Radius
 
pRy:Number — Y Radius

Example
This example shows how to create a rounded red ellipse in the current page :
    myPDF.lineStyle ( new RGBColor ( 255, 255, 255 ), 1, .3, new DashedLine ([0, 1, 2, 6]), CapsStyle.NONE, JointStyle.ROUND);
  myPDF.beginFill ( new RGBColor ( 150, 0, 0 ) );
  myPDF.drawEllipse( 45, 275, 40, 15 );
  

drawPolygone()method 
public function drawPolygone(pPoints:Array):void

The drawPolygone method draws a polygone

Parameters
pPoints:Array — Array of points

Example
This example shows how to create a polygone with a few points :
    myPDF.beginFill ( new RGBColor ( 255, 255, 255 ) );
  myPDF.drawPolygone( [10, 30, 100, 5, 80, 18]  );
  

drawRect()method 
public function drawRect(pRect:Rectangle):void

The drawRect method draws a rectangle shape

Parameters
pRect:Rectangle — A flash.geom.Rectange object

Example
This example shows how to create a blue rectangle in the current page :
    myPDF.lineStyle ( new RGBColor ( 255, 255, 255 ), 1, .3, null, CapsStyle.ROUND, JointStyle.MITER);
  myPDF.beginFill ( new RGBColor ( 0, 0, 190 ) );
  myPDF.drawRect ( new Rectangle ( 20, 46, 100, 45 ) );
  

drawRoundRect()method 
public function drawRoundRect(pRect:Rectangle, pR:*):void

The drawRoundedRect method draws a rounded rectangle shape

Parameters
pRect:Rectangle — A flash.geom.Rectange object
 
pR:* — Angle radius

Example
This example shows how to create a rounded green rectangle in the current page :
    myPDF.lineStyle ( new RGBColor ( 255, 0, 0 ), 1, .3, null, CapsStyle.ROUND, JointStyle.MITER);
  myPDF.beginFill ( new RGBColor ( 0, 190, 0 ) );
  myPDF.drawRoundedRect ( new Rectangle ( 20, 46, 100, 45 ), 20 );
  

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
    myPDF.lineStyle( new RGBColor ( 255, 200, 0), 1, 1 );
  myPDF.moveTo ( 10, 20 );
  myPDF.lineTo ( 40, 20 );
  myPDF.lineTo ( 40, 40 );
  myPDF.lineTo ( 10, 40 );
  myPDF.lineTo ( 10, 20 );
  // end the stroke
  myPDF.end();
  

endFill()method 
public function endFill():void

Ends all previous filling


Example
This example shows how to create a red rectangle in the current page :
    myPDF.beginFill ( new RGBColor ( 0, 255, 255 ) );
  myPDF.moveTo ( 10, 10 );
  myPDF.lineTo ( 20, 90 );
  myPDF.lineTo ( 90, 50);
  myPDF.end()
  myPDF.endFill();
  

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 :
    myPDF.getCurrentPage ();
  

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 :
    var marginsDimensions:Rectangle = myPDF.getMargins ();
  // output : (x=10.001249999999999, y=10.001249999999999, w=575.2774999999999, h=811.88875)
  trace( marginsDimensions )
  

getPage()method 
public function getPage(pPage:int):Page

Lets you retrieve a Page object

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

Returns
Page — Page

Example
This example shows how to retrieve the first page :
    myPDF.getPage ( 1 );
  

getPageCount()method 
public function getPageCount():int

Lets you retrieve the number of pages in the PDF document

Returns
int — int Number of pages in the PDF

Example
This example shows how to retrieve the number of pages :
    var totalPages:int = myPDF.getPageCount ();
  

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
hasEventListener()method 
public function hasEventListener(type:String):BooleanParameters
type:String

Returns
Boolean
lineStyle()method 
public function lineStyle(pColor:Color, pThickness:Number = 1, pAlpha:Number = 1.0, pBlend:String = "Normal", pStyle:DashedLine = null, pCaps:String = null, pJoints:String = null, pMiterLimit:Number = 3, pMatrix:Matrix = null):void

Sets the stroke style

Parameters
pColor:Color — Color object, can be CMYKColor, GrayColor, or RGBColor
 
pThickness:Number (default = 1)
 
pAlpha:Number (default = 1.0)
 
pBlend:String (default = "Normal")
 
pStyle:DashedLine (default = null)
 
pCaps:String (default = null)
 
pJoints:String (default = null)
 
pMiterLimit:Number (default = 3)
 
pMatrix:Matrix (default = null)

Example
This example shows how to set a specific stroke style :
    myPDF.lineStyle ( new RGBColor ( 150, 250, 0 ), 1, 1, null, Caps.NONE, Joint.MITER);
  

lineTo()method 
public function lineTo(pX:Number, pY:Number):void

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

Parameters
pX:Number — X position
 
pY: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
    myPDF.lineStyle( new RGBColor ( 255, 200, 0), 1, 1 );
  myPDF.moveTo ( 10, 20 );
  myPDF.lineTo ( 40, 20 );
  myPDF.lineTo ( 40, 40 );
  myPDF.lineTo ( 10, 40 );
  myPDF.lineTo ( 10, 20 );
  myPDF.end();
  

moveTo()method 
public function moveTo(pX:Number, pY:Number):void

Lets you move the current drawing point to the specified destination

Parameters
pX:Number — X position
 
pY:Number — Y position

Example
This example shows how to move the pen to 120,200 :
    myPDF.moveTo ( 120, 200 );
  

newLine()method 
public function newLine(pHeight:*):void

Lets you insert a line break for text

Parameters
pHeight:* — Line break height

Example
This example shows how to add a line break :
    myPDF.newLine ( 10 );
  

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 :
  myPDF.removeAllPages();
  

removeEventListener()method 
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):voidParameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
removePage()method 
public function removePage(pPage:int):Page

Lets you remove a Page from the PDF

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

Returns
Page — Page

Example
This example shows how to remove the first page :
  myPDF.removePage(1);
  
If you want to remove pages each by each, you can combine removePage with getPageCount
  myPDF.removePage(myPDFEncoder.getPageCount());
  

rotatePage()method 
public function rotatePage(pPage:int, pRotation:Number):void

Lets you rotate a specific page (between 1 and last one)

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

Throws

Example
This example shows how to rotate the first page 90 cw
    myPDF.rotatePage ( 1, 90 );
  

savePDF()method 
public function savePDF(pMethod:String, pURL:String = "", pDownload:String = "inline", pName:String = "generated.pdf"):*

Lets you finalize and save the PDF document and make it available for download

Parameters
pMethod: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
 
pURL:String (default = "") — The url of the create.php file
 
pDownload: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
 
pName:String (default = "generated.pdf") — The name of the PDF, only available when Method.REMOTE is used

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

Example
This example shows how to save the PDF with a download dialog-box :
    var myPDFStream:ByteArray = myPDF.getPDF();
  

setAlpha()method 
public function setAlpha(pAlpha:Number, pBlendMode:String = "Normal"):void

Lets you move the current drawing point to the specified destination

Parameters
pAlpha:Number — Opacity
 
pBlendMode:String (default = "Normal") — Blend mode, can be Blend.DIFFERENCE, BLEND.HARDLIGHT, etc.

Example
This example shows how to set the alpha for any following drawing, image or text operation.
    myPDF.setAlpha ( .5 );
  

setAuthor()method 
public function setAuthor(pAuthor:String):void

Sets the specified author for the PDF tags

Parameters
pAuthor:String — The author

Example
This example shows how to add a specific author to the tags :
    myPDF.setAuthor ( "Bob" );
  

setBottomMargin()method 
public function setBottomMargin(pMargin:Number):void

Lets you specify the bottom margin

Parameters
pMargin:Number — Bottom margin

Example
This example shows how set bottom margin for the PDF document :
    myPDF.setBottomMargin ( 10 );
  

setCreator()method 
public function setCreator(pCreator:String):void

Sets the specified creator for the PDF tags

Parameters
pCreator:String — Page number

Example
This example shows how to rotate the first page 90 cw
    myPDF.rotatePage ( 1, 90 );
  

setDisplayMode()method 
public function setDisplayMode(pZoom:String = "FullWidth", pLayout:String = "SinglePage", pPageMode:String = "UseNone"):void

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

Parameters
pZoom:String (default = "FullWidth") — Zoom mode, can be Display.FULL_PAGE, Display.FULL_WIDTH, Display.REAL, Display.DEFAULT
 
pLayout:String (default = "SinglePage") — Layout of the PDF document, can be Layout.SINGLE_PAGE, Layout.ONE_COLUMN, Layout.TWO_COLUMN_LEFT, Layout.TWO_COLUMN_RIGHT
 
pPageMode:String (default = "UseNone") — PageMode can be pageMode.USE_NONE, PageMode.USE_OUTLINES, PageMode.USE_THUMBS, PageMode.FULL_SCREEN

Example
This example creates a PDF which opens at full page scaling, one page at a time
    myPDF.setDisplayMode (Display.FULL_PAGE, Layout.SINGLE_PAGE);
  

setFont()method 
public function setFont(pFamily:String, pStyle:String = "", pSize:int = 0):void

Lets you set a specific font

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

Example
This example shows how to set the Helvetica font, with a bold style :
    myPDF.setFont( FontFamily.HELVETICA, Style.BOLD );
  

setFontSize()method 
public function setFontSize(size:int):void

Lets you retrieve a Page object

Parameters
size:int — Page Format, can be Size.A3, Size.A4, Size.A5, Size.LETTER or Size.LEGAL

Example
This example shows how to retrieve the first page :
    myPDF.getPage ( 1 );
  

setKeywords()method 
public function setKeywords(pKeywords:String):void

Sets the specified keywords for the PDF tags

Parameters
pKeywords:String — The keywords

Example
This example shows how to add keywords to the tags :
    myPDF.setKeywords ( "Design, Agency, Communication, etc." );
  

setLeftMargin()method 
public function setLeftMargin(pMargin:Number):void

Lets you specify the left margin

Parameters
pMargin:Number — Left margin

Example
This example shows how set left margin for the PDF document :
    myPDF.setLeftMargin ( 10 );
  

setMargins()method 
public function setMargins(pLeft:Number, pTop:Number, pRight:Number = -1, pBottom:Number = 20):void

Lets you specify the left, top, and right margins

Parameters
pLeft:Number — Left margin
 
pTop:Number — Right number
 
pRight:Number (default = -1) — Top number
 
pBottom:Number (default = 20)

Example
This example shows how set margins for the PDF document :
    myPDF.setMargins ( 10, 10, 10 );
  

setPagination()method 
public function setPagination(pActive:Boolean):void

Lets you activate the auto pagination mode

Parameters
pActive:Boolean — Activate the mode

Example
This example shows how to activate the auto pagination mode :
    myPDF.setPagination ( true );
  

setRightMargin()method 
public function setRightMargin(pMargin:Number):void

Lets you specify the right margin

Parameters
pMargin:Number — Right margin

Example
This example shows how set right margin for the PDF document :
    myPDF.setRightMargin ( 10 );
  

setSubject()method 
public function setSubject(pSubject:String):void

Lets you set a subject for the PDF tags

Parameters
pSubject:String — The subject

Example
This example shows how to set a specific subject to the PDF document :
    myPDF.setSubject ( "Any topic" );
  

setTitle()method 
public function setTitle(pTitle:String):void

Lets you set a subject for the PDF tags

Parameters
pTitle:String — The title

Example
This example shows how to set a specific title to the PDF document :
    myPDF.setTitle ( "AlivePDF !" );
  

setTopMargin()method 
public function setTopMargin(pMargin:Number):void

Lets you specify the top margin

Parameters
pMargin:Number — Top margin

Example
This example shows how set top margin for the PDF document :
    myPDF.setTopMargin ( 10 );
  

setViewerPreferences()method 
public function setViewerPreferences(pToolBar:String = "false", pMenuBar:String = "false", pWindowUI:String = "false", pFitWindow:String = "false", pCenteredWindow:String = "false", pDisplayTitle:String = "false"):void

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

Parameters
pToolBar:String (default = "false") — Toolbar behavior
 
pMenuBar:String (default = "false") — Menubar behavior
 
pWindowUI:String (default = "false") — WindowUI behavior
 
pFitWindow:String (default = "false") — Specify whether to resize the document's window to fit the size of the first displayed page.
 
pCenteredWindow:String (default = "false") — Specify whether to position the document's window in the center of the screen.
 
pDisplayTitle: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 :
    myPDF.setViewerPreferences (ToolBar.HIDE, MenuBar.HIDE, WindowUI.HIDE, FitWindow.DEFAULT, CenterWindow.CENTERED);
  

setX()method 
public function setX(pX:Number):void

Lets you specify the X position for the current page

Parameters
pX:Number — the X position
setXY()method 
public function setXY(pX:Number, pY:Number):void

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

Parameters
pX:Number — The X position
 
pY:Number — The Y position
setY()method 
public function setY(pY:Number):void

Lets you specify the Y position for the current page

Parameters
pY:Number — the Y position
textStyle()method 
public function textStyle(pColor:Color, pAlpha:int = 1, pRendering:int = 0, pWordSpace:Number = 0, pCharSpace:Number = 0, pScale:Number = 100, pLeading:Number = 0):void

Sets the text style

Parameters
pColor:Color — Color object, can be CMYKColor, GrayColor, or RGBColor
 
pAlpha:int (default = 1) — Text opacity
 
pRendering:int (default = 0) — pRendering Specify the text rendering mode
 
pWordSpace:Number (default = 0) — Spaces between each words
 
pCharSpace:Number (default = 0) — Spaces between each characters
 
pScale:Number (default = 100) — Text scaling
 
pLeading:Number (default = 0) — Text leading

Example
This example shows how to set a specific black text style with full opacity :
    myPDF.textStyle ( new RGBColor ( 0, 0, 0 ), 1 ); 
  

willTrigger()method 
public function willTrigger(type:String):BooleanParameters
type:String

Returns
Boolean
writeText()method 
public function writeText(pHeight:Number, pText:String, pLink:String = ""):void

Lets you write some text

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 (default = "") — 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 :
    myPDF.writeText ( 5, "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", "http://www.google.fr");
  
This example shows how to add some text with a clickable link :
    myPDF.writeText ( 5, "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", "http://www.google.fr");
  

Event detail
completeevent 
Event object type: flash.events.Event.COMPLETE

Dispatched when PDF is generated. The finish() method generate this event


Example
This example shows how to create a valid PDF document :
    myPDF.addEventListener ( Event.COMPLETE, generated );