Taking vector screenshot from Firefox

2

I am trying to take a vector screenshot of a webpage. What I did:

  1. Start a fresh Ubuntu 15.10 from the LiveCD
  2. Install Firefox Nightly from the PPA, it's currently 47.0a1
  3. Install 'gtk-vector-screenshot' from universe
  4. Log out and log in again, to reload X with its modules
  5. Start the vector screenshot utility and click on the webpage

The sad result: it saves an empty image.

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" 
xmlns:xlink="http://www.w3.org/1999/xlink" width="1106pt" 
height="690pt" viewBox="0 0 1106 690" version="1.1">
<g id="surface9511">
</g>
</svg> 

Am I doing something wrong, or did I find a bug? Should it be possible to take a vector screenshot from Firefox? Has somebody been able to do it, and if yes, what am I missing?

rumtscho

Posted 2016-03-16T15:39:11.887

Reputation: 3 586

Answers

2

gtk-vector-screenshot isn't going to work as you expect from all apps. Some apps use a canvas and do custom drawing to that. All you would get is a canvas placeholder (as you did). gtk-vector-screenshot gets its vector draw commands from GTK and converts them into the equivalent SVG commands. If the software isn't using GTK draw functions to do its rendering, you won't get anything. If you're interested, source code is available here.

Ouroborus

Posted 2016-03-16T15:39:11.887

Reputation: 2 549

Do I understand right that the problem is that Firefox doesn't use GTK draw functions, so gtk-vector-screenshot won't work? If Firefox is what you need to capture, it requires some other software? – fixer1234 – 2016-06-13T07:18:07.840

That would be my guess. Also, it's unlikely there is other software that could capture Firefox's renderings as vector. It's likely that you'd have to modify the Firefox source code to enable this. Fortunately, Firefox is open source.

– Ouroborus – 2016-06-13T07:21:49.390

Or convert the screenshot to vector afterwards? – fixer1234 – 2016-06-13T07:24:08.273

1

Raster screenshots can't be converted to vector, as the original conversion from vector to raster is a one-way operation. A lot of drawing information is irrecoverably lost when rendering as raster. Though, if you really just need a vector version, regardless of how, there are tools that will do a best effort conversion.

– Ouroborus – 2016-06-13T07:27:11.320

So, there is no way to capture a web page as a vector? As far as I could find, gtk-vector-screenshot is the only software available for vector screenshots, and Firefox is the only browser to use the required GTK version. And yes I really wanted a vector, so I could edit it a bit and then export in a higher resolution than possible with a simple raster screenshot. I ended up editing the CSS and then doing weird things with zoom to get a somewhat acceptable resolution for printing. – rumtscho – 2016-06-13T07:35:08.630

The tool I linked will give a vector image from a normal screenshot, but it won't be based on the original draw commands. Whether or not that's usable for what you want, I don't know. – Ouroborus – 2016-06-13T07:37:40.583