I need to display a PDF inside the default WebView of JavaFX. I assumed, that i would easily be able to do that like this.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class ShowPdfTest extends Application {
public static void main(String[] args) {
launch();
}
@Override
public void start(Stage primaryStage) throws Exception {
WebView webView = new WebView();
WebEngine engine = webView.getEngine();
Scene scene = new Scene(webView);
primaryStage.setScene(scene);
primaryStage.show();
// engine.load("https://www.google.com");
engine.load("http://www.orimi.com/pdf-test.pdf");
}
}
I was wrong. Nothing happens. It seems like the WebEngine has no built-in PDF-Renderer. I tried JxBrowser which worked fine, but is a rather costly alternative.
So is there any way to display a PDF directly inside the default WebView component?