Add support for page layout settings in builds
This commit is contained in:
@@ -147,7 +147,7 @@ class ToOdt(Tokenizer):
|
||||
self._dLanguage = "en"
|
||||
self._dCountry = "GB"
|
||||
|
||||
# Text Margings in Units of em
|
||||
# Text Margings
|
||||
self._mTopTitle = "0.423cm"
|
||||
self._mTopHead1 = "0.423cm"
|
||||
self._mTopHead2 = "0.353cm"
|
||||
@@ -166,11 +166,13 @@ class ToOdt(Tokenizer):
|
||||
self._mBotText = "0.247cm"
|
||||
self._mBotMeta = "0.106cm"
|
||||
|
||||
# Document Margins
|
||||
self._mDocTop = "2.000cm"
|
||||
self._mDocBtm = "2.000cm"
|
||||
self._mDocLeft = "2.000cm"
|
||||
self._mDocRight = "2.000cm"
|
||||
# Document Size and Margins
|
||||
self._mDocWidth = "21.0cm"
|
||||
self._mDocHeight = "29.7cm"
|
||||
self._mDocTop = "2.000cm"
|
||||
self._mDocBtm = "2.000cm"
|
||||
self._mDocLeft = "2.000cm"
|
||||
self._mDocRight = "2.000cm"
|
||||
|
||||
# Colour
|
||||
self._colHead12 = None
|
||||
@@ -200,6 +202,19 @@ class ToOdt(Tokenizer):
|
||||
self._colourHead = state
|
||||
return
|
||||
|
||||
def setPageLayout(
|
||||
self, width: int | float, height: int | float,
|
||||
top: int | float, bottom: int | float, left: int | float, right: int | float
|
||||
):
|
||||
"""Set the document page size and margins in millimetres."""
|
||||
self._mDocWidth = f"{width/10.0:.3f}cm"
|
||||
self._mDocHeight = f"{height/10.0:.3f}cm"
|
||||
self._mDocTop = f"{top/10.0:.3f}cm"
|
||||
self._mDocBtm = f"{bottom/10.0:.3f}cm"
|
||||
self._mDocLeft = f"{left/10.0:.3f}cm"
|
||||
self._mDocRight = f"{right/10.0:.3f}cm"
|
||||
return
|
||||
|
||||
##
|
||||
# Class Methods
|
||||
##
|
||||
@@ -721,10 +736,13 @@ class ToOdt(Tokenizer):
|
||||
xPage = ET.SubElement(self._xAut2, _mkTag("style", "page-layout"), attrib=tAttr)
|
||||
|
||||
tAttr = {}
|
||||
tAttr[_mkTag("fo", "page-width")] = self._mDocWidth
|
||||
tAttr[_mkTag("fo", "page-height")] = self._mDocHeight
|
||||
tAttr[_mkTag("fo", "margin-top")] = self._mDocTop
|
||||
tAttr[_mkTag("fo", "margin-bottom")] = self._mDocBtm
|
||||
tAttr[_mkTag("fo", "margin-left")] = self._mDocLeft
|
||||
tAttr[_mkTag("fo", "margin-right")] = self._mDocRight
|
||||
tAttr[_mkTag("fo", "print-orientation")] = "portrait"
|
||||
ET.SubElement(xPage, _mkTag("style", "page-layout-properties"), attrib=tAttr)
|
||||
|
||||
xHead = ET.SubElement(xPage, _mkTag("style", "header-style"))
|
||||
|
||||
Reference in New Issue
Block a user