]> git.lyx.org Git - lyx.git/commitdiff
Fix pdf format conversion
authorJulien Rioux <jrioux@lyx.org>
Sat, 13 Jul 2013 14:12:04 +0000 (16:12 +0200)
committerVincent van Ravesteijn <vfr@lyx.org>
Sat, 13 Jul 2013 14:15:13 +0000 (16:15 +0200)
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

index 84918b0657cea13a69d6512eb2aeb0a83f52546d..207c58cb7b37f722e41d43015b74c50b9f4fc5fc 100644 (file)
@@ -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,