Replies: 7 comments 4 replies
-
So what would you expect to happen if neither a fill nor a stroke color is given? |
Beta Was this translation helpful? Give feedback.
-
I would say I would raise an error. I guess when no stroke nor fill are given, nothing should be drawn? Or is it possible to have paths in PDF which have absolutely no color (but for which opacity is 1)? |
Beta Was this translation helpful? Give feedback.
-
Raising an error definitely is an option - probably the most adequate one. |
Beta Was this translation helpful? Give feedback.
-
The next version will react with an exception if |
Beta Was this translation helpful? Give feedback.
-
After giving it more thought, I would like to discuss this in more detail with you guys. |
Beta Was this translation helpful? Give feedback.
-
@jn-chrn and @Luux - Please react to the following argument: In all of PDF specification, the stroke color default is black. Which means, it will be taken, if an explicit stroke color is absent. This is exactly what has been implemented in PyMuPDF: if both color arguments, If I do make the change you request, then PyMuPDF would
So I have changed my mind: I think this update would be wrong. |
Beta Was this translation helpful? Give feedback.
-
We agree you should not add a breaking change. This is even more true in this particular case, as this follows the PDF specifications. From our side, we should also be able to work around it. So we think not adding an exception is fine. However the user needs then some insights that this may happen: potential solutions would be a warning, more details in the docstring and/or mentions of this issue in the documentation. What do you think? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
A drawing added to a shape for which no color is applied (
shape.finish(color=None)
) is then drawn as shape with stroke color set to(0, 0, 0)
. When read usingPage.get_drawings()
, the same occurs: the drawing is parsed as being black.To Reproduce
The following script draws a
Rect
without color on a page. The drawings from the page are then read, and the path which contains theRect
object is now black.Expected behavior
Maybe the behavior shown by the script was actually expected. However, for me it seems inconsistent to draw an object without color and get a color out of it. In some of my use cases, PDF have no stroke color, but still have a fill color. Thus, I would expect here an error, because stroke color or fill color must be set. But I may be overlooking something.
Screenshots
Your configuration
Result of the command:
PyMuPDF is installed inside a conda environment with pip.
Beta Was this translation helpful? Give feedback.
All reactions