On 10/16/2017 7:52 AM, Michal Hoftich wrote:
URL:
   <http://puszcza.gnu.org.ua/bugs/?371>

                  Summary: TikZ externalization and PDF images
                  Project: tex4ht
             Submitted by: michal_h21
             Submitted on: Mon 16 Oct 2017 03:52:24 PM EEST
                 Category: None
                 Priority: 5 - Normal
                 Severity: 5 - Normal
                   Status: None
                  Privacy: Public
              Assigned to: None
         Originator Email:
              Open/Closed: Open
          Discussion Lock: Any

     _______________________________________________________

Details:

I've added support for TikZ externalization and for PDF image inclusion.

The externalization supports means that TikZ will not try to externalize the
images with tex4ht compilation, saved images will be used instead. So it is
necessary to compile the document using (pdf|lua|xe)latex first, with
-shell-escape option. The externalized images will be included as PDF.

This is connected with the second new feature, which is PDF image support. PDF
images will be converted to some supported format, I've added support for SVG
support as default. Inkscape is used for the conversion. New configuration,
PdfConvert have been added. It has two arguments, first is the image format
which should be used, the second is a command used for conversion.

This is the default configuration:

\Configure{PdfConvert}{svg}{"inkscape -z -f '\g...@base.pdf' -l
'\Gin@base.\a:PdfConvert'"}

I think we can add more configurations and use the command line options for
choosing among them.

The main reason to use the externalization instead of the default TikZ support
for tex4ht, is that it has better support for text nodes  and more TikZ
features. And also the compilation speed should be better.


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?

I put the command you show in my .cfg, but I must be doing
something wrong. I keep getting this error:

=================================
make4ht --shell-escape --lua -u -c nma.cfg document.tex

(/usr/local/texlive/2017/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
l.13 --- TeX4ht warning --- \Configure{PdfConvert}? ---

! LaTeX Error: Missing \begin{document} in `nma.cfg'.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...
l.13 \Configure{PdfConvert}{s
                           vg}{"inkscape -z -f '\g...@base.pdf' -l '\Gin@base...

? x

=================================

Is it in wrong place?

Here is the .cfg I am using. Do I need to keep all the
other configuration in there I had from before? I tried
removing them, but the error still there.

=== nma.cfg========
\Preamble{xhtml,p-width}
\DeclareGraphicsExtensions{.svg,.png}
\Configure{Picture}{.svg}
%this below to make it resize the SVG image, if it is there, to
%what is in the includegraphics.
%thanks to @Michael.h21 for this trick
\makeatletter
\newcommand\emwidth{10}
\newcommand\CalcRem[1]{\strip@pt\dimexpr(#1)/\emwidth}

\Configure{graphics*}
           {svg}
            {\Picture[pict]{\csname Gin@base\endcsname.svg
            \space style="width:\CalcRem{\Gin@req@width}em;"
            }%
            \special{t4ht+@File: \csname Gin@base\endcsname.svg}
           }
%added this on oct 17,2017. Per email from @Michael.h21
\Configure{PdfConvert}{svg}{"inkscape -z -f '\g...@base.pdf' -l 
'\Gin@base.\a:PdfConvert'"}
\makeatother
\begin{document}
\EndPreamble
== end nma.cfg ==============

Here is the small latex file I am trying to test with

=== 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?

Running on Linux, latest texlive update.

which inkscape
/usr/bin/inkscape

inkscape --version
Inkscape 0.91 r13725

Thank you
--Nasser


Reply via email to