Skip to content
This repository has been archived by the owner on Aug 15, 2021. It is now read-only.

Commit

Permalink
0.5 version
Browse files Browse the repository at this point in the history
  • Loading branch information
Dansoftowner committed Feb 15, 2020
1 parent 8aa2bd6 commit f613f91
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'FXPDFViewer'
version '0.3'
version '0.5'

sourceCompatibility = 1.8

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/dansoftware/pdfdisplayer/PDFDisplayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public void displayPdf(InputStream inputStream) throws IOException {
}


@SuppressWarnings("all")
public void setSecondaryToolbarToggleVisibility(boolean value) {
setVisibilityOf("secondaryToolbarToggle", value);

Expand Down Expand Up @@ -139,6 +140,22 @@ public void setVisibilityOf(String id, boolean value){
}
}

public int getActualPageNumber(){
try {
return (int) nodeValue.getEngine().executeScript("PDFViewerApplication.page;");
} catch (Exception e) {
return 0;
}
}

public int getTotalPageCount(){
try {
return (int) nodeValue.getEngine().executeScript("PDFViewerApplication.pagesCount;");
} catch (Exception e) {
return 0;
}
}

public void navigateByPage(int pageNum) {
String jsCommand = "goToPage(" + pageNum + ");";
try {
Expand Down
31 changes: 31 additions & 0 deletions src/test/java/PageNavigationDemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import com.dansoftware.pdfdisplayer.PDFDisplayer;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

import java.net.URL;

public class PageNavigationDemo extends Application {

@Override
public void start(Stage primaryStage) throws Exception {
PDFDisplayer displayer = new PDFDisplayer(new URL("https://www.tutorialspoint.com/javafx/javafx_tutorial.pdf"));

Button goToPage10 = new Button("Go to page 10");
goToPage10.setOnAction(e -> {
displayer.navigateByPage(10);
});

primaryStage.setScene(new Scene(new VBox(displayer.toNode(), new StackPane(goToPage10))));
primaryStage.show();

//
}

public static void main(String[] args) {
launch(args);
}
}
1 change: 0 additions & 1 deletion src/test/java/ProcessListenerDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
public class ProcessListenerDemo extends Application {
@Override
public void start(Stage primaryStage) throws Exception {

//create a progressBar
ProgressBar progressBar = new ProgressBar();
progressBar.setPrefWidth(500);
Expand Down

0 comments on commit f613f91

Please sign in to comment.