-
Notifications
You must be signed in to change notification settings - Fork 5
Reference: XML attributes
###Color definition
By description: red,blue,brown,cyan ... (see reportlab\lib\colors.py)
By RGB (#RRGGBB): #DE22FF, #AA00CC, #123456
###Fonts Default Reportlab fonts are: Times-Roman, Courier, Helvetica, Symbol, ZapfDingbats
If you need to use additional fonts:
from reportlab.pdfbase.ttfonts import TTFont
arial_ttf = TTFont('Arial Black', 'ArialBD.TTF')
comic_ttf = TTFont('Comic', 'comic.TTF')
xml2pdf.genpdf(xml_filename, pdf_filename, fonts=[arial_ttf,comic_ttf])
-
make sure they are available on your system.
-
you might also need to configure reportlab to find your system fonts
-
Lastly, register the fonts within the genpdf(...fonts=[..,..,..]) call.
###background-color Background color
Example: background-color="red", background-color="#FFAABB"
###border Border thickness
Example: border="2.0", border="3.5"
###border-color Border color
Example: border-color="red", border-color="gray"
###bottom-padding The padding to be inserted bewteen the element and it's boundary rectangle defined by posx, posy, width, height.
__Example:__bottom-padding="2.0"
###class Specifies the style to be used to display the element. The style's name is to be used as value. If an attribute is specified in the element and in the class used by the element, the value specified in the element directly takes priority.
Example: class="normal_text"
###color The color of a graphical element
Example: color="red", color="#AABBCC"
###endx The ending x coordinate for an element
Example: endx="223"
###endy The ending y coordinate for an element
Example: endy="678"
###font The font name to be used.
Example: font="Courier"
###font-size The size of the font to be used.
Example: font-size="12"
###font-style This specifies a modifier for the font
Example: font-style="italic" (or "underline")
###font-weight This specifies if you want a bold typeface or not.
Example: font-weight="bold"
###height Specifies the Height of the element
Example: height="20"
###id This is an identifier for the tag element. It can be any alphanumeric string. It does not need to be unique within the xml file, and this id will always refer to the last tag element having this id.
Example: id="bigbox", id="textfield_001"
###left-padding The padding at the left of the text field rectangle boundary
Example: left-padding="5.0"
###orientation This specifies the orientation of the page
Example: orientation="portrait" (or "lanscape")
###pagesize This specifies the width and height of the page
Example: pagesize="612:792"
###posx This specifies the starting x coordinate
Example: posx="10"
###posy This specifies the starting x coordinate
Example: posy="711"
###rx The horizontal radius size for an ellipse. When rx=ry you get a circle.
Example: rx="134"
###ry The vertical radius size for an ellipse. When rx=ry you get a circle.
Example: rx="89"
###right-padding The padding at the right of the text field rectangle boundary
Example: right-padding="5.0"
###src The path to an image file.
Example: src="/home/john/pictures/vacation.jpg"
###snapto This allows to position an element relatively to another. If multiple elements have the same id, the last one declared will be used as the element we will position relatively to.
The attribute values should be of the form :
snapto="other_element_id|pos_this_element|pos_other_element"
In this way you can snap an element onto another one. Each corner of an element's rectangle boundary is NW, NE, SE, SW and C (center). Any combination of these 5 snap positions can be made to suit your needs.
When using this attribute, make sure:
-
the id of the element you wish to position this relatively to exists
-
do not specify posx, posy when wanting to position an element relative to another.
Example: snapto="bigbox|C|C" Also, click here for a detailed look at snapto.
###text-align Text alignment in a text element. Example: text-align="center" (or "right" or "left")
###top-padding The padding at the top of the text field's rectangle boundary Example: top-padding="4.0"
###transform This attribute is used only with the rltransform tag. It is of the form : transform = "rotate:degrees" or ... = "translate:tx:ty" or ... = "scale:multx:multy"
Example: transform="rotate:-45" or transform="translate:100:25" or transform="scale:-1.0:2.0"
###width Width of a rectangle boundary of an element
Example: width="175.2"
###wrap Used in a text field element (p) to specify word wrap.
Example: wrap="1"