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







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 Nasser M. Abbasi

Thank youfor your solution. It works very well.

I just need to convert all my images which is now in pdf files
to eps since I do not have them in eps format.

I found number of ways to do this at this post:

http://tex.stackexchange.com/questions/20883/how-to-convert-pdf-to-eps

And it worked very well.

thanks again for your help
--Nasser

On 5/16/2015 3:27 AM, Radhakrishnan CV wrote:

On Sat, May 16, 2015 at 6:55 AM, Nasser M. Abbasi  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:


   


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





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


  


​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