Python remove shapes from a pdf

496 Views Asked by At

In my setup, I have a student submit a pdf, and the teacher can annotate the pdf using the adobe embed api. This really nice since the teacher can create and delete comments.

However, take the example case where a student writes their answers on a paper then scans them to a pdf. They then draw on the pdf with a pdf editor like Microsoft edge. after they submit and the teacher is editing, it is possible for the teacher to delete what the student has drawn because the embed API treats it as a shape. I don't want this to be possible.

My backend is Django, so maybe there is some way for python to open a pdf file and "flatten" the shapes.

Thanks

1

There are 1 best solutions below

0
On

The Embed API has an annotations API, and as part of that, you can delete them (https://developer.adobe.com/document-services/docs/overview/pdf-embed-api/howtos_comments/#deleteannotations-api). You would need to build the UI yourself to provide a way for a user to select an annotation and remote it. The API covers everything (getting, adding, deleting), so it's just up to you to build it out.