I have added a DataExporter. If the data grid has Arabic letters, they are not being deployed at all, or they are being displayed disjoint and above each other. Here is an image:
To solve the issue, I have added PDFOption, including a new Arial font.
pdfOpt = new PDFOptions();
InputStream fontStream = FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream("/resources/fonts/arial.ttf");
BaseFont baseFont = null;
try {
baseFont = BaseFont.createFont("arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, true, fontStream.readAllBytes(), null);
} catch (IOException ex) {
Logger.getLogger(PrimefacesPDFExporterOptions.class.getName()).log(Level.SEVERE, null, ex);
} catch (DocumentException ex) {
Logger.getLogger(PrimefacesPDFExporterOptions.class.getName()).log(Level.SEVERE, null, ex);
}
Font font = new Font(baseFont, 12, Font.NORMAL);
pdfOpt.setFontName(font.getBaseFont().getFullFontName()[0][3]);
The problem with this solution is that I am not being able to set the font it self, just the name of it. So, I need to set the encoding. To do that, I added encoding attribute to the p:dataExporter and set the value to Identity-H:
<p:dataExporter options="#{primefacesPDFExporterOptions.pdfOpt}" encoding="Identity-H" type="pdf" preProcessor="#{primefacesPDFExporterOptions.makePDFLandscape}" pageOnly="false" target="explorerResultsTableId" fileName="data"/>
This did not solve the issue!
Another option I am trying to apply, is to change the font of every cell in the PDF to the created one. But I am not able to get the cells!

This is a basic solution for
PF 12, to get the work done, with few changes, but can be improved. I define a customexporterin thexhtml, like this:I use a font compatible with Arabic characters, like
ARIALUNI.TTFand I embedded the file in the project (it's easily findable on the internet).I initialized the
exporteron class creation:MyPDFExporteris most likely PF version (DataTableExporter), I only change theapplyFontfunction, to use the embedded one (I can't get it working directly, passing by option), so it looks like thisThe only change with
PF 12default version is the use of a font compatible with Unicode characters.AFAIK the older
PFversion doesn't useopenpdfso you needpdfCalligraphto get it works withitext.Some useful related questions: