| Package | org.alivepdf.pdf |
| Class | public final class PDF |
| Implements | flash.events.IEventDispatcher |
| Property | Defined by | ||
|---|---|---|---|
| totalPages : int [read-only]
Lets you retrieve the number of pages in the PDF document
| |||
| Method | Defined by | ||
|---|---|---|---|
|
PDF(orientation:String = "Portrait", unit:String = "Mm", pageSize:Object = null, rotation:int = 0)
The PDF class represents a PDF document.
| |||
|
addBookmark(text:String, level:int, y:Number, color:RGBColor):void
Lets you add a bookmark
| |||
|
addCell(width:Number = 0, height:Number = 0, text:String = "", border:Number = 0, ln:String = "0", align:Number, fill:String = "0", link:*):void
Add a cell with some text to the current page
| |||
|
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
| |||
|
addImage(displayObject:DisplayObject, x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0, imageFormat:String = "JPG", 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.
| |||
|
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 = ""):void
The addImageStream method takes an incoming image as a ByteArray.
| |||
|
addLink(x:Number, y:Number, width:Number, height:Number, link:String, highlight:* = I):void
Lets you add clickable link to a specific position
| |||
|
addMultiCell(width:Number, height:Number, text:String, border:String = "0", align:int = J, filled:* = 0):void
Add a multicell with some text to the current page
| |||
|
Lets you add a page to the current PDF
| |||
|
addText(text:String, x:Number = 0, y:Number = 0):void
Lets you set some text to any position on the page
| |||
|
addTextNote(x:Number, y:Number, width:Number, height:Number, text:String = "A note !"):void
Lets you add a text annotation to the current page
| |||
|
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
| |||
|
Sets the filling color for different color spaces CMYK/RGB/DEVICEGRAY
| |||
|
curveTo(controlX1:Number, controlY1:Number, controlX2:Number, controlY2:Number, finalX3:Number, finalY3:Number):void
The curveTo method draws a cubic bezier curve
| |||
|
dispatchEvent(event:Event):Boolean
| |||
|
drawCircle(x:Number, y:Number, radius:Number):void
The drawCircle method draws a circle
| |||
|
drawEllipse(x:Number, y:Number, radiusX:Number, radiusY:Number):void
The drawEllipse method draws an ellipse
| |||
|
drawPolygone(points:Array):void
The drawPolygone method draws a polygone
| |||
|
drawRect(rect:Rectangle):void
The drawRect method draws a rectangle shape
| |||
|
drawRoundRect(rect:Rectangle, ellipseWidth:Number):void
The drawRoundedRect method draws a rounded rectangle shape
| |||
|
end():void
The end method closes the stroke
| |||
|
endFill():void
Ends all previous filling
| |||
|
Lets you retrieve the current Page
| |||
|
getDefaultOrientation():String
Returns the default PDF orientation
| |||
|
Returns the default PDF Size
| |||
|
getDefaultUnit():String
Returns the default PDF unit unit
| |||
|
getMargins():Rectangle
Lets you retrieve the margins dimensions
| |||
|
Lets you retrieve a Page object
| |||
|
getPages():Array
Lets you retrieve all the PDF pages
| |||
|
getX():Number
Lets you retrieve the X position for the current page
| |||
|
getY():Number
Lets you retrieve the Y position for the current page
| |||
|
gotoPage(page:int):void
Lets you move to a Page in the PDF
| |||
|
hasEventListener(type:String):Boolean
| |||
|
lineStyle(color:Color, thickness:Number = 1, flatness:Number = 0, alpha:Number = 1, blendMode:String = "Normal", style:DashedLine = null, caps:String = null, joints:String = null, miterLimit:Number = 3):void
Sets the stroke style
| |||
|
lineTo(x:Number, y:Number):void
Lets you draw a stroke from the current point to the new point
| |||
|
moveTo(x:Number, y:Number):void
Lets you move the current drawing point to the specified destination
| |||
|
newLine(height:*):void
Lets you insert a line break for text
| |||
|
removeAllPages():void
Lets you remove all the pages from the PDF
| |||
|
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
| |||
|
removePage(page:int):Page
Lets you remove a Page from the PDF
| |||
|
rotatePage(number:int, rotation:Number):void
Lets you rotate a specific page (between 1 and n-1)
| |||
|
save(method:String, url:String = "", downloadMethod:String = "inline", fileName:String = "generated.pdf"):*
| |||
|
setAliasNbPages(alias:String = "{nb}"):void
Lets you specify an alias for the total number of pages
| |||
|
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)
| |||
|
setAuthor(author:String):void
Sets the specified author for the PDF
| |||
|
setAutoPageBreak(auto:Boolean, margin:Number):void
Lets you enable or disable auto page break mode and triggering margin
| |||
|
setBottomMargin(margin:Number):void
Lets you specify the bottom margin
| |||
|
setCreator(creator:String):void
Sets the specified creator for the PDF
| |||
|
setDisplayMode(zoom:String = "FullWidth", layout:String = "SinglePage", mode:String = "UseNone"):void
Lets you set a specific display mode, the DisplayMode takes care of the general layout of the PDF in the PDF reader
| |||
|
setFont(family:String, style:String = "", size:int = 0):void
Lets you set a specific font
| |||
|
setFontSize(size:int):void
Lets you set a new size for the current font
| |||
|
setKeywords(keywords:String):void
Sets the specified keywords for the PDF
| |||
|
setLeftMargin(margin:Number):void
Lets you specify the left margin
| |||
|
setMargins(left:Number, top:Number, right:Number = -1, bottom:Number = 20):void
Lets you specify the left, top, and right margins
| |||
|
setRightMargin(margin:Number):void
Lets you specify the right margin
| |||
|
setSubject(subject:String):void
Lets you set a subject for the PDF
| |||
|
setTitle(title:String):void
Lets you set a title for the PDF
| |||
|
setTopMargin(margin:Number):void
Lets you specify the top margin
| |||
|
setUnit(unit:String):String
| |||
|
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.
| |||
|
setX(x:Number):void
Lets you specify the X position for the current page
| |||
|
setXY(x:Number, y:Number):void
Lets you specify the X and Y position for the current page
| |||
|
setY(y:Number):void
Lets you specify the Y position for the current page
| |||
|
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
| |||
|
toString():String
| |||
|
willTrigger(type:String):Boolean
| |||
|
writeText(lineHeight:Number, text:String, link:String = ""):void
Lets you write some text
| |||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| Dispatched when a page has been added to the PDF. | ||||
| Dispatched when PDF has been generated and available. | ||||
| Dispatched when the PDF page tree has been generated. | ||||
| Dispatched when the required resources (fonts, images, etc.) haven been written into the PDF. | ||||
| Dispatched when the PDF generation has been initiated. | ||||
| totalPages | property |
totalPages:int [read-only]Lets you retrieve the number of pages in the PDF document
Implementation public function get totalPages():int
var totalPages:int = myPDF.getPageCount ();
| () | constructor |
public function PDF(orientation:String = "Portrait", unit:String = "Mm", pageSize:Object = null, rotation:int = 0)The PDF class represents a PDF document.
Parametersorientation:String (default = "Portrait") |
|
unit:String (default = "Mm") |
|
pageSize:Object (default = null) |
|
rotation:int (default = 0) |
var myPDF:PDF = new PDF ( Orientation.PORTRAIT, Unit.MM, Size.A4 );
| addBookmark | () | method |
public function addBookmark(text:String, level:int, y:Number, color:RGBColor):voidLets you add a bookmark
Parameterstext: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
|
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(width:Number = 0, height:Number = 0, text:String = "", border:Number = 0, ln:String = "0", align:Number, fill:String = "0", link:*):voidAdd a cell with some text to the current page
Parameterswidth:Number (default = 0) — Cell width
|
|
height:Number (default = 0) — Cell height
|
|
text:String (default = "") — Text to add into the cell
|
|
border:Number (default = 0) — Sets the new position after cell is drawn, default value is 0
|
|
ln:String (default = "0") — Lets you center or align the text into the cell
|
|
align:Number — Lets you specify if the cell is colored (1) or transparent (0)
|
|
fill:String (default = "0") — Any http link, like http://www.mylink.com
|
|
link:* |
myPDF.setFont(FontFamily.HELVETICA, 'B', 12);
myPDF.textStyle ( new RGBColor ( 0x990000 ) );
myPDF.addCell(50,10,'Some text into a cell !',1,1);
myPDF.setFont(FontFamily.HELVETICA, 'B', 12);
myPDF.textStyle ( new RGBColor ( 0x990000 ) );
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(displayObject:DisplayObject, x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0, imageFormat:String = "JPG", quality:Number = 100, alpha:Number = 1, resizeMode:String = "None", blendMode:String = "Normal", keepTransformation:Boolean = true, link:String = ""):voidThe addImage method takes an incoming DisplayObject. A JPG snapshot is done and included in the PDF document
ParametersdisplayObject:DisplayObject |
|
x:Number (default = 0) |
|
y:Number (default = 0) |
|
width:Number (default = 0) |
|
height:Number (default = 0) |
|
imageFormat:String (default = "JPG") |
|
quality:Number (default = 100) |
|
alpha:Number (default = 1) |
|
resizeMode:String (default = "None") |
|
blendMode:String (default = "Normal") |
|
keepTransformation:Boolean (default = true) |
|
link:String (default = "") |
myPDF.addImage ( displayObject, 0, 0, 0, 0, ImageFormat.JPG, 100, .2 );
| 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 = ""):voidThe addImageStream method takes an incoming image as a ByteArray. This method can be used to embed high-quality images (300 dpi) to the PDF
ParametersimageBytes: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 (default = "") |
myPDF.addImageStream( bytes, 0, 0, 0, 0, 1, ImageResize.RESIZE_PAGE );
| addLink | () | method |
public function addLink(x:Number, y:Number, width:Number, height:Number, link:String, highlight:* = I):voidLets you add clickable link to a specific position
Parametersx:Number — Page Format, can be Size.A3, Size.A4, Size.A5, Size.LETTER or Size.LEGAL
|
|
y:Number |
|
width:Number |
|
height:Number |
|
link:String |
|
highlight:* (default = I) |
myPDF.addLink ( 70, 4, 60, 16, "http://www.alivepdf.org");
| addMultiCell | () | method |
public function addMultiCell(width:Number, height:Number, text:String, border:String = "0", align:int = J, filled:* = 0):voidAdd a multicell with some text to the current page
Parameterswidth:Number — Cell width
|
|
height:Number — Cell height
|
|
text:String — Text to add into the cell
|
|
border:String (default = "0") — Lets you specify if a border should be drawn around the cell
|
|
align: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
|
|
filled:* (default = 0) — Lets you specify if the cell is colored (1) or transparent (0)
|
myPDF.setFont( FontFamily.COURIER, Style.BOLD, 14 );
myPDF.textStyle ( new RGBColor ( 0x990000 ) );
myPDF.addMultiCell ( 70, 24, "A multicell :)", 1);
myPDF.addMultiCell ( 70, 24, "A multicell :)", 1);
| addPage | () | method |
public function addPage(page:Page = null):PageLets you add a page to the current PDF
Parameterspage:Page (default = null) |
Page |
var page:Page = new Page ( Orientation.LANDSCAPE, Unit.MM, Size.A4 );
myPDF.addPage( page );
var customSize:Size = new Size ( [420.94, 595.28], "CustomSize", [5.8, 8.3], [148, 210] );
var page:Page = new Page ( Orientation.PORTRAIT, Unit.MM, customSize );
myPDF.addPage ( page );
| addText | () | method |
public function addText(text:String, x:Number = 0, y:Number = 0):voidLets you set some text to any position on the page
Parameterstext:String — The text to add
|
|
x:Number (default = 0) — X position
|
|
y:Number (default = 0) — Y position
|
myPDF.addText ('Cubic Bezier curve with curveTo', 14, 110);
| addTextNote | () | method |
public function addTextNote(x:Number, y:Number, width:Number, height:Number, text:String = "A note !"):voidLets you add a text annotation to the current page
Parametersx: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
|
myPDF.addNote (100, 75, 50, 50, "A note !");
| addTransition | () | method |
public function addTransition(style:String = "R", duration:Number = 1, dimension:String = "H", motionDirection:String = "I", transitionDirection:int = 0):voidLets 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
Parametersstyle: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
|
myPDF.addTransition (Transition.WIPE, 4, Dimension.VERTICAL); myPDF.addPage(); myPDF.addTransition (Transition.WIPE, 4, Dimension.VERTICAL);
| beginFill | () | method |
public function beginFill(color:Color):voidSets the filling color for different color spaces CMYK/RGB/DEVICEGRAY
Parameterscolor:Color — Color object, can be CMYKColor, GrayColor, or RGBColor
|
myPDF.beginFill ( new RGBColor ( 0x990000 ) );
myPDF.drawRect ( new Rectangle ( 10, 26, 50, 25 ) );
| curveTo | () | method |
public function curveTo(controlX1:Number, controlY1:Number, controlX2:Number, controlY2:Number, finalX3:Number, finalY3:Number):voidThe curveTo method draws a cubic bezier curve
ParameterscontrolX1:Number |
|
controlY1:Number |
|
controlX2:Number |
|
controlY2:Number |
|
finalX3:Number |
|
finalY3:Number |
myPDF.lineStyle ( new RGBColor ( 0x990000 ), 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 |
Boolean |
| drawCircle | () | method |
public function drawCircle(x:Number, y:Number, radius:Number):voidThe drawCircle method draws a circle
Parametersx:Number — X Position
|
|
y:Number — Y Position
|
|
radius:Number — Circle Radius
|
myPDF.beginFill ( new RGBColor ( 0x990000 ) );
myPDF.drawCircle ( 30, 180, 20 );
| drawEllipse | () | method |
public function drawEllipse(x:Number, y:Number, radiusX:Number, radiusY:Number):voidThe drawEllipse method draws an ellipse
Parametersx:Number — X Position
|
|
y:Number — Y Position
|
|
radiusX:Number — X Radius
|
|
radiusY:Number — Y Radius
|
myPDF.lineStyle ( new RGBColor ( 0x990000 ), 1, .3, new DashedLine ([0, 1, 2, 6]), CapsStyle.NONE, JointStyle.ROUND );
myPDF.beginFill ( new RGBColor ( 0x990000 ) );
myPDF.drawEllipse( 45, 275, 40, 15 );
| drawPolygone | () | method |
public function drawPolygone(points:Array):voidThe drawPolygone method draws a polygone
Parameterspoints:Array — Array of points
|
myPDF.beginFill ( new RGBColor ( 0x990000 ) );
myPDF.drawPolygone ( [89, 40, 20, 90, 40, 50, 10, 60, 70, 90] );
| drawRect | () | method |
public function drawRect(rect:Rectangle):voidThe drawRect method draws a rectangle shape
Parametersrect:Rectangle — A flash.geom.Rectange object
|
myPDF.lineStyle ( new RGBColor ( 0x990000 ), 1, .3, null, CapsStyle.ROUND, JointStyle.MITER );
myPDF.beginFill ( new RGBColor ( 0x009900 ) );
myPDF.drawRect ( new Rectangle ( 20, 46, 100, 45 ) );
| drawRoundRect | () | method |
public function drawRoundRect(rect:Rectangle, ellipseWidth:Number):voidThe drawRoundedRect method draws a rounded rectangle shape
Parametersrect:Rectangle — A flash.geom.Rectange object
|
|
ellipseWidth:Number — Angle radius
|
myPDF.lineStyle ( new RGBColor ( 0x00FF00 ), 1, 0, .3, BlendMode.NORMAL, null, CapsStyle.ROUND, JointStyle.MITER );
myPDF.beginFill ( new RGBColor ( 0x009900 ) );
myPDF.drawRoundRect ( new Rectangle ( 20, 46, 100, 45 ), 20 );
| end | () | method |
public function end():voidThe end method closes the stroke
myPDF.lineStyle( new RGBColor ( 0x990000 ), 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():voidEnds all previous filling
myPDF.beginFill ( new RGBColor ( 0x990000 ) );
myPDF.moveTo ( 10, 10 );
myPDF.lineTo ( 20, 90 );
myPDF.lineTo ( 90, 50);
myPDF.end()
myPDF.endFill();
| getCurrentPage | () | method |
public function getCurrentPage():PageLets you retrieve the current Page
ReturnsPage —
Page A Page object
|
var page:Page = myPDF.getCurrentPage ();
| getDefaultOrientation | () | method |
public function getDefaultOrientation():StringReturns the default PDF orientation
ReturnsString — String
|
| getDefaultSize | () | method |
| getDefaultUnit | () | method |
public function getDefaultUnit():StringReturns the default PDF unit unit
ReturnsString — String
|
| getMargins | () | method |
public function getMargins():RectangleLets you retrieve the margins dimensions
ReturnsRectangle — Rectangle
|
var marginsDimensions:Rectangle = myPDF.getMargins ();
// output : (x=10.00, y=10.0012, w=575.27, h=811.88)
trace( marginsDimensions )
| getPage | () | method |
public function getPage(page:int):PageLets you retrieve a Page object
Parameterspage:int — page number, from 1 to total numbers of pages
|
Page —
Page
|
var page:Page = myPDF.getPage ( 1 );
| getPages | () | method |
public function getPages():ArrayLets you retrieve all the PDF pages
ReturnsArray — Array
|
var pdfPages:Array = myPDF.getPages ();
for each ( var p:in pdfPages ) trace( p );
outputs :
[Page orientation=Portrait width=210 height=297]
[Page orientation=Landscape width=297 height=210]
| getX | () | method |
public function getX():NumberLets you retrieve the X position for the current page
ReturnsNumber — Number the X position
|
| getY | () | method |
public function getY():NumberLets you retrieve the Y position for the current page
ReturnsNumber — Number the Y position
|
| gotoPage | () | method |
public function gotoPage(page:int):voidLets you move to a Page in the PDF
Parameterspage:int — page number, from 1 to total numbers of pages
|
myPDF.gotoPage ( 1 );
// draw on the first page
myPDF.lineStyle( new RGBColor(0xFF0000), 2, 0 );
myPDF.drawRect( 60, 60, 40, 40 );
| hasEventListener | () | method |
public function hasEventListener(type:String):BooleanParameters
type:String |
Boolean |
| lineStyle | () | method |
public function lineStyle(color:Color, thickness:Number = 1, flatness:Number = 0, alpha:Number = 1, blendMode:String = "Normal", style:DashedLine = null, caps:String = null, joints:String = null, miterLimit:Number = 3):voidSets the stroke style
Parameterscolor:Color |
|
thickness:Number (default = 1) |
|
flatness:Number (default = 0) |
|
alpha:Number (default = 1) |
|
blendMode:String (default = "Normal") |
|
style:DashedLine (default = null) |
|
caps:String (default = null) |
|
joints:String (default = null) |
|
miterLimit:Number (default = 3) |
myPDF.lineStyle ( new RGBColor ( 0x990000 ), 1, 0, 1, null, Caps.NONE, Joint.MITER );
| lineTo | () | method |
public function lineTo(x:Number, y:Number):voidLets you draw a stroke from the current point to the new point
Parametersx:Number — X position
|
|
y:Number — Y position
|
myPDF.lineStyle( new RGBColor ( 0x990000 ), 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(x:Number, y:Number):voidLets you move the current drawing point to the specified destination
Parametersx:Number — X position
|
|
y:Number — Y position
|
myPDF.moveTo ( 120, 200 );
| newLine | () | method |
public function newLine(height:*):voidLets you insert a line break for text
Parametersheight:* — Line break height
|
myPDF.newLine ( 10 );
| removeAllPages | () | method |
public function removeAllPages():voidLets you remove all the pages from the PDF
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(page:int):PageLets you remove a Page from the PDF
Parameterspage:int — page number, from 1 to total numbers of pages
|
Page —
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(number:int, rotation:Number):voidLets you rotate a specific page (between 1 and n-1)
Parametersnumber:int — Page number
|
|
rotation:Number — Page rotation (must be a multiple of 90)
|
— |
myPDF.rotatePage ( 1, 90 );
myPDF.rotatePage ( 1, -90 );
| save | () | method |
public function save(method:String, url:String = "", downloadMethod:String = "inline", fileName:String = "generated.pdf"):*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 (default = "") — 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 = "generated.pdf") — The name of the PDF, only available when Method.REMOTE is used
|
* — The ByteArray PDF when Method.LOCAL is used, otherwise the method returns null
|
var f:FileStream = new FileStream();
file = File.desktopDirectory.resolvePath("generate.pdf");
f.open( file, FileMode.WRITE);
var bytes:ByteArray = myPDF.save( Method.LOCAL );
f.writeBytes(bytes);
f.close();
myPDF.save( Method.REMOTE, "http://localhost/save.php", Download.ATTACHMENT );
myPDF.save( Method.REMOTE, "http://localhost/save.php", Download.INLINE );
| setAliasNbPages | () | method |
public function setAliasNbPages(alias:String = "{nb}"):voidLets you specify an alias for the total number of pages
Parametersalias:String (default = "{nb}") — Alias to use
|
myPDF.setAliasNbPages ( "[nb]" );
myPDF.textStyle( new RGBColor (0,0,0), 1 );
myPDF.setFont( FontFamily.HELVETICA, Style.NORMAL, 18 );
// then use the alias when needed
myPDF.addText ("There are [nb] pages in the PDF !", 150, 50);
| setAlpha | () | method |
public function setAlpha(alpha:Number, blendMode:String = "Normal"):voidLets you specify the opacity for the next drawing operations, from 0 (100% transparent) to 1 (100% opaque)
Parametersalpha:Number — Opacity
|
|
blendMode:String (default = "Normal") — Blend mode, can be Blend.DIFFERENCE, BLEND.HARDLIGHT, etc.
|
myPDF.setAlpha ( .5 );
| setAuthor | () | method |
public function setAuthor(author:String):voidSets the specified author for the PDF
Parametersauthor:String — The author
|
myPDF.setAuthor ( "Bob" );
| setAutoPageBreak | () | method |
public function setAutoPageBreak(auto:Boolean, margin:Number):voidLets you enable or disable auto page break mode and triggering margin
Parametersauto:Boolean — Page break mode
|
|
margin:Number — Bottom margin
|
| setBottomMargin | () | method |
public function setBottomMargin(margin:Number):voidLets you specify the bottom margin
Parametersmargin:Number — Bottom margin
|
myPDF.setBottomMargin ( 10 );
| setCreator | () | method |
public function setCreator(creator:String):voidSets the specified creator for the PDF
Parameterscreator:String — Name of the PDF creator
|
myPDF.setCreator ( "My Application 1.0" );
| setDisplayMode | () | method |
public function setDisplayMode(zoom:String = "FullWidth", layout:String = "SinglePage", mode:String = "UseNone"):voidLets you set a specific display mode, the DisplayMode takes care of the general layout of the PDF in the PDF reader
Parameterszoom: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
|
myPDF.setDisplayMode (Display.FULL_PAGE, Layout.SINGLE_PAGE);
myPDF.setDisplayMode( Display.FULL_PAGE, Layout.SINGLE_PAGE, PageMode.FULLSCREEN );
| setFont | () | method |
public function setFont(family:String, style:String = "", size:int = 0):voidLets you set a specific font
Parametersfamily:String — Font family, can be any of FontFamily.COURIER, FontFamily.HELVETICA, FontFamily.ARIAL, FontFamily.TIMES, FontFamily.SYMBOL, FontFamily.ZAPFDINGBATS.
|
|
style:String (default = "") — Any font style, can be Style.BOLD, Style.ITALIC, Style.BOLD_ITALIC, Style.NORMAL
|
|
size:int (default = 0) |
myPDF.setFont( FontFamily.HELVETICA, Style.BOLD );
| setFontSize | () | method |
public function setFontSize(size:int):voidLets you set a new size for the current font
Parameterssize:int — Font size
|
myPDF.setFontSize( 18 );
| setKeywords | () | method |
public function setKeywords(keywords:String):voidSets the specified keywords for the PDF
Parameterskeywords:String — The keywords
|
myPDF.setKeywords ( "Design, Agency, Communication, etc." );
| setLeftMargin | () | method |
public function setLeftMargin(margin:Number):voidLets you specify the left margin
Parametersmargin:Number — Left margin
|
myPDF.setLeftMargin ( 10 );
| setMargins | () | method |
public function setMargins(left:Number, top:Number, right:Number = -1, bottom:Number = 20):voidLets you specify the left, top, and right margins
Parametersleft:Number — Left margin
|
|
top:Number — Right number
|
|
right:Number (default = -1) — Top number
|
|
bottom:Number (default = 20) — Bottom number
|
myPDF.setMargins ( 10, 10, 10, 10 );
| setRightMargin | () | method |
public function setRightMargin(margin:Number):voidLets you specify the right margin
Parametersmargin:Number — Right margin
|
myPDF.setRightMargin ( 10 );
| setSubject | () | method |
public function setSubject(subject:String):voidLets you set a subject for the PDF
Parameterssubject:String — The subject
|
myPDF.setSubject ( "Any topic" );
| setTitle | () | method |
public function setTitle(title:String):voidLets you set a title for the PDF
Parameterstitle:String — The title
|
myPDF.setTitle ( "AlivePDF !" );
| setTopMargin | () | method |
public function setTopMargin(margin:Number):voidLets you specify the top margin
Parametersmargin:Number — Top margin
|
myPDF.setTopMargin ( 10 );
| setUnit | () | method |
public function setUnit(unit:String):StringParameters
unit:String |
String |
| setViewerPreferences | () | method |
public function setViewerPreferences(toolbar:String = "false", menubar:String = "false", windowUI:String = "false", fitWindow:String = "false", centeredWindow:String = "false", displayTitle:String = "false"):voidLets you control the way the document is to be presented on the screen or in print.
Parameterstoolbar: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
|
myPDF.setViewerPreferences (ToolBar.HIDE, MenuBar.HIDE, WindowUI.HIDE, FitWindow.DEFAULT, CenterWindow.CENTERED);
| setX | () | method |
public function setX(x:Number):voidLets you specify the X position for the current page
Parametersx:Number — The X position
|
| setXY | () | method |
public function setXY(x:Number, y:Number):voidLets you specify the X and Y position for the current page
Parametersx:Number — The X position
|
|
y:Number — The Y position
|
| setY | () | method |
public function setY(y:Number):voidLets you specify the Y position for the current page
Parametersy:Number — The Y position
|
| 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):voidSets the text style
Parameterscolor: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
|
myPDF.textStyle ( new RGBColor ( 0x000000 ), 1 );
| toString | () | method |
public function toString():String
Returns
String |
| willTrigger | () | method |
public function willTrigger(type:String):BooleanParameters
type:String |
Boolean |
| writeText | () | method |
public function writeText(lineHeight:Number, text:String, link:String = ""):voidLets you write some text
ParameterslineHeight: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 (default = "") — Any link, like http://www.mylink.com, will open te browser when clicked
|
myPDF.writeText ( 5, "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", "http://www.google.fr");
myPDF.writeText ( 5, "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", "http://www.google.fr");
| added | event |
org.alivepdf.events.PageEvent
Dispatched when a page has been added to the PDF. The addPage() method generate this event
myPDF.addEventListener ( PageEvent.ADDED, pageAdded );
| complete | event |
org.alivepdf.events.ProcessingEvent
Dispatched when PDF has been generated and available. The save() method generate this event
myPDF.addEventListener ( ProcessingEvent.COMPLETE, generationComplete );
| pageTree | event |
org.alivepdf.events.ProcessingEvent
Dispatched when the PDF page tree has been generated. The save() method generate this event
myPDF.addEventListener ( ProcessingEvent.PAGE_TREE, pageTreeAdded );
| resources | event |
org.alivepdf.events.ProcessingEvent
Dispatched when the required resources (fonts, images, etc.) haven been written into the PDF. The save() method generate this event
myPDF.addEventListener ( ProcessingEvent.RESOURCES, resourcesAdded );
| started | event |
org.alivepdf.events.ProcessingEvent
Dispatched when the PDF generation has been initiated. The save() method generate this event
myPDF.addEventListener ( ProcessingEvent.STARTED, generationStarted );