hide/show layers in generated PDF, or SVG in a browser

Post questions on how to use or achieve an effect in Inkscape.
Alain Ruet
Posts: 3
Joined: Sat Aug 21, 2010 1:22 am

hide/show layers in generated PDF, or SVG in a browser

Postby Alain Ruet » Sat Aug 21, 2010 1:39 am

Hello !

I've made with Inkscape some layers to add information on maps. With Inkscape it's easy to show/hide these layers.
I want some people (not using Inkscape) to access these maps, keeping the ability to choice the visible layers.
I used to give them PDF version of the maps : could I generate PDF using interactive features of the format to do this ? Or should I keep it in SVG (that they would open with FireFox or any browser) using Javascript interactivity features ? But I don't know the javascript commands to activate/deactivate the layers...

Hopefully..

User avatar
prkos
Posts: 1625
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: hide/show layers in generated PDF, or SVG in a browser

Postby prkos » Sat Aug 21, 2010 9:26 am

Maybe Jessyink extension can help, it turns Inkscape layers into slides using javascript.

http://freshmeat.net/projects/jessyink
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download

User avatar
tomh
Posts: 218
Joined: Sat Feb 14, 2009 10:14 pm

Re: hide/show layers in generated PDF, or SVG in a browser

Postby tomh » Sun Aug 22, 2010 7:55 am

There probably is a way of doing it with pdf's, but I don't know how you would do it.

Javascript can defiantly do what you want though, although it takes a bit of effort ;-(

I have actually gone half way towards this before, but it got too messy to make it work properly, so I may try to tidy it up a bit and post it here for you to look at.

In the meen time, have a look at this threed: viewtopic.php?f=16&t=5237, and this example from it: http://test.netstreams.org/jsvg/jsvg.svg . It's not quite what you want, but the principle is the same.

User avatar
tomh
Posts: 218
Joined: Sat Feb 14, 2009 10:14 pm

Re: hide/show layers in generated PDF, or SVG in a browser

Postby tomh » Sun Aug 22, 2010 8:32 am

Ok, look at this from within firefox: http://www.openclipart.org/people/tom/m ... test_1.svg

you should be able to copy the key layer and adapt as necessary:
1) select a show / hide button
2)right click -> Object peoperties
3) expand the 'interactivity' section
4) under 'onclick': just edit the layer1, layer2 in getElementById to match the id of the layer you want to show hide with that button.

The javascript is fairly simple, so hopefully you will be able to understand it.

Alain Ruet
Posts: 3
Joined: Sat Aug 21, 2010 1:22 am

Re: hide/show layers in generated PDF, or SVG in a browser

Postby Alain Ruet » Wed Aug 25, 2010 1:17 am

Thanks a lot !

I adapted the example from OpenClipArt, changing it with a single button on/off. It works fine with (from slower to faster) FireFox, Opera, Chromium.
The problem is that I can't impose a browser at my job, and they massively use M$ IE... :(
IE 9 is announced to natively read SVG, but for the moment...

So I ask you again for information with PDF : layers information aren't conserved when converted. Will it be in future version ?

Thanks again.

vwanweb
Posts: 169
Joined: Sun Jun 06, 2010 1:48 pm

Re: hide/show layers in generated PDF, or SVG in a browser

Postby vwanweb » Wed Aug 25, 2010 2:40 am

try scribus for multipage .pdf, scribus imports .svg files

User avatar
tomh
Posts: 218
Joined: Sat Feb 14, 2009 10:14 pm

Re: hide/show layers in generated PDF, or SVG in a browser

Postby tomh » Wed Aug 25, 2010 5:46 am

OK, if you need to go down the PDF route (and you have the latest Adobe Reader) then you can use the latest Scribus to make the layers in the PDF.

From within Scribus:
1) Go, File->Import->Get Vector file... select the .svg document
2) Right click on the imported image and ungroup. Each inkscape layer will now be a separate object.
3) Go to Window -> Layers. Add enough new layers.
4) Select each object and right click and select Send to layer...

To save as a pdf:
File ->Export -> Save as PDF...
File Options:
Compatibility: PDF 1.6 (Acrobat 6)
and Include Layers.

In Adobe PDF Reader 9 the layers dialogue is the second option down the side bar.

Alain Ruet
Posts: 3
Joined: Sat Aug 21, 2010 1:22 am

Re: hide/show layers in generated PDF, or SVG in a browser

Postby Alain Ruet » Tue Aug 31, 2010 3:19 am

Thanks for all again : this solution works, apart from the fact that little things are lost converting from Inkscape to Scribus (mainly problems of text alignment, solved by converting text to path). The fact is that my Inkscape document is complex (City map with more than 600 objects including complex pathes, and 15 layers), and Scribus open it much more slowly than Inkscape...

The main difficulty is that you must re-create all layers each time your Inkscape source evoluate... Boring. But waiting for Inkscape to export layers to PDF I'll use this method. To get it easier to select groups to move in particular layers, you just have, for each layer, to put (out of the document boundaries) a text object with the layer's name : under scribus, after ungroupping, you just need to click on it as a tab to select the group you want.

ivan.alvarado
Posts: 2
Joined: Tue Feb 02, 2010 2:29 am

Re: hide/show layers in generated PDF, or SVG in a browser

Postby ivan.alvarado » Tue May 13, 2014 2:20 am

tomh wrote:OK, if you need to go down the PDF route (and you have the latest Adobe Reader) then you can use the latest Scribus to make the layers in the PDF.

From within Scribus:
1) Go, File->Import->Get Vector file... select the .svg document
2) Right click on the imported image and ungroup. Each inkscape layer will now be a separate object.
3) Go to Window -> Layers. Add enough new layers.
4) Select each object and right click and select Send to layer...

To save as a pdf:
File ->Export -> Save as PDF...
File Options:
Compatibility: PDF 1.6 (Acrobat 6)
and Include Layers.

In Adobe PDF Reader 9 the layers dialogue is the second option down the side bar.


Obviously not the direct solution from Inkscape. But for me it is the best way to export a PDF with layers.
Thank you!


Return to “Help with using Inkscape”