Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dashes #668

Closed
josch opened this issue Sep 26, 2020 · 2 comments
Closed

dashes #668

josch opened this issue Sep 26, 2020 · 2 comments
Assignees

Comments

@josch
Copy link
Contributor

josch commented Sep 26, 2020

There are some problems and inconsistencies with the docs. Here it says:

dashes (str) Causes lines to be dashed. A continuous line with no dashes is drawn with “[]0” or None. For (the rather complex) details on how to achieve dashing effects, see Adobe PDF References, page 217. Simple versions look like “[3 4]”, which means dashes of 3 and gaps of 4 pixels length follow each other. “[3 3]” and “[3]” do the same thing.

But when I write code like this:

shape = page.newShape()
shape.drawCircle(center, radius)
shape.finish(width=1, color=(0.5, 0.5, 0.5), dashes="[3]")
shape.commit()

then my printer will refuse to print a circle. It works fine without the dashes argument. In mupdf the dashed circle shows up fine. Another odd observation is, that ghostscript complains like this, when trying to process the pdf:

   **** Error reading a content stream. The page may be incomplete.
               Output may be incorrect.
   **** Error: File did not complete the page properly and may be damaged.
               Output may be incorrect.

I then went into the PDF ref page 217 and saw that all examples there had the phase at the end after the brackets. Funnily, when I rewrite my code like this:

shape = page.newShape()
shape.drawCircle(center, radius)
shape.finish(width=1, color=(0.5, 0.5, 0.5), dashes="[3] 0")
shape.commit()

Then there are no errors anymore. So maybe the examples in the documentation should be amended, like so:

Simple versions look like “[3 4] 0”, which means dashes of 3 and gaps of 4 pixels length follow each other. “[3 3] 0” and “[3] 0” do the same thing.

Thanks!

@JorjMcKie
Copy link
Collaborator

Thanks for reporting this - you are right. I had to learn the same lesson some time ago ... and forgot to update some places in the docu.
Dashes (apart from same thing in annotations!) must include the so-called phase, even if it is 0.

@JorjMcKie
Copy link
Collaborator

This issue is fixed with v1.18.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants