-
Notifications
You must be signed in to change notification settings - Fork 688
Open
Labels
Description
Hello everyone,
I'm using Eclipse BIRT Report Designer to generate reports in PDF format, but I’m facing issues with rendering Khmer Unicode Font. The Khmer characters either:
- Appear as blank or missing text, or
- Show incorrect khmer characters.
I've tested generating a simple PDF using OpenPDF with the Hanuman font. Here’s the code I used:
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Font;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws DocumentException, IOException {
// Output PDF file
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream("Khmer_Font_Test.pdf"));
} catch (DocumentException | FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
document.open();
// Load Hanuman TTF font
BaseFont hanumanFont = BaseFont.createFont("/Users/sinsarath/eclipse-workspace/SamplePdf/fonts/Hanuman.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font font = new Font(hanumanFont, 14); // Set font size to 14
// Add Khmer text
String khmerText = "លេខ";
document.add(new Paragraph(khmerText, font));
document.close();
System.out.println("PDF generated successfully!");
}
}
Result are render not correct:
It should be displayed like that: លេខ
Reactions are currently unavailable