it's good to be back here.
I am using Primefaces Extension's exporter to export data table to PDF, in which some cells contain Hebrew text while others contain English text.
However at last the Hebrew text is always reversed. Even by adding dir="rtl" to the data table, it is never exported in the same order as its display in web page or in Excel file.
And I still have to use iText's free version (lowagie) because of budget constraint.
So do I have to create a specific method to reverse the text in Java if the cell is in Hebrew?
In order to integrate arial unicode font, I developped an exporter:
Code: Select all
public class PDFUTFExporter extends PDFExporter {
@Override
protected void createCustomFonts(String encoding) {
//In this method we shall enforce the use of UTF font.
Font f = FontFactory.getFont(
"fonts/ARIALUNI.TTF",
"Identity-H",
true, 11.0f, 0, null);
try { //cellFont has private access so it may only be modified by reflection.
Field fCellFont = getClass().getSuperclass().getDeclaredField("cellFont");
fCellFont.setAccessible(true);
fCellFont.set(this, f);
} catch (NoSuchFieldException nsfe) {
nsfe.printStackTrace(System.err);
} catch(IllegalAccessException iae){
iae.printStackTrace(System.err);
}
try { //facetFont has private access so it may only be modified by reflection.
Field fFacetFont = getClass().getSuperclass().getDeclaredField("facetFont");
fFacetFont.setAccessible(true);
fFacetFont.set(this, f);
} catch (NoSuchFieldException nsfe) {
nsfe.printStackTrace(System.err);
} catch(IllegalAccessException iae){
iae.printStackTrace(System.err);
}
try { //fontName has private access so it may only be modified by reflection. Thus we no longer use Helvetica.
Field fFontName = getClass().getSuperclass().getDeclaredField("fontName");
fFontName.setAccessible(true);
fFontName.set(this, "ArialUnicodeMS");
} catch (NoSuchFieldException nsfe) {
nsfe.printStackTrace(System.err);
} catch(IllegalAccessException iae){
iae.printStackTrace(System.err);
}
}
}