我就是想让它显示在我定义好的一个table里。不过运行的时候pdf是生成了,可是它占了整个页面。页面上其它的内容都无法显示?有什么好的办法吗?
我页面的代码是这样的:
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="java.util.*,java.io.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>PDF report</title>
<script language=javascript>    
function doPrint() {    
bdhtml=window.document.body.innerHTML;    
sprnstr="<!--startprint-->";    
eprnstr="<!--endprint-->";    
prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);    
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));    
window.document.body.innerHTML=prnhtml;    
window.print();    
}    
</script>
</head> <body>
<table>
<tr>
<td>
预览
</td>
</tr>
<tr>
<td>
<input type="button" value="打印" onclick="doPrint()" />
</td>
</tr>
</table>
<table>
<tr>
<!--startprint-->
<td width="400" height="400">
<%
byte[] pdfReport = (byte[]) request.getAttribute("pdfReport");
if (pdfReport != null) {
OutputStream outputStream = response.getOutputStream();
String style = (String) request.getAttribute("style");
if (style.equalsIgnoreCase("html")) {
response.setContentType("text/html");
} else if (style.equalsIgnoreCase("excel")) {
response.setContentType("application/msexcel");
} else if (style.equalsIgnoreCase("excel")) {
response.setContentType("application/pdf");
}
response.setContentLength(pdfReport.length); outputStream.write(pdfReport, 0, pdfReport.length);
outputStream.flush();
outputStream.close();
} else {
%>
</td>
<!--endprint-->
</tr>
<%
}
%>
</table>
</body>
</html>有没有可能是在输出的时候又重新生成了一个页面覆盖了自己定义的页面?