Is it possible to include a link to a pdf- or svg-file inside an Inkscape svg instead of embedding?

Post questions on how to use or achieve an effect in Inkscape.
cheflo
Posts: 8
Joined: Fri May 27, 2016 4:27 am

Is it possible to include a link to a pdf- or svg-file inside an Inkscape svg instead of embedding?

Postby cheflo » Fri May 27, 2016 4:30 am

Hi,
I am using python to create a bunch of plots of my data and then Inkscape to layout individual plots and schematics within panels of a master figure. I also add some extra elements such as panel names and titles.

Every time I modify something in my Python code, I have to manually paste the svg/pdf plots into Inkscape. I have noticed that if I create the plots as raster images instead of vectors, I can insert a link in the Inkscape document, and have the figure panel update every time I regenerate the plots in python, which is phenomenal!

Currently I am using this approach with a high DPI, but ideally, I would like to insert a link to a svg/pdf file so that the entire figure is a vector instead of a high DPI, big sized raster. I have seen that it is possible to include pdfs (don't think svgs work) in this manner in Adobe Illustrator .ai-files, and I wonder if there is any way to do it in Inkscape as well?

When I insert image links, Inkscape creates a tag in the svg similar to this

Code: Select all

    <image
       sodipodi:absref="path/to/image.png"
       xlink:href="./image.png"
       y="14.014872"
       x="5.9285898"
       id="image12160"
       preserveAspectRatio="none"
       height="441.91879"
       width="466.55328" />


I can modify the path to point to an svg file, but Inkscape will automatically convert the svg to a low resolution raster. If I change the path to a pdf, I get an error. Is there anything I can modify in the svg-code to be able to link pdf/svg-files and have them render in Inkscape as vector files?

User avatar
Maestral
Posts: 982
Joined: Sat Aug 27, 2011 7:10 am

Re: Is it possible to include a link to a pdf- or svg-file inside an Inkscape svg instead of embedding?

Postby Maestral » Fri May 27, 2016 4:46 am

Perhaps this page of Manual would help but you should also check the Object properties (Shift+Ctrl+O) and Interactivity at the bottom of that dialog.

Chime back if these would not work, I did it before but can`t be sure how. It`s been a while.
:tool_zoom: <<< click! - but, those with a cheaper tickets should go this way >>> :!:

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Is it possible to include a link to a pdf- or svg-file inside an Inkscape svg instead of embedding?

Postby Lazur » Fri May 27, 2016 5:05 am

My guessing is that you are after symbols.

There is not much other options to render external vector images in inkscape.
Like storing them as custom markers or making fonts from the plots would hardly work.

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Is it possible to include a link to a pdf- or svg-file inside an Inkscape svg instead of embedding?

Postby Moini » Fri May 27, 2016 8:17 am

Linking to external SVG files isn't possible (and I doubt it's allowed by the SVG standard). What you can do in your python script would be to insert the SVG code (load from a specified file) into your new SVG file (you'd need to cut off some parts from the SVG you want to insert before you do that). That's how all extensions in Inkscape that render something work - they create something new (and you would load it from a file here) and add that to the document tree.

Hope that's helpful :)
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

cheflo
Posts: 8
Joined: Fri May 27, 2016 4:27 am

Re: Is it possible to include a link to a pdf- or svg-file inside an Inkscape svg instead of embedding?

Postby cheflo » Mon May 30, 2016 8:24 am

Thanks everyone for the responses! Sorry for not getting back earlier, the forum notifications do not seem to work for me, so I did not realize someone had replied to my question.

@Maestral That manual page seems to explain how to make shapes within inkscape link to URLs and similar, but I can't find out how to achieve what I want. Similarly with the Object Properties, I can use it to link an object to a webpage on click for example. But what I want to do is to link a location in the inkscape svg to an external svg/pdf file, in the same way I can link images instead of having to embed them.

@Lazur URH Interesting suggestion with symbols. It seems to work, but it requires that I modify the svg of the plots every times I create them to include the symbols tags. And since there are several <def> tags, I am guessing I need to restructure the code so that there is one big <def> and one big <symbol> tag so that the entire plot is encompassed within one single symbol. Maybe I will be able to automate that somehow...

If I correctly understand how symbols work thought, it seems like the entire code for the symbol svg is pasted into the main document, rather than just referring to the external file (like with images).

@Moini This will probably the approach I opt for if I end up trying to automate this process. I wish inkscape could link to the file instead of me pasting all the code programatically, which I think will make Inkscape a bit slow since some of my scatterplots have thousands of points. Maybe I will settle on using the low resolution images for fiddling around with the layout and then use a script to replace all images with the svg for the final export to a high quality pdf.

I still wish there would be an option in inscape to vectors and maybe render them quickly as a raster in the canvas, but then use the vector images when exporting to pdf or orther vector formats.

Thanks again for all the suggestions!

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Is it possible to include a link to a pdf- or svg-file inside an Inkscape svg instead of embedding?

Postby Moini » Fri Jun 10, 2016 9:32 am

@cheflo I just stumbled about the right way to link svg images into svgs:

http://alchemise.net/Svg/Main.svg
(it uses an image with an xlink)
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

cheflo
Posts: 8
Joined: Fri May 27, 2016 4:27 am

Re: Is it possible to include a link to a pdf- or svg-file inside an Inkscape svg instead of embedding?

Postby cheflo » Fri Jun 10, 2016 9:48 am

Thanks for the answer @Moini. This is what I mentioned at the end of my question. This works for displaying a low resolution raster of the external svg inside another svg. However, I would like to display the full vector version of the external svg and being able to export the entire svg, without getting pixelated images in place of the externally linked svg files.

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Is it possible to include a link to a pdf- or svg-file inside an Inkscape svg instead of embedding?

Postby Moini » Fri Jun 10, 2016 10:50 am

It's not a raster image as such. Display depends upon the renderer... Sorry for overlooking that, it's already too long ago!
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

cheflo
Posts: 8
Joined: Fri May 27, 2016 4:27 am

Re: Is it possible to include a link to a pdf- or svg-file inside an Inkscape svg instead of embedding?

Postby cheflo » Fri Jun 10, 2016 11:27 am

Cool, I tried it out and the svg is pixelated when displayed in Inkscape or my image viewer (eye of gnome). However, when displayed in Chromium or Firefox, the svg is not pixelated and looks like a vector image. When I print the page to a pdf via Chromium/Firefox the pdf has perfect resolution (vector), but when I save the inkscape file as a pdf, the crappy pixelated resolution is kept.

So I guess Inkscape not only displays the svg as a pixelated raster, but also converts it to a raster when saving into another format such as pdf.

Theoretically, I would now be able to use inkscape to layout my figure panels using the displayed raster version of the linked external svgs and then open the Inkscape svg in a browser and print it to pdf for full resolution. This does sound a little cumbersome and it still involves manually adding the svg extension in the image tag, but I might just try it out.

It makes me hopeful that the limitation here seems to be inkscapes inability/preference to not handle externally linked svgs, rather than this being a limitation of the svg format itself.


Return to “Help with using Inkscape”