Produkty
XFRX
Download Demo Objednávka Manuál Licence
PDF Library
Download
Demo
Objednávka
Manuál
Licence
PDM
Kontakt
|
PDFL - Manual
Navigation: Installation | Using PDFL | PDFL class methods |
Modifying pages generated by XFRX
Installation
Unzip the zip archive. For a quick preview of the capabilities look at
DEMOPDFL.PRG. The utility consists of three files:
- XFRX.APP - the XFRX and PDFL application
- HNDLIB.DLL - dynamic library. This library must be in the same directory as XFRX.APP
- ZLIB.DLL - freeware compression utility, see http://www.zlib.org for more info
Using PDFL
| |
At the beginning, the PDFL object has to be created:
loDocument=evaluate([XFRX("PDFL#INIT")])
When using PDFL together with XFRX to mix VFP reports with pages generated from
code, use AttachToPDFDocument() method of the XFRXSession object to attach to the existing document. Send the XFRXSession object as a parameter:
loDocument.attachToPDFDocument(loXFRXSession)
When using PDFL independently, call createDocument method with a file name as a parameter to create a new PDF file:
loDocument.createDocument("output.pdf")
Call newPage() at the beginning and endPage() at the end of each page. NewPage() has to be called before any objects (text, lines) are added
to the document.
When using PDFL independently, call finishDocument() method to close the document:
loDocument.finishDocument()
Never call finishDocument() when running PDFL together with XFRX.
|
PDFL class methods
| |
Document structure
createDocument(tcFileName)
| |
Creates a new pdf document, using the filename in the parameter. If the file cannot be created, -1 is returned, otherwise 0 is returned.
|
newPage(tnWidth, tnHeight)
| |
A new page, wide, high, is added to the document.
|
newPage(tcPaperSize)
| |
Altenatively, you can define the paper size by sending "A4" or "letter" as the parameter. "letter" is the default value.
|
endPage()
| |
Ends the current page. Each page has to be ended before the document can be finished.
|
finishDocument()
| |
Finishes the document cration. The PDF file is created.
|
Document content
Setting colors
setForeColor(tnRed, tnGreen, tnBlue)
| |
Sets the foregroung color
|
setBackColor(tnRed, tnGreen, tnBlue)
| |
Sets the background color
|
setColor(tnForeRed, tnForeGreen, tnForeBlue, tnBackRed, tnBackGreen, tnBackBlue)
| |
Sets foreground and background color
|
Drawing text
setFont(tcFontName, tnFontSize, tlBold, tlItalic)
| |
Sets a font for further usage
|
setPos(tnXpos, tnYpos)
| |
Sets the drawing position
|
outText(tcText)
| |
Prints the string in parameter. The drawing position advances to the right accordingly
|
newLine()
| |
Moves the drawing position to the next line
|
Basic shapes
addLine(tnXPos1, tnYPos1, tnXPos2, tnYPos2, tnLineWidth, lnPattern)
| |
Draws a line from [tnXPos1, tnYPos1] to [tnXPos2, tnYPos2]. inLineWidth is a
line width in pixels, 0 is a hairline width.
lnPattern controls the line dash pattern:
1 ... dotted
2 ... dashed
3 ... dash-dot
4 ... dash-dot-dot
|
addBox(tnXPos, tnYPos, tnWidth, tnHeight, tnLineWidth, tnFill, tnPenPattern, tnRoundFactor)
| |
draws a rectangle at tnXPos, tyYpos, tnWidth wide, tnHeight high.
tnFill:
0 ... not filled
1 ... filled
tnPenPattern:
0 ... no border
1 ... dotted
2 ... dashed
3 ... dash-dot
4 ... dash-dot-dot
tnRoundFactor:
0 ... no rouding. The higher value is sended the more rounded the corners are. 99 prints an ellipse.
|
Using drawing paths
startPath(tnXPos, tnYpos)
| |
Begins a new path at [tnXpos, tnYpos]
|
appendLine(tnXpos, tnYpos)
| |
Appends a straight line from the current point to [tnXpos, tnYpos]
|
appendBezier(tnXpos1, tnYpos1, tnXpos2, tnYpos2, tnXpos3, tnYpos3)
| |
Appends a cubic Bezier curve from the current point to [tnXpos3, tnYpos3], using [tnXpos1, tnYpos1] and [tnXpos2, tnYpos2] as the Bézier control points.
|
closePath()
| |
Closes the path by appending a straight line from the current point to the starting point of the path.
|
stroke()
fill()
strokeandfill()
| |
Strokes and fills the path.
|
Adding pictures
addPicture(tcFileName, tnXpos, tnYpos, tnWidth, tnHeight, tnAdjType)
| |
Paints a picture located in a file. Only BMP and JPG files are supported.
tnAdjType:
1 ... stretch picture, retain shape
2 ... stretch picture, fill frame
|
|
Modifying pages generated by XFRX
| |
You can use PDF Library to add any custom graphics (e.g. watermarks) and/or text to the pages generated by XFRX. You can also add new pages between the report pages. To do this, you need to create procedures with PDFL commands (PDFL scripts) and tell XFRX when to invoke these procedures:
- Create PDFL object
loDocument=evaluate([XFRX("PDFL#INIT")])
- And attach it to the existing XFRX session:
loDocument.attachToPDFDocument(loXFRXSession)
- Create an instance of PDFLScripts class. Use the PDFL object as a parameter of the init method. The rest of the class methods
are the PDFL Scripts.
loScr = createobject("PDFLScripts",loDocument)
The class definition with one simple script can look like this:
define class PDFLScripts as custom
oPDFLDocument = null
procedure init
lpara toPDFLDocument
this.oPDFLDocument = toPDFLDocument
procedure script1
this.oPDFLDocument.addPicture("xfrx.jpg",10,673,300,500,2)
endproc
enddef
- Now we need to tell XFRX when (on which pages) to invoke the script(s). For each script, call loXFRXSession.registerPDFLScript() method:
loXFRXSession.registerPDFLScript(toScriptObject,tcMethodName,tnZIndex,tcScope,
tnPageNumberingType)
| toScriptObject | The PDFLScripts object reference |
| tcMethodName | The name of the method containing the script |
| tnZIndex | 0 ... print below (before) the report page, 1 ... print above (after) the report page |
| tcScope | Defines which pages to invoke the scripts on. Can contain "ALL", "ODD", "EVEN" and numbers delimited with commas. Hyphens can be used to define the from-to scope. Examples: "ODD", "1,5-19", "ODD,4,8" |
| tnPageNumberingType | Defines how XFRX determines the page number:
0 ... absolute - the page number in the document,
1 ... relative - the page number in the current report,
2 ... the value of _PAGENO |
Example:
loXFRXSession.registerPDFLScript(loScr,"script1",0,"ALL",0)
- Whenever you print out text from the script, call oPDFLDocument.manageText() at the end of the script.
- You can register as many scripts as you need. To unregister all scripts, call
loXFRXSession.unregisterAllPDFLScripts()
Please check the sample application that comes with XFRX to see a complete example of this.
|
|
|