From 73368ed2d97728ee3ec889383b3803d8e3309e9d Mon Sep 17 00:00:00 2001 From: Julien Rioux Date: Sat, 13 Jul 2013 16:12:04 +0200 Subject: [PATCH] Fix pdf format conversion When calling the default converter (convert) we pass the format on the command line. In LyX we have various pdf, pdf2, pdf3, etc. formats all representing PDF. We need to strip to trailing digit in the format string otherwise the format is not understood by convert. --- src/graphics/GraphicsConverter.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/graphics/GraphicsConverter.cpp b/src/graphics/GraphicsConverter.cpp index 84918b0657..207c58cb7b 100644 --- a/src/graphics/GraphicsConverter.cpp +++ b/src/graphics/GraphicsConverter.cpp @@ -255,6 +255,13 @@ static void build_conversion_command(string const & command, ostream & script) } +static string const strip_digit(string const & format) +{ + // Strip trailing digits from format names e.g. "pdf6" -> "pdf" + return format.substr(0, format.find_last_not_of("0123456789") + 1); +} + + static void build_script(string const & from_file, string const & to_file, string const & from_format, @@ -318,12 +325,12 @@ static void build_script(string const & from_file, << libScriptSearch("$$s/scripts/convertDefault.py", quote_python) << ' '; if (!from_format.empty()) - os << from_format << ':'; + os << strip_digit(from_format) << ':'; // The extra " quotes around infile and outfile are needed // because the filename may contain spaces and it is used // as argument of os.system(). os << "' + '\"' + infile + '\"' + ' " - << to_format << ":' + '\"' + outfile + '\"' + '"; + << strip_digit(to_format) << ":' + '\"' + outfile + '\"' + '"; string const command = os.str(); LYXERR(Debug::GRAPHICS, -- 2.39.5