在Android中生成带有Unicode字符的PDF
我正在尝试使用以下代码使用android生成PDF文件。 此PDF文件可能包含英文和中文字符。 汉字不能识别为中文字母(转换为图像),但英文字母可以 这个问题有解决办法吗 public void generatePDDFDoc(活动、视图、字符串pdfFileName){在Android中生成带有Unicode字符的PDF,android,unicode,Android,Unicode,我正在尝试使用以下代码使用android生成PDF文件。 此PDF文件可能包含英文和中文字符。 汉字不能识别为中文字母(转换为图像),但英文字母可以 这个问题有解决办法吗 public void generatePDDFDoc(活动、视图、字符串pdfFileName){ { File pdfFile = null; PrintAttributes printAttrs = new PrintAttributes.Builder().
{
File pdfFile = null;
PrintAttributes printAttrs = new PrintAttributes.Builder().
setColorMode(PrintAttributes.COLOR_MODE_COLOR).
setMediaSize(PrintAttributes.MediaSize.NA_LETTER).
setResolution(new PrintAttributes.Resolution("print", activity.PRINT_SERVICE,
25, 25)).
setMinMargins(PrintAttributes.Margins.NO_MARGINS).
build();
PdfDocument document = new PrintedPdfDocument(activity, printAttrs);
View content = view;
int width = content.getWidth();
int height = content.getHeight();
PdfDocument.PageInfo pageInfo = new PdfDocument.PageInfo.Builder(width, height, 1).create();
PdfDocument.Page page = document.startPage(pageInfo);
content.draw(page.getCanvas());
document.finishPage(page);
try {
pdfFile = new File(pdfFileName);
if (pdfFile != null) {
FileOutputStream os = new FileOutputStream(pdfFile);
document.writeTo(os);
document.close();
os.close();
}
} catch (Exception e) {
throw new RuntimeException("Error generating file", e);
} finally {
if (pdfFile != null) {
//Success Generate PDF file
}
}
}
}