我的 iText pdf 文档在 IE 中运行良好,但在 Firefox 中无法运行。我得到这个混乱的文字。
����I{:�3�М֠� n:^;q0�����v�x����ɕ����y��~�E�?9|��f��� �$�c"h��Z�f�YR7L[��w9|����H��V0�������x>B_�Z|��SK������dB�� ������n�r�S���+;����ɘ����aJ��Ǹ~r��f�g�q�☄��f[�7���HТ� 带入��<em>W�=`l��:�����Լ��l��)�8 C��ﳵ��/N79���Ԛg��%�P���( uE�.e������{,r�3�e�Xw^����D���0rwi�<��Y�x5 ����� |⿊�㹳w������� L�.6�����Z�=��9ӆ endstream endobj 126 0 obj <>/ProcSet [/PDF /Text
下面是我的jsp代码。我看到另一个有类似问题的线程,但没有解决方案。任何帮助是极大的赞赏。我安装了 Adobe Reader XI。如果您需要任何其他信息,请告诉我。
Document document = new Document(PageSize.LETTER, widthMargin, widthMargin, heightMargin, heightMargin);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter writer = PdfWriter.getInstance(document, baos);
document.open();
document.add(createImageTable(image1,image2));
document.close();
//response.setHeader("Expires", "0");
response.setContentType("application/pdf");
response.setHeader("Cache-Control",
"must-revalidate, post-check=0, pre-check=0");
response.setHeader("Pragma", "public");
// setting the content type
response.setContentType("application/pdf");
String countryName = filename.substring(filename.lastIndexOf('/')+1, filename.indexOf("."));
//String attachment = "attachment; filename=" + countryName + ".pdf";
String attachment = "inline; filename=" + countryName + ".pdf";
response.setHeader("Content-disposition",attachment);
response.setContentLength(baos.size());
// write ByteArrayOutputStream to the ServletOutputStream
OutputStream os = response.getOutputStream();
baos.writeTo(os);
os.flush();
os.close();