# Extracting typeset lines

For a research project, I'd like to extract an image of each typeset line in a page of plain text all in the same font.

I've considered two ways, both hacks of course, but I don't mind hacking:

• Use dvipng and extract the image of each line:
Probably fragile and hard to get the line heights right.

• Use dvips and hack the PostScript code:
It seems that y signals a new line.

Is there a simple, robust solution?

I control the TeX input completely, if that helps.

• Extract? In what way?
– Werner
Jun 22, 2015 at 17:51
• @Werner, as an image, but PS or PDF works for me as well.
– lhf
Jun 22, 2015 at 17:51
• I wonder if you could use the geometry package to make your page height so small that pdflatex would only output one line per page. Jun 22, 2015 at 18:15

How about making each line its own page? Perhaps someone else can show how to make TeX hyphenate across the page breaks the same way it would for regular lines.

\documentclass{article}
\usepackage[margin=0pt,paperheight=12pt,paperwidth=6.5in]{geometry}
\usepackage{kantlipsum}
\begin{document}
\kant
\end{document}


this typesets one line per page, producing output like

then imagemagic convert for example would convert the pdf to one png per page.

\documentclass{article}

\def\a{For a research project, I'd like to extract an image of each
typeset line in a page of plain text all in the same font. }
\def\b{\stepcounter{enumi}\roman{enumi}) \a\ifodd\value{enumi}\a\fi}
\def\c{\b\b Is there a simple, robust solution? Is there a simple, robust solution?
[\Roman{enumi}] \b\b}

\setlength\textheight{\baselineskip}
\setlength\topskip{0pt}
\setlength\topmargin{-1.1in}
\pdfpageheight60pt
\pagestyle{empty}
\interlinepenalty-10000
\clubpenalty-10000
\widowpenalty-10000
\begin{document}

\c\c\c\c\c

\end{document}