[Tex/LaTex] Converting from LaTeX to HTML using htlatex

conversionhtmlscripts

Using htlatex to convert LaTeX to HTML

Referring to the question posted above.

So I used both the script and the htlatex command from the command-prompt in order to convert my LaTeX file to HTML but both are giving me errors.

Error with the htlatex command (without script):

*! Package pdftex.def Error: PDF mode expected, but DVI mode detected! (pdftex.def) If you are using latex', then callpdflatex'. (pdftex.def) Otherwise check and correct the driver options. (pdftex.def) Error recovery by switching to PDF mode.
See the pdftex.def package documentation for explanation.*

Error with the script:

--- warning --- Can't find/open file User_Manual.dvi' --- error --- Can't find/open fileUser_Manual.dvi' --- warning --- Can't find/open file `User_Manual.lg'
Could Not Find F:\Documents and Settings\My Documents\User_Manual_new\User_Manual.idv
Could Not Find F:\Documents and Settings\My Documents\User_Manual_new\User_Manual.lg
Could Not Find F:\Documents and Settings\tbinchisti\My Documents\User_Manual\User_Manual.html
Could Not Find F:\Documents and Settings\My Documents\User_Man ual_new\User_Manual.css

I believe it has something to do with the packages I have but I dont know which ones.

This is my main .tex file:

    \documentclass[11pt,a4paper]{report}  
    \usepackage{fancyhdr}  
    \usepackage[pdftex]{color,graphicx}  
    \usepackage{epstopdf}  
    \usepackage{lastpage}  
    \usepackage{makeidx}  
    \usepackage[english]{babel}  
    \usepackage{float}  
    \usepackage{subfig}  
    \usepackage{hyperref}  
    \usepackage{fullpage}  
    \usepackage{multirow}  
    \usepackage{appendix} 
    \usepackage{verbatim} 

        \renewcommand{\appendixtocname}{Appendix: Algorithm Parameters} \renewcommand{\appendixpagename}{Appendix-Algorithm Parameters}

        \setlength{\topmargin}{-1.3cm} \setlength{\headsep}{0.6cm}

        \renewcommand{\tablename}{\bfseries{Table}}

        %The top margin above a chapter can be changed using the titlesec package 

    \hypersetup{
            bookmarks=true,         % show bookmarks bar?
            unicode=false,          % non-Latin characters in Acrobat’s bookmarks
            pdftoolbar=true,        % show Acrobat’s toolbar?
            pdfmenubar=true,        % show Acrobat’s menu?
            pdffitwindow=false,     % window fit to page when opened
            pdfstartview={FitH},    % fits the width of the page to the window
            pdftitle={My title},    % title
            pdfauthor={Author},     % author
            pdfsubject={Subject},   % subject of the document
            pdfcreator={Creator},   % creator of the document
            pdfproducer={Producer}, % producer of the document
            pdfkeywords={keyword1} {key2} {key3}, % list of keywords
            pdfnewwindow=true,      % links in new window
            colorlinks=true,       % false: boxed links; true: colored links
            linkcolor=black,          % color of internal links
            citecolor=green,        % color of links to bibliography
            filecolor=magenta,      % color of file links
            urlcolor=cyan           % color of external links }

        \input{Macro} %\renewcommand{\caption}[1]{{\underline{#1}}}

        \makeindex

        \renewcommand{\headheight}{0.6in} %Space above header \renewcommand{\headrulewidth}{1pt} %thickness of line under header \renewcommand{\footrulewidth}{1pt} \newcommand{\HRule}{\rule{\linewidth}{0.5mm}} %thickness of line on title page

\setlength{\headwidth}{\textwidth}

\fancyhead[L]{\rightmark} 
\fancyhead[R]{\includegraphics[height=0.43in]{Images/Fugrologo.eps}} % right with logo \fancyfoot{}%to remove centered default footer 
\fancyfoot[L]{Fugro Roadware Inc.} 
\fancyfoot[R]{\thepage \  of \pageref*{LastPage}}% page# of reference page(last)

\fancypagestyle{plain}% no header, footer contains page number centered { 
\fancyhf{} %for the pages outside of content, list of figures etc. 
\fancyhead[R]{ \includegraphics[height=0.43in]{Images/Fugrologo.eps}} % right with logo

\fancyfoot[L]{Fugro Roadware Inc.} \fancyfoot[R]{\thepage \  of \pageref*{LastPage}} }

\pagestyle{fancy}
\usepackage[absolute]{textpos}



\begin{document}

\input{titlepage} 
\input{DocumentRevisionRecord}
\tableofcontents 
\listoffigures 
\listoftables 
\input{GettingStarted} 
\input{TourtheViews} 
\input{SetuptheWorkspace} 
\input{Map} 
\input{Video}
\input{SectionComposition} 
\input{Segmenting} 
\input{AutomaticMatching} 
\input{Events} 
\input{RoutingEditor} 
\input{DataAnalysis}
\input{CurveFitChapter} 
\input{BatchProcessing} 
\input{TransverseProfile}
\input{PavementModule}
\input{Dashboard} 
\input{TransferAssistant}
\input{DBGenerator} 
\input{DCS} 
\input{WiseCraxImporter} 
\input{RoutingImporter} 
\input{ReportingFramework}


\appendix 
\appendixpage 
\addappheadtotoc 
\input{Roughness} 
\input{CurveFit} 
\input{Faulting} 
\input{ERD} 
\input{Exif} 
\input{LCMSplugin} 
\input{Rut}
\input{PondingDepth} 
\input{Thumbnail}

\printindex

\clearpage 

\end{document}

Best Answer

Try to change your preamble this way:

\documentclass[11pt,a4paper]{report}  
    \usepackage{fancyhdr}
    \makeatletter
    \@ifpackageloaded{tex4ht}{%
      \usepackage[dvips]{color,graphicx}
      \usepackage[tex4ht]{hyperref}
    }{%
      \usepackage[pdftex]{color,graphicx}
      \usepackage{hyperref}

      \setlength{\headwidth}{\textwidth}

      \fancyhead[L]{\rightmark} 
      \fancyhead[R]{\includegraphics[height=0.43in]{Images/Fugrologo.eps}} % right with logo \fancyfoot{}%to remove centered default footer 
      \fancyfoot[L]{Fugro Roadware Inc.} 
      \fancyfoot[R]{\thepage \  of \pageref*{LastPage}}% page# of reference page(last)

      \fancypagestyle{plain}% no header, footer contains page number centered { 
      \fancyhf{} %for the pages outside of content, list of figures etc. 
      \fancyhead[R]{ \includegraphics[height=0.43in]{Images/Fugrologo.eps}} % right with logo

      \fancyfoot[L]{Fugro Roadware Inc.} \fancyfoot[R]{\thepage \  of \pageref*{LastPage}} 

      \pagestyle{fancy}
      \usepackage[absolute]{textpos}
      \usepackage{fullpage}
    }
    \makeatother  

    \usepackage{epstopdf}  
    \usepackage{lastpage}  
    \usepackage{makeidx}  
    \usepackage[english]{babel}  
    \usepackage{float}  
    \usepackage{subfig}  
    \usepackage{multirow}  
    \usepackage{appendix} 
    \usepackage{verbatim} 

        \renewcommand{\appendixtocname}{Appendix: Algorithm Parameters} \renewcommand{\appendixpagename}{Appendix-Algorithm Parameters}

        \setlength{\topmargin}{-1.3cm} \setlength{\headsep}{0.6cm}

        \renewcommand{\tablename}{\bfseries{Table}}

        %The top margin above a chapter can be changed using the titlesec package 

    \hypersetup{
            bookmarks=true,         % show bookmarks bar?
            unicode=false,          % non-Latin characters in Acrobat’s bookmarks
            pdftoolbar=true,        % show Acrobat’s toolbar?
            pdfmenubar=true,        % show Acrobat’s menu?
            pdffitwindow=false,     % window fit to page when opened
            pdfstartview={FitH},    % fits the width of the page to the window
            pdftitle={My title},    % title
            pdfauthor={Author},     % author
            pdfsubject={Subject},   % subject of the document
            pdfcreator={Creator},   % creator of the document
            pdfproducer={Producer}, % producer of the document
            pdfkeywords={keyword1} {key2} {key3}, % list of keywords
            pdfnewwindow=true,      % links in new window
            colorlinks=true,       % false: boxed links; true: colored links
            linkcolor=black,          % color of internal links
            citecolor=green,        % color of links to bibliography
            filecolor=magenta,      % color of file links
            urlcolor=cyan           % color of external links }
        }
        \input{Macro} %\renewcommand{\caption}[1]{{\underline{#1}}}

        \makeindex

        \renewcommand{\headheight}{0.6in} %Space above header \renewcommand{\headrulewidth}{1pt} %thickness of line under header \renewcommand{\footrulewidth}{1pt} \newcommand{\HRule}{\rule{\linewidth}{0.5mm}} %thickness of line on title page

\begin{document}
bhg fgfgf hgh ghghgf fdfd 
\end{document}

important is the command \@ifpackageloaded{tex4ht}{true part ...}{false part ...}. Now we can exclude packages which aren't needed when htlatex is run, such as fancyheader settings, and we can have different settings for packages which causes errors. In this case graphicx with pdftex option, htlatex is running in dvi mode, so we can set it to dvips