在 Java Applet 中生成/下载文档

发布于 2024-12-24 22:52:10 字数 183 浏览 3 评论 0原文

我目前有一个财务计算器小程序,可以根据用户的请求生成为用户计算的信息的 PDF。生成后,PDF 将在本地创建,并且 JFileChooser 允许用户将 PDF 移动到他们选择的计算机上的目的地。

JFileChooser 的运行需要证书。我可以做什么来将 PDF 交付给用户,作为 JFileChooser 和签名小程序的替代方案?

I currently have a finance calculator applet that at the users request generates a PDF of the information calculated for the user. When it is generated, the PDF is created locally, and a JFileChooser allows the user to move the PDF to the destination on their machine of their choosing.

A certificate is required for the JFileChooser to run. What can I do to deliver the PDF to the user as an alternative to the JFileChooser and signing the applet?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

宣告ˉ结束 2024-12-31 22:52:10

来自官方 Java Applet 教程

当使用 JNLP 启动时,未签名的小程序也可以执行
以下操作:

* 他们可以在客户端上打开、读取和保存文件。

查看这个作为示例。

如果您必须坚持使用传统的小程序,则应该对 jar 进行签名,即使这意味着自签名(我认为在这种情况下会显示警告,但用户可以继续)。

From the official Java Applet tutorial:

When launched by using JNLP, unsigned applets can also perform the
following operations:

* They can open, read, and save files on the client.

Check this out as an example.

If you have to stick to traditional applets, you should sign the jar, even if that means self-signing (I think in this case a warning is displayed, but the user can proceed).

如果没有 2024-12-31 22:52:10

使用此方法:

URL url = new URL(getCodeBase().getProtocol(),
                      getCodeBase().getHost(),
                      getCodeBase().getPort(),
                      "/your_pdf_file");

getAppletContext().showDocument(url);

它只会提示用户下载文件或内联查看它

编辑:这仅在服务器生成 PDF 而不是客户端小程序时有用

Use this method:

URL url = new URL(getCodeBase().getProtocol(),
                      getCodeBase().getHost(),
                      getCodeBase().getPort(),
                      "/your_pdf_file");

getAppletContext().showDocument(url);

It would just prompt the user to download the file or view it inline

EDIT: This is only useful if the Server is generating the PDF and not the Client Applet

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文