From 4cec6d0c7d401ed0616e91a923a7ec4caf806f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Wed, 5 Jun 2013 16:03:06 -0300 Subject: Add command line option to specify PDF export version. Patch from schwieni. From the patch's author: Additional command line option added to export to different PDF-versions supported by cairo (currently only "PDF 1.4" and "PDF 1.5"). The user must provide the exact string found in the PDF-export dialog of Inkscape. This feature was previously only accessible via the GUI of Inkscape. This option is useful for people opting for PDF-a conformance in their PDFs. Moreover, the Extension and Parameter classes are extended by setters for enum parameters (used in combo boxes). (bzr r12348) --- src/main.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 5bb42d405..d9e731912 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -148,6 +148,7 @@ enum { SP_ARG_EXPORT_PS, SP_ARG_EXPORT_EPS, SP_ARG_EXPORT_PDF, + SP_ARG_EXPORT_PDF_VERSION, SP_ARG_EXPORT_LATEX, #ifdef WIN32 SP_ARG_EXPORT_EMF, @@ -201,6 +202,7 @@ static gchar *sp_export_svg = NULL; static gchar *sp_export_ps = NULL; static gchar *sp_export_eps = NULL; static gchar *sp_export_pdf = NULL; +static gchar *sp_export_pdf_version = NULL; #ifdef WIN32 static gchar *sp_export_emf = NULL; #endif //WIN32 @@ -245,6 +247,7 @@ static void resetCommandlineGlobals() { sp_export_ps = NULL; sp_export_eps = NULL; sp_export_pdf = NULL; + sp_export_pdf_version = NULL; #ifdef WIN32 sp_export_emf = NULL; #endif //WIN32 @@ -386,6 +389,12 @@ struct poptOption options[] = { N_("Export document to a PDF file"), N_("FILENAME")}, + {"export-pdf-version", 0, + POPT_ARG_STRING, &sp_export_pdf_version, SP_ARG_EXPORT_PDF_VERSION, + // TRANSLATORS: "--export-pdf-version" is an Inkscape command line option; see "inkscape --help" + N_("Export PDF to given version. (hint: make sure to input the exact string found in the PDF export dialog, e.g. \"PDF 1.4\" which is PDF-a conformant)"), + N_("PDF_VERSION")}, + {"export-latex", 0, POPT_ARG_NONE, &sp_export_latex, SP_ARG_EXPORT_LATEX, N_("Export PDF/PS/EPS without text. Besides the PDF/PS/EPS, a LaTeX file is exported, putting the text on top of the PDF/PS/EPS file. Include the result in LaTeX like: \\input{latexfile.tex}"), @@ -1638,6 +1647,33 @@ static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) } (*i)->set_param_float("bleed", margin); + // handle --export-pdf-version + bool set_export_pdf_version_fail=true; + const gchar *pdfver_param_name="PDFversion"; + if(sp_export_pdf_version) { + // combine "PDF " and the given command line + std::string version_gui_string=std::string("PDF ")+sp_export_pdf_version; + try{ + // first, check if the given pdf version is selectable in the ComboBox + if((*i)->get_param_enum_contains("PDFversion", version_gui_string.c_str())) { + (*i)->set_param_enum(pdfver_param_name, version_gui_string.c_str()); + set_export_pdf_version_fail=false; + } else { + g_warning("Desired PDF export version \"%s\" not supported! Hint: input one of the versions found in the pdf export dialog e.g. \"1.4\".", + sp_export_pdf_version); + } + } catch (...) { + // can be thrown along the way: + // throw Extension::param_not_exist(); + // throw Extension::param_not_enum_param(); + g_warning("Parameter or Enum \"%s\" might not exist",pdfver_param_name); + } + } + // set default pdf export version to 1.4, also if something went wrong + if(set_export_pdf_version_fail) { + (*i)->set_param_enum(pdfver_param_name, "PDF 1.4"); + } + //check if specified directory exists if (!Inkscape::IO::file_directory_exists(uri)) { g_warning("File path \"%s\" includes directory that doesn't exist.\n", uri); -- cgit v1.2.3