KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Accessing SVG Images in Picture Variable Objects
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: July 26, 2010

New 4D v12 commands allow developers to access SVG images which are displayed in 4D Picture Variable objects directly.

In 4D, the SVG paradigm includes an XML document which is stored in memory that is then sent to a 4D Picture via the SVG EXPORT TO PICTURE command. That picture now has its own copy of the XML document, which can be referred to as the data source. Every time that picture is referenced, the given data source is used. In 4D v11 SQL it was necessary to keep a copy of the original XML document as well to adjust and then re-send that document to the 4D Picture with SVG EXPORT TO PICTURE.

In 4D v12, developers can programmatically access the SVG data source after it has been sent to the 4D Picture, and therefore a copy of the original XML document does not need to be stored. For more information on this behavior see the Technical Note "Editing SVG Pictures in 4D v12".

The following 4D SVG commands can access the SVG image in two ways.


For each command, the picture which it is executed on can either be passed as a variable or as an object. To pass the picture as an object, the * parameter must precede the picture.

If the picture is passed to a command as a variable then the original XML document which was saved with the image is referenced. If the picture is passed to a command as an object then the actual image which is currently rendered is referenced. This is important because SVG SET ATTRIBUTE and SVG SHOW ELEMENT can change the currently rendered image so it does not match its data source.

Note that you can pass an object or variable to SVG SET ATTRIBUTE and SVG SHOW ELEMENT as well. These commands only update the rendered image though, they never act on the data source which defines the image.