This article explains how to lock a PDF layer, extract PDF layer elements, flatten a layered PDF, and merge all layers inside a PDF into one....below use the Document and Page APIs and manipulate Layer objects...layers : layer . flatten ( cleanup_content_stream = True ) document...