Sitelet https://web.archive.org/web/20210820002017/https://github.com/xournalpp/xournalpp/issues/3189
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fulll pdf path is saved regardless of mode. #3189

Open
rolandlo opened this issue Jun 26, 2021 · 5 comments
Open

Fulll pdf path is saved regardless of mode. #3189

rolandlo opened this issue Jun 26, 2021 · 5 comments

Comments

@rolandlo
Copy link
Member

@rolandlo rolandlo commented Jun 26, 2021

Affects versions :

  • OS: Linux (doesn't matter)
  • X11 (doesn't matter)
  • Which version of libgtk do you use: 3.24.25 (doesn't matter)
  • Version of Xournal++: 1.1.0+dev
  • PPA (doesn't matter)

Describe the bug
The pdf background filename is saved in absolute mode, regardless of the mode it has been originally saved with previously. So if a document is created in attach mode, saved, reopened and saved again, the path to the pdf will now be in absolute mode.

To Reproduce
Steps to reproduce the behavior:

  1. Open a pdf test.pdf with "Annotate pdf" and check the "attach to journal" checkbox on the bottom left of the file dialog
  2. Edit the pdf and save the xopp-file test.xopp. Observe that a test.xopp.bg.pdf file is created in the same directory and the (ungzipped) xopp-file contains a tag
<background type="pdf" domain="attach" filename="bg.pdf" pageno="1ll"/>

as expected
3. Open the xopp-file from the file manager or with "Open File"
4. Edit and save again
5. Observe that the (unzipped) xopp-file now contains a tag

<background type="pdf" domain="absolute" filename="full/path/to/pdf/test.xopp.bg.pdf" pageno="1ll"/>

instead of the attach mode

Expected behavior
A document that has been created in attach mode should remain in attach mode when reopend and saved again

Additional context
There is a related issue #2736, that relative pdf background filenames can be opened, but when they are saved, the relative path gets replaced by the full absolute path.

@ashwincreates
Copy link

@ashwincreates ashwincreates commented Jun 27, 2021

Hey, how do i see the unzipped version ?

@rolandlo
Copy link
Member Author

@rolandlo rolandlo commented Jun 27, 2021

Just rename the .xopp-filename ending to .gz, then gunzip it, then open it up in a text editor. After making your changes, gzip it again and rename the filename ending again from .gzto .xopp. Make sure you make a backup copy of the xopp-file if experimenting with it the first time.
By the way, I have a little python script which gives me a dropdown menu entry in the file manager (nautilus) with with I can open and edit a .xopp-file in gedit in human-readable format. It does all of the above automatically. If anyone likes, I can share it (without any warranty).

@Rmano
Copy link
Contributor

@Rmano Rmano commented Jun 27, 2021

If you use vim, adding this to your .vimrc:

" edit xournal files (see https://vi.stackexchange.com/a/10390/854)
augroup gzip_local2
    autocmd!
    autocmd BufReadPre,FileReadPre     *.xopp setlocal bin
    autocmd BufReadPost,FileReadPost   *.xopp call gzip#read("gzip -dn -S .xopp")
    autocmd BufWritePost,FileWritePost *.xopp call gzip#write("gzip -S .xopp")
    autocmd FileAppendPre              *.xopp call gzip#appre("gzip -dn -S .xopp")
    autocmd FileAppendPost             *.xopp call gzip#write("gzip -S .xopp")
augroup END

...will let you directly edit .xopp files

@ashwincreates
Copy link

@ashwincreates ashwincreates commented Jun 27, 2021

Thanks, i duplicated the bug, So like which part of the codebase should i start exploring to find more abt the bug, will i get it in src/pdf?

@rolandlo
Copy link
Member Author

@rolandlo rolandlo commented Jun 27, 2021

@ashwincreates You will have to look at the LoadHandler.cpp and the SaveHandler.cpp code files and possibly at the Control.cpp and Document.cpp code files. Search for the string "attach" and the boolean variable attachToDocument to get started.

@rolandlo rolandlo mentioned this issue Jun 27, 2021
28 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants