commit 73368ed2d97728ee3ec889383b3803d8e3309e9d
Author: Julien Rioux <[email protected]>
Date:   Sat Jul 13 16:12:04 2013 +0200

    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.

diff --git a/src/graphics/GraphicsConverter.cpp 
b/src/graphics/GraphicsConverter.cpp
index 84918b0..207c58c 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,

Reply via email to