Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a long LaTeX document with lots of figures that were included using commands of the form

\includegraphics[page=10]{foo.pdf}

Everything compiles fine with pdfLaTeX. I planned to convert the document into HTML using TeX4ht, but it seems that TeX4ht does not understand the page= attributes in \includegraphics.

Are there any easy solutions? Ideally, I would prefer to keep my main Latex source unmodified and just tweak the preamble.

share|improve this question
add comment

2 Answers 2

Sorry for being late. Following code is likely to help the Jukka:

\makeatletter

\@ifundefined{Configure}
 {\def\Includegraphics[#1]#2{\includegraphics[page={#1}]{#2}}}
 {\def\Includegraphics[#1]#2{\def\GPT@page{#1}\includegraphics{#2}}
  \Configure{graphics*}
   {pdf}
   {\Needs{"
    pdftops -eps -f \GPT@page\space -l \GPT@page\space \Gin@base.pdf \Gin@base-\GPT@page.eps"
    ;
    convert \Gin@base-\GPT@page.eps \Gin@base-\GPT@page.png
    "}%
    \Picture[pict]{\Gin@base-\GPT@page.png}%
   }%
  }%
\makeatother

\Includegraphics[10]{foo.pdf} should work now both with pdfLaTeX and TeX4ht.

share|improve this answer
1  
We are glad to have you here in TeX.SX. A warm welcome to you. –  Harish Kumar Sep 15 '12 at 6:44
2  
Thanks, Harish. Glad to meet you here. –  CV Radhakrishnan Sep 16 '12 at 9:55
add comment

TeX4ht does not use pdfTeX in PDF mode, but dvips instead. However dvips can neither read PDF files nor multipage files. Page 10 can be extracted and converted to eps with epstopdf of xpdf:

epstopdf -eps -f 10 -l 10 foo.pdf foo-10.eps

Or ghostscript can be used, e.g.:

gs -dFirstPage=10 -dLastPage=10 -sDEVICE=epswrite -dBATCH -dNOPAUSE -sOutputFile=foo-10.eps foo.pdf

Then in the source:

\ifpdf
  \includegraphics[page=10]{foo.pdf}
\else
  \includegraphics{foo-10.eps}
\fi

And package ifpdf is needed in the preamble:

\usepackage{ifpdf}
share|improve this answer
    
Something along these lines certainly works, but it requires changes in the body of the Latex document. I wonder if I could easily redefine \includegraphics; moreover, perhaps I could have Latex run gs automatically to when needed? –  Jukka Suomela Aug 28 '12 at 18:02
    
It could be done, looking at package epstopdf that support external conversion programs for pdfTeX in PDF mode, I would expect several hundred lines of code. –  Heiko Oberdiek Aug 28 '12 at 20:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.