【发布时间】:2019-03-15 11:22:08
【问题描述】:
当我将布局转换为 PDF 时,Name 即使在 PDF 中也会显示文本,但 CheckBox 不会在 PDF 中打开。
我尝试在 XML 布局中打开 CheckBox 切换开关,当我转换为 PDF 时,CheckBox 显示正确,但以编程方式不起作用。
TextView tvName = content.findViewById(R.id.txtNameInsert);
CheckBox chM = content.findViewById(R.id.checkMinsert);
tvName.setText(Name.getText());
chM.toggle();
content.draw(page.getCanvas());
document.finishPage(page);
String targetPdf = "/sdcard/pdffromlayout.pdf";
File filePath;
filePath = new File(targetPdf);
try {
document.writeTo(new FileOutputStream(filePath));
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(SchedaPaziente.this, "Something wrong: " + e.toString(), Toast.LENGTH_LONG).show();
}
// close the document
document.close();
Toast.makeText(SchedaPaziente.this, "PDF is created!!!", Toast.LENGTH_SHORT).show();
openGeneratedPDF();
【问题讨论】:
标签: android android-layout checkbox