7

I want to save a single web page (or section of a webpage) as a vector graphic in my latex document.

How can I save a webpage as a vector image?

Stevoisiak
  • 13,555
  • 39
  • 101
  • 154
Robin
  • 612
  • 2
  • 9
  • 21
  • We would need a web browser (or a program which does the relevant functions of it, the rendering engine) which will output to a vector graphic (in any form) instead of to a pixel-based device (like a screen). I'm note sure if something like that exists which supports modern HTML and CSS. – Paŭlo Ebermann Nov 05 '11 at 19:39

4 Answers4

8

I suppose you mean a single web page, not a whole web site!

Perhaps you could print to a PDF file from your browser, and either \includegraphic the PDF file, or convert it to *.eps or *.svg using some utilities?

Of course, the problem with printing is you'll get output that looks like it was meant to be printed. Normally that's what you want after all...

If you go into your browser's print settings, you can instruct it to print background colors and images, and turn off header / footer text - that's the easy part. However, it won't get around anything the page itself does to improve the printed output: for instance, Wikipedia has a custom set of styles that are used when printing, to remove superfluous text and graphics (the header, sidebar, edit/expand links, etc).

You might prefer something like this: https://addons.mozilla.org/en-US/firefox/addon/save-as-pdf/

Shog9
  • 512
  • 2
  • 17
  • 34
  • Thank you for your answer. Yes, I mean a single web page. I had this idea too, but the pdf always looks ever different to the representation in the browser. – Robin Nov 05 '11 at 19:02
  • Then you might take a screenshot, but the result is pixelized, not vector... –  Nov 05 '11 at 19:04
  • There are some things that speak against screenshots. One of them is that the document is difficult to homogenize and it getting heavier and heavier. I know to use screenshots, but I want the flexibility of vector graphics. – Robin Nov 05 '11 at 19:12
  • Perhaps you might try with different browsers (either more recent versions, or different brands)? –  Nov 05 '11 at 19:14
  • Okay, I've it tried with Chromium 14 and Firefox 7. Which should i try? – Robin Nov 05 '11 at 19:16
  • Perhaps Opera ? –  Nov 05 '11 at 19:19
  • The result is same as it is with other browser which I have tested. (latest version of opera, with a pdf printer..) – Robin Nov 05 '11 at 19:26
  • The web page is poorly designed... –  Nov 05 '11 at 19:27
  • It was en.wikipedia.org. I think the printing function is so designed that it is not printing out everything. – Robin Nov 05 '11 at 19:34
  • Why can't you copy & paste the text? –  Nov 05 '11 at 19:36
  • I need it as it is and not just the text. – Robin Nov 05 '11 at 19:40
  • @openscript.ch [This thread](http://stackoverflow.com/questions/7258722/webpage-as-is-to-pdf) suggests [wkhtmltopdf](http://code.google.com/p/wkhtmltopdf/). I have no experience with it, but it does an ok job with `http://stackoverflow.com/`. – Gilles 'SO- stop being evil' Nov 05 '11 at 20:09
  • 1
    wkhtmltopdf seems like exactly the sort of heavy-duty thing required. Remember, for the HTML to be saved as vector graphics, something will need to be a full-on web-renderer in order to actually render the HTML, CSS, JavaScript, etc. Even then, any raster graphics will not be vectorized (at least not automatically). @openscript.ch, a browser extension *could* simplify things, but even then, a separate program would likely be required. – Synetech Nov 05 '11 at 20:37
5

Use wkhtmltopdf as Giles suggests above in a comment. It uses webkit to render your page as a vector PDF from the command line.

(I'm promoting this to a top level answer since this jewel is likely to go unnoticed in the mess of comments).

jhclark
  • 213
  • 2
  • 4
0

A project, that seems to cover this use-case seems to be the project WebVector, that uses CSSBox as rendering engine: http://cssbox.sourceforge.net/webvector/

This uses WebKit and saves it as PDF, which could may be more accurate: http://wkhtmltopdf.org/

SimonSimCity
  • 191
  • 1
  • 3
0

Try this service. Creates a vector PDF from a website as you see it in the browser. https://lomotoh.com/ (I am affiliated with this site)

David Herse
  • 101
  • 1