MCPcopy Create free account
hub / github.com/Distrotech/reportlab / drawToFile

Function drawToFile

src/reportlab/graphics/renderPDF.py:259–292  ·  view source on GitHub ↗

Makes a one-page PDF with just the drawing. If autoSize=1, the PDF will be the same size as the drawing; if 0, it will place the drawing on an A4 page with a title above it - possibly overflowing if too big.

(d, fn, msg="", showBoundary=rl_config._unset_, autoSize=1)

Source from the content-addressed store, hash-verified

257 draw(self.drawing, self.canv, 0, 0)
258
259def drawToFile(d, fn, msg="", showBoundary=rl_config._unset_, autoSize=1):
260 """Makes a one-page PDF with just the drawing.
261
262 If autoSize=1, the PDF will be the same size as
263 the drawing; if 0, it will place the drawing on
264 an A4 page with a title above it - possibly overflowing
265 if too big."""
266 d = renderScaledDrawing(d)
267 c = Canvas(fn)
268 if msg:
269 c.setFont(rl_config.defaultGraphicsFontName, 36)
270 c.drawString(80, 750, msg)
271 c.setTitle(msg)
272
273 if autoSize:
274 c.setPageSize((d.width, d.height))
275 draw(d, c, 0, 0, showBoundary=showBoundary)
276 else:
277 #show with a title
278 c.setFont(rl_config.defaultGraphicsFontName, 12)
279 y = 740
280 i = 1
281 y = y - d.height
282 draw(d, c, 80, y, showBoundary=showBoundary)
283
284 c.showPage()
285 c.save()
286 if sys.platform=='mac' and not hasattr(fn, "write"):
287 try:
288 import macfs, macostools
289 macfs.FSSpec(fn).SetCreatorType("CARO", "PDF ")
290 macostools.touched(fn)
291 except:
292 pass
293
294def drawToString(d, msg="", showBoundary=rl_config._unset_,autoSize=1):
295 "Returns a PDF as a string in memory, without touching the disk"

Callers 3

spider.pyFile · 0.90
doughnut.pyFile · 0.90
drawToStringFunction · 0.70

Calls 9

setFontMethod · 0.95
drawStringMethod · 0.95
setTitleMethod · 0.95
setPageSizeMethod · 0.95
showPageMethod · 0.95
saveMethod · 0.95
renderScaledDrawingFunction · 0.90
CanvasClass · 0.90
drawFunction · 0.70

Tested by

no test coverage detected