3

Using Primefaces 6.0 and JAVA 1.8

Using below code to view the PDF document using DefaultStreamedContent.

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

Below code to get the Stream as 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");

When I upload and store a PDF file which contents Chineese charactes getting below exception in PDF Viewer.

PDF.js v1.0.21 (build: f954cde) Message: InvalidPDFException

Note: Plain text PDF which contents English characters working fine and able to view the PDF.

I have tried to set different character-encoding such as UTF-8,UTF-16

Please assist me how to resolve above exception. Where I can find PDF.js for further analysis ?

sagar
  • 31
  • 2
  • *"I have tried to set different character-encoding such as UTF-8,UTF-16"* - have you also tried not setting an encoding at all? PDF is a *binary* format, so trying to apply any *character* encoding is likely to damage the file... – mkl May 23 '19 at 10:35
  • @mkl yes, I did same without setting character encoding also getting _InvalidPDFException_ . – sagar May 23 '19 at 10:41
  • That is very old version is there any way you can upgrade to PFE 6.2.10 or PFE 7.0.1 which use a much newer version of PDF.js? – Melloware May 23 '19 at 10:50

0 Answers0