Menu

#48 Add commandline options (pdf export and jump to page)

Unstable_(example)
open
nobody
5
2015-09-01
2010-02-14
dino
No

This patch supersets 2949921 and 2924825.

* adds glib based commandline option parsing
* the ability to convert xoj files to pdf
* jump to page

Usage:
xournal [OPTION...] [FILE]

Help Options:
-h, --help Show help options
--help-all Show all help options
--help-gtk Show GTK+ Options

Application Options:
-p, --page=N Jump to Page
-A, --export-pdf=FILENAME Export document to a PDF file
--display=DISPLAY X display to use

Discussion

  • dino

    dino - 2010-02-14
     
  • Denis Auroux

    Denis Auroux - 2010-02-14

    Thanks very much. I deleted your earlier submission, since that one did not actually include the patch, and this one seems to supersede it.

    Denis

     
  • David Rasmus Piegdon

    when starting xournal without parameters, your patch will let it show a warning "Error opening file '(null)'". to fix this, set `success = 1' in main.c:100 in function init_stuff(...):

    ...
    if (file_arguments == NULL) {
    + success = 1;
    if(export_pdf_file) {
    ...

     
  • David Rasmus Piegdon

    further, argv[1] should be replaced with file_arguments[0] in a few calls in init_stuff(...). notably:

    main.c:120

    if (!success && !show_gui) { // GUI error is showed later
    printf(_("Error opening file '%s\n'"), file_arguments[0]);
    // also note the newline at end of string.
    exit(2);
    }

    main.c:330

    if (!success) {
    w = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT,
    GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error opening file '%s'"), file_arguments[0]);
    gtk_dialog_run(GTK_DIALOG(w));
    gtk_widget_destroy(w);
    }

     
  • Jim

    Jim - 2011-09-06

    With my version of xournal (erroneously) doing -p 1 causes a core dump. I suggest while initializing that you add
    something like
    if (open_page_nr <= 0)
    open_page_nr = 1;

    Jim

     
  • Stefan Kuczera

    Stefan Kuczera - 2015-09-01

    Had a look at this patch again and with the help of the previous comments I made some corrections. Main change is to use "file_arguments" instead of "argv" in the init function where applicable. I'm providing a diff/patch with respect to the latest repo pulled with "git clone git://git.code.sf.net/p/xournal/code xournal-code". Patch can be applied with "patch -p1 path_to/xournal-code/src/main.c < path_to/xournal-code/patches/cmd_line.patch".

     

Log in to post a comment.