Layers got deleted Automatically on saving PDF page. #2767
-
@JorjMcKie` I am creating new pdf page based on page number , While creating new pdf page all annotation attribute are correct except Layer.Layers got automatically removed while saving pdf page. This is my code. `output_pdf_with_color = fitz.open(filetype = "pdf")
Could you please let me know How to fix it ? Original file contains layers. Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
For the time being, this is not a bug, but a question. |
Beta Was this translation helpful? Give feedback.
-
I am sorry, but your code is hardly readable, because of the mixture formatted and unformatted code. |
Beta Was this translation helpful? Give feedback.
-
Inserting pages from a source to a target PDF is a page-oriented process. Layers however are stored centrally in a PDF - not by page or inside a page. While OCGs referenced by a page will copied over to the targt PDF - like any other referenced object - they will still not become known as OCGs by this copy. You therefore must find a way to replicate the source Optional Content situation in the target somehow. This is currently not supported and requires your own - probably hacky - code. I cannot think of a complete and failsafe way to do that to be honest. |
Beta Was this translation helpful? Give feedback.
I am sorry, but your code is hardly readable, because of the mixture formatted and unformatted code.
What I understood is that your output PDF is filled with pages from some source PDF via
insert_pdf()
.Correct so far?