|
33 | 33 |
|
34 | 34 | log = logging.getLogger(__name__)
|
35 | 35 |
|
36 |
| -def render(source, vector=True, prog_cb=lambda x: None): |
| 36 | +def render(source, *, progress_cb=lambda x: None): |
37 | 37 | # Exports the self as a PDF document to disk
|
38 | 38 |
|
39 |
| - # prog_cb will be called with a progress percentage between 0 and |
| 39 | + # progress_cb will be called with a progress percentage between 0 and |
40 | 40 | # 100. This percentage calculation is split 50% for the rendering
|
41 | 41 | # of the lines and 50% merging with the base PDF file. This callback
|
42 | 42 | # also provides an opportunity to abort the process. If the callback
|
43 | 43 | # raises an error, this function will take steps to abort gracefullly
|
44 | 44 | # and pass the error upwards.
|
45 | 45 |
|
| 46 | + vector=True # TODO: Different rendering styles |
46 | 47 | source = sources.get_source(source)
|
47 | 48 |
|
48 | 49 | # If this is using a base PDF, the percentage is calculated
|
@@ -78,15 +79,15 @@ def render(source, vector=True, prog_cb=lambda x: None):
|
78 | 79 | changed_pages.append(i)
|
79 | 80 | page.render_to_painter(pdf_canvas, vector)
|
80 | 81 | annotations.append(page.get_grouped_annotations())
|
81 |
| - prog_cb((i + 1) / len(pages) * 50) |
| 82 | + progress_cb((i + 1) / len(pages) * 50) |
82 | 83 | pdf_canvas.save()
|
83 | 84 | tmpfh.seek(0)
|
84 | 85 |
|
85 | 86 | # This new PDF represents just the notebook. If there was a
|
86 | 87 | # parent PDF, merge it now.
|
87 | 88 | if uses_base_pdf and not changed_pages:
|
88 | 89 | # Since there is no stroke data, just return the PDF data
|
89 |
| - prog_cb(100) |
| 90 | + progress_cb(100) |
90 | 91 |
|
91 | 92 | log.info('exported pdf')
|
92 | 93 | return source.open('{ID}.pdf', 'rb')
|
@@ -132,7 +133,7 @@ def render(source, vector=True, prog_cb=lambda x: None):
|
132 | 133 | if uses_base_pdf:
|
133 | 134 | merge_pages(basepage, rmpage, i in changed_pages)
|
134 | 135 |
|
135 |
| - prog_cb(((i + 1) / rmpdfr.numPages * 50) + 50) |
| 136 | + progress_cb(((i + 1) / rmpdfr.numPages * 50) + 50) |
136 | 137 |
|
137 | 138 | # Apply the OCG order. The basepdf may have already had OCGs
|
138 | 139 | # and so we must not overwrite them. NOTE: there are other
|
|
0 commit comments