Script: PRINT_CLASS
Author: Valentin Schmidt
Version: 0.2
Created: 19.06.2009
Modified: 22.07.2009
Description
This script implements printing based on flash.
Usage:
p = script("PRINT_CLASS").new()
p.mAddPage()
p.mAddText("Hello World!", 50, 50, 100)
p.mPrint()
p.mDestroy()
p=0
History
v0.1 First version
v0.2 Minor bug fix
Dependencies
- (empty) flash 8 sprite with scaleMode=#noScale
Public Interface
Methods Description
new
new (me, tFlashSprite, tPageFormat, tOrientation)
Parameters
- tFlashSprite {sprite}: a flash sprite reference (flash 8 movie, can be empty)
- tPageFormat {list|string}: (optional) either a list [widthInPt, heightInPt] or one of the following strings: "A3", "A4"(=default), "A5", "letter", "legal"
- tOrientation {string}: (optional) "L" for landscape or "P" for portrait (=default)
Description
Constructor
mDestroy
mDestroy (me)
Description
Safely deletes object, releases memory
mSetMargins
mSetMargins (me, tMargins)
Parameters
- tMargins {propList}: propList containing one or more of the following properties: #left, #right, #top, #bottom
Description
Sets page marginsmargins are specified as floats
mSetAutoPageBreak
mSetAutoPageBreak (me, tBool)
Parameters
Description
(De)Activates autoPageBreak
mAddPage
mAddPage (me)
Description
Adds a new page to the document
mSetActivePage
mSetActivePage (me, tPageNum)
Parameters
Description
Changes the active page
mAddText
mAddText (me, tText, tX, tY, tW, tH, tSettings, tFormat)
Parameters
- tText {string}: can be plain text or html. To use html, pass ["html":1, ....] as tSettings parameter. See html.htm for supported HTML tags.
- tX {integer}
- tY {integer}
- tW {integer}
- tH {integer}: (optional)
- tSettings {propList}: (optional) propList of setting-values. See settings.htm for a list of supported values.
- tFormat {propList|string}: (optional) propList of setting-values or a CSS string. See format.htm and css.htm for lists of supported values.
Returns
{float}: y-position of text bottom
Description
Adds a text to the document at the specified position
mGetTextWidth
mGetTextWidth (me, tText, tSettings, tFormat)
Parameters
- tText {string}
- tSettings {propList}: (optional) propList of setting-values
- tFormat {propList|string}: (optional) propList of setting-values or a CSS string
Returns
{float}
Description
Returns width of string when printed with current/specified format
See also
mAddText
mAddImage
mAddImage (me, tImage, tX, tY, tW, tH, tSettings)
Parameters
- tImage {image}
- tX {integer}
- tY {integer}
- tW {integer}: (optional)
- tH {integer}: (optional)
- tSettings {propList}: (optional)
Description
Adds an image to the document at the specified position
mSetDrawColor
mSetDrawColor (me, tColor)
Parameters
Description
Sets the draw color
mSetFillColor
mSetFillColor (me, tColor)
Parameters
Description
Sets the fill color
mSetFillAlpha
mSetFillAlpha (me, tAlpha)
Parameters
- tAlpha {integer}: 0=transparent, 100=opaque
Description
Sets the fill alpha value
mSetTextFormat
mSetTextFormat (me, tFormat)
Parameters
- tFormat {propList}: propList of format-values (as flash-style); see format.htm for a list of supported values
Description
Sets the default text format for all text
mSetTextColor
mSetTextColor (me, tColor)
Parameters
Description
Sets the text color
mSetFont
mSetFont (me, tFont)
Parameters
Description
Sets the font
mSetFontSize
mSetFontSize (me, tFontSize)
Parameters
Description
Sets the fontsize
mSetLineStyle
mSetLineStyle (me, tLineStyle)
Parameters
- tLineStyle {propList}: supported properties: thickness:Number, rgb:Number, alpha:Number, pixelHinting:Boolean, noScale:String, capsStyle:String, jointStyle:String, miterLimit:Number
Description
Sets the linestyle
mAddLine
mAddLine (me, tX1, tY1, tX2, tY2, tLineGradProps)
Parameters
- tX1 {integer}
- tY1 {integer}
- tX2 {integer}
- tY2 {integer}
- tLineGradProps {propList}: (optional)
Description
Draws a line
mAddRect
mAddRect (me, tX, tY, tW, tH, tStyle, tLineGradProps, tFillGradProps)
Parameters
- tX {integer}
- tY {integer}
- tW {integer}
- tH {integer}
- tStyle {string}: (optional) "D" for draw (=default), "F" for fill, "DF" for both
- tLineGradProps {propList}: (optional)
- tFillGradProps {propList}: (optional)
Description
Draws a rect
mAddRoundedRect
mAddRoundedRect (me, tX, tY, tW, tH, tR, tStyle, tLineGradProps, tFillGradProps)
Parameters
- tX {integer}
- tY {integer}
- tW {integer}
- tH {integer}
- tR {integer}
- tStyle {string}: (optional) "D" for draw (=default), "F" for fill, "DF" for both
- tLineGradProps {propList}: (optional)
- tFillGradProps {propList}: (optional)
Description
Draws a rounded rect
mAddOval
mAddOval (me, tX, tY, tRX, tRY, tStyle, tLineGradProps, tFillGradProps)
Parameters
- tX {integer}
- tY {integer}
- tRX {integer}
- tRY {integer}: (optional)
- tStyle {string}: (optional) "D" for draw (=default), "F" for fill, "DF" for both
- tLineGradProps {propList}: (optional)
- tFillGradProps {propList}: (optional)
Description
Draws a circle or oval
mAddPoly
mAddPoly (me, tPoints, tStyle, tLineGradProps, tFillGradProps)
Parameters
- tPoints {list}: List of points
- tStyle {string}: (optional) "D" for draw (=default), "F" for fill, "DF" for both
- tLineGradProps {propList}: (optional)
- tFillGradProps {propList}: (optional)
Description
Draws a polygon
mAddCurve
mAddCurve (me, tPoints, tStyle, tLineGradProps, tFillGradProps)
Parameters
- tPoints {list}: List of points, alternately a control and an anchor point
- tStyle {string}: (optional) "D" for draw (=default), "F" for fill, "DF" for both
- tLineGradProps {propList}: (optional)
- tFillGradProps {propList}: (optional)
Description
Draws a quadratic bezier curve
mSetPagePrintAsBitmapMode
mSetPagePrintAsBitmapMode (me, tPageNum, tBool)
Parameters
- tPageNum {integer}
- tBool {integer}
Description
Explicitely sets the printMode for the specified page
mGetPreview
mGetPreview (me, tPageNum, tAddBorder)
Parameters
- tPageNum {integer}: pageNumber as integer
- tAddBorder {integer}: (optional) if specified and true, a 1px black border will be drawn around the page image
Returns
{image}
Description
Returns an image of the specified page (as 72 dpi)
mPrint
mPrint (me, tPrintAllPagesAsBitmap)
Parameters
- tPrintAllPagesAsBitmap {integer}: (optional) if specified, forces to print all pages as bitmap, ignoring the previous settings
Returns
{integer}: (1 or 0)
Description
Prints the current document
mHeader (me)
Description
This method is used to render the page header. It is automatically called by mAddPage() and should not be called directly by the application. The implementation in the PRINT class is empty, so you have to subclass it and override the method if you want a specific processing.
mFooter (me)
Description
This method is used to render the page footer. It is automatically called by mAddPage() and should not be called directly by the application. The implementation in the PRINT class is empty, so you have to subclass it and override the method if you want a specific processing.