shape.finish() somtimes drawing dashed lines #2171
-
First of all, I love the pymupdf library. I'm a beginner but man I have been able to accomplish some great projects with it. Anyway, I have a script where I am iterating over pages and inserting page numbers of a PDF package. I use shape.drawrect() and shape.insert_textbox() to put these page numbers in a red box. Inside the loop I have:
The code works very well but there is one issue: sometimes, seemingly randomly, the box draws with a dashed line once in an individual PDF package. This is why I have dashes = "[] 0" in shape.finish(). That did not seem to help. Any ideas what's going on here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Thank you for the feedback ❤️! Seems to be an existing page on which you are drawing? |
Beta Was this translation helpful? Give feedback.
Thank you for the feedback ❤️!
Seems to be an existing page on which you are drawing?
Maybe previously existing drawing instructions come in your way, so try executing
page.clean_contents()
before you insert anything.This does a lot of cleaning obviously, but most importantly encapsulates existing page appearance instructions by proper stack/unstack commands (
"q"
/"Q"
).