-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add PDF Viewer #2692
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
Add PDF Viewer #2692
Conversation
Code looks ok to me 👍 Need to try it out, still. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good,.but you still have GPL headers in the code. Maybe they got auto generated?
/* | ||
* Copyright (C) 2003-2016 JabRef contributors. | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The header still days GPL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Some of the code was written in an era, when such copyright notices were still included 😄
Thanks for the feedback. I also noticed some of these rendering issues (and, in addition, some math characters are displaced or not shown at all). I did some investigation and it seems that most of these problems are fixed/improved upon with PDFBox 2.0. But the update to 2.0 is still not possible for us #1096. The only other decent PDF rendering engine I found for java is itext, but it is licensed under the incompatible AGPL (this is also the reason why #2474 is blocked at the moment). Do we want to include the PDF viewer nonetheless or do you think the quality is too bad for "production"? We already had a PDF viewer? I was only aware of the PDF thumbnail, which was totally buged. For me the navigation in the maintable with arrow keys still works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also played around with it a little, and it seems to work fine in most cases. I got a lot of warnings, although the pdf displayed fine to me, so it would be cool if the tool could be a little less verbose. On open:
Apr 05, 2017 9:58:45 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-fx-accent' while resolving lookups for '-fx-background-color' from rule '*.progress-indicator:indeterminate *.segment' in stylesheet jar:file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
Apr 05, 2017 9:58:45 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-fx-accent' while resolving lookups for '-fx-background-color' from rule '*.progress-indicator:indeterminate *.segment' in stylesheet jar:file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
Apr 05, 2017 9:58:45 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-fx-accent' while resolving lookups for '-fx-background-color' from rule '*.progress-indicator:indeterminate *.segment' in stylesheet jar:file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
Apr 05, 2017 9:58:45 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-fx-accent' while resolving lookups for '-fx-background-color' from rule '*.progress-indicator:indeterminate *.segment' in stylesheet jar:file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
Apr 05, 2017 9:58:45 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-fx-accent' while resolving lookups for '-fx-background-color' from rule '*.progress-indicator:indeterminate *.segment' in stylesheet jar:file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
Apr 05, 2017 9:58:45 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-fx-accent' while resolving lookups for '-fx-background-color' from rule '*.progress-indicator:indeterminate *.segment' in stylesheet jar:file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
Apr 05, 2017 9:58:45 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-fx-accent' while resolving lookups for '-fx-background-color' from rule '*.progress-indicator:indeterminate *.segment' in stylesheet jar:file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
Apr 05, 2017 9:58:45 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-fx-accent' while resolving lookups for '-fx-background-color' from rule '*.progress-indicator:indeterminate *.segment' in stylesheet jar:file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
Apr 05, 2017 9:58:45 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-fx-accent' while resolving lookups for '-fx-background-color' from rule '*.progress-indicator:indeterminate *.segment' in stylesheet jar:file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
Apr 05, 2017 9:58:45 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-fx-accent' while resolving lookups for '-fx-background-color' from rule '*.progress-indicator:indeterminate *.segment' in stylesheet jar:file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
Apr 05, 2017 9:58:45 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-fx-accent' while resolving lookups for '-fx-background-color' from rule '*.progress-indicator:indeterminate *.segment' in stylesheet jar:file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
Apr 05, 2017 9:58:45 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-fx-accent' while resolving lookups for '-fx-background-color' from rule '*.progress-indicator:indeterminate *.segment' in stylesheet jar:file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
And then every time I scrolled to a new page:
09:58:46.787 [Thread-22] WARN org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage - Colour key masking isn't supported
09:58:46.845 [Thread-22] INFO org.apache.pdfbox.pdmodel.font.PDTrueTypeFont - Using font Times New Roman instead
09:58:46.864 [Thread-22] WARN org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage - Colour key masking isn't supported
09:58:46.920 [Thread-22] INFO org.apache.pdfbox.pdmodel.font.PDTrueTypeFont - Using font Times New Roman instead
Personally, I would not put too much effort in this as I think pdf viewing is not a central purpose of JabRef. I also hope that we do not open a can of worms here and once we have the feature, the users will find 1000 issues and improvements to pdf viewing, which would distract us from other tasks. However, JabRef is open source and if some of the developers want to have a pdf viewer in there and are ready to invest the effort to get it in, this is fine by me.
I wonder a little what the relation of this feature is to the pdf comments tab that we have now. Isn't this somehow a duplication of functionality? What are your thoughts about this?
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
import org.jabref.logic.util.io.FileUtil; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an architectural violation. Please reverse it: The conversion of ParsedFileField
to a Path should be moved to FileUtil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I also put FileUtil
in model
since it is our abstraction of the File
object? Reason: I really want the ParsedFileField
to have a method that returns the path to the linked file. There are around 15 places where expandFilename
is used upon ParsedFileField::getLink
and all of them could be replaced by the new toPath
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is, FileUtil
has more dependencies to logic classes, which would then also need to move to model. At some point, the distinction between the two packages would be completely lost.
Can't you just add a method public static Path getPath(ParsedFileField fileField)
to FileUtil
instead? Not much better than the current version, I know, but at least a little. Alternatively, extract the methods you need, and just those, into a new FileUtil
class in model (maybe with a better name). It wouldn't hurt to break up these util classes into more meaningful smaller units. They all devolve into god classes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the method to FileUtil as you proposed and will open a new PR with the refactoring since it turned out to be a bit more extensive than I have expected.
And one more thing that just came to my mind: What are the licenses of the libraries you are including here? |
@lenhard Thanks for the additional feedback. Moreover, I added the licenses: Apache 2.0 and BSD 2, so this shouldn't be a problem. |
Since @lynyus wants to implement a fulltext pdf search 😛, we need a proper way to display the results. In this PR a very plain PDF viewer is implemented. Most #PDFs are displayed correctly, maybe with a few small glitches here and there. Basic features like scrolling, changing pages and zooming work. In addition, while being in "live mode" the linked document of the currently selected BibEntry is shown - this is very handy in a two-display setup since one can have JabRef's maintable on one screen and the always-current PDF on the second.
Feedback welcome! (I will update the language files before merge.)
gradle localizationUpdate
?