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

2015-05-19 Thread Michal Hoftich

 Thanks Michal. I tried the above option you have, but I have not
 been able to get it working. I am on TL 2014. I keep getting

 --
 (/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
 (./foo.aux))
 l.6 --- TeX4ht warning --- Cannot determine size of graphic in 2.svg (no
 Boundi
 ngBox) ---
 

you need to create a .xbb file for each svg file. you can create it
with `ebb -x` command (I am not sure whether it is installed by
default with TeX Live.



 Here is the tex file:
 ---
 \documentclass[12pt]{article}
 \usepackage{graphicx}
 \begin{document}
 \includegraphics[width=0.2\paperwidth]{2}
 \end{document}
 

 There is a file called 2.pdf and 2.svg in the folder.
 pdflatex works fine and the image shows small as expected. But
 the HTML shows the image as SVG, but not resized due to the
 above warning.


in this example the image should have width of 1/5 textwidth, original
image size isn't used at all, so the warning shouldn't matter.

 Here is the .cfg I am using (from your last email)

 
 \Preamble{ext=htm,p-width,pic-align} %work well with something, I forgot
 what
 \DeclareGraphicsExtensions{.svg,.png,.jpg}
 \Configure{Picture}{.svg}
 \makeatletter
 \Configure{graphics*}
 {svg}
 {
   {\Configure{Needs}{File: \g...@base.svg}\Needs{}}
   \Picture[\csname a:GraphicsAlt\endcsname]{\csname
 Gin@base\endcsname.svg width=\expandafter\the\csname
 Gin@req@width\endcsname  height=\expandafter\the\csname
 Gin@req@height\endcsname
 }
 }
 \begin{document}
 \EndPreamble
 


this config file doesn't use image size information from the .xbb
file. as I said, it doesn't work with explicit setting of image size.
(error `Package graphics Error: Division by 0.` is produced)


 Here is the command I used

 make4ht foo.tex nma,htm,charset=utf-8  -cunihtf -utf8

you can also use

make4ht -uc nma.cfg foo.tex htm

instead



 also tried

 htlatex foo.tex nma,htm

 Both give the same warning and the image do not resize.

of course :)

add

 \DeclareGraphicsRule{.svg}{svg}{.xbb}{}

to the .cfg file under \DeclareGraphicsExtensions if you want to use
original image dimensions. but if you use that with explicit width
setting, it will fail with `Division by 0` error, as I said earlier.
It is maybe graphicx bug, because the same error is produced with
plain LaTeX.


 btw, when one writes \makeatletter  does one need to also add \makeatother
 at the end? I noticed you did not have \makeatother in the above.


I forgot it :)

 Also, since I got your attention, I am confused about one thing:
 When using your build system make4ht, does it still use/read the
 tex4ht.env or does it not need it?  Please let me know if I can
 try anything. I'd like to use your method above, since it saves
 me having to make .eps for each image.

it does use it, but you can modify image generation and conversion in
a build file

Regards,
Michal






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

2015-05-19 Thread Nasser M. Abbasi


Sorry, please ignore my last email.

I needed to use ebb -x on the PDF file, not the SVG.

I am all set now.

sorry about that, never used this command before.

--Nasser

On 5/19/2015 12:21 PM, Nasser M. Abbasi wrote:

On 5/19/2015 10:35 AM, Michal Hoftich wrote:



you need to create a .xbb file for each svg file. you can create it
with `ebb -x` command (I am not sure whether it is installed by
default with TeX Live.



fyi, I get this:



extractbb -x flow.svg

extractbb:warning: Can't handle file type for file named flow.svg


ebb -x flow.svg

ebb:warning: Can't handle file type for file named flow.svg


ebb --version


This is extractbb Version 20140317
A bounding box extraction utility from PDF, PNG, and JPEG.
--

Using TL 2014. May be need to update something.

Thanks for the information below





Here is the tex file:
---
\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=0.2\paperwidth]{2}
\end{document}


There is a file called 2.pdf and 2.svg in the folder.
pdflatex works fine and the image shows small as expected. But
the HTML shows the image as SVG, but not resized due to the
above warning.



in this example the image should have width of 1/5 textwidth, original
image size isn't used at all, so the warning shouldn't matter.


Here is the .cfg I am using (from your last email)


\Preamble{ext=htm,p-width,pic-align} %work well with something, I forgot
what
\DeclareGraphicsExtensions{.svg,.png,.jpg}
\Configure{Picture}{.svg}
\makeatletter
\Configure{graphics*}
{svg}
{
{\Configure{Needs}{File: \g...@base.svg}\Needs{}}
\Picture[\csname a:GraphicsAlt\endcsname]{\csname
Gin@base\endcsname.svg width=\expandafter\the\csname
Gin@req@width\endcsname  height=\expandafter\the\csname
Gin@req@height\endcsname
}
}
\begin{document}
\EndPreamble




this config file doesn't use image size information from the .xbb
file. as I said, it doesn't work with explicit setting of image size.
(error `Package graphics Error: Division by 0.` is produced)



Here is the command I used

make4ht foo.tex nma,htm,charset=utf-8  -cunihtf -utf8


you can also use

  make4ht -uc nma.cfg foo.tex htm

instead




also tried

htlatex foo.tex nma,htm

Both give the same warning and the image do not resize.


of course :)

add

   \DeclareGraphicsRule{.svg}{svg}{.xbb}{}

to the .cfg file under \DeclareGraphicsExtensions if you want to use
original image dimensions. but if you use that with explicit width
setting, it will fail with `Division by 0` error, as I said earlier.
It is maybe graphicx bug, because the same error is produced with
plain LaTeX.



btw, when one writes \makeatletter  does one need to also add \makeatother
at the end? I noticed you did not have \makeatother in the above.



I forgot it :)


Also, since I got your attention, I am confused about one thing:
When using your build system make4ht, does it still use/read the
tex4ht.env or does it not need it?  Please let me know if I can
try anything. I'd like to use your method above, since it saves
me having to make .eps for each image.


it does use it, but you can modify image generation and conversion in
a build file

Regards,
Michal









regards,
--Nasser






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

2015-05-18 Thread Michal Hoftich
Hi Nasser,

I think your setup is too complicated.

First of all, you should conditionals for tex4ht in text of your
document, you should use that only for conditional package loading in
the preamble. You can configure graphicx package to include pdf image
when you compile to pdf and svg when you compile with tex4ht. You only
need to remove the image extension from the document:


\documentclass[12pt]{article}

\usepackage{graphicx}

\begin{document}
% \includegraphics[]{p}

\includegraphics[width=0.5\paperwidth]{p}
\end{document}

Now you need to decide. If you always use
\includegraphics[width=something]{imagename}, you can just configure
graphicx to include svg files and configure tex4ht to support it:



\Preamble{ext=htm,p-width,pic-align} %work well with something, I forgot what
\DeclareGraphicsExtensions{.svg,.png,.jpg}
\Configure{Picture}{.svg}
\makeatletter
\Configure{graphics*}
{svg}
{
  {\Configure{Needs}{File: \g...@base.svg}\Needs{}}
  \Picture[\csname a:GraphicsAlt\endcsname]{\csname
Gin@base\endcsname.svg width=\expandafter\the\csname
Gin@req@width\endcsname  height=\expandafter\the\csname
Gin@req@height\endcsname
}
}
\begin{document}
\EndPreamble

see \DeclareGraphicsExtensions and \Configure{graphics*}{svg}

if you want to include images using their natural size, you need to
extract the boinding box using `ebb -x imagename.pdf` command. This
will create file imagename.xbb. Graphicx package with dvipdfmx option
can then use this file for extracting the bounding box of the image:

\DeclareGraphicsExtensions{.svg,.png,.jpg}
\documentclass[12pt]{article}
\ifdefined\HCode
\usepackage[dvipdfmx]{graphicx}
\else
 \usepackage{graphicx}
\fi
\begin{document}
 \includegraphics[]{p}

% \includegraphics[width=0.5\paperwidth]{p}
\end{document}

and add to the .cfg file under \makeatletter:

\@namedef{Gin@rule@.svg}#1{{svg}{.xbb}{#1}}
\@namedef{Gin@rule@.SVG}#1{{svg}{.xbb}{#1}}

Regards,
Michal


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

2015-05-16 Thread Karl Berry
TeX4ht needs .eps format of
the figure since it works with dvips graphics driver and hence cannot
accept any other graphics file format.

I use png and jpg with tex4ht all the time.  tex4ht.env has rules to
convert them on the fly (highly problematic in itself, but anyway).

I see a rule in tex4ht.env for svg using dvips (??) and then pstoedit.
Maybe that is what failed for Nasser, or maybe it never got run.  (It is
darn hard to figure out what parts of tex4ht.env are executed on any
given run, so far as I've ever been able to discern.  Maybe I am missing
it in the logs ...)

k


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

2015-05-16 Thread Radhakrishnan CV
On Sat, May 16, 2015 at 6:55 AM, Nasser M. Abbasi n...@12000.org wrote:

 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}
 ---


​You may kindly change the above to the following:

documentclass[12pt]{article}
\usepackage{graphicx}

\begin{document}

\makeatletter
\Configure{graphics*}
  {eps}
  {\Picture[pict]{\csname Gin@base\endcsname.svg
   width=\expandafter\the\csname
  Gin@req@width\endcsname
   height=\expandafter\the\csname
   Gin@req@height\endcsname
  }%
   }
\makeatother

\ifdefined\HCode
 \includegraphics[width=0.5\paperwidth]{gr1.eps}
\else
 \includegraphics[width=0.5\paperwidth]{gr1.pdf}
\fi

\end{document}

I got the following output for graphics inclusion part:

p class=noindent
  img src=gr1.svg alt=pict
   width=307.14749pt height=307.26057pt 
/p

​Hope this is what you have been looking for.  TeX4ht needs .eps format of
the figure since it works with dvips graphics driver and hence cannot
accept any other graphics file format.
​
​Best regards​

-- 
Radhakrishnan
River Valley
https://maps.google.com/maps?q=River%20Valley,%20Thiruvananthapuram%20Neyyardam%20Road,%20Kerala,%20Indiavector=1


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

2015-05-16 Thread Nasser M. Abbasi

On 5/16/2015 4:36 PM, Karl Berry wrote:

 TeX4ht needs .eps format of
 the figure since it works with dvips graphics driver and hence cannot
 accept any other graphics file format.

I use png and jpg with tex4ht all the time.  tex4ht.env has rules to
convert them on the fly (highly problematic in itself, but anyway).



I used to use png also with tex4ht for images. But png is not
vector format so does not work as well as svg for different
resolutions of the web page. So I switched to SVG now.


I see a rule in tex4ht.env for svg using dvips (??) and then pstoedit.
Maybe that is what failed for Nasser, or maybe it never got run.  (It is
darn hard to figure out what parts of tex4ht.env are executed on any
given run, so far as I've ever been able to discern.  Maybe I am missing
it in the logs ...)

k


May be. I gave up trying to uderstand tex4ht.env long time ago with
having to add or remove a space and trying to figure which section
is actually active or which is not.

I am now making a small note to summarize all of this, will add it
to my tex4ht cheat sheet.  But basically the steps I use now are:

1. Generate PDF for the image (from the external graphics program, such
as visio or anyother tool. All support saving as pdf now.
2. Crop the PDF if needed to remove extra space around image
3. Use pdf2svg  to generate .svg from the .pdf
4. Use pdf2eps  to generate .eps from .pdf
5. Use this in Latex to include the graphics

\ifdefined\HCode
 \includegraphics[width=0.2\paperwidth]{p1.eps}
\else
 \includegraphics[width=0.5\paperwidth]{p.pdf}
\fi

6. Make sure to have .cfg file with these in it:

\Configure{Picture}{.svg}
\makeatletter
\Configure{graphics*}
{svg}
{
  {\Configure{Needs}{File: \g...@base.svg}\Needs{}}
  \Picture[\csname a:GraphicsAlt\endcsname]
{\csname Gin@base\endcsname.svg \csname a:Gin-dim\endcsname}
}
\makeatother


% Thanks to CVR for this below
\makeatletter
\Configure{graphics*}
  {eps}
  {\Picture[pict]{\csname Gin@base\endcsname.svg
   width=\expandafter\the\csname
  Gin@req@width\endcsname
   height=\expandafter\the\csname
   Gin@req@height\endcsname
  }%
   }
\makeatother

7. Now compile using htlatex using the above .cfg file

Now the HTML page will use the .svg image in it with
correct width/height and will resize well since it is
vector format and keep sharp at different resolutions.

--Nasser







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

2015-05-15 Thread Nasser M. Abbasi

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: \g...@base.svg}\Needs{}}
  \Picture[\csname a:GraphicsAlt\endcsname]{\csname
  Gin@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