def style(self): width = self.page_width / POINTS_PER_EM styles = { 'body': { 'width': '%.2fem' % width, 'margin': '0px auto', } } result = [] for name, definition in sorted(PYDOCX_STYLES.items()): result.append('.pydocx-%s {%s}' % ( name, convert_dictionary_to_style_fragment(definition), )) for name, definition in sorted(styles.items()): result.append('%s {%s}' % ( name, convert_dictionary_to_style_fragment(definition), )) return self.make_element( tag='style', contents=''.join(result), )
def indent( self, text, alignment=None, firstLine=None, left=None, right=None, ): attrs = {} if alignment: attrs['class'] = 'pydocx-%s' % alignment style = {} if firstLine: firstLine = self._convert_measurement(firstLine) style['text-indent'] = '%.2fem' % firstLine if left: left = self._convert_measurement(left) style['margin-left'] = '%.2fem' % left if right: right = self._convert_measurement(right) style['margin-right'] = '%.2fem' % right if style: attrs['style'] = convert_dictionary_to_style_fragment(style) return self.make_element( tag='span', contents=text, attrs=attrs, )