We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello again! Let's say I want to export an ellipse to PDF with stroke and fill. The library does so, by creating two separate objects: one for stroke and another for fill. Is it possible to create only one with the two properties? If not, any workaround? Like a script for Illustrator or something? Thank you!
Answers
Indeed, I can reproduce your problem with a simple adaptation of the OneFrame example:
and by opening the result with Inkscape. It shows two objects, one for the interior of the rectangle, another for the stroke itself;
I tried with my library, P8gGraphicsSVG:
and I end with a similar result.
Conclusion: since both libraries use a similar process, leveraging the underlying Java library (iText, Batik) to be called each time a Java2D graphics method is called, I think that's the Processing way to handle such drawing. So, it cannot be avoided at generation time.
Not sure if there is an easy way to transform such generated file: a script must detect the two shapes are actually the same and must be merged. Doable, not simple.
If you open the document in Illustrator, the layers are arranged by drawing order: the first thing to be drawn in Processing, gets to the bottom of the layers. So for an object #1, you get it's fill and stroke, then for object #2 it's fill and stroke and so on. For example, with this:
You get this:
Since the Clipping Path is always removed you get a sequence of shapes that you can either group, or even better, combine.
Illustrator supports JavaScript... But I'm barely new to programming languages, so I can't offer a better answer right now. I've seen some scripts which ungroup/group layers inside Illustrator, and it didn't seem that hard... If I come up with something, I'll share it with everybody.
Hi there!
The other day I was working with openFrameworks and the same issue appeared. To solve this, I did a really simple and specific Illustrator sketch to combine the two paths. You can get it here.
Like I said before, it's just something I did to solve my specific problem. In openFrameworks, you don't get a Clipping Path and Clip Group, so this sketch won't work with a PDF exported from Processing, out-of-the-box. But it's enough to get you started, or to, at least, realize that you going to face this issue some day.