"Presentation Mode" PDF export

Anonymous
2011-05-17
2013-03-05

  • Anonymous
    2011-05-17

    Hello,

    First, this is a wonderful program, and thank you for maintaining it.  I am a math professor looking to experiment with an electronic lecture style; because even LyX is time-consuming this has led me to Xournal and similar programs.  Xournal seems to be the ideal platform for this purpose, with just enough functionality, but not too much. 

    However, to fully replace the flow of a chalkboard lecture, I wanted to suggest one small feature.  Right now Xournal creates one PDF page per Xournal page when exporting to PDF - what I would call "Handout Mode".  If instead it created one PDF page per layer, then you would get something more approximating a powerpoint presentation - what I am proposing to call "Presentation Mode".

    The idea is that in a chalkboard lecture, you alternate between writing and talking about what you have written.  To replicate this electronically, one would create each piece of a calculation as a separate layer, and then reveal them one at a time.  Of course, one could just present from within Xournal, but a PDF presentation is much cleaner - lectures could be given from within Evince, one could use a clicker/laser pointer to advance the slides remotely, etc..

    With some guidance, I would be happy to attempt a patch - I know nothing of GTK but I suspect the patch for the actual export would be quite simple:  if the current code were something like (pseudo-code)

    pdf_file = empty_pdf_file()
    for p in pages {
      pdf_page = empty_pdf_page()
      for l in p.layers { pdf_page.add(l) }
      pdf_file.add(pdf_page)
    }
    

    then the only change would be to add a flag and add another "pdf_file.add()" command inside the layer loop:

    pdf_file = empty_pdf_file()
    for p in pages {
      pdf_page = empty_pdf_page()
      for l in p.layers {
        pdf_page.add(l)
        if (presentation_mode) { pdf_file.add(pdf_page) }
      }
      if (handout_mode) { pdf_file.add(pdf_page) }
    }
    

    Of course, there would need to be another entry under the File … menu.  But I would even settle for a command-line conversion flag (I saw another patch posted that allows command line conversion in Handout Mode, and I could try to modify that patch set to incorporate the proposed functionality if you can point me to where the PDF is actually created/saved.

     
  • ManDay
    ManDay
    2011-05-17

    Hello, I can't add much to this thread but that I like your idea. It sounds fairly easy to realize and useful, too.

    Cheers,
    MD

     
  • Denis Auroux
    Denis Auroux
    2011-05-21

    This is indeed not insanely complicated. (But I am not sure how much sense it makes given that xournal++ should soon be replacing xournal).

    The printing loop would indeed need to be modified more or less in the manner you suggest, though you'll find that you need to regenerate the page once it's sent out to export. Namely,. to use the notation of your pseudo-code, you'll find that "pdf_file.add" requires you to finalize the page and then you need to redraw everything before processing the next layer (or, for PDF export, there's a smarter way but it requires more code writing).

    If you want to modify the printing loop for "File -> Export to PDF", that's the function print_to_pdf() in xo-print.c, and the loop over pages is the one that starts with

      for (pglist = journal.pages, n_page = 0; pglist!=NULL;
           pglist = pglist->next, n_page++) {

      }

    The actual drawing (of all layers) is done in pdf_draw_page() in the same file xo-print.c, which is essentially a loop over layers. Essentially the easiest thing to do is:
    - add an extra argument to pdf_draw_page() which is the number of layers to draw (or -1 to draw them all); change the main for() loop of that function accordingly
    - insert a second loop immediately within the first one in print_to_pdf() that iterates over the number of layers to include, from 1 to the total number of layers in the page. Call pdf_draw_page() with that extra argument. This means that the pdf code gets re-processed each time for each new layer, but it's a much easier patch than trying to reuse PDF objects more smartly.

    And of course, add a UI interface or configure file option to enable/disable this possibility. (See e.g. how things are done with the print_ruling option by searching for "print_ruling" in the entire code).

    This is about "export to PDF"; if instead you want to affect the "file -> Print" command it's a bit more complicated because GtkPrint takes care of the iteration over pages, so it needs to be told specifically how to compute the correct number of pages, and then you'll have to decode back from a page number in the print job to a page/layer pair. The relevant functions are print_job_render_page() in xo-print.c, and on_filePrint_activate() in xo-callbacks.c

    Denis