summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2006-06-27 04:23:05 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2006-06-27 04:23:05 +0000
commit7def3db1968bdf3a75d68a5391e9da439e77ca16 (patch)
tree73532d82cce2b9a36532b322e772ffebdfc7fa3e /src
parentmove ensure_vector to correct place so that gradients with transparency can b... (diff)
downloadinkscape-7def3db1968bdf3a75d68a5391e9da439e77ca16.tar.gz
inkscape-7def3db1968bdf3a75d68a5391e9da439e77ca16.zip
pdf export from commandline
(bzr r1304)
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp62
1 files changed, 56 insertions, 6 deletions
diff --git a/src/main.cpp b/src/main.cpp
index aa97f3aec..03aeebb40 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -130,6 +130,7 @@ enum {
SP_ARG_EXPORT_SVG,
SP_ARG_EXPORT_PS,
SP_ARG_EXPORT_EPS,
+ SP_ARG_EXPORT_PDF,
SP_ARG_EXPORT_TEXT_TO_PATH,
SP_ARG_EXPORT_BBOX_PAGE,
SP_ARG_EXTENSIONDIR,
@@ -149,6 +150,7 @@ int sp_main_gui(int argc, char const **argv);
int sp_main_console(int argc, char const **argv);
static void sp_do_export_png(SPDocument *doc);
static void do_export_ps(SPDocument* doc, gchar const* uri, char const *mime);
+static void do_export_pdf(SPDocument* doc, gchar const* uri, char const *mime);
static void do_query_dimension (SPDocument *doc, bool extent, NR::Dim2 const axis, const gchar *id);
@@ -170,6 +172,7 @@ static gboolean sp_export_id_only = FALSE;
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 gboolean sp_export_text_to_path = FALSE;
static gboolean sp_export_bbox_page = FALSE;
static gboolean sp_query_x = FALSE;
@@ -296,6 +299,11 @@ struct poptOption options[] = {
N_("Export document to an EPS file"),
N_("FILENAME")},
+ {"export-pdf", 'A',
+ POPT_ARG_STRING, &sp_export_pdf, SP_ARG_EXPORT_PDF,
+ N_("Export document to a PDF file"),
+ N_("FILENAME")},
+
{"export-text-to-path", 'T',
POPT_ARG_NONE, &sp_export_text_to_path, SP_ARG_EXPORT_TEXT_TO_PATH,
N_("Convert text object to paths on export (EPS)"),
@@ -438,6 +446,8 @@ main(int argc, char **argv)
|| !strncmp(argv[i], "--export-ps", 11)
|| !strcmp(argv[i], "-E")
|| !strncmp(argv[i], "--export-eps", 12)
+ || !strcmp(argv[i], "-A")
+ || !strncmp(argv[i], "--export-pdf", 12)
|| !strcmp(argv[i], "-W")
|| !strncmp(argv[i], "--query-width", 13)
|| !strcmp(argv[i], "-H")
@@ -712,6 +722,9 @@ sp_main_console(int argc, char const **argv)
if (sp_export_eps) {
do_export_ps(doc, sp_export_eps, "image/x-e-postscript");
}
+ if (sp_export_pdf) {
+ do_export_pdf(doc, sp_export_pdf, "application/pdf");
+ }
if (sp_query_width || sp_query_height) {
do_query_dimension (doc, true, sp_query_width? NR::X : NR::Y, sp_query_id);
} else if (sp_query_x || sp_query_y) {
@@ -974,12 +987,6 @@ sp_do_export_png(SPDocument *doc)
static void do_export_ps(SPDocument* doc, gchar const* uri, char const* mime)
{
- /** \todo
- * FIXME: I've no idea if this is the `proper' way to do this.
- * If anyone feels qualified to say that it is, perhaps they
- * could remove this comment.
- */
-
Inkscape::Extension::DB::OutputList o;
Inkscape::Extension::db.get_output_list(o);
Inkscape::Extension::DB::OutputList::const_iterator i = o.begin();
@@ -1023,6 +1030,49 @@ static void do_export_ps(SPDocument* doc, gchar const* uri, char const* mime)
}
}
+/**
+ * Perform a PDF export
+ *
+ * \param doc Document to export.
+ * \param uri URI to export to.
+ * \param mime MIME type to export as.
+ */
+
+static void do_export_pdf(SPDocument* doc, gchar const* uri, char const* mime)
+{
+ Inkscape::Extension::DB::OutputList o;
+ Inkscape::Extension::db.get_output_list(o);
+ Inkscape::Extension::DB::OutputList::const_iterator i = o.begin();
+ while (i != o.end() && strcmp( (*i)->get_mimetype(), mime ) != 0) {
+ i++;
+ }
+
+ if (i == o.end())
+ {
+ g_warning ("Could not find an extension to export this file.");
+ return;
+ }
+
+ bool old_text_to_path = false;
+
+ try {
+ old_text_to_path = (*i)->get_param_bool("textToPath");
+ (*i)->set_param_bool("textToPath", sp_export_text_to_path);
+ }
+ catch (...) {
+ g_warning ("Could not set export-text-to-path option for this export.");
+ }
+
+ (*i)->save(doc, uri);
+
+ try {
+ (*i)->set_param_bool("textToPath", old_text_to_path);
+ }
+ catch (...) {
+
+ }
+}
+
#ifdef WIN32
bool replaceArgs( int& argc, char**& argv )
{