Search code examples
javabi-publisherxml-publisher

Oracle BI Publisher Java APIs convert Chinese characters to question marks (?)


I've BI publisher Desktop installed that helps us to generate and visualize PDF from RTF file with sample data. RTF file which we are using is a mix of English and Chinese characters and with sample XML data , we are able to see PDF as we want.

As Expected PDF When we use the same RTF in our java code (using BI publisher Java APIs) to create PDF , all the Chinese characters get replaced with question marks (?).

Resultant PDF

Below is the code where we are converting RTF to PDF

        RTFProcessor rtfp = new RTFProcessor(pTemplate);
        ByteArrayOutputStream xslOutStream = new ByteArrayOutputStream();
        rtfp.setOutput(xslOutStream);
        
        rtfp.process();

        //Use XSL Template and Data from the VO to generate report and return the OutputStream of report
        ByteArrayInputStream xslInStream = new ByteArrayInputStream(xslOutStream.toByteArray());

        FOProcessor processor = new FOProcessor();
        ByteArrayInputStream dataStream =
            new ByteArrayInputStream((byte[])pXmlOut); ///amDpc.getXMLData(pVoInstName));
        processor.setData(dataStream);
        processor.setTemplate(xslInStream);
        
        ByteArrayOutputStream pdfOutStream = new ByteArrayOutputStream();
        processor.setOutput(pdfOutStream);
        byte outFileTypeByte = FOProcessor.FORMAT_PDF;
        
        processor.setOutputFormat(outFileTypeByte); 
        processor.generate();

        dataBytes = pdfOutStream.toByteArray();

Googling suggests adding font file to BI publisher $oracle_top location or in $java_home/jre/lib/fonts locations. Since BI publisher is not directly used , option 1 ($oracle_top) is ruled out and Option 2 would require testing of all ADF applications deployed on PROD servers , which I would like to avoid .

Any suggestions on how to print Chinese characters ?

SW Version : Oracle BI Publisher Desktop 12.2.1.4.0


Solution

  • This was achieved by placing fonts under $java_home/jre/lib/fonts location.No server bounce was needed.