Code

PDF export. Fix for Bug #664335 (pdf export with cairo 1.10 defaults to version PDF...
authorJazzyNico <nicoduf@yahoo.fr>
Fri, 22 Oct 2010 12:48:23 +0000 (14:48 +0200)
committerJazzyNico <nicoduf@yahoo.fr>
Fri, 22 Oct 2010 12:48:23 +0000 (14:48 +0200)
src/extension/internal/cairo-render-context.cpp
src/extension/internal/cairo-renderer-pdf-out.cpp

index 28d1db9a4abbe185a39f631eb27823cc381d266b..098c56a79d47894766c7b587eebb872d77cd325c 100644 (file)
@@ -108,7 +108,7 @@ static cairo_status_t _write_callback(void *closure, const unsigned char *data,
 
 CairoRenderContext::CairoRenderContext(CairoRenderer *parent) :
     _dpi(72),
-    _pdf_level(0),
+    _pdf_level(1),
     _ps_level(1),
     _eps(false),
     _is_texttopath(FALSE),
@@ -782,6 +782,9 @@ CairoRenderContext::setupSurface(double width, double height)
 #ifdef CAIRO_HAS_PDF_SURFACE
         case CAIRO_SURFACE_TYPE_PDF:
             surface = cairo_pdf_surface_create_for_stream(Inkscape::Extension::Internal::_write_callback, _stream, width, height);
+#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0))
+            cairo_pdf_surface_restrict_to_version(surface, (cairo_pdf_version_t)_pdf_level);   
+#endif
             break;
 #endif
 #ifdef CAIRO_HAS_PS_SURFACE
@@ -791,8 +794,8 @@ CairoRenderContext::setupSurface(double width, double height)
                 return FALSE;
             }
 #if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2))
-            cairo_ps_surface_restrict_to_level (surface, (cairo_ps_level_t)_ps_level);
-            cairo_ps_surface_set_eps (surface, (cairo_bool_t) _eps);
+            cairo_ps_surface_restrict_to_level(surface, (cairo_ps_level_t)_ps_level);
+            cairo_ps_surface_set_eps(surface, (cairo_bool_t) _eps);
 #endif
             break;
 #endif
index cacaa03a19c4c31cdc66698568fe8b480e0895a8..32df1193b97730eac1072dd09be3c484a2956c77 100644 (file)
@@ -135,11 +135,11 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc,
     int level = 0;
     try {
         new_level = mod->get_param_enum("PDFversion");
-//        if((new_level != NULL) && (g_ascii_strcasecmp("PDF-1.x", new_level) == 0))
-//            level = 1;
+        if((new_level != NULL) && (g_ascii_strcasecmp("PDF-1.5", new_level) == 0))
+            level = 1;
     }
     catch(...) {
-//        g_warning("Parameter <PDFversion> might not exist");
+        g_warning("Parameter <PDFversion> might not exist");
     }
 
     bool new_textToPath  = FALSE;
@@ -237,7 +237,10 @@ CairoRendererPdfOutput::init (void)
                        "<name>Portable Document Format</name>\n"
                        "<id>org.inkscape.output.pdf.cairorenderer</id>\n"
                        "<param name=\"PDFversion\" gui-text=\"" N_("Restrict to PDF version:") "\" type=\"enum\" >\n"
-                               "<_item value='PDF14'>" N_("PDF 1.4") "</_item>\n"
+#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0))
+                               "<_item value='PDF-1.5'>" N_("PDF 1.5") "</_item>\n"
+#endif
+                "<_item value='PDF-1.4'>" N_("PDF 1.4") "</_item>\n"
                        "</param>\n"
                        "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
                        "<param name=\"textToLaTeX\" gui-text=\"" N_("PDF+LaTeX: Omit text in PDF, and create LaTeX file") "\" type=\"boolean\">false</param>\n"