使用Primeface DefaultStreamedContent查看中文内容PDF时出现InvalidPDFException

时间:2019-05-23 10:08:08

标签: java pdf primefaces primefaces-extensions

使用 Primefaces 6.0 JAVA 1.8

使用以下代码使用DefaultStreamedContent查看PDF文档。

<pe:documentViewer locale="en"  height="600" value="#{documentMBean.pdfFile}" id="pdfDocViewer" >

下面的代码将流作为pdfFile获取。

byte[] documentData = null;
setPdfFile(new DefaultStreamedContent());
documentData =//Getting the byte array from DB
getPdfFile().setStream(new ByteArrayInputStream(documentData)); 
getPdfFile().setContentType("application/pdf"); 
getPdfFile().setContentEncoding("UTF-8");

当我上载并存储包含中文字符的PDF文件时,在PDF Viewer中出现异常。

  

PDF.js v1.0.21(内部版本:f954cde)消息:InvalidPDFException

注意:纯文本PDF,其中的英文字符可以正常工作并且可以查看PDF。

我尝试设置不同的字符编码,例如UTF-8,UTF-16

请协助我解决以上异常。在哪里可以找到PDF.js进行进一步分析?

0 个答案:

没有答案