在 Java WebBrowser 控件中显示 PDF 时如何隐藏 Adob​​e Reader 工具栏?

发布于 2024-12-03 16:40:52 字数 1119 浏览 3 评论 0原文

我在 .NET 和文件中看到了同样的问题,但这是不同的:

我有一个 Java 应用程序,它调用一个带有一些参数的方法,它们之间的响应:

myCode.launchPDF(response, someOtherData...)

函数 launchPDF 得到 带有参数的 ByteArrayOutputStream使用响应向用户显示 PDF

private static void launchPDF(HttpServletResponse response, Object... someData) {
    try{

        ByteArrayOutputStream baos = getPDFFromWS(...);

        response.setContentType("application/pdf");
        response.setHeader("Content-Disposition","attachment; filename=\"example.pdf");
        OutputStream out1 = response.getOutputStream();

        if ( baos!=null && out1!=null)
            baos.writeTo( out1 );

        out1.flush();
        out1.close();

        if (!FacesContext.getCurrentInstance().getResponseComplete())
            FacesContext.getCurrentInstance().responseComplete();
        } catch (Exception e){...}
 }

并且它工作完美......但是(这就是问题)我需要隐藏控件将 PDF 发送给应用程序的用户...

是否可以使用任何参数或类似的东西隐藏工具栏? 是否可以控制pdf阅读器插件? 是否可以在 PDF 中包含任何类型的脚本来隐藏工具栏?

非常感谢

I have seen the same question with .NET and a file, but this is different:

I have a Java aplication that calls a method with some parameters, response between them:

myCode.launchPDF(response, someOtherData...)

The function launchPDF get the ByteArrayOutputStream with the parameters and use the response to show a PDF to the user:

private static void launchPDF(HttpServletResponse response, Object... someData) {
    try{

        ByteArrayOutputStream baos = getPDFFromWS(...);

        response.setContentType("application/pdf");
        response.setHeader("Content-Disposition","attachment; filename=\"example.pdf");
        OutputStream out1 = response.getOutputStream();

        if ( baos!=null && out1!=null)
            baos.writeTo( out1 );

        out1.flush();
        out1.close();

        if (!FacesContext.getCurrentInstance().getResponseComplete())
            FacesContext.getCurrentInstance().responseComplete();
        } catch (Exception e){...}
 }

And it works perfect... BUT (here is the problem) I need to hide the controls of the PDF to the user of the application...

Is it possible to hide the toolbar with any parameter or something similar?
Is it possible to take the control of the pdf reader plugin?
Is it possible to include any kind of script inside the PDF to hide the toolbar?

Thanks A LOT.

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

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

发布评论

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

评论(1

还在原地等你 2024-12-10 16:40:52

您需要将 #toolbar=0 与 url 一起使用
例如:http://somesite.com/file.pdf#toolbar=0

这将在没有工具栏的浏览器中打开 pdf 文档。

此处是 adobe 上的文档显示 pdf 时的可用选项

you need to use #toolbar=0 with the url
ex: http://somesite.com/file.pdf#toolbar=0

this would open the pdf document in the browser without a toolbar.

here is a document from adobe on available options while displaying pdf's

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