Show More
@@ -15,6 +15,7 b' Contains writer for writing nbconvert output to PDF.' | |||
|
15 | 15 | |
|
16 | 16 | import subprocess |
|
17 | 17 | import os |
|
18 | import sys | |
|
18 | 19 | |
|
19 | 20 | from IPython.utils.traitlets import Integer, List, Bool |
|
20 | 21 | |
@@ -44,6 +45,9 b' class PDFPostProcessor(PostProcessorBase):' | |||
|
44 | 45 | config=True, help=""" |
|
45 | 46 | Filename extensions of temp files to remove after running. |
|
46 | 47 | """) |
|
48 | pdf_open = Bool(True, config=True, help=""" | |
|
49 | Whether or not to open the pdf after the compile call. | |
|
50 | """) | |
|
47 | 51 | |
|
48 | 52 | def run_command(self, command_list, filename, count, log_function): |
|
49 | 53 | """Run command_list count times. |
@@ -113,6 +117,16 b' class PDFPostProcessor(PostProcessorBase):' | |||
|
113 | 117 | except OSError: |
|
114 | 118 | pass |
|
115 | 119 | |
|
120 | def open_pdf(self,filename): | |
|
121 | filepath = filename+'.pdf' | |
|
122 | if sys.platform.startswith('darwin'): | |
|
123 | subprocess.call(('open', filepath)) | |
|
124 | elif os.name == 'nt': | |
|
125 | os.startfile(filepath) | |
|
126 | elif os.name == 'posix': | |
|
127 | subprocess.call(('xdg-open', filepath)) | |
|
128 | return | |
|
129 | ||
|
116 | 130 | def postprocess(self, filename): |
|
117 | 131 | """Build a PDF by running pdflatex and bibtex""" |
|
118 | 132 | self.log.info("Building PDF") |
@@ -128,5 +142,8 b' class PDFPostProcessor(PostProcessorBase):' | |||
|
128 | 142 | filename = os.path.splitext(filename)[0] |
|
129 | 143 | if os.path.isfile(filename+'.pdf'): |
|
130 | 144 | self.log.info('PDF successfully created') |
|
145 | if self.pdf_open: | |
|
146 | self.open_pdf(filename) | |
|
147 | self.log.info('Viewer called') | |
|
131 | 148 | return |
|
132 | ||
|
149 |
General Comments 0
You need to be logged in to leave comments.
Login now