[tex4ht] TeX4ht warning --- Cannot determine size of graphic in svg graphics. Does tex4ht support bounding box on svg?

Nasser M. Abbasi nma at 12000.org
Sat May 16 03:25:58 CEST 2015


Currently I use svg graphics for all images since it looks better
than png on the web. Here is a typical latex file. I use
pdf version of the image for pdflatex and use the svg version
for htlatex.

I convert the pdf to svg using the program  pdf2svg which works
much better thank inkscape I found.

-------------------------------
\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
\ifdefined\HCode
  \includegraphics[width=0.5\paperwidth]{p.svg}
\else
  \includegraphics[width=0.5\paperwidth]{p.pdf}
\fi
\end{document}
---------------------------

The only problem is that I can't resize the svg image, so it shows
up in its original size on the web page.

The errors are

--------------------------------------
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(./foo.aux))
l.5 --- TeX4ht warning --- Cannot determine size of graphic in p.svg (no Boundi
ngBox) ---
[1] (./foo.aux) )
Output written on foo.dvi (1 page, 9672 bytes).
Transcript written on foo.log.
-----------------------------------

I think this is becuase htlatex does not see the bounding box?
However, looking at the svg file, I see the following

-------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="401.982pt" height="347.121pt" viewBox="0 0 401.982 347.121"
version="1.1">
<defs>
....
------------------------------------

Is the above not a bounding box using svg syntax?

My question is: How can one tell htlatex to resize the SVG graphics
similar to when using pdf with pdflatex?

Here are the commands to build the above file

htlatex foo.tex "nma,htm"

the nma.cfg contains this:

---------------------------
\Preamble{ext=htm,charset="utf-8",p-width,pic-align}
\Configure{Picture}{.svg}
\makeatletter
\Configure{graphics*}
{svg}
{
   {\Configure{Needs}{File: \Gin at base.svg}\Needs{}}
   \Picture[\csname a:GraphicsAlt\endcsname]{\csname
       Gin at base\endcsname.svg \csname a:Gin-dim\endcsname}
}
\begin{document}
\EndPreamble
-----------------------

I put all the files (.tex, svg, pdf, nma.cfg) in one folder, and
put it in one zip file. THe zip file can be downloaded from

http://12000.org/tmp/svg_support/

Any sugegstions on what to do or try are welcome.
I am using tex4ht from tex live 2014 on Linux box.

thanks,
--Nasser


More information about the tex4ht mailing list