Please give a brief summary of your issue:
Cannot print only fillable pdf fields.
Please describe your issue and provide steps to reproduce it:
I’m trying to print just the fillable pdf fields not all the other annotations that have been included or drawn on. When doing this the print job includes all annotations not just fillable fields
val printContent =
0 or Print.PRINT_CONTENT_DOCUMENT_BIT or Print.PRINT_CONTENT_ANNOTATION_BIT
Print.startPrintJob(
activity,
activity?.getString(R.string.app_name),
pdfDoc,
printContent,
false
)
How can I achieve that?
Please provide a link to a minimal sample where the issue is reproducible:
which removes all the annotations that are not fillable fields. Is there nothing like this in the Android sdk?
What is the best way to remove annotation fields that aren’t fillable? I have the data object from our server of all annotations with the appropriate id but cannot find the best way to remove solely for share/print and not the viewing of the document
The rest would be the same PDF with all the non-fillable annotations being removed. Next you can print that copy of the document and discard the copy it at the end if you wish. Could you please give this a try to see if it works for you?
It appears we gave you the incorrect sample for this ticket, please see the correct sample below:
val pdfDoc = pdfViewCtrlTabHostFragment?.currentPdfViewCtrlFragment?.pdfDoc
val tempPath = "/data/data/com.canopytax.practitioner/files/testing.pdf"
pdfDoc!!.save(tempPath, SDFDoc.SaveMode.NO_FLAGS, null)
val pdfDocTemp = PDFDoc(tempPath)
val pageIterator = pdfDocTemp.pageIterator
while(pageIterator.hasNext()) {
val page = pageIterator.next()
if (page!!.isValid) {
val annotationCount = page.numAnnots
for (a in annotationCount - 1 downTo 0) {
val annot = page.getAnnot(a)
if (annot != null && annot.isValid) {
if (Annot.e_Widget != annot.type) {
page.annotRemove(annot)
}
}
}
}
}
val printContent =
0 or Print.PRINT_CONTENT_DOCUMENT_BIT or Print.PRINT_CONTENT_ANNOTATION_BIT
Print.startPrintJob(
activity,
activity?.getString(R.string.app_name),
pdfDocTemp,
printContent,
false
)