I have this picture, which is contained in a html page (see below, you can download the code and open the pic in your browser). From what I see the picture is produced through webgl code inside the html file (I know littel about all of this, even if I did produce the picture myself using asymptote program with the html output option).

I want to include this in a pdflatex doc which I want to print. Thus I do not need in the latex doc a link to the html file but I want to have a final pdf where the picture has been inserted and is clearly visible as any other pdf picture would do.

Is there any possibility of doing this, maybe with hyperref package?

Thanks Maurizio

html with webgl code to be included into latex doc

  • 1
    If you want a PDF with interactive 3D content, the only option is using Asymptote with the PRC option and Acrobat Reader for viewing.
    – AlexG
    May 11, 2020 at 7:53
  • Thanks. No I do not want interactive 3D content. In this case I want to get a file which can be inserted in a latex source so that at the end I get a printed copy of the picture "as it is" in my final pdf file of the doc. I had to go through html and webgl because of problems I had with "Asymptote" program (assuming you know what it is...
    – mvs
    May 11, 2020 at 10:06
  • In at least some browsers (I use Chrome), you can right-click on the webgl image and select "Save Image As" to download a png version. Jun 10, 2020 at 13:59
  • It seems like you should try to get Asymptote working so that asy -f png or asy -f pdf give you a usable output, instead of trying to convert a webgl or html file into an image.
    – Teepeemm
    Mar 5, 2021 at 23:24

1 Answer 1


You can have both, interactive 3D content that opens on click and a nicely rendered vector image for printing and PDF viewers that don't support PRC. For this, add

import three;
settings.render = 0;

at top of the asy code.

Compile example.tex with

pdflatex example
asy example-1.asy
pdflatex example

enter image description here

Input example.tex:





Example \verb+cylinder.asy+, taken from\\

import three;
settings.render = 0;

import solids;

triple v=O;
real r=1;
real h=1.5;
triple axis=Y+Z;

// Optimized cylinder
surface cylinder=shift(v)*align(unit(axis))*scale(r,r,h)*unitcylinder;

// Skeleton
revolution r=cylinder(v,r,h,axis);


If you want only the vector image that is used as the poster image for the inactive 3D content as a stand-alone file, run asy with option -k (keep files) and look for example-1+0_0.pdf. This file can be included in other documents in the usual way using \includegraphics:

asy -k example-1.asy
  • Thanks, I tried. But that leads me to step one. I get a (wrong) pdf image because asymptote will not give me a nice result if I ask pdf output even if it is imbedded in a latex source. My problem is that I get a nice (perfect) asy output (for this picture) only if I ask for html output (that has to do with some opengl issue...) and then I am left with the problem of putting the picture (and not a link to it) back in a standard latex source for a final pdf output to be printed on paper (it is a book).
    – mvs
    May 11, 2020 at 11:02
  • I can tell you better what my problem is. Suppose you download one of the html images (with webgl code inside) which you find at asymptote.sourceforge.io/gallery/3Dwebgl on the gallery of asymptote. I mean the html file itself and not the asymptote code used for generating it . Could you put that picture into a latex doc and get a (reasonably high quality) pdf out of it?
    – mvs
    May 11, 2020 at 11:11
  • With Asymptote installed correctly, you should download the asy source, not the html, and process it as described in the (updated) answer to get the PDF vector image (asy -k). This can be included in other documents in the usual way.
    – AlexG
    May 11, 2020 at 11:33
  • Yes, I know, that's the way to go. I have done hundreds of picture with asymptote. But now, for reasons related with problems with opengl or something like that I have one specific picture which turns out nice with -f html outoption on asymtote command line but NOT with other options. Thus, I was wondering if I could put back the html (webgl) picture into my latex source (what you do with \includegraphics etc) . If I could produce a nice pdf or png picture directly from asy code I wouldn't think of this, of course.
    – mvs
    May 11, 2020 at 12:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .