How to use the xhtml2pdf.util.set_value function in xhtml2pdf

To help you get started, we’ve selected a few xhtml2pdf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xhtml2pdf / xhtml2pdf / tests / test_utils.py View on Github external
def test_set_value(self):

        a = self.A()
        b = self.B(20, 30)
        c = self.C()
        set_value(a, ["attr", "attr1"], 8)
        set_value(b, ["attr", "attr1"], 8)
        set_value(c, ["attr", "attr1"], 8)

        self.assertEqual(a.attr, 8)
        self.assertEqual(a.attr1, 8)
        self.assertEqual(b.attr, 8)
        self.assertEqual(b.attr1, 8)
        self.assertEqual(c.attr, 8)
        self.assertEqual(c.attr1, 8)
github xhtml2pdf / xhtml2pdf / tests / test_utils.py View on Github external
def test_set_value(self):

        a = self.A()
        b = self.B(20, 30)
        c = self.C()
        set_value(a, ["attr", "attr1"], 8)
        set_value(b, ["attr", "attr1"], 8)
        set_value(c, ["attr", "attr1"], 8)

        self.assertEqual(a.attr, 8)
        self.assertEqual(a.attr1, 8)
        self.assertEqual(b.attr, 8)
        self.assertEqual(b.attr1, 8)
        self.assertEqual(c.attr, 8)
        self.assertEqual(c.attr1, 8)
github xhtml2pdf / xhtml2pdf / xhtml2pdf / context.py View on Github external
def getParaFrag(style):
    frag = ParaFrag()

    set_value(frag,
              ('sub', 'super', 'rise', 'underline', 'strike', 'greek',
               'leading', 'leadingSpace', 'spaceBefore',
               'spaceAfter', 'leftIndent', 'rightIndent', 'firstLineIndent',
               'borderPadding', 'paddingLeft', 'paddingRight',
               'paddingTop', 'paddingBottom', 'bulletIndent',
               'insideStaticFrame', 'outlineLevel'
               ),
              0)

    set_value(frag,
              ('backColor', 'vAlign', 'link', 'borderStyle',
               'borderColor', 'listStyleType', 'listStyleImage',
               'wordWrap', 'height', 'width', 'bulletText'
               ),
              None
              )
github xhtml2pdf / xhtml2pdf / xhtml2pdf / tables.py View on Github external
def set_borders(self, frag, attrs):

        set_value(frag,
                  ('borderLeftColor', 'borderRightColor', 'borderTopColor',
                   'borderBottomColor'), attrs.bordercolor)

        set_value(frag,
                  ('borderLeftWidth', 'borderRightWidth', 'borderTopWidth',
                   'borderBottomWidth'),
                  attrs.border)
        set_value(frag,
                  ('borderBottomStyle', 'borderLeftStyle', 'borderTopStyle',
                   'borderRightStyle'),
                  "solid"
                  )
github xhtml2pdf / xhtml2pdf / xhtml2pdf / tables.py View on Github external
tdata.add_style(('LEADING', begin, end, 1.0))

        # Vertical align
        valign = self.attr.valign or c.frag.vAlign
        if valign is not None:
            tdata.add_style(('VALIGN', begin, end, valign.upper()))

        # Reset border, otherwise the paragraph block will have borders too
        frag = c.frag

        set_value(frag,
                  ('borderLeftWidth', 'borderRightWidth',
                   'borderTopWidth', 'borderBottomWidth'),
                  0)

        set_value(frag,
                  ('borderLeftColor', 'borderLeftStyle', 'borderRightColor',
                   'borderRightStyle', 'borderTopColor', 'borderTopStyle',
                   'borderBottomColor', 'borderBottomStyle'),
                  None
                  )
github xhtml2pdf / xhtml2pdf / xhtml2pdf / context.py View on Github external
def __init__(self, path, debug=0, capacity=-1):
        self.fontList = copy.copy(xhtml2pdf.default.DEFAULT_FONT)
        set_value(self,
                  ('path', 'story', 'text', 'log', 'frameStaticList',
                   'pisaBackgroundList', 'frameList', 'anchorFrag',
                   'anchorName', 'fragList', 'fragAnchor', 'fragStack'
                   ), [],  _copy=True)

        set_value(self, ('node', 'indexing_story',
                         'template', 'keepInFrameIndex',
                         'tableData', 'image'),
                  None)
        set_value(self, ('err', 'warn', 'uidctr', 'listCounter'), 0)
        set_value(self, ('text', 'cssText', 'cssDefaultText'), "")
        set_value(self, ('templateList', 'frameStatic', 'imageData'),
                  {}, _copy=True)

        self.capacity = capacity
        self.toc = PmlTableOfContents()
        self.multiBuild = False
        self.pageSize = A4
        self.baseFontSize = getSize("12pt")
        self.frag = self.fragBlock = getParaFrag(
            ParagraphStyle('default%d' % self.UID()))
        self.fragStrip = True
        self.force = False

        # External callback function for path calculations
        self.pathCallback = None
github xhtml2pdf / xhtml2pdf / xhtml2pdf / context.py View on Github external
'leading', 'leadingSpace', 'spaceBefore',
               'spaceAfter', 'leftIndent', 'rightIndent', 'firstLineIndent',
               'borderPadding', 'paddingLeft', 'paddingRight',
               'paddingTop', 'paddingBottom', 'bulletIndent',
               'insideStaticFrame', 'outlineLevel'
               ),
              0)

    set_value(frag,
              ('backColor', 'vAlign', 'link', 'borderStyle',
               'borderColor', 'listStyleType', 'listStyleImage',
               'wordWrap', 'height', 'width', 'bulletText'
               ),
              None
              )
    set_value(frag,
              ('pageNumber', 'pageCount', 'outline',
               'outlineOpen', 'keepWithNext'),
              False)

    frag.text = ""
    frag.fontName = "Times-Roman"
    frag.fontName, frag.bold, frag.italic = ps2tt(style.fontName)
    frag.fontSize = style.fontSize
    frag.textColor = style.textColor

    # Extras
    frag.letterSpacing = "normal"
    frag.leadingSource = "150%"
    frag.alignment = TA_LEFT
    frag.borderWidth = 1
github xhtml2pdf / xhtml2pdf / xhtml2pdf / tables.py View on Github external
def set_borders(self, frag, attrs):

        set_value(frag,
                  ('borderLeftColor', 'borderRightColor', 'borderTopColor',
                   'borderBottomColor'), attrs.bordercolor)

        set_value(frag,
                  ('borderLeftWidth', 'borderRightWidth', 'borderTopWidth',
                   'borderBottomWidth'),
                  attrs.border)
        set_value(frag,
                  ('borderBottomStyle', 'borderLeftStyle', 'borderTopStyle',
                   'borderRightStyle'),
                  "solid"
                  )