##// END OF EJS Templates
handle 'application/pdf' in nbconvert...
MinRK -
Show More
@@ -67,7 +67,7 b' class LatexExporter(TemplateExporter):'
67 def default_config(self):
67 def default_config(self):
68 c = Config({
68 c = Config({
69 'NbConvertBase': {
69 'NbConvertBase': {
70 'display_data_priority' : ['latex', 'pdf', 'png', 'jpg', 'svg', 'jpeg', 'text']
70 'display_data_priority' : ['latex', 'application/pdf', 'png', 'jpg', 'svg', 'jpeg', 'text']
71 },
71 },
72 'ExtractOutputPreprocessor': {
72 'ExtractOutputPreprocessor': {
73 'enabled':True
73 'enabled':True
@@ -34,7 +34,7 b' class ExtractOutputPreprocessor(Preprocessor):'
34 output_filename_template = Unicode(
34 output_filename_template = Unicode(
35 "{unique_key}_{cell_index}_{index}.{extension}", config=True)
35 "{unique_key}_{cell_index}_{index}.{extension}", config=True)
36
36
37 extract_output_types = Set({'png', 'jpg', 'svg', 'pdf'}, config=True)
37 extract_output_types = Set({'png', 'jpg', 'svg', 'pdf', 'application/pdf'}, config=True)
38
38
39 def preprocess_cell(self, cell, resources, cell_index):
39 def preprocess_cell(self, cell, resources, cell_index):
40 """
40 """
@@ -70,7 +70,7 b' class ExtractOutputPreprocessor(Preprocessor):'
70 data = out[out_type]
70 data = out[out_type]
71
71
72 #Binary files are base64-encoded, SVG is already XML
72 #Binary files are base64-encoded, SVG is already XML
73 if out_type in ('png', 'jpg', 'jpeg', 'pdf'):
73 if out_type in ('png', 'jpg', 'application/pdf', 'pdf'):
74
74
75 # data is b64-encoded as text (str, unicode)
75 # data is b64-encoded as text (str, unicode)
76 # decodestring only accepts bytes
76 # decodestring only accepts bytes
@@ -39,9 +39,11 b' class SVG2PDFPreprocessor(ConvertFiguresPreprocessor):'
39 """
39 """
40 Converts all of the outputs in a notebook from SVG to PDF.
40 Converts all of the outputs in a notebook from SVG to PDF.
41 """
41 """
42
42
43 from_format = Unicode('svg', config=True, help='Format the converter accepts')
43 def _from_format_default(self):
44 to_format = Unicode('pdf', config=False, help='Format the converter writes')
44 return 'svg'
45 def _to_format_default(self):
46 return 'application/pdf'
45
47
46 command = Unicode(config=True,
48 command = Unicode(config=True,
47 help="""The command to use for converting SVG to PDF
49 help="""The command to use for converting SVG to PDF
@@ -9,7 +9,7 b''
9
9
10 ((*- block data_priority scoped -*))
10 ((*- block data_priority scoped -*))
11 ((*- for type in output | filter_data_type -*))
11 ((*- for type in output | filter_data_type -*))
12 ((*- if type in ['pdf']*))
12 ((*- if type in ['pdf', 'application/pdf']*))
13 ((*- block data_pdf -*))
13 ((*- block data_pdf -*))
14 ((*- endblock -*))
14 ((*- endblock -*))
15 ((*- endif -*))
15 ((*- endif -*))
@@ -5,7 +5,7 b''
5
5
6 {%- block data_priority scoped -%}
6 {%- block data_priority scoped -%}
7 {%- for type in output | filter_data_type -%}
7 {%- for type in output | filter_data_type -%}
8 {%- if type in ['pdf']%}
8 {%- if type in ['pdf', 'application/pdf']%}
9 {%- block data_pdf -%}
9 {%- block data_pdf -%}
10 {%- endblock -%}
10 {%- endblock -%}
11 {%- endif -%}
11 {%- endif -%}
@@ -22,14 +22,14 b' from IPython.utils.traitlets import Unicode'
22 class NbConvertBase(LoggingConfigurable):
22 class NbConvertBase(LoggingConfigurable):
23 """Global configurable class for shared config
23 """Global configurable class for shared config
24
24
25 Usefull for display data priority that might be use by many trasnformers
25 Useful for display data priority that might be use by many transformers
26 """
26 """
27
27
28 display_data_priority = List(['html', 'pdf', 'svg', 'latex', 'png', 'jpg', 'jpeg' , 'text'],
28 display_data_priority = List(['html', 'application/pdf', 'pdf', 'svg', 'latex', 'png', 'jpg', 'jpeg' , 'text'],
29 config=True,
29 config=True,
30 help= """
30 help= """
31 An ordered list of prefered output type, the first
31 An ordered list of preferred output type, the first
32 encounterd will usually be used when converting discarding
32 encountered will usually be used when converting discarding
33 the others.
33 the others.
34 """
34 """
35 )
35 )
General Comments 0
You need to be logged in to leave comments. Login now