JavaFX:在WebView中显示PDF [英] JavaFX: Display PDF in WebView

查看:758
本文介绍了JavaFX:在WebView中显示PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在JavaFX的默认WebView中显示PDF。我假设,我很容易就能做到这一点。

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");
    }
}

我错了。什么都没发生。似乎WebEngine没有内置的PDF-Renderer。我尝试了 JxBrowser ,它运行良好,但是代价相当昂贵。

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.

那么有没有办法直接在默认的WebView组件中显示PDF?

So is there any way to display a PDF directly inside the default WebView component?

推荐答案


JxBrowser运行良好,但是代价相当昂贵。

JxBrowser which worked fine, but is a rather costly alternative.

如果您的应用程序是开源项目,则可以获取JxBrowser开源许可证这里

If you your application is an open-source project, you can obtain the JxBrowser Open-Source license here.

这篇关于JavaFX:在WebView中显示PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆