I am using pdfrw package to fill pdf file and i am looking for make the pdf to read only but i am not able to create can any one help me with this
def write_fillable_pdf(input_pdf_path, output_pdf_path, data_dict):
template_pdf = PdfReader(input_pdf_path)
annotations = template_pdf.pages[0][ANNOT_KEY]
for annotation in annotations:
if annotation[SUBTYPE_KEY] == WIDGET_SUBTYPE_KEY:
if annotation[ANNOT_FIELD_KEY]:
key = annotation[ANNOT_FIELD_KEY][1:-1]
if key in data_dict.keys():
annotation.update(
PdfDict(V='{}'.format(data_dict[key]))
)
PdfWriter().write(output_pdf_path, template_pdf)