在 Java WebBrowser 控件中显示 PDF 时如何隐藏 Adobe Reader 工具栏?
我在 .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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将 #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