Copy link to clipboard
Copied
Hello!
I'm trying to script an action that places an SVG file, but then does some manual manipulation to that SVG's code (changing some curves, new styles, updating fills, etc.). Is such a thing possible or do I have to make any changes to the SVG code prior to placing it in InDesign?
Thank you!
Lukas
Since an SVG file is simply a text file with XML contents you should be able to change the code from that file.
With ExtendScript's File object you could use open, read, write and close methods:
https://www.indesignjs.de/extendscriptAPI/indesign14/#File.html
And yes, it would be good to make that changes before you place and link the file.
But of course you could also look into the methods of the Link object in InDesign. E.g. into method update():
https://www.indesignjs.de/extendscriptAPI/indesign14/#Link.html#d1e294199__d1e295194
...Copy link to clipboard
Copied
As a placed SVG is only linked to the InDesign document, you wouldn't have access to the SVG code from InDesign's scripting interface.
Using either Visual Basic or AppleScript as your language, depending on your OS platform, you could develop a script that could process linked SVGs in Illustrator (or in a text editor, since SVGs are XML). You're much more limited interacting with multiple applications using JavaScript.
Copy link to clipboard
Copied
Since an SVG file is simply a text file with XML contents you should be able to change the code from that file.
With ExtendScript's File object you could use open, read, write and close methods:
https://www.indesignjs.de/extendscriptAPI/indesign14/#File.html
And yes, it would be good to make that changes before you place and link the file.
But of course you could also look into the methods of the Link object in InDesign. E.g. into method update():
https://www.indesignjs.de/extendscriptAPI/indesign14/#Link.html#d1e294199__d1e295194
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Uwe, I should've realized that the File object allowed access to an SVG in JavaScript as it's essentially a text file. Thanks for correcting me.
Copy link to clipboard
Copied
Ah yeh, of course! Thank you!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more