Hi,
I try to read a UTF-8 file with Khmer characters and try to out it as a PDF using Aspose PDF. However, the output PDF is blank. May I know is Aspose support Khmer character ? The following is my code:
import java.io.File;
import java.nio.charset.Charset;
import aspose.pdf.*;
import org.apache.commons.io.FileUtils;
public class AsposePdf {
public static void main(String[] args) throws Exception {
new AsposePdf().createPdf();
}
public void createPdf() throws Exception {
// Instantiate Pdf object by calling its empty constructor
Pdf pdf = new Pdf();
// Create a new section in the Pdf object
Section sec = pdf.getSections().add();
final String hello = FileUtils.readFileToString(new File("hello.txt"), Charset.forName("UTF-8"));
// Create a new text paragraph and pass the text to its constructor as argument
Text text = new Text(sec, hello);
text.getTextInfo().setFontName("Arial Unicode MS");
sec.getParagraphs().add(text);
pdf.setUnicode();
pdf.save("hello.pdf");
}
}
Regards,
Cheong
I try to read a UTF-8 file with Khmer characters and try to out it as a PDF using Aspose PDF. However, the output PDF is blank. May I know is Aspose support Khmer character ? The following is my code:
import java.io.File;
import java.nio.charset.Charset;
import aspose.pdf.*;
import org.apache.commons.io.FileUtils;
public class AsposePdf {
public static void main(String[] args) throws Exception {
new AsposePdf().createPdf();
}
public void createPdf() throws Exception {
// Instantiate Pdf object by calling its empty constructor
Pdf pdf = new Pdf();
// Create a new section in the Pdf object
Section sec = pdf.getSections().add();
final String hello = FileUtils.readFileToString(new File("hello.txt"), Charset.forName("UTF-8"));
// Create a new text paragraph and pass the text to its constructor as argument
Text text = new Text(sec, hello);
text.getTextInfo().setFontName("Arial Unicode MS");
sec.getParagraphs().add(text);
pdf.setUnicode();
pdf.save("hello.pdf");
}
}
Regards,
Cheong