summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2018-06-20 17:48:04 +0000
committerMarc Jeanmougin <marc@jeanmougin.fr>2018-06-20 17:48:04 +0000
commit045470ccd3633a598540fa9fc22ed28fd71bbf88 (patch)
tree7475a9e6997d4c9c73343c2a5c5dba9374f81d35 /src
parentReplace typedef enum with enum in POD type declarations. (diff)
parentAdd command-line option to select PDF page (diff)
downloadinkscape-045470ccd3633a598540fa9fc22ed28fd71bbf88.tar.gz
inkscape-045470ccd3633a598540fa9fc22ed28fd71bbf88.zip
Merge branch 'select-page' of gitlab.com:bobqwatson/inkscape
Diffstat (limited to 'src')
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp2
-rw-r--r--src/inkscape.h8
-rw-r--r--src/main.cpp11
3 files changed, 21 insertions, 0 deletions
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index bdda43279..fa9942230 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -777,6 +777,8 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
is_importvia_poppler = dlg->getImportMethod();
// printf("PDF import via %s.\n", is_importvia_poppler ? "poppler" : "native");
#endif
+ } else {
+ page_num = INKSCAPE.get_pdf_page();
}
SPDocument *doc = nullptr;
diff --git a/src/inkscape.h b/src/inkscape.h
index e5fa93ba4..d383da15d 100644
--- a/src/inkscape.h
+++ b/src/inkscape.h
@@ -192,6 +192,13 @@ public:
// may not be reflected by a selection change and thus needs a separate signal
sigc::signal<void> signal_external_change;
+ void set_pdf_page(gint page) {
+ _pdf_page = page;
+ }
+ gint get_pdf_page() {
+ return _pdf_page;
+ }
+
private:
static Inkscape::Application * _S_inst;
@@ -217,6 +224,7 @@ private:
char * _argv0;
static bool _crashIsHappening;
bool _use_gui;
+ gint _pdf_page;
};
} // namespace Inkscape
diff --git a/src/main.cpp b/src/main.cpp
index 88a1392b8..fb73eb810 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -159,6 +159,7 @@ enum {
SP_ARG_EXPORT_XAML,
SP_ARG_EXPORT_TEXT_TO_PATH,
SP_ARG_EXPORT_IGNORE_FILTERS,
+ SP_ARG_PDF_PAGE,
SP_ARG_EXTENSIONDIR,
SP_ARG_QUERY_X,
SP_ARG_QUERY_Y,
@@ -223,6 +224,7 @@ static gchar *sp_export_xaml = nullptr;
static gboolean sp_export_text_to_path = FALSE;
static gboolean sp_export_ignore_filters = FALSE;
static gboolean sp_export_font = FALSE;
+static gint sp_pdf_page = 1;
static gboolean sp_query_x = FALSE;
static gboolean sp_query_y = FALSE;
static gboolean sp_query_width = FALSE;
@@ -278,6 +280,7 @@ static void resetCommandlineGlobals() {
sp_export_text_to_path = FALSE;
sp_export_ignore_filters = FALSE;
sp_export_font = FALSE;
+ sp_pdf_page = 1;
sp_query_x = FALSE;
sp_query_y = FALSE;
sp_query_width = FALSE;
@@ -471,6 +474,11 @@ struct poptOption options[] = {
N_("Render filtered objects without filters, instead of rasterizing (PS, EPS, PDF)"),
nullptr},
+ {"pdf-page", 0,
+ POPT_ARG_INT, &sp_pdf_page, SP_ARG_PDF_PAGE,
+ N_("PDF page to import"),
+ N_("PAGE")},
+
{"query-x", 'X',
POPT_ARG_NONE, &sp_query_x, SP_ARG_QUERY_X,
// TRANSLATORS: "--query-id" is an Inkscape command line option; see "inkscape --help"
@@ -971,6 +979,7 @@ sp_main_gui(int argc, char const **argv)
/// \todo FIXME BROKEN - non-UTF-8 sneaks in here.
Inkscape::Application::create(argv[0], true);
+ INKSCAPE.set_pdf_page(sp_pdf_page);
for (auto i:fl) {
if (sp_file_open(i,nullptr)) {
@@ -1154,6 +1163,7 @@ static int sp_main_shell(char const* command_name)
poptSetOtherOptionHelp(ctx, _("[OPTIONS...] [FILE...]\n\nAvailable options:"));
if ( ctx ) {
std::vector<gchar *> fl = sp_process_args(ctx);
+ INKSCAPE.set_pdf_page(sp_pdf_page);
if (sp_process_file_list(fl)) {
retval = -1;
}
@@ -1206,6 +1216,7 @@ int sp_main_console(int argc, char const **argv)
}
Inkscape::Application::create(argv[0], false);
+ INKSCAPE.set_pdf_page(sp_pdf_page);
if (sp_shell) {
int retVal = sp_main_shell(argv[0]); // Run as interactive shell