+ latex_status, latex_stdout = run_latex(latex, latex_file)
+
+ if pdf_output:
+ return legacy_conversion_step3(latex_file, dpi, output_format, True, skipMetrics)
+ else:
+ return legacy_conversion_step2(latex_file, dpi, output_format, skipMetrics)
+
+# Creates a new LaTeX file from the original with pages specified in
+# failed_pages, pass it through pdflatex and updates the metrics
+# from the standard legacy route
+def legacy_conversion_pdflatex(latex_file, failed_pages, legacy_metrics, gs,
+ gs_device, gs_ext, alpha, resolution, output_format):
+
+ # Search for pdflatex executable
+ pdflatex = find_exe(["pdflatex"])
+ if pdflatex == None:
+ warning("Can't find pdflatex. Some pages failed with all the possible routes.")
+ else:
+ # Create a new LaTeX file from the original but only with failed pages
+ pdf_latex_file = latex_file_re.sub("_pdflatex.tex", latex_file)
+ filter_pages(latex_file, pdf_latex_file, failed_pages)
+
+ # pdflatex call
+ pdflatex_status, pdflatex_stdout = run_latex(pdflatex, pdf_latex_file)
+
+ pdf_file = latex_file_re.sub(".pdf", pdf_latex_file)
+
+ # GhostScript call to produce bitmaps
+ gs_call = '%s -dNOPAUSE -dBATCH -dSAFER -sDEVICE=%s ' \
+ '-sOutputFile="%s%%d.%s" ' \
+ '-dGraphicsAlphaBit=%d -dTextAlphaBits=%d ' \
+ '-r%f "%s"' \
+ % (gs, gs_device, latex_file_re.sub("", pdf_latex_file), \
+ gs_ext, alpha, alpha, resolution, pdf_file)
+ gs_status, gs_stdout = run_command(gs_call)
+ if gs_status:
+ # Give up!
+ warning("Some pages failed with all the possible routes")
+ else:
+ # We've done it!
+ pdf_log_file = latex_file_re.sub(".log", pdf_latex_file)
+ pdf_metrics = legacy_extract_metrics_info(pdf_log_file)
+
+ original_bitmap = latex_file_re.sub("%d." + output_format, pdf_latex_file)
+ destination_bitmap = latex_file_re.sub("%d." + output_format, latex_file)
+
+ # Join the metrics with the those from dvips and rename the bitmap images
+ join_metrics_and_rename(legacy_metrics, pdf_metrics, failed_pages,
+ original_bitmap, destination_bitmap)
+
+
+# The file has been processed through latex and we expect dvi output.
+# Run dvips, taking note whether it was successful.
+def legacy_conversion_step2(latex_file, dpi, output_format, skipMetrics = False):
+ # External programs used by the script.
+ dvips = find_exe_or_terminate(["dvips"])