我正在使用 Android 的内置PrintedPdfDocument使用 Canvas 绘制 PDF,如本文档示例代码中所述:
private void drawPage(PdfDocument.Page page) {
Canvas canvas = page.getCanvas();
// units are in points (1/72 of an inch)
int titleBaseLine = 72;
int leftMargin = 54;
Paint paint = new Paint();
paint.setColor(Color.BLACK);
paint.setTextSize(36);
canvas.drawText("Test Title", leftMargin, titleBaseLine, paint);
paint.setTextSize(11);
canvas.drawText("Test paragraph", leftMargin, titleBaseLine + 25, paint);
paint.setColor(Color.BLUE);
canvas.drawRect(100, 100, 172, 172, paint);
}
是否可以在此文档中添加表情符号文本?我不知道如何设置字符集/编码。
每当我尝试添加表情符号输出时,它都会在 pdf 中显示为乱码。
这是保存pdf的代码:
mPdfDocument = new PrintedPdfDocument(context, printAttributes);
mCurrentPage = mPdfDocument.startPage(1);
Canvas canvas = mCurrentPage.getCanvas();
... // add stuff to canvas
mPdfDocument.finishPage(mCurrentPage);
FileOutputStream fos = new FileOutputStream(new File(path));
mPdfDocument.writeTo(fos);
fos.close();
谢谢!
qq_遁去的一_1
冉冉说
相关分类