# Convert Tex document with pdf images

I've found thousands of posts and articles describing how to convert Latex documents into HTML or odt.

I tried everything but it seems my problem is peculiar.

I have 250 pages of compiled document which uses pdflatex to build. No problem at all.

A lot of pictures are produced exporting PDF+LaTeX in Inkscape, which produce a PDF + LaTeX file. Please, refer to: How to include SVG diagrams in LaTeX?

Other pictures are produced with octave in the same format. An empty graphics pdf.

And a LaTeX file with labels info.

% Title: glps_renderer figur
% Creator: GL2PS 1.3.8, (C) 1999-2012 C. Geuzaine
% For: Octave
% CreationDate: Thu Mar  3 23:22:20 2016
\setlength{\unitlength}{1pt}
\begin{picture}(0,0)
\includegraphics{TensaoCorrente3_4kW-inc}
\end{picture}%
\begin{picture}(720,360)(0,0)
\fontsize{22}{0}
\selectfont\put(70,33.5081){\makebox(0,0)[t]{\textcolor[rgb]{0,0,0}{{0}}}}
\fontsize{22}{0}
\selectfont\put(179.245,33.5081){\makebox(0,0)[t]{\textcolor[rgb]{0,0,0}{{0.5}}}}
\end{picture}


I include the file using:

\begin{figure}
\centering
\resizebox{1\columnwidth}{!}{\input{img/TensaoCorrente3kW.tex}}
\end{figure}


The final result is:

When I try to use Latex I got many errors about bounding boxes in my figures which are pdf. No problem since pdflatex works fine.

The problem is that my professor only use Word to review my document, so I must convert my LaTeX document in to a readable word format.

Latex2HTML prints ugly pictures and equations.

So I tried htlatex which complains about same errors as latex compiler.

There is no way I can manually add bb option to every picture. I tried with 8 page paper and it took the whole day.

I don't think layout matters. I just need to convert my LaTeX to Word to be editable.

• the inkscape ones are presumably svg originally so that can go straight to the web page without conversion, similarly octave can i assume generate pngs that can be includes straight to the web, so you only need to convert the text of your latex file to html and then re-insert the images. – David Carlisle Mar 30 '16 at 20:02
• Please, consider the post info, the images are pdf exported. In inkscape, it export a tex file with pdf embed. In octave the same way. I need tex4ht to convert pdf files as images. Please, refer to this post to understand. tex.stackexchange.com/questions/299836/… – Thales Maia Mar 31 '16 at 1:28
• I find this question very confusing. What are you trying to convert to? Presumably, html2latex converts from HTLM to LaTeX, but the rest of the post suggests you're doing something else. Then you mention tracking changes which is something Word does, I believe, and Word. But how is this related to the rest? It isn't clear what the files exported by Inkscape are - you don't give an example, which would help people to understand. But Inkscape certainly can export SVG. – cfr Mar 31 '16 at 2:07
• sorry, I edited to post for better understanding. – Thales Maia Mar 31 '16 at 13:12
• Could you please provide full example including document preamble and links to sample images? – michal.h21 Mar 31 '16 at 13:32

Your sample file includes packages which are incompatible with tex4ht and which aren't useful in HTML mode anyway: transparent and pst-pdf. You can enable them only in PDF mode using:

\ifdefined\HCode\else
\usepackage{pst-pdf}
\usepackage{transparent}
\fi


Your document can be compiled without these packages.

There is then question of image inclusion. You use two ways, first is direct PDF inclusion, the second is using TeX files with drawing commands exported by Inkscape.

The first way:

\begin{figure}%
\centering
\caption{Final model of total flux density inside the electric generator}
\end{figure}


use \includegraphics instead:

\begin{figure}%
\centering
\caption{Final model of total flux density inside the electric generator}
\end{figure}


The Inkscape generated files must be converted to PDF first and then included using \includegraphics as well. For each file create driver TeX file in this form (bencada.tex):

\documentclass[preview,margin=5pt]{standalone}

\usepackage{graphicx,xcolor}
\begin{document}
\end{document}


compile the driver files to pdf and include them in the main document:

% \input{img/bancada_geracao.pdf_tex}


You need now configure tex4ht to support PDF images. It can be done using a config file, mycfg.cfg for example:

\Preamble{xhtml}
\makeatletter
\Configure{graphics*}
{pdf}
{\Needs{"convert \csname Gin@base\endcsname.pdf
\csname Gin@base\endcsname.png"}%
\expandafter\getImgFile\expandafter{\Gin@base}{.png}
\Picture[IMG]{\imgBase.png \ifx\noBoundingBox\UnDefined
svg:width="\the\Gin@req@width"
svg:height="\the\Gin@req@height"
\fi
}
\special{t4ht+@File: \csname Gin@base\endcsname.png}
}
\makeatother
\begin{document}
\EndPreamble


you can compile your document now using

mk4ht oolatex Example mycfg


command. You may need to run it twice for the first time, because pdf files are converted in the first run and they will be used only in the consecutive runs.

Result opened in LibreOffice:

Full modified Example.tex:

\documentclass[twocolumn,10pt]{article}

\usepackage{graphicx}

\graphicspath{{img/}}
\ifdefined\HCode\else
\usepackage{pst-pdf}
\usepackage{transparent}
\fi
\usepackage{tikz}
\usepackage{amsmath}

\title{Example}

\begin{document}

\maketitle

\section{Images}

Convert this document to word

\begin{figure}[h]
% \centerline{\psfig{figure=img/processo_termodinamico.pdf,width=3.34in}}
\centering
\includegraphics[width=1\columnwidth,bb=6 1 503 141]{img/processo_termodinamico.pdf}
\caption{}
\label{fig:processo_termodinamico}
\end{figure}

$$P_{Fe} = K_h B^2 f + K_c \left( Bf \right)^2 + K_e \left( Bf \right)^{3/2} \label{eq:formula_perdas}$$

\begin{figure}
\centering
% \resizebox{1\columnwidth}{!}{\input{img/BHCurve.tex}}
\resizebox{1\columnwidth}{!}{\includegraphics{bh.pdf}}
\caption{BH curve obtained from experimental evaluation from three different electrical steel materials at $1200~Hz$}
\label{fig:BHCurve}
\end{figure}

\begin{figure}

\centering
\caption{Final model of total flux density inside the electric generator}
\end{figure}

\begin{table}[h]
\caption{Total losses from three different electrical steel materials}
\begin{center}
\label{tab:machine_simulated}
\begin{tabular}{c c}
& \\ % put some space after the caption
\hline
Parameters & Value \\
\hline
Induced voltage & $220~V_{RMS}$ (16 coils) \\
Ratted speed & $70000~RPM$\\
Ratted current & $9.2~A$ \\
Ratted power & $3.5~kW$ \\
Stator length & $100~mm$ \\
PM diameter & $21~mm$ \\
\hline
\end{tabular}
\end{center}
\end{table}

$$\dot{W}_{T} = \dot{m} \, c_p \, \eta_{T} \, T_{Tin} \left[ 1 - \left( \frac{P_{Tout}}{P_{Tin}} \right)^{\frac{\gamma -1}{\gamma }} \right] \label{eq:formula_potencia}$$

\begin{figure}
\centering
\def\svgwidth{\columnwidth}