Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

.ai and .svg file writing

by merrymonk (Hermit)
on Mar 12, 2020 at 09:53 UTC ( [id://11114165]=perlquestion: print w/replies, xml ) Need Help??

merrymonk has asked for the wisdom of the Perl Monks concerning the following question:

I have data of 2d shapes which consists of lines, arc and circles. I want to write this out in .svg and .ai formated files. The .svg format seems reasonably straightforward the .ai format less so (the problem is that is can be used for more types of data other than lines and circles).
Does anyone know of any Perl resources that would help me?

Replies are listed 'Best First'.
Re: .ai and .svg file writing
by tobyink (Canon) on Mar 12, 2020 at 10:06 UTC

    Although there is a module called SVG to generate SVG files, I'd probably just use XML::LibXML. The SVG module doesn't seem to gain you much.

    Rather than directly trying to generate Adobe Illustrator files, I'd look at converting the SVG file you already created. If you have Adobe Illustrator on the same computer you'll be generating these files, it's capable of importing SVG files and saving them in its native format. If there are a lot, then it can apparently be automated.

    An alternative way to do the conversion would be to look at using convertio.co. I haven't tried it myself but it claims to be able to convert between these formats, and it offers an API. Shouldn't be a lot of work using JSON::MaybeXS and HTTP::Tiny to submit your SVG files to their API and receive Adobe Illustrator files.

Re: .ai and .svg file writing
by vr (Curate) on Mar 12, 2020 at 12:08 UTC

    Native Illustrator format is sort of "augmented Postscript", see the spec, AFAIK this was last official document for 20+ y.o. version. New features were added of course, but the core and syntax remain the same. Among free tools, both Inkscape (regardless of what they claim on linked page) and sk1 have long dropped support for exporting to ai. Online, here I succeeded with conversion, (while the link which tobyink provided has failed), looks like some old version of sk1 uniconvertor was used on the server, and indeed some very old ai file (version 5, 25+ y.o.) was produced.

    Is this necessary at all? For the last 20 years, ai are saved as pdf (file extension doesn't matter), with pdf as "envelope" and "ai" hidden inside as private data. Worth checking -- change extension to ai, will Illustrator silently import the pdf "envelope"? I suspect it might, so receiving side won't even know. Then, experiment a little, which Perl distribution (PDF::API2, etc.) produce cleanest (or just good enough) pdf code for your kind of data (I mean, since PDF is "machingen for machines", source never seen by human eyes, there may be ugly redundancies, etc.). Of course, if consumer is strongly serious about "ai only", this little cheat won't do, no choice but use Adobe (or more expensive) tools.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11114165]
Approved by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-25 11:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found