+ # If some pages require running pdflatex pass them to legacy method
+ if len(pdf_pages) > 0:
+ # Create a new LaTeX file just for the snippets needing
+ # the legacy method
+ legacy_latex_file = latex_file_re.sub("_legacy.tex", latex_file)
+ filter_pages(latex_file, legacy_latex_file, pdf_pages)
+
+ # Pass the new LaTeX file to the legacy method
+ progress("Pages %s require processing with pdflatex" % pdf_pages)
+ progress("Using the legacy conversion method (PDF support)")
+ legacy_status, legacy_metrics = legacy_conversion_step1(legacy_latex_file,
+ dpi, output_format, fg_color, bg_color, "pdflatex", True, True)
+
+ # Now we need to mix metrics data from dvipng and the legacy method
+ original_bitmap = latex_file_re.sub("%d." + output_format, legacy_latex_file)
+ destination_bitmap = latex_file_re.sub("%d." + output_format, latex_file)
+
+ # Join metrics from dvipng and legacy, and rename legacy bitmaps
+ join_metrics_and_rename(dvipng_metrics, legacy_metrics, pdf_pages,
+ original_bitmap, destination_bitmap)
+
+ # Invalidate metrics for pages that produced errors
+ if len(error_pages) > 0:
+ error_count = 0
+ for index in error_pages:
+ if index not in ps_pages and index not in pdf_pages:
+ dvipng_metrics.pop(index - 1)
+ dvipng_metrics.insert(index - 1, (index, -1.0))
+ error_count += 1
+ if error_count:
+ warning("Failed to produce %d preview snippet(s)" % error_count)
+