# PDF image files and htlatex: Problem

I branch from "PDF image files and htlatex" as advised by michal.h21.

I use myxhtml.cfg as follows


\Preamble{xhtml}
\makeatletter
\Configure{graphics*}
{pdf}
{
\Needs{"convert      \csname Gin@base\endcsname.pdf
\csname Gin@base\endcsname.png"}%
\Picture[pict]      {\csname Gin@base\endcsname.png}%
\special{t4ht+@File: \csname Gin@base\endcsname.png}
}
\begin{document}
\EndPreamble


Then test.tex


\documentclass[12pt]{article}
\usepackage[dvips]{xcolor}
\usepackage[dvips]{graphicx}
\usepackage[tex4ht]{hyperref}
\begin{document}
\begin{picture}(0,0)%
\includegraphics{1fig2dev.pdf}%
\end{picture}%
\end{document}


and pdf file 1fig2dev.pdf is quite small


%PDF-1.5
%Çì¢
5 0 obj
>
stream
x­S»R^C1^Lìý^UªS^HKgëñ^EÔ   ^E^_¤H      ^Tü>ò½^RrÇ^LEæ
¥´ëµ/ ·o\÷çô´S8|¥KÊ@Y2SK^R³Ýüô©S:&Ò¬(^E:,^BNjJAá^Z(R¤^A©£gi^Qñ^NÕ^Cc¨äë^QUBV jQ\úÈïYmþë^F>^Rc×&}÷T3ì^S^G^GaR:4­A«@^E+g^T30«(ÊP      ­zôä@y»OTX0Ì^@áU¢^PU¼^X­èÖâØ^Eñ}zIÛ pX=^U¹÷âÞ7+Â^^Õü^XtÿíñØÏã,\|Ù;êQmðxpÝ«^V¹é^X¯Á"00÷^RgìtÃ|tuxôS¢ýÞ:Fåä&å\yrsÚ^Ý^A£PhvÓ»¸¢.£«Âï)/T-4^OêÔ\B^Aukâ^T+^S÷oíóm^Bã^_éÒ¦±
Ù¦^_¸´Î!endstream
endobj
6 0 obj
352
endobj
4 0 obj
>
/Contents 5 0 R
>>
endobj
3 0 obj
>
endobj
1 0 obj
>
endobj
7 0 obj
>endobj
8 0 obj
>
endobj
9 0 obj
>stream

2016-10-17T21:01:33+02:00
2016-10-17T21:01:33+02:00
fig2dev Version 3.2 Patchlevel 5e

1fig2dev.fig

endstream
endobj
2 0 obj
>endobj
xref
0 10
0000000000 65535 f
0000000646 00000 n
0000002219 00000 n
0000000587 00000 n
0000000456 00000 n
0000000015 00000 n
0000000437 00000 n
0000000710 00000 n
0000000751 00000 n
0000000780 00000 n
trailer
]
>>
startxref
2407
%%EOF


all residing in the same folder.

Now i type htlatex test.tex myxhtml but this does not work:


! LaTeX Error: Cannot determine size of graphic in 1fig2dev.pdf (no BoundingBox
).

See the LaTeX manual or LaTeX Companion for explanation.
Type  H   for immediate help.
...

l.7 \includegraphics{1fig2dev.pdf}


It seems as if the pdf is not replaced. I tried convert 1fig2dev.pdf 1fig2dev.png manually and verified with gwenview 1fig2dev.png... seems to be fine.

What went wrong????

ok, partial answer: The problem disappears if i remove the picture environment. Is this a bug in htlatex????

• Please post a full question. – Heiko Oberdiek Oct 17 '16 at 19:01
• should be ok now, sorry – user2609605 Oct 17 '16 at 19:24

contents of picture environment is converted to image using some dvi to image converter. tex4ht configurations are suppressed inside it, so the configuration for graphics* in not executed at all, the PDF file is inserted as it is. If you try to run your document with latex, you would get exactly the same error.

If you move the \includegraphics outside the picture environment, the graphics* configuration will take an effect and the PDF picture will be included. If you really want to include image in the picture environment, you need to use eps format, which is supported in the DVI mode.

I would use following method:

Prepare the images in all needed formats (pdf, png, eps), declare which extensions should LaTeX use in particular mode, remove extensions from \includegraphics command and let LaTeX decide which one it should use.

You modified document:

\documentclass[12pt]{article}
\usepackage[]{xcolor}
\usepackage[]{graphicx}
\usepackage[tex4ht]{hyperref}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\DeclareGraphicsExtensions{pdf,png,jpg}
\begin{document}
\begin{picture}(0,0)%
\includegraphics{1fig2dev}%
\end{picture}%

\includegraphics{1fig2dev}
\end{document}


As you can see, \DeclareGraphicsExtensions command is used to define extensions, which should be tried when image is included. These will be used in the PDF mode. Now you need to modify the .cfg file:

\Preamble{xhtml}
\Configure{picture}
{\DeclareGraphicsExtensions{.eps}\Picture+[PICT]{}}
{\EndPicture}
\begin{document}
\DeclareGraphicsExtensions{.png,.jpg,.gif}

\EndPreamble


\Configure{picture} is used to declare that eps images should be used inside picture environment, png,jpg or gif` should be used otherwise.