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

Fix document viewer not showing first page #7132

Merged
merged 3 commits into from
Nov 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ inserting new citations in a OpenOffic/LibreOffice document. [#6957](https://git
- We fixed an issue where the EndNote XML Import would fail on empty keywords tags [forum#2387](https://discourse.jabref.org/t/importing-in-unknown-format-fails-to-import-xml-library-from-bookends-export/2387)
- We fixed an issue where the color of groups of type "free search expression" not persisting after restarting the application [#6999](https://github.com/JabRef/jabref/issues/6999)
- We fixed an issue where modifications in the source tab where not saved without switching to another field before saving the library [#6622](https://github.com/JabRef/jabref/issues/6622)
- We fixed an issue where the "Document Viewer" did not show the first page of the opened pdf document and did not show the correct total number of pages [#7108](https://github.com/JabRef/jabref/issues/7108)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;
import java.util.Objects;

import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ListProperty;
Expand Down Expand Up @@ -55,9 +56,11 @@ public DocumentViewerViewModel(StateManager stateManager) {
}
});

maxPages.bindBidirectional(
// we need to wrap this in run later so that the max pages number is correctly shown
Platform.runLater(() -> {
maxPages.bindBidirectional(
EasyBind.wrapNullable(currentDocument).selectProperty(DocumentViewModel::maxPagesProperty));

});
setCurrentEntries(this.stateManager.getSelectedEntries());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Image render(int width, int height) {

@Override
public int getPageNumber() {
return pageNumber;
return pageNumber + 1;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ObservableList<DocumentPageViewModel> getPages() {
List<PdfDocumentPageViewModel> pdfPages = new ArrayList<>();
// There is apparently no neat way to get the page number from a PDPage...thus this old-style for loop
for (int i = 0; i < pages.getCount(); i++) {
pdfPages.add(new PdfDocumentPageViewModel(pages.get(i), i + 1, document));
pdfPages.add(new PdfDocumentPageViewModel(pages.get(i), i, document));
}
return FXCollections.observableArrayList(pdfPages);
}
Expand Down