People maybe do not know that SVG files could be imported as image Object in iWork.
And its possible to make the object editable.
The handler parameters: page index, path to svg file, position-x and position-y.
Have tested to use PDF file but iWork do not make it editable.
So it means iWork at last with some struggle could import vector format and make it editable.
Ps. To make this to work you need to figure-out the export options for your svg file.
And Apple do not make it easier to describe what kind of SVG file that it could import
and break apart to make it editable. They only say its possible and thats it.
I was able to locate the format iWork is using: I tested SVG Tiny 1.1 version
I’m not sure if version 1.2 works but here is an link: Introduction – SVG Tiny 1.2
It looks like Inkscape 1.2 export to SVG is working very well. Also it does not support SVGZ files. But if you happen to have one you could maybe try to use gzip decompress the image.
Lets do an example:
set thePath to (path to desktop as text) & "test.svg"
set theObject to its makeImageWithProperties(1, thePath, 10, 10)
(**
* This we have to do manually:
* 1. Break Apart
* 2. Ungroup
* 3. Make editable
*
* It could maybe be done with GUI Scripting.
*)
on makeImageWithProperties(pageNumber, filePath, xPos, yPos)
tell application "Pages"
tell page pageNumber of front document
set theObject to make new image with properties {file:filePath}
tell theObject
set position to {xPos, yPos}
end tell
end tell
end tell
end makeImageWithProperties
1 Like
There are some online services that convert PDF to SVG. With this little detour, one can perhaps add the content of a PDF to iWork.
PDF format is a very complex format that could almost store anything. And to make parser that could extract objects from PDF and make it editable. The problem could be if the image are missing stroke width or if the object have color fill of white (specially if transparent) document
automatic display the background with white color. For the user that would be a document
with no objects. (or object that have the same color as the background).
Adobe Illustrator could edit PDF file so why would it be different in iWork.
This application could also edit PDF and make it very robust. Not only that the path become layers. Next you could export it to SVG and import in iWork.
I guess its time to learn how SVG works. This example draw red rect with black stroke in front document of Pages. The SVG file is saved on the Desktop folder.
(**
* viewBox:
* attribute is used to define the coordinate system and aspect ratio for the SVG content.
* position, size of the viewport within which the SVG content is drawn.
**
*)
set svgContent to "<?xml version=\"1.0\"?>
<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.2\" baseProfile=\"tiny\"
viewBox=\"0 0 100 100\">
<desc>Example SVG file</desc>
<rect
x=\"0\" y=\"0\"
width=\"100\" height=\"100\"
fill=\"red\" stroke=\"black\"
/>
</svg>"
set savePath to (path to desktop as text) & "svgContent.svg"
tell application "TextEdit"
make new document with properties {text:svgContent}
save front document in file savePath
close front document
end tell
delay 1
set thePath to (path to desktop as text) & "svgContent.svg"
set theObject to its makeImageWithProperties(1, thePath, 260, 310)
(**
* 1. Break Apart
* 2. Ungroup
* 3. Make editable
*)
on makeImageWithProperties(pageNumber, filePath, xPos, yPos)
tell application "Pages"
tell page pageNumber of front document
set theObject to make new image with properties {file:filePath}
tell theObject
set position to {xPos, yPos}
end tell
end tell
end tell
end makeImageWithProperties
If you make SVG code that looks like this:
In the image (above):
The right SVG object is ONLY imported.
The left object have been using iWorks Break Apart
The problem is the right SVG object do not have border but if you add a border it will not be correct. To get correct border you need to use (Break Apart). Apple’s quick hack to support SVG in iWorks is kind of ugly and not well engineered.
The biggest problem to edit SVG or any vector in iWorks is to not support layers. Or in other words Apple use linear approach to do boolean operations. Its not possible to move/change object after boolean operation is made. (you could only undo). This kind of approach was used in application 20 years ago.