本文整理汇总了Python中reportlab.test.utils.outputfile函数的典型用法代码示例。如果您正苦于以下问题:Python outputfile函数的具体用法?Python outputfile怎么用?Python outputfile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了outputfile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test0
def test0(self):
"A basic document drawing some strings"
self.luxi = TTFont("DejaVu", "DejaVuSans.ttf")
pdfmetrics.registerFont(self.luxi)
# if they do not have the Japanese font files, go away quietly
# from reportlab.pdfbase.cidfonts import UnicodeCIDFont, findCMapFile
## enc = 'ETenms-B5-H'
## try:
## findCMapFile(enc)
## except:
## #they don't have the font pack, return silently
## print 'CMap not found'
## return
# pdfmetrics.registerFont(UnicodeCIDFont('MSung-Light'))
c = Canvas(outputfile("test_multibyte_gr.pdf"))
c.setFont("Helvetica", 24)
c.drawString(100, 700, "Greek characters Font Support")
c.setFont("Helvetica", 10)
c.drawString(100, 680, "Short sample: ")
hBoxText("Αυτό είναι ενα δοκιμαστικό κείμενο.", c, 100, 600, "DejaVu")
##
c.save()
if VERBOSE:
print "saved " + outputfile("test_multibyte_gr.pdf")
开发者ID:xrg,项目名称:OpenERP,代码行数:29,代码来源:test_multibyte_gr.py
示例2: main
def main(pattern='test_*.py'):
try:
folder = os.path.dirname(__file__)
except:
folder = os.path.dirname(sys.argv[0]) or os.getcwd()
from reportlab.lib.utils import isSourceDistro
haveSRC = isSourceDistro()
def cleanup(folder,patterns=('*.pdf', '*.log','*.svg','runAll.txt', 'test_*.txt')):
for pat in patterns:
for filename in GlobDirectoryWalker(folder, pattern=pat):
try:
os.remove(filename)
except:
pass
# special case for reportlab/test directory - clean up
# all PDF & log files before starting run. You don't
# want this if reusing runAll anywhere else.
if string.find(folder, 'reportlab' + os.sep + 'test') > -1: cleanup(folder)
cleanup(outputfile(''))
NI = []
testSuite = makeSuite(folder,nonImportable=NI,pattern=pattern+(not haveSRC and 'c' or ''))
unittest.TextTestRunner().run(testSuite)
if haveSRC: cleanup(folder,patterns=('*.pyc','*.pyo'))
if NI:
sys.stderr.write('\n###################### the following tests could not be imported\n')
for f,tb in NI:
print 'file: "%s"\n%s\n' % (f,string.join(tb,''))
print 'Logs and output files written to folder "%s"' % outputfile('')
开发者ID:eaudeweb,项目名称:naaya,代码行数:31,代码来源:runAll.py
示例3: 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:eaudeweb,项目名称:naaya,代码行数:33,代码来源:test_graphics_speed.py
示例4: 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.utils import _RL_DIR
gif = os.path.join(_RL_DIR,'test','pythonpowered.gif')
story.append(ParagraphAndImage(Paragraph(text,bt),Image(gif)))
phrase = 'This should be a paragraph spanning at least three pages. '
description = phrase * 250
story.append(Paragraph(description, bt))
doc = MyDocTemplate(outputfile('test_platypus_paragraphs.pdf'))
doc.multiBuild(story)
开发者ID:eaudeweb,项目名称:naaya,代码行数:31,代码来源:test_platypus_paragraphs.py
示例5: 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:eaudeweb,项目名称:naaya,代码行数:7,代码来源:test_graphics_charts.py
示例6: 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:radical-software,项目名称:radicalspam,代码行数:7,代码来源:test_platypus_breaking.py
示例7: test1
def test1(self):
"Test two strings in group in drawing."
path = outputfile("test_renderSVG_simple_test1.svg")
d = Drawing(200, 100)
g = Group()
g.add(String(0, 0, "foo"))
g.add(String(100, 0, "bar"))
d.add(g)
renderSVG.drawToFile(d, path)
if not HAVE_XML_PARSER:
warnIgnoredRestofTest()
return
svg = load(path)
fg = svg.getElementsByTagName('g')[0] # flipping group
dg = fg.getElementsByTagName('g')[0] # diagram group
g = dg.getElementsByTagName('g')[0] # custom group
textChildren = g.getElementsByTagName('text') # text nodes
t0 = string.strip(textChildren[0].childNodes[0].nodeValue)
t1 = string.strip(textChildren[1].childNodes[0].nodeValue)
assert t0 == 'foo'
assert t1 == 'bar'
开发者ID:ShaulBarkan,项目名称:PRION,代码行数:26,代码来源:test_renderSVG.py
示例8: 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:eaudeweb,项目名称:naaya,代码行数:7,代码来源:test_pdfgen_callback.py
示例9: 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:ShaulBarkan,项目名称:PRION,代码行数:25,代码来源:test_pdfbase_postscript.py
示例10: ___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:eaudeweb,项目名称:naaya,代码行数:35,代码来源:test_multibyte_jpn.py
示例11: 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(u'\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:ShaulBarkan,项目名称:PRION,代码行数:47,代码来源:test_multibyte_chs.py
示例12: _test0
def _test0(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(
"""
Subsequent pages test pageBreakBefore, frameBreakBefore and
keepTogether attributes. Generated at %s. The number in brackets
at the end of each paragraph is its position in the story. (%d)"""
% (time.ctime(time.time()), len(story)),
bt,
)
)
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))
doc = MyDocTemplate(outputfile("test_platypus_breaking.pdf"))
doc.multiBuild(story)
开发者ID:eaudeweb,项目名称:naaya,代码行数:59,代码来源:test_platypus_breaking.py
示例13: test0
def test0(self):
"Test two strings in drawing."
path = outputfile("axestest0.svg")
from reportlab.graphics.charts.axes import XCategoryAxis
d = XCategoryAxis().demo()
renderSVG.drawToFile(d, path)
开发者ID:ShaulBarkan,项目名称:PRION,代码行数:8,代码来源:test_renderSVG.py
示例14: 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:eaudeweb,项目名称:naaya,代码行数:8,代码来源:test_pdfgen_pycanvas.py
示例15: 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:eaudeweb,项目名称:naaya,代码行数:8,代码来源:test_source_chars.py
示例16: 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:ShaulBarkan,项目名称:PRION,代码行数:58,代码来源:test_platypus_leftright.py
示例17: _test0
def _test0(self):
"Perform original test function."
pdfPath = outputfile('test_charts_textlabels.pdf')
c = Canvas(pdfPath)
label = Label()
demoLabel = label.demo()
demoLabel.drawOn(c, 0, 0)
c.save()
开发者ID:ShaulBarkan,项目名称:PRION,代码行数:11,代码来源:test_charts_textlabels.py
示例18: _showDoc
def _showDoc(fn,story):
pageTemplate = PageTemplate('normal', [Frame(72, 440, 170, 284, id='F1'),
Frame(326, 440, 170, 284, id='F2'),
Frame(72, 72, 170, 284, id='F3'),
Frame(326, 72, 170, 284, id='F4'),
], myMainPageFrame)
doc = BaseDocTemplate(outputfile(fn),
pageTemplates = pageTemplate,
showBoundary = 1,
)
doc.multiBuild(story)
开发者ID:ShaulBarkan,项目名称:PRION,代码行数:11,代码来源:test_platypus_pleaseturnover.py
示例19: __del__
def __del__(self):
if IMAGES[-1] != None:
return
else:
del IMAGES[-1]
d = Drawing(A4[0], A4[1])
for img in IMAGES:
d.add(img)
outPath = outputfile("test_graphics_images.pdf")
renderPDF.drawToFile(d, outPath) #, '')
assert os.path.exists(outPath) == 1
开发者ID:ShaulBarkan,项目名称:PRION,代码行数:12,代码来源:test_graphics_images.py
示例20: test0
def test0(self):
"""Test story with TOC and a cascaded header hierarchy.
The story should contain exactly one table of contents that is
immediatly followed by a list of of cascaded levels of header
lines, each nested one level deeper than the previous one.
Features to be visually confirmed by a human being are:
1. TOC lines are indented in multiples of 1 cm.
2. Wrapped TOC lines continue with additional 0.5 cm indentation.
3. ...
"""
maxLevels = 12
# Create styles to be used for document headers
# on differnet levels.
headerLevelStyles = []
for i in range(maxLevels):
headerLevelStyles.append(makeHeaderStyle(i))
# Create styles to be used for TOC entry lines
# for headers on differnet levels.
tocLevelStyles = []
d, e = tableofcontents.delta, tableofcontents.epsilon
for i in range(maxLevels):
tocLevelStyles.append(makeTocHeaderStyle(i, d, e))
# Build story.
story = []
styleSheet = getSampleStyleSheet()
bt = styleSheet['BodyText']
description = '<font color=red>%s</font>' % self.test0.__doc__
story.append(XPreformatted(description, bt))
toc = TableOfContents()
toc.levelStyles = tocLevelStyles
story.append(toc)
for i in range(maxLevels):
story.append(Paragraph('HEADER, LEVEL %d' % i,
headerLevelStyles[i]))
#now put some body stuff in.
txt = randomtext.randomText(randomtext.PYTHON, 5)
para = Paragraph(txt, makeBodyStyle())
story.append(para)
path = outputfile('test_platypus_toc.pdf')
doc = MyDocTemplate(path)
doc.multiBuild(story)
开发者ID:eaudeweb,项目名称:naaya,代码行数:52,代码来源:test_platypus_toc.py
注:本文中的reportlab.test.utils.outputfile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论