I have a document which I'd like to apply pdftotext -layout and parse the output text. The problem I'm having is that the text is in twocolumn, and the output of pdftotext sometimes interlaces the two columns (because the baselines of the two columns are not on a grid).

Is there a way to output the same pdf but treating the two columns as different pages (so that pdftotext -layout won't read the two columns on the same page)? An simple example is below. I thought about simply changing the margins so that the page would be a single column in \textwidth, but the concrete example involves floats, switches to one column + longtable mid-document, and things like page references, ibids, etc. The intended use of pdftotext -layout is to examine things like whether or not a word is repeated on consecutive lines, so the text and layout need to be identical.

For example,





which produces:

Lorem ipsum dolor sit amet, consectetuer adip- vulputate metus eu enim. Vestibulum pellen-
iscing elit. Ut purus elit, vestibulum ut, plac- tesque felis eu massa.
erat ac, adipiscing vitae, felis. Curabitur dic-
                                                      Quisque ullamcorper placerat ipsum. Cras nibh.
tum gravida mauris. Nam arcu libero, nonummy
                                                      Morbi vel justo vitae lacus tincidunt ultrices.
eget, consectetuer id, vulputate a, magna. Donec
                                                      Lorem ipsum dolor sit amet, consectetuer adip-
vehicula augue eu neque. Pellentesque habitant
                                                      iscing elit. In hac habitasse platea dictumst.
morbi tristique senectus et netus et malesuada
                                                      Integer tempus convallis augue. Etiam facili-
fames ac turpis egestas. Mauris ut leo. Cras
                                                      sis. Nunc elementum fermentum wisi. Aenean
viverra metus rhoncus sem. Nulla et lectus vestibu-
                                                      placerat. Ut imperdiet, enim sed gravida sollic-
lum urna fringilla ultrices. Phasellus eu tellus sit
                                                      itudin, felis odio placerat quam, ac pulvinar elit
amet tortor gravida placerat. Integer sapien est,
                                                      purus eget enim. Nunc vitae tortor. Proin tem-
iaculis in, pretium quis, viverra ac, nunc. Prae-
                                                      pus nibh sit amet nisl. Vivamus quis tortor vitae
sent eget sem vel leo ultrices bibendum. Aenean
                                                      risus porta vehicula.
faucibus. Morbi dolor nulla, malesuada eu, pul-
vinar at, mollis ac, nulla. Curabitur auctor sem- Fusce mauris. Vestibulum luctus nibh at lectus.
per nulla. Donec varius orci eget risus. Duis Sed bibendum, nulla a faucibus semper, leo velit
nibh mi, congue eu, accumsan eleifend, sagittis ultricies tellus, ac venenatis arcu wisi vel nisl.
  • Probably the "right" way would be to use article threads (see section 7.13 of the pdftex manual) iff pdftotext would honour them. – Martin Schröder Dec 1 '16 at 14:53
  • It's section 8.13 as far as I can tell, but that's as far as my expertise takes me... – Hugh Dec 3 '16 at 2:16

Seeing as this is just for text extraction it's not that pretty, but just arrange to put out the columns one above the other instead of side by side

enter image description here

It's copying a largeish macro but just changing the hbox and vrule to a vbox and hrule




     \setbox\@outputbox\vsplit\@outputbox to\maxdimen
       \hb@xt@\columnwidth{\box\@leftcolumn \hss}%
%        \hfil
%        {\normalcolor\vrule \@width\columnseprule}%
%        \hfil
       \hb@xt@\columnwidth{\box\@outputbox \hss}}%
      \@whilesw\if@fcolmade \fi{\@outputpage



| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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