jeudi 14 mars 2019

CheckBox doesen't toggle on in PDF view in Android

When I convert the layout to PDF, Name shows the text even in PDF but the CheckBox doesen't toggle on in PDF

I try to put the CheckBox toggle on in XML layout and when I convert to PDF the CheckBox shows correctly but programmaticaly doesen't work.

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();




Aucun commentaire:

Enregistrer un commentaire