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)
| 257 | draw(self.drawing, self.canv, 0, 0) |
| 258 | |
| 259 | def 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 | |
| 294 | def drawToString(d, msg="", showBoundary=rl_config._unset_,autoSize=1): |
| 295 | "Returns a PDF as a string in memory, without touching the disk" |
no test coverage detected