Impossible to target a chosen page on a multipage Inkscape document #140
-
In Inkscape when multipages are created it's impossible to target the script to the desired page. It is always rendered on the first page only. So how would it be possible to target the script on page 2 only for example? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
Because SVG doesn't actually support pages, Inkscape implements them as coordinates that lie outside of the viewbox. Simple Inkscape Scripting enables scripts to query a page's coordinates by invoking the # Create a few pages.
npages = 3
pages = [page(i + 1) for i in range(npages)]
# Draw a large circle in the center of each page.
rad = min(pages[0].width, pages[0].height)*3/8
for pg in pages:
bbox = pg.bounding_box()
circle(bbox.center, rad, stroke=2, fill=randcolor()) Hence, to target a script to a particular page, you'll need to acquire the page's bounding box as in the preceding example and limit the script's operations only to objects that lie within that bounding box. See Page creation in the Simple Inkscape Scripting wiki for more information. |
Beta Was this translation helpful? Give feedback.
Yes. You can acquire the bounding box for each page then add each bounding box's left coordinate to x and top coordinate to y:
Alternatively, you might want to use an
inkex.transforms.ImmutableVector2d
to make the code easier to read: