Generate vector images

I just had a customer asking if I could come up with something like eps or illustrator.

Is there any plugin that can generate vector files ?

macOS I seem to recall that you export the contents of a canvas as EPS, via declares.

In the good old days of RB,
if you create an empty picture, and add Object2D items
then save as a PICT file
You have a vector image.

macOS doesn’t support PICT now,
RB/Xojo never added EMF or WMF support

I believe your current options will be to dig out the prototype SVG work done in the last few years (not sure that was ever finished)
or use a PDF document

Are you trying to create an Illustrator equivalent, or something that creates files that Illustrator can open?

An eps file could be quite difficult, but an svg file shouldn’t be insurmountable.

Assuming that this is something that you are initially displaying on a canvas, then all of the drawline, drawrect, drawstring calls etc., have a direct correspondence to vector elements. You could subclass these so that every time you draw something on a canvas, an equivalent item is saved in an array, and then you could do some basic conversion of this array to export it as an svg file.

Edit:
I should mention that I’ve done a lot of work creating utilities to convert from one file format to another. Some formats are much simpler than others. SVG is reasonably straightforward. EPS (encapsulated postscript) can be unbelievable complicated. If what you wish to export is a series of draw commands that were used to create graphics on a canvas, then it should be possible to directly translate this into some kind of vector graphics file such as SVG. On the other hand EPS is much more than simple vector graphics, and could be quite an ordeal.

[quote=308171:@Jeff Tullin]then save as a PICT file
You have a vector image.[/quote]

Precisely that was what I was doing with that program until Apple decided to retire Pict.

No. I sell a barcode program that uses my fonts. So the basis is already vectoriel. Some customer regretted not to be able to save under a vector format that Illustrator can load.

I had hoped Christian had some plugin that would do it, as I am not ready to spend countless hours on the feature.

Do you need this cross-platform? Would PDF work?

That’s an idea. I see that Illustrator can import PDF. At least on Mac, it is very easy to do.

But I just see that ImageMagick can export PostScript. I guess it should be something like EPS. Christian ? Are you here ? Does your plugin support all ImageMagick export capabilities ?

Someone had an svg project here a while ago. That should work.

Check:

https://forum.xojo.com/1819-svg-support/68

http://cpsc.ucalgary.ca/~gaines/O2DSVG.zip (46KB)

[quote=308191:@Michel Bujardet]That’s an idea. I see that Illustrator can import PDF. At least on Mac, it is very easy to do.

But I just see that ImageMagick can export PostScript. I guess it should be something like EPS. Christian ? Are you here ? Does your plugin support all ImageMagick export capabilities ?[/quote]
Hi Michel

Unless the situation has changed, ImageMagick’s Postscript & EPSF support come via Ghostscript so you would need that installed. Last time I checked, Ghostscript was GPL license so that restrict what you can use it for.

That is right. I remember now. I will have a look.

AFAIK HTMLEdit from Tim Parnell uses GhostScript. So there must be a way.

I just noticed Einhugur Barcode plugin generates SVG :slight_smile:

I wrapped up the declares into a sample project.
http://www.ohanaware.com/xojo/VectorExporter.zip

Simply size the canvas to the correct size, draw what you want and call either.

  • canvas.exportAsPDF( folderitem )
  • canvas.exportAsEPS( folderitem )

It appears that the exported EPS is a wrapper for PDF data.

Edit: macOS only.

[quote=308451:@Sam Rowlands]I wrapped up the declares into a sample project.
http://www.ohanaware.com/xojo/VectorExporter.zip
[/quote]

Sam, you are so great. I will be able to add that to my barcode products for Mac.

Thank you so much !

You need Xojo 2015r4 (CGFloat).

No problem. I don’t dab in ancient stuff. It works in 2016R4.1 that’s all I need.

If you don’t want to use a newer version of Xojo you could always replace the CGFloat with ‘Single’ if you build 32-bit or ‘Double’ if you build 64-Bit.

The code is free, so do with as you wish.

I just played with VectorExporter. It is great, the code is so simple to use.

Thank you again, Sam.

[quote=308716:@Michel Bujardet]I just played with VectorExporter. It is great, the code is so simple to use.

Thank you again, Sam.[/quote]
You’re welcome. It’s times like this when I really appreciate being a Mac developer… Then go back to the current problem I’m trying to solve and that feeling disappears…

More thanks Sam.