【问题标题】:how to inject a dynamically generated pdf into a gwt iframe如何将动态生成的 pdf 注入 gwt iframe
【发布时间】:2017-07-31 13:22:08
【问题描述】:

我想要一个动态生成的 pdf 显示到 iframe 中,我可以成功调用 iframe 内的 servlet,如下:

Frame frame = new Frame();
frame.setUrl( downloadUrl );

其中“downloadUrl”是一个包含 servlet 地址和参数的字符串。问题是在过程结束时我被问到是否要下载 pdf 文件,并且 iframe 仍然为空。

这是 servlet 的相关部分

//the pdf file
byte[] outArray = null;

[...]

response.setContentType( "application/pdf" );
response.setHeader( "Content-Disposition", "attachment;filename=Customer_Print.pdf" );

[...]

outArray = functionToGeneratePdfFile();

if ( outArray != null ) {
OutputStream outStream = response.getOutputStream();
outStream.write( outArray );
outStream.flush();
}

有什么提示吗? 提前致谢

解决方案:

好的,我可以通过以下方式更改标题来获得 iframe 内的预览:

response.setHeader( "Content-Disposition: inline", "filename=Customer_Print.pdf" );

【问题讨论】:

标签: java pdf servlets iframe gwt


【解决方案1】:

我认为主要问题是由您添加“附件”引起的;到标题,只需将其删除。

【讨论】:

    猜你喜欢
    • 2019-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多