Copying xournal-devel since there's an actual UI proposal further down this message (in fact several -- as usual with me, there's the first idea, then the amended hopefully better idea). The question is how to adjust the xournal file to create/delete xoj pages when the PDF file it annotates changes in length, possibly by having pages inserted/deleted in the middle of it rather than at the end.
On 04/04/2017 01:41 AM, Ragnarok wrote: > Just wondering if it might be possible/feasible to compare the total > number of pages actually present in the linked PDF file, and the largest > page number mentioned in the XOJ file, each time the XOJ file is opened. > If there is a mismatch in the two, the following actions could be taken: > /If the PDF file has fewer pages than the XOJ file, the annotations in > the XOJ file's extra pages are placed on blank pages. > / If the PDF file has more pages than the XOJ file, the extra PDF pages > are just inserted as backgrounds with no annotations to the end of the > XOJ file. This is not a good idea in general, because many people (at least me) annotate PDF files but insert blank pages of "plain paper" for extra comments in between PDF pages wherever extra space is needed. So I might have a page of handwritten annotations between pages 3 and 4 of the PDF file, etc. etc. > If I'm not mistaken, I don't see any real need to maintain a one-to-one > relation between PDF and XOJ pages, hence requiring no change to the > GUI. For instance, if an extra page is added to the middle of the PDF > file, the XOJ file is not aware of this and one-to-one correlation is > lost anyway. Indeed -- but then the GUI should help the user fix the correlation in the right way, because: > This is not really an issue even, since as I mentioned > before, I could just shift all annotations in the XOJ file down by one > page to solve this problem. How do you propose to do this? There is no easy way to move a whole page, especially if there are several layers on it, and there is even less of a way to move a range of pages. > I could, similarly, move all annotations up > by one page if I delete a page from the PDF file (I haven't tried this > feature yet, but I'm assuming it would work if I'm viewing my PDF file > in continuous mode). No it doesn't -- sorry! Continuous is a *viewing* mode, doesn't change the behavior of the drawing tools which still work one layer at a time on one page at a time. So: the right thing to do is instead add an entry or two in the page menu. Most obviously, one that sets the background of the current page to be page <N> of the PDF for your favorite value of N. Then by using Page -> New Page After/Before and this new command, you can create the extra pages you need and assign them to the PDF pages you want. Second, there should be a bit of magic that figures when you are trying to adjust PDF page numbers and asks if you are trying to adjust all following page numbers as well. Initial thought: Perhaps the new commands should be - Page -> Paper style -> PDF page: sets background of current page to specified PDF page - Page -> Adjust PDF Pages After: asks for a number k of pages to shift by, if run on a xoj page that annotates page n of the PDF and k is positive then creates k new blank xoj pages that annotate pages n+1, ..., n+k of the PDF, and shifts all PDF pages greater than n in subsequent xoj pages by +k. If k is negative, then replaces backgrounds in subsequent xoj pages by blank background if page number is n+1, ..., n+|k|, and shifts PDF page numbers by k for page numbers greater than n+|k|. Example, if I'm currently having backgrounds in the xoj that are PDF pages 1 2 3 blank 4 5 6 blank 7 and on xoj page 5 = PDF page 4 I ask to adjust PDF pages after by 2, then it inserts two blank pages annotating pages 5 and 6, and the pages with backgrounds 5 6 blank 7 become 7 8 blank 9. Whereas if I ask to adjust by -2, then no xoj page disappears but the backgrounds become 1 2 3 blank 4 blank blank blank 5. Perhaps for simplicity there should also be Page -> Adjust PDF Pages at End (that does it at the end of the file). Revised thought, which I think is better: Instead of creating Page -> Adjust PDF Pages, this should be just built into Page -> New Page Before/After/At End, and Page -> Delete Page. Namely, when running a "new page" command when the current (or last) page is annotating a PDF, then New Page should ask the user whether the new page is blank, a duplicate of the current PDF page, or a new PDF page to insert by shifting all PDF page numbers by 1. And similarly Delete Page should ask whether to shift all remaining PDF page numbers by 1. This is probably much more intuitive than creating a new command "adjust PDF pages" -- the user who wants to fix pages will probably try to add or remove pages in the xoj and might reasonably expect xournal to adjust the xoj/pdf page correspondence as this happens, so this is where we should ask. (One would still have Page -> Paper style -> PDF page to allow for manual adjustments whenever needed). Is this reasonable? Further thoughts for beyond phase 1: - As an additional bit of magic, "New page at End" could detect if the last PDF page used is less than the current PDF file page count and ask if you want to create all the missing pages at once if more than one. (Not going to happen in phase 1 of the plan, don't get your hopes up. I assume that doing things one page at a time will still be useful at first and should handle the most pressing needs). - Yet another issue is that xournal does not refresh when the PDF changes under its nose (even though printing/exporting might in some cases work with the PDF file on disk rather than the one shown on screen). Perhaps the File menu should contain an entry to refresh the PDF background. I don't know if this is easy to do though, I think it may be easier to just do the current thing and ask the user to save and re-open the xoj as a way to refresh the PDF. One could imagine however an automagic command that refreshes by saving (prompting the user of course), re-opening the xoj, and then detects if page count has increased in the PDF and offers to create new pages at end if needed. Or even better, perhaps we should monitor the PDF file for changes (not all the time, perhaps only after specific operations such as scrolling beyond a page or saving the file) and, if it has changed, prompt the user whether they want to save and re-open to refresh the PDF. What do you think? Denis -- Denis Auroux UC Berkeley, Department of Mathematics 817 Evans Hall, Berkeley CA 94720-3840, USA aur...@math.berkeley.edu ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Xournal-devel mailing list Xournal-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xournal-devel