|
NAMEpdf4tcl - Pdf document generationSYNOPSISpackage require Tcl 8.4package require ?dict? package require snit package require pdf4tcl ?0.8? ::pdf4tcl::new objectName ?option value...? ::pdf4tcl::getPaperSize paper ::pdf4tcl::getPaperSizeList ::pdf4tcl::getPoints val ::pdf4tcl::loadBaseTrueTypeFont basefontname ttf_file_name ::pdf4tcl::createBaseTrueTypeFont basefontname ttf_data ::pdf4tcl::loadBaseType1Font basefontname AFM_file_name PFB_file_name ::pdf4tcl::createBaseType1Font basefontname AFM_data PFB_data ::pdf4tcl::createFont basefontname fontname encoding_name ::pdf4tcl::createFontSpecEnc basefontname fontname subset objectName method ?arg arg ...? objectName configure objectName configure option objectName configure -option value... objectName cget -option objectName destroy objectName startPage ?option value...? objectName endPage objectName finish objectName get objectName write ?-file filename? objectName getDrawableArea objectName canvas path ?option value...? objectName metadata ?option value...? objectName bookmarkAdd ?option value...? objectName setFont size ?fontname? objectName getStringWidth str objectName getCharWidth char objectName setTextPosition x y objectName moveTextPosition dx dy objectName getTextPosition objectName newLine ?spacing? objectName setLineSpacing spacing objectName getLineSpacing objectName text str ?option value...? objectName drawTextBox x y width height str ?option value...? objectName getFontMetric metric objectName putImage id x y ?option value...? objectName putRawImage data x y ?option value...? objectName addImage filename ?option value...? objectName addRawImage data ?option value...? objectName getImageHeight id objectName getImageSize id objectName getImageWidth id objectName setBgColor red green blue objectName setFillColor red green blue objectName setStrokeColor red green blue objectName setLineWidth width objectName setLineDash ?on off...? ?offset? objectName setLineStyle width args objectName line x1 y1 x2 y2 objectName curve x1 y1 x2 y2 x3 y3 ?x4 y4? objectName polygon ?x y...? ?option value...? objectName circle x y radius ?option value...? objectName oval x y radiusx radiusy ?option value...? objectName arc x y radiusx radiusy phi extend ?option value...? objectName arrow x1 y1 x2 y2 size ?angle? objectName rectangle x y width height ?option value...? DESCRIPTIONThis package provides a container class for generating pdf documents.COORDINATESAll coordinates and distances can be expressed with or without a unit. See UNITS for valid units. When the page is configured with -orient set to false, origin is in the bottom left corner. With -orient true (the default), origin is in the top left corner. Origin is displaced to account for margins, i.e. if margins are 100, the user coordinate (0,0) corresponds to (100,100) on the paper. Page option -orient can also affect the anchor point for things like images.UNITSAny coordinates and distances can be expressed with or without an explicit unit. If no unit is given, the default unit for the document is used. A unit may be one of mm (millimeter), m (millimeter), cm (centimeter), c (centimeter), p (points) or i (inches). Commands returning coordinates or distances always return a double value in the document's default unit.PUBLIC APIPACKAGE COMMANDS
pdf4tcl::loadBaseTrueTypeFont BaseArial "arial.ttf" pdf4tcl::createFont BaseArial MyArial cp1251 pdf4tcl::loadBaseType1Font BaseType1 "a010013l.afm" "a010013l.pfb" pdf4tcl::createFont BaseType1 MyType1 cp1251 pdf4tcl::new mypdf -paper a4 -compress 1 mypdf startPage mypdf setFont 10 MyArial set txt "\u042D\u0442\u043E \u0442\u0435\u043A\u0441\u0442 \u043D\u0430 \u0440\u0443\u0441\u0441\u043A\u043E\u043C \u044F\u0437\u044B\u043A\u0435. This is text in Russian." mypdf text $txt -bg #CACACA -x 50 -y 100 mypdf setFont 10 MyType1 mypdf text $txt -x 50 -y 200 mypdf write -file fonts.pdf mypdf destroy
OBJECT COMMANDAll commands created by ::pdf4tcl::new have the following general form and may be used to invoke various operations on their pdf object.
OBJECT METHODS
OBJECT METHODS, PAGE
OBJECT METHODS, TEXT
OBJECT METHODS, IMAGESA limited set of image formats are directly understood by pdf4tcl, currently JPEG and some PNG formats. To use unsupported formats, use Tk and the Img package to load and dump images to raw format which can be fed to putRawImage and addRawImage.
image create photo img1 -file image.gif set imgdata [img1 data] mypdf putRawImage $imgdata 60 20 -height 40
image create photo img1 -file image.gif set imgdata [img1 data] set id [mypdf addRawImage $imgdata] mypdf putImage $id 20 60 -width 100
OBJECT METHODS, COLORSColors can be expressed in various formats. First, as a three element list of values in the range 0.0 to 1.0. Second, in the format #XXXXXX where the Xes are two hexadecimal digits per color value. Third, if Tk is available, any color accepted by winfo rgb is accepted.
OBJECT METHODS, GRAPHICS
OBJECT CONFIGURATIONAll pdf4tcl objects understand the options from PAGE CONFIGURATION, which defines default page settings when used with a pdf4tcl object. The objects also understand the following configuration options:
PAGE CONFIGURATION
EXAMPLESpdf4tcl::new mypdf -paper a3 mypdf startPage mypdf setFont 12 Courier mypdf text "Hejsan" -x 50 -y 50 mypdf write -file mypdf.pdf mypdf destroy SEE ALSOdoctoolsKEYWORDSdocument, pdfCOPYRIGHTCopyright (c) 2007-2011 Peter Spjuth Copyright (c) 2009 Yaroslav Schekin
Visit the GSP FreeBSD Man Page Interface. |