• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python testutils.outputfile函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中reportlab.lib.testutils.outputfile函数的典型用法代码示例。如果您正苦于以下问题:Python outputfile函数的具体用法?Python outputfile怎么用?Python outputfile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了outputfile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test0

    def test0(self, isFast=0):
        """Hello World, on a rectangular background.

        The rectangle's fillColor is yellow.
        The string's fillColor is red.
        """
        reportlab.rl_config.shapeChecking = not isFast

        pdfPath = outputfile('test_graphics_speed_fast.pdf')
        c = Canvas(pdfPath)
        t0 = time.time()

        d = Drawing(400, 200)
        num = 100
        for i in range(num):
            pc = Pie()
            pc.x = 150
            pc.y = 50
            pc.data = [10,20,30,40,50,60]
            pc.labels = ['a','b','c','d','e','f']
            pc.slices.strokeWidth=0.5
            pc.slices[3].popout = 20
            pc.slices[3].strokeWidth = 2
            pc.slices[3].strokeDashArray = [2,2]
            pc.slices[3].labelRadius = 1.75
            pc.slices[3].fontColor = colors.red
            d.add(pc)
        d.drawOn(c, 80, 500)

        t1 = time.time()

        result = 'drew %d pie charts in %0.4f' % (num, t1 - t0)
        open(outputfile('test_graphics_speed_test%s.log' % (isFast+1)), 'w').write(result)
开发者ID:B-Rich,项目名称:M2M,代码行数:33,代码来源:test_graphics_speed.py


示例2: test1

    def test1(self):
        c=canvas.Canvas(outputfile('test_pdfgen_obscure.pdf'))
        c.setViewerPreference('PrintScaling','None')
        c.setViewerPreference('HideToolbar','true')
        c.setViewerPreference('HideMenubar','true')
        c.addPageLabel(0, prefix="Front")
        c.addPageLabel(1, style='ROMAN_LOWER', start=2)
        c.addPageLabel(8, style='ARABIC')
        # (These are fixes for missing pages)
        c.addPageLabel(11, style='ARABIC',start=6)
        c.addPageLabel(17, style='ARABIC', start=14)
        c.addPageLabel(21, style='ARABIC', start=22)
        #check that duplicate page start will not cause sort error in python 3.x
        c.addPageLabel(98, style='ROMAN_LOWER', start=99, prefix='r')
        c.addPageLabel(98, style='ARABIC', start=99, prefix='A')
        c.addPageLabel(99, style='LETTERS_UPPER')
        c.addPageLabel(102, prefix="Back",start=1)

        # Make some (mostly) empty pages
        for i in range(113):
            c.drawString(100, 100, 'This is page '+str(i))
            c.showPage()

        # Output the PDF
        c.save()
开发者ID:Distrotech,项目名称:reportlab,代码行数:25,代码来源:test_pdfgen_general.py


示例3: test1

    def test1(self):
        "This makes several special paragraphs."

        # Build story.
        story = []
        styleSheet = getSampleStyleSheet()
        bt = styleSheet["BodyText"]
        btN = ParagraphStyle("BodyTextTTNone", parent=bt, textTransform="none")
        btL = ParagraphStyle("BodyTextTTLower", parent=bt, textTransform="lowercase")
        btU = ParagraphStyle("BodyTextTTUpper", parent=bt, textTransform="uppercase")
        btC = ParagraphStyle("BodyTextTTCapitalize", parent=bt, textTransform="capitalize")
        story.append(Paragraph("""This should be ORDINARY text.""", style=bt))
        story.append(Paragraph("""This should be ORDINARY text.""", style=btN))
        story.append(Paragraph("""This should be LOWER text.""", style=btL))
        story.append(Paragraph("""This should be upper text.""", style=btU))
        story.append(Paragraph("""This should be cAPITALIZED text.""", style=btC))

        story.append(Paragraph("""T<i>hi</i>s shoul<font color="red">d b</font>e <b>ORDINARY</b> text.""", style=bt))
        story.append(Paragraph("""T<i>hi</i>s shoul<font color="red">d b</font>e <b>ORDINARY</b> text.""", style=btN))
        story.append(Paragraph("""T<i>hi</i>s shoul<font color="red">d b</font>e <b>LOWER</b> text.""", style=btL))
        story.append(Paragraph("""T<i>hi</i>s shoul<font color="red">d b</font>e <b>upper</b> text.""", style=btU))
        story.append(
            Paragraph("""T<i>hi</i>s shoul<font color="red">d b</font>e <b>cAPITALIZED</b> text.""", style=btC)
        )
        doc = MyDocTemplate(outputfile("test_platypus_specialparagraphs.pdf"))
        doc.multiBuild(story)
开发者ID:TribunoDev,项目名称:pm,代码行数:26,代码来源:test_platypus_paragraphs.py


示例4: testVisible

    def testVisible(self):
        "Makes a document with extra text - should export and distill"
        c = Canvas(outputfile('test_pdfbase_postscript_visible.pdf'))
        c.setPageCompression(0)

        c.setFont('Helvetica-Bold', 18)
        c.drawString(100,700, 'Hello World. This is page 1 of a 2 page document.')
        c.showPage()

        c.setFont('Helvetica-Bold', 16)
        c.drawString(100,700, 'Page 2. This has some postscript drawing code.')
        c.drawString(100,680, 'If you print it using a PS device and Acrobat 4/5,')
        c.drawString(100,660, 'or export to Postscript, you should see the word')
        c.drawString(100,640, '"Hello PostScript" below.  In ordinary Acrobat Reader')
        c.drawString(100,620, 'we expect to see nothing.')
        c.addPostScriptCommand('/Helvetica findfont 48 scalefont setfont 100 400 moveto (Hello PostScript) show')


        c.drawString(100,500, 'This document also inserts two postscript')
        c.drawString(100,480, ' comments at beginning and endof the stream;')
        c.drawString(100,460, 'search files for "%PS_BEFORE" and "%PS_AFTER".')
        c.addPostScriptCommand('%PS_BEFORE', position=0)
        c.addPostScriptCommand('%PS_AFTER', position=2)

        c.save()
开发者ID:ingob,项目名称:mwlib.ext,代码行数:25,代码来源:test_pdfbase_postscript.py


示例5: test0

    def test0(self):
        "This makes one long multi-page paragraph."

        # Build story.
        story = []
        styleSheet = getSampleStyleSheet()
        bt = styleSheet['BodyText']
        text = '''If you imagine that the box of X's tothe left is
an image, what I want to be able to do is flow a
series of paragraphs around the image
so that once the bottom of the image is reached, then text will flow back to the
left margin. I know that it would be possible to something like this
using tables, but I can't see how to have a generic solution.
There are two examples of this in the demonstration section of the reportlab
site.
If you look at the "minimal" euro python conference brochure, at the end of the
timetable section (page 8), there are adverts for "AdSu" and "O'Reilly". I can
see how the AdSu one might be done generically, but the O'Reilly, unsure...
I guess I'm hoping that I've missed something, and that
it's actually easy to do using platypus.
'''
        from reportlab.platypus.flowables import ParagraphAndImage, Image
        from reportlab.lib.testutils import testsFolder
        gif = os.path.join(testsFolder,'pythonpowered.gif')
        story.append(ParagraphAndImage(Paragraph(text,bt),Image(gif)))
        phrase = 'This should be a paragraph spanning at least three pages. '
        description = ''.join([('%d: '%i)+phrase for i in xrange(250)])
        story.append(ParagraphAndImage(Paragraph(description, bt),Image(gif),side='left'))

        doc = MyDocTemplate(outputfile('test_platypus_paragraphandimage.pdf'))
        doc.multiBuild(story)
开发者ID:Jbaumotte,项目名称:web2py,代码行数:31,代码来源:test_platypus_paragraphs.py


示例6: test5

 def test5(self):
     from reportlab.lib.pagesizes import A4,LETTER
     canv = canvas.Canvas(outputfile('test_pdfgen_general_page_sizes.pdf'),
                     pagesize=A4,
                     )
     canv.setFont('Helvetica',10)
     S = A4
     canv.drawString(0,S[1]-10,'Top Left=(%s,%s) Page Size=%s x %s' % (0,S[1],S[0],S[1]))
     canv.drawCentredString(0.5*S[0],0.5*S[1],'Center =(%s,%s) Page Size=%s x %s' % (0.5*S[0],0.5*S[1],S[0],S[1]))
     canv.drawRightString(S[0],2,'Bottom Right=(%s,%s) Page Size=%s x %s' % (S[0],0,S[0],S[1]))
     canv.showPage()
     S = LETTER
     canv.setPageSize(S)
     canv.drawString(0,S[1]-10,'Top Left=(%s,%s) Page Size=%s x %s' % (0,S[1],S[0],S[1]))
     canv.drawCentredString(0.5*S[0],0.5*S[1],'Center =(%s,%s) Page Size=%s x %s' % (0.5*S[0],0.5*S[1],S[0],S[1]))
     canv.drawRightString(S[0],2,'Bottom Right=(%s,%s) Page Size=%s x %s' % (S[0],0,S[0],S[1]))
     canv.showPage()
     S = A4
     canv.setPageSize(S)
     canv.setPageRotation(180)
     canv.drawString(0,S[1]-10,'Top Left=(%s,%s) Page Size=%s x %s' % (0,S[1],S[0],S[1]))
     canv.drawCentredString(0.5*S[0],0.5*S[1],'Center =(%s,%s) Page Size=%s x %s' % (0.5*S[0],0.5*S[1],S[0],S[1]))
     canv.drawRightString(S[0],2,'Bottom Right=(%s,%s) Page Size=%s x %s' % (S[0],0,S[0],S[1]))
     canv.showPage()
     S = A4[1],A4[0]
     canv.setPageSize(S)
     canv.setPageRotation(0)
     canv.drawString(0,S[1]-30,'Top Left=(%s,%s) Page Size=%s x %s' % (0,S[1],S[0],S[1]))
     canv.drawCentredString(0.5*S[0],0.5*S[1],'Center =(%s,%s) Page Size=%s x %s' % (0.5*S[0],0.5*S[1],S[0],S[1]))
     canv.drawRightString(S[0],32,'Bottom Right=(%s,%s) Page Size=%s x %s' % (S[0],0,S[0],S[1]))
     canv.showPage()
     canv.save()
开发者ID:Jbaumotte,项目名称:web2py,代码行数:32,代码来源:test_pdfgen_general.py


示例7: ___test2_all

    def ___test2_all(self):
        """Dumps out ALl GLYPHS in a CID font.

        Reach for your microscope :-)"""
        try:
            from reportlab.pdfbase.cidfonts import CIDFont, findCMapFile
            findCMapFile('90ms-RKSJ-H')
            findCMapFile('Identity-H')
        except:
            #don't have the font pack.  return silently
            return

        pdfmetrics.registerFont(CIDFont('HeiseiMin-W3','Identity-H'))

        c = Canvas('test_japanese_2.pdf')
        c.setFont('Helvetica', 30)
        c.drawString(100,800, 'All Glyphs in Adobe-Japan-1-2 collection!')

        # the two typefaces
        c.setFont('HeiseiMin-W3-Identity-H', 2)

        x0 = 50
        y0 = 700
        dx = 2
        dy = 2
        for row in range(256):
            for cell in range(256):
                s = chr(row) + chr(cell)
                x = x0 + cell*dx
                y = y0 - row*dy
                c.drawString(x,y,s)

        c.save()
        if VERBOSE:
            print('saved '+outputfile('test_multibyte_jpn.pdf'))
开发者ID:Distrotech,项目名称:reportlab,代码行数:35,代码来源:test_multibyte_jpn.py


示例8: test5

    def test5(self):
        from reportlab.lib.pagesizes import A4, LETTER

        canv = canvas.Canvas(outputfile("test_pdfgen_general_page_sizes.pdf"), pagesize=A4)
        canv.setFont("Helvetica", 10)
        S = A4
        canv.drawString(0, S[1] - 10, "Top Left=(%s,%s) Page Size=%s x %s" % (0, S[1], S[0], S[1]))
        canv.drawCentredString(
            0.5 * S[0], 0.5 * S[1], "Center =(%s,%s) Page Size=%s x %s" % (0.5 * S[0], 0.5 * S[1], S[0], S[1])
        )
        canv.drawRightString(S[0], 2, "Bottom Right=(%s,%s) Page Size=%s x %s" % (S[0], 0, S[0], S[1]))
        canv.showPage()
        S = LETTER
        canv.setPageSize(S)
        canv.drawString(0, S[1] - 10, "Top Left=(%s,%s) Page Size=%s x %s" % (0, S[1], S[0], S[1]))
        canv.drawCentredString(
            0.5 * S[0], 0.5 * S[1], "Center =(%s,%s) Page Size=%s x %s" % (0.5 * S[0], 0.5 * S[1], S[0], S[1])
        )
        canv.drawRightString(S[0], 2, "Bottom Right=(%s,%s) Page Size=%s x %s" % (S[0], 0, S[0], S[1]))
        canv.showPage()
        S = A4
        canv.setPageSize(S)
        canv.setPageRotation(180)
        canv.drawString(0, S[1] - 10, "Top Left=(%s,%s) Page Size=%s x %s" % (0, S[1], S[0], S[1]))
        canv.drawCentredString(
            0.5 * S[0], 0.5 * S[1], "Center =(%s,%s) Page Size=%s x %s" % (0.5 * S[0], 0.5 * S[1], S[0], S[1])
        )
        canv.drawRightString(S[0], 2, "Bottom Right=(%s,%s) Page Size=%s x %s" % (S[0], 0, S[0], S[1]))
        canv.showPage()
        canv.save()
开发者ID:ingob,项目名称:mwlib.ext,代码行数:30,代码来源:test_pdfgen_general.py


示例9: tearDown

    def tearDown(self):
        "Hook method for deconstructing the test fixture after testing it."

        if FINISHED:
            path=outputfile('test_graphics_charts.pdf')
            doc = MyDocTemplate(path)
            doc.build(self.story)
开发者ID:Jbaumotte,项目名称:web2py,代码行数:7,代码来源:test_graphics_charts.py


示例10: func

 def func(val):
     story = [
             DocAssert(val,'this should fail'),
             DocPara('repr(doc._nameSpace)',escape=True),
             ]
     doc = SimpleDocTemplate(outputfile('test_doc_programming_asserts.pdf'))
     doc.build(story)
开发者ID:nickpack,项目名称:reportlab,代码行数:7,代码来源:test_platypus_programming.py


示例11: textAccum2

def textAccum2():
    doc = MyDocTemplate(outputfile("test_platypus_accum2.pdf"), pagesize=(8.5 * inch, 11 * inch), showBoundary=1)
    story = []
    story.append(Paragraph("A table with 500 rows", styleSheet["BodyText"]))
    sty = [
        ("GRID", (0, 0), (-1, -1), 1, colors.green),
        ("BOX", (0, 0), (-1, -1), 2, colors.red),
        ("FONTNAME", (0, 0), (-1, -1), "Helvetica"),
        ("FONTSIZE", (0, 0), (-1, -1), 10),
    ]

    def myCV(s, fontName="Helvetica", fontSize=10, maxWidth=72):
        return "\n".join(simpleSplit(s, fontName, fontSize, maxWidth))

    data = [
        [
            PA.onDrawStr(str(i + 1), i + 1),
            myCV("xx " * (i % 10), maxWidth=100 - 12),
            myCV("blah " * (i % 40), maxWidth=200 - 12),
        ]
        for i in range(500)
    ]
    t = LongTable(data, style=sty, colWidths=[50, 100, 200])
    story.append(t)
    doc.build(story)
开发者ID:FatihZor,项目名称:infernal-twin,代码行数:25,代码来源:test_platypus_accum.py


示例12: testAAbsoluteAndRelativeFields

 def testAAbsoluteAndRelativeFields(self):
     # the old test1 in pdfform
     c = canvas.Canvas(outputfile("test_pdfbase_pdfform_formtest.pdf"))
     # first page
     c.setFont("Courier", 10)
     c.drawString(100, 500, "hello world")
     pdfform.textFieldAbsolute(c, "fieldA", 100, 600, 100, 20, "default value")
     pdfform.textFieldAbsolute(c, "fieldB", 100, 300, 100, 50, "another default value", multiline=1)
     pdfform.selectFieldAbsolute(c, "fieldC", "France", ["Canada", "France", "China"], 100, 200, 100, 20)
     c.rect(100, 600, 100, 20)
     pdfform.buttonFieldAbsolute(c, "field2", "Yes", 100, 700, width=20, height=20)
     c.rect(100, 700, 20, 20)
     pdfform.buttonFieldAbsolute(c, "field3", "Off", 100, 800, width=20, height=20)
     c.rect(100, 800, 20, 20)
     # second page
     c.showPage()
     c.setFont("Helvetica", 7)
     c.translate(50, 20)
     c.drawString(100, 500, "hello world")
     pdfform.textFieldRelative(c, "fieldA_1", 100, 600, 100, 20, "default value 2")
     c.setStrokeColorRGB(1, 0, 0)
     c.setFillColorRGB(0, 1, 0.5)
     pdfform.textFieldRelative(c, "fieldB_1", 100, 300, 100, 50, "another default value 2", multiline=1)
     pdfform.selectFieldRelative(c, "fieldC_1", "France 1", ["Canada 0", "France 1", "China 2"], 100, 200, 100, 20)
     c.rect(100, 600, 100, 20)
     pdfform.buttonFieldRelative(c, "field2_1", "Yes", 100, 700, width=20, height=20)
     c.rect(100, 700, 20, 20)
     pdfform.buttonFieldRelative(c, "field3_1", "Off", 100, 800, width=20, height=20)
     c.rect(100, 800, 20, 20)
     c.save()
开发者ID:FatihZor,项目名称:infernal-twin,代码行数:30,代码来源:test_pdfbase_pdfform.py


示例13: test0

    def test0(self):
        "Make a PDFgen document with most graphics features"

        self.pageCount = 0
        makeDocument(outputfile('test_pdfgen_callback.pdf'), pageCallBack=self.callMe)
        #no point saving it!
        assert self.pageCount >= 7, 'page count not called!'
开发者ID:Distrotech,项目名称:reportlab,代码行数:7,代码来源:test_pdfgen_callback.py


示例14: test1

 def test1(self):
     """Ilpo Nyyss\xf6nen posted this broken test"""
     normalStyle = ParagraphStyle(name="normal")
     keepStyle = ParagraphStyle(name="keep", keepWithNext=True)
     content = [Paragraph("line 1", keepStyle), Indenter(left=1 * cm), Paragraph("line 2", normalStyle)]
     doc = SimpleDocTemplate(outputfile("test_platypus_breaking1.pdf"))
     doc.build(content)
开发者ID:jameshickey,项目名称:ReportLab,代码行数:7,代码来源:test_platypus_breaking.py


示例15: test0

    def test0(self):
        "A basic document drawing some strings"

        # if they do not have the Japanese font files, go away quietly
        from reportlab.pdfbase.cidfonts import UnicodeCIDFont, findCMapFile


        pdfmetrics.registerFont(UnicodeCIDFont('STSong-Light'))

        c = Canvas(outputfile('test_multibyte_chs.pdf'))
        c.setFont('Helvetica', 30)
        c.drawString(100,700, 'Simplified Chinese Font Support')


        c.setFont('Helvetica', 10)
        c.drawString(100,680, 'Short sample: "China - Zhang Ziyi"  (famous actress)')
        # the two typefaces

        hBoxText('\u4e2d\u56fd - \u7ae0\u5b50\u6021',
                 c,
                 100,
                 660,
                 'STSong-Light',
                 )


        c.setFont('Helvetica',10)
        c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
        c.showPage()

##        # full kuten chart in EUC
##        c.setFont('Helvetica', 18)
##        c.drawString(72,750, 'Characters available in GB 2312-80, EUC encoding')
##        y = 600
##        enc = 'GB_EUC_H'
##        for row in range(1, 95):
##            KutenRowCodeChart(row, 'STSong-Light',enc).drawOn(c, 72, y)
##            y = y - 125
##            if y < 50:
##                c.setFont('Helvetica',10)
##                c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
##                c.showPage()
##                y = 700
##
        c.save()
        if VERBOSE:
            print('saved '+outputfile('test_multibyte_chs.pdf'))
开发者ID:wolf29,项目名称:EG-notifications,代码行数:47,代码来源:test_multibyte_chs.py


示例16: _test0

def _test0(self):
    "This makes one long multi-page paragraph."
    from reportlab.platypus.flowables import DocAssign, DocExec, DocPara, DocIf, DocWhile

    # Build story.
    story = []

    styleSheet = getSampleStyleSheet()
    h1 = styleSheet["Heading1"]
    h1.pageBreakBefore = 1
    h1.keepWithNext = 1
    h1.outlineLevel = 0

    h2 = styleSheet["Heading2"]
    h2.backColor = colors.cyan
    h2.keepWithNext = 1
    h2.outlineLevel = 1

    bt = styleSheet["BodyText"]

    story.append(Paragraph("""Cross-Referencing Test""", styleSheet["Title"]))
    story.append(
        Paragraph(
            """
        Subsequent pages test cross-references: indexes, tables and individual
        cross references.  The number in brackets at the end of each paragraph
        is its position in the story. (%d)"""
            % len(story),
            bt,
        )
    )

    story.append(Paragraph("""Table of Contents:""", styleSheet["Title"]))
    toc = TableOfContents()
    story.append(toc)

    chapterNum = 1
    for i in range(10):
        story.append(Paragraph("Chapter %d: Chapters always starts a new page" % chapterNum, h1))
        chapterNum = chapterNum + 1
        for j in range(3):
            story.append(
                Paragraph(
                    "Heading1 paragraphs should always"
                    "have a page break before.  Heading 2 on the other hand"
                    "should always have a FRAME break before (%d)" % len(story),
                    bt,
                )
            )
            story.append(Paragraph("Heading 2 should always be kept with the next thing (%d)" % len(story), h2))
            for j in range(3):
                story.append(Paragraph(randomText(theme=PYTHON, sentences=2) + " (%d)" % len(story), bt))
                story.append(Paragraph("I should never be at the bottom of a frame (%d)" % len(story), h2))
                story.append(Paragraph(randomText(theme=PYTHON, sentences=1) + " (%d)" % len(story), bt))
    story.append(Paragraph("The Index which goes at the back", h1))
    story.append(SimpleIndex())

    doc = MyDocTemplate(outputfile("test_platypus_xref.pdf"))
    doc.multiBuild(story)
开发者ID:jbacou,项目名称:myReportLab_installPackage,代码行数:59,代码来源:test_platypus_xref.py


示例17: setUp

    def setUp(self):
        SecureTestCase.setUp(self)
        try:
            fn = __file__
        except:
            fn = sys.argv[0]

        self.output = open(outputfile(os.path.splitext(os.path.basename(fn))[0]+'.txt'),'w')
开发者ID:sengupta,项目名称:scilab_cloud,代码行数:8,代码来源:test_source_chars.py


示例18: test_doctemplate

 def test_doctemplate(self):
     "Test generating an encrypted pdf by setting a user password on the DocTemplate."
     header = ParagraphStyle(name='Heading', fontSize=36)
     story = [Paragraph("Top secret", header)]
     fname = outputfile('test_encrypt_doctemplate.pdf')
     doc = SimpleDocTemplate(fname, encrypt='User')
     doc.build(story)
     parsedoc(fname)
开发者ID:sengupta,项目名称:scilab_cloud,代码行数:8,代码来源:test_encrypt.py


示例19: run

def run(filename):
    c = makeDocument(filename)
    c.save()
    source = str(c)
    open(outputfile("test_pdfgen_pycanvas_out.txt"),"w").write(source)
    import reportlab.rl_config
    if reportlab.rl_config.verbose:
        print source
开发者ID:nickpack,项目名称:reportlab,代码行数:8,代码来源:test_pdfgen_pycanvas.py


示例20: testIt

    def testIt(self):
        "This makes one long multi-page paragraph."

        # Build story.
        story = []

        styleSheet = getSampleStyleSheet()
        h1 = styleSheet['Heading1']
        h1.pageBreakBefore = 1
        h1.keepWithNext = 1

        h2 = styleSheet['Heading2']
        h2.frameBreakBefore = 1
        h2.keepWithNext = 1

        h3 = styleSheet['Heading3']
        h3.backColor = colors.cyan
        h3.keepWithNext = 1

        bt = styleSheet['BodyText']

        story.append(Paragraph("""
            This tests ability to alternate left and right templates.  We start on
            a plain one. The next page should display a left-side template,
            with a big inner margin and staple-like holes on the right.""",style=bt))

        story.append(NextPageTemplate(['left','right']))

        story.append(Paragraph("""
            One can specify a list of templates instead of a single one in
            order to sequence through them.""",style=bt))
        def doSome():
            for i in range(10):
                story.append(Paragraph('Heading 1 always starts a new page (%d)' % len(story), h1))
                for j in range(3):
                    story.append(Paragraph('Heading1 paragraphs should always'
                                    'have a page break before.  Heading 2 on the other hand'
                                    'should always have a FRAME break before (%d)' % len(story), bt))
                    story.append(Paragraph('Heading 2 always starts a new frame (%d)' % len(story), h2))
                    story.append(Paragraph('Heading1 paragraphs should always'
                                    'have a page break before.  Heading 2 on the other hand'
                                    'should always have a FRAME break before (%d)' % len(story), bt))
                    for j in range(3):
                        story.append(Paragraph(randomText(theme=PYTHON, sentences=2)+' (%d)' % len(story), bt))
                        story.append(Paragraph('I should never be at the bottom of a frame (%d)' % len(story), h3))
                        story.append(Paragraph(randomText(theme=PYTHON, sentences=1)+' (%d)' % len(story), bt))

        doSome()
        story.append(NextPageTemplate('plain'))
        story.append(Paragraph('Back to plain old page template',h1))
        story.append(Paragraph('Back to plain old formatting', bt))
        story.append(Paragraph("""use a template name of * to indicate where the iteration should restart""",style=bt))
        story.append(NextPageTemplate(['left','*','right']))
        doSome()

        #doc = MyDocTemplate(outputfile('test_platypus_leftright.pdf'))
        doc = MyDocTemplate(outputfile('test_platypus_leftright.pdf'))
        doc.multiBuild(story)
开发者ID:makinacorpus,项目名称:reportlab-ecomobile,代码行数:58,代码来源:test_platypus_leftright.py



注:本文中的reportlab.lib.testutils.outputfile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python testutils.printLocation函数代码示例发布时间:2022-05-26
下一篇:
Python testutils.makeSuiteForClasses函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap