[tex4ht] Fwd: [bug #371] TikZ externalization and PDF images

Michal Hoftich michal.h21 at gmail.com
Wed Oct 18 10:25:28 CEST 2017


Hi Nasser,

> Thank you Michal for all of this. I am trying to test
> this, but keep getting an error with the .cfg
>
> It might be useful to make a template complete .cfg file for
> users to use? Or a small example folder with the
> commands you used and put them in zip file to download
> and use them as reference?
>


> === document.tex====
> \documentclass[11pt]{article}
> \usepackage{ifluatex}
> \ifluatex
>   \usepackage{shellesc}
>   \IfFileExists{luatex85.sty}{\usepackage{luatex85}}{}
>   \ifdefined\HCode
>     \usepackage[utf8]{luainputenc}
>   \else
> \fi
>
> \usepackage{tikz}
> \usepackage{pgffor}
> \usepackage{graphicx}
>
> \begin{document}
> \pdfximage{foo.pdf}
>
> \foreach \n in {1,...,\the\pdflastximagepages} %loop over each page
> {
>   \fbox{
>     \includegraphics[width=0.95\textwidth,page=\n]{foo}
>   }
>  }
> \end{document}
> =========================
>
> Just need to put some PDF file to test with.
> It compiles OK with lualtex. But gives the above error with
> make4ht. I think I have syntax error in my .cfg file?
>

It is not in TL yet, I've just updated the sources. So you can't use
the \Configure{PdfConvert} in your config file yet.

Anyway, testing your TeX document, I've found some issues. First of
all, you can't use \pdfximage and \pdflastximagepages with tex4ht,
because these commands aren't available in the DVI mode. I think there
is nothing we could do about this. Second, you should replace \else
after \usepackage[utf8]{luainputenc} with \fi. I don't even think that
you need to use luainputenc anymore, utf8 should work out of the box
with LuaLaTeX.

The biggest issue is that page selection seems to be unsupported by
Inkscape. It converts the first page every time. So other conversion
method should be used. I've found pdf2svg script, which is included in
Fedora or Ubuntu repos, so I think it should be widely available on
Linux, I am not sure about Windows.

Another possibility might be ImageMagick, but the default result seems
to be of low quality.


Anyway, here is a config file for testing:

\Preamble{xhtml}

\NewConfigure{PdfConvert}{2}
\makeatletter
\catcode`\:=11
\Configure{PdfConvert}{svg}{"pdf2svg '\Gin at base.pdf'
'\Gin at base-\Gin at page.\a:PdfConvert' \Gin at page"}
\Configure{graphics*}
   {pdf}
   {\Needs{\b:PdfConvert}%
   \edef\svg:filename{\Gin at base-\Gin at page.\a:PdfConvert}
   {\Configure{Needs}{File: \svg:filename}\Needs{}}%
   \Picture[\a:GraphicsAlt]{{\svg:filename}\csname a:Gin-dim\endcsname
}}
\catcode`\:=12
\makeatother
\begin{document}

\EndPreamble

Best regards,
Michal


More information about the tex4ht mailing list