How to use the xhtml2pdf.paragraph2.Text 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 / xhtml2pdf / paragraph2.py View on Github external
def test():
        doc = SimpleDocTemplate("test.pdf")
        story = []

        style = Style(fontName="Helvetica", textIndent=24.0)
        fn = style["fontName"]
        fs = style["fontSize"]
        sampleText1 = createText(TEXT[:100], fn, fs)
        sampleText2 = createText(TEXT[100:], fn, fs)

        text = Text(sampleText1 + makeSpecial(fn, fs) + sampleText2)

        story.append(Paragraph(
            copy.copy(text),
            style,
            debug=0))

        if 0:  # FIXME: Why is this here?
            for i in range(10):
                style = copy.deepcopy(style)
                style["textAlign"] = ALIGNMENTS[i % 4]
                text = createText(("(%d) " % i) + TEXT, fn, fs)
                story.append(Paragraph(
                    copy.copy(text),
                    style,
                    debug=0))
github xhtml2pdf / xhtml2pdf / xhtml2pdf / paragraph2.py View on Github external
def split(self, availWidth, availHeight):
        """
        Split ourself in two paragraphs.
        """

        if self.debug:
            print ("*** split (%f, %f)") % (availWidth, availHeight)

        splitted = []
        if self.splitIndex:
            text1 = self.text[:self.splitIndex]
            text2 = self.text[self.splitIndex:]
            p1 = Paragraph(Text(text1), self.style, debug=self.debug)
            p2 = Paragraph(Text(text2), self.style, debug=self.debug, splitted=True)
            splitted = [p1, p2]

            if self.debug:
                print ("*** text1 %s / text %s") % (len(text1), len(text2))

        if self.debug:
            print ('*** return %s') % self.splitted

        return splitted
github xhtml2pdf / xhtml2pdf / xhtml2pdf / paragraph2.py View on Github external
def split(self, availWidth, availHeight):
        """
        Split ourself in two paragraphs.
        """

        if self.debug:
            print ("*** split (%f, %f)") % (availWidth, availHeight)

        splitted = []
        if self.splitIndex:
            text1 = self.text[:self.splitIndex]
            text2 = self.text[self.splitIndex:]
            p1 = Paragraph(Text(text1), self.style, debug=self.debug)
            p2 = Paragraph(Text(text2), self.style, debug=self.debug, splitted=True)
            splitted = [p1, p2]

            if self.debug:
                print ("*** text1 %s / text %s") % (len(text1), len(text2))

        if self.debug:
            print ('*** return %s') % self.splitted

        return splitted
github xhtml2pdf / xhtml2pdf / xhtml2pdf / paragraph2.py View on Github external
def createText(data, fn, fs):
        text = Text(list(textGenerator(data, fn, fs)))
        return text
github xhtml2pdf / xhtml2pdf / xhtml2pdf / paragraph2.py View on Github external
def test2():
        # text = Text(list(textGenerator(TEXT, "Times-Roman", 10)))
        text = Text(makeSpecial())
        text.calc()
        print (text[1].type)
        while 1:
            width, br, group = text.getGroup()
            if not group:
                print ("ENDE", repr(group))
                break
            print (width, br, " ".join([str(x) for x in group]))