pdf4tcl(n) 0.3 pdf4tcl "Pdf document generation"
pdf4tcl - Pdf document generation
TABLE OF CONTENTS
SYNOPSIS
DESCRIPTION
PUBLIC API
PACKAGE COMMANDS
OBJECT COMMAND
OBJECT METHODS
OBJECT CONFIGURATION
PAGE CONFIGURATION
EXAMPLES
SEE ALSO
KEYWORDS
COPYRIGHT
package require Tcl 8.4
package require snit
package require pdf4tcl ?0.3?
This package provides a container class for
generating pdf documents.
- ::pdf4tcl::new objectName ?option value...?
-
This command creates a new pdf4tcl object with an associated Tcl
command whose name is objectName. This object command is
explained in full detail in the sections OBJECT COMMAND
and OBJECT METHODS. The object command will be created
under the current namespace if the objectName is not fully
qualified, and in the specified namespace otherwise.
If objectName is %AUTO% a name will generated.
The return value is the newly created object's name.
The options and their values coming after the name of the object are
used to set the initial configuration of the object.
See OBJECT CONFIGURATION.
- ::pdf4tcl::getPaperSize paper
-
This call returns the size of a named paper type, e.g. "a4".
Paper names are case insensitive.
The argument paper may also be a two element list
with values as accepted by ::pdf4tcl::getPoints.
The return value is a list with width and height in points.
- ::pdf4tcl::getPaperSizeList
-
This call returns the list of known paper types.
- ::pdf4tcl::getPoints val
-
This call translates a measurement to points (1/72 inch).
The format of val is 'num ?unit?' where
num is a valid integer or double. unit may be one of
mm, cm, or i. If no unit
is given, the value is interpreted as points.
All commands created by ::pdf4tcl::new have the following
general form and may be used to invoke various operations on their
pdf object.
- objectName method ?arg arg ...?
-
The method method and its arg'uments determine the exact
behavior of the command. See section OBJECT METHODS for
the detailed specifications.
- objectName configure
-
The method returns a list of all known options and their current
values when called without any arguments.
- objectName configure option
-
The method behaves like the method cget when called with a
single argument and returns the value of the option specified by said
argument.
- objectName configure -option value...
-
The method reconfigures the specified options of the object,
setting them to the associated values, when called with an even
number of arguments, at least two.
The legal options are described in the section
OBJECT CONFIGURATION.
- objectName cget -option
-
This method expects a legal configuration option as argument and will
return the current value of that option for the object the method was
invoked for.
The legal configuration options are described in section
OBJECT CONFIGURATION.
- objectName destroy
-
This method destroys the object it is invoked for.
If the -file option was given at object creation,
the output file will be finished and closed.
- objectName startPage ?option value...?
-
This method starts a new page in the document. The page will have the
default page settings for the document unless overridden by option.
See PAGE CONFIGURATION for page settings.
- objectName endPage
-
This method ends a page in the document.
- objectName finish
-
This method ends the document.
This will do endPage if needed.
If the -file option was given at object creation,
the output file will be finished and closed.
- objectName get
-
This method returns the generated pdf.
This will do endPage and finish if needed.
If the -file option was given at object creation, nothing is returned.
- objectName write ?-file filename?
-
This method writes the generated pdf to the given filename.
If no filename is given, it is written to stdout.
This will do endPage and finish if needed.
If the -file option was given at object creation, an empty file
is created.
- objectName getDrawableArea
-
This method returns the size of the available area on the page,
after removing margins. The return value is a list of width and height,
in points.
- objectName setFont size ?fontname?
-
This method sets the font used by text drawing routines.
- objectName getStringWidth str
-
This method returns the width of a string under the current font.
- objectName getCharWidth char
-
This method returns the width of a character under the current font.
- objectName setTextPosition x y
-
Set coordinate for next text command.
- objectName newLine
-
Moves text coordinate one line down and resets x to where the latest
setTextPosition was.
- objectName drawText str
-
Draw text.
- objectName text str ?option value...?
-
Draw text.
- objectName drawTextAt x y str ?option value...?
-
Draw text. Deprecated. Use text.
- objectName drawTextBox x y width height str ?option value...?
-
Draw text.
- objectName beginTextObj
-
- objectName endTextObj
-
- objectName closePath
-
- objectName moveTo x y
-
- objectName putImage id x y args
-
- objectName addJpeg filename id
-
- objectName getFontMetric metric
-
- objectName rotateText angle
-
- objectName setBgColor red green blue
-
- objectName setFillColor red green blue
-
- objectName setStrokeColor red green blue
-
- objectName skewText xangle yangle
-
- objectName setLineStyle width args
-
- objectName line x1 y1 x2 y2
-
- objectName qCurve x1 y1 xc yc x2 y2
-
- objectName polygon isfilled ?x y...?
-
- objectName circle isfilled x y radius
-
- objectName arc x y radius phi extend
-
- objectName arrow x1 y1 x2 y2 size ?angle?
-
- objectName rectangle x y width height ?option value...?
-
All 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:
- -compress boolean
-
Pages will be zlib compressed if this option is set to true.
This requires the presence of the zlib package.
This option can only be set at object creation.
- -file filename
-
Continuously write pdf to filename instead of storing it
in memory.
This option can only be set at object creation.
- -paper name
-
The argument of this option defines the paper size.
The paper size may be a string like "a4", where valid values
are available through ::pdf4tcl::getPaperSizeList.
Paper size may also be a two element list specifying width and height.
The default value of this option is "a4".
- -landscape boolean
-
If true, paper width and height are switched.
The default value of this option is false.
- -orient boolean
-
If true, the y axis of the coordinate system is inverted.
Normally origo is in the top left corner. With -orient true,
origo is in the bottom left corner.
The default value of this option is false.
- -margin values
-
The margin is a one, two or four element list of margins.
For one element, it specifies all margins.
Two elements specify left/right and top/bottom.
Four elements specify left, right, top and bottom.
The default value of this option is zero.
|
pdf4tcl::new mypdf -paper a3
mypdf startPage
mypdf setFont 12 Courier
mypdf drawTextAt 50 50 "Hejsan"
mypdf write -file mypdf.pdf
mypdf destroy
|
doctools
document, pdf
Copyright © 2007 Peter Spjuth