masongyli / simple-xopp-merger

A tiny shell script that merges all Xoural++ files (with .xopp file extension) in the current folder into a single Xournal++ file
0 stars 0 forks source link

Poppler error #1

Open FedericoCalzoni opened 6 months ago

FedericoCalzoni commented 6 months ago

I've tried to merge two xournal files. The resulting output seems to have some problems. Some pages (the firsts ones or the last ones) are gray (they not load properly). And xournal when it tries to load them sometimes crashes. This is the log:

errorlog.20240219-133102.log

masongyli commented 6 months ago

Thank you for the feedback. Could you provide the xournal++ files you want to merge (or some xournal++ files that would reveal the bug)? I would find some time to investigate it.

FedericoCalzoni commented 6 months ago

I can't provide you with the xournal files in which I have the problem mentioned before, because I do not have the permissions to share it.

Anyway, I have tried to reproduce the bug by using other material.

I discovered that the issue may not come from your script, but instead from a script that I execute to the PDFs to change their page size and margins.

You can find everything inside the following zip. (read the README files).

xournal-bug.zip

masongyli commented 6 months ago

I see the problem. In short, a xournal++ file cannot handle multiple pdf files, at least in the current Xournal++ version (v1.2.2). (see https://github.com/xournalpp/xournalpp/discussions/3848) I would find some time to implement the workaround.

I would explain what happens in your case

why some pdf backgrounds of 1-wide_merged are wrong

After your script (PDF-Margin.sh), 1-wide.pdf has 52 pages, except that page 19 is 595pt x 1100pt, other pages are 1100pt x 595pt. (The 1-wide.xopp has the same page width and height) 2-wide.pdf has 19 pages, except that page 1 and 15 are 595pt x 1100pt, other pages are 1100pt x 595pt. (The 2-wide.xopp has the same page width and height)

After my script (merge-xopp.sh), it merges the content of 1-width.xopp and 2-width.xopp together. We might expect the result is

But xournal++ v1.2.2 could only handle 1 pdf file. so the actual result would be

why there are gray areas in page 54, 67, 71 in 1-wide_merged.xopp

Take page 71 in 1-wide_merged.xopp as example. the xournal++ page is from page 19 of 1-wide.xopp (595pt x 1100pt) but the background is page 19 of 1-wide.pdf (1100pt x 595pt)

image

summary

My current script cannot cope with multiple pdf. But it's ok to cope with up to 1 pdf. Since Xournal++ v1.2.2 doesn't support 1 xopp file with multiple pdf files, the workaround is to merge multiple pdf into 1 pdf, and then renumber the page numbers, and link the xopp to that 1 pdf. (I would find some time to implement it),

FedericoCalzoni commented 6 months ago

Thank you for your detailed explanation. Now it's also clear to me what was happening. I also realized that after moving the file to another path, the merged xopp file was asking me for the background of the first pdf. I think that the workaround you proposed can work.

FedericoCalzoni commented 2 months ago

I created a Python script to handle merging with PDF backgrounds: xopp-merger.

I hope you find it useful! :)