Thank you Andreas, that setting solves the problem for a particular set of documents.
For other documents, however, it gives me a wrong word order. So I wondered whether I can infer if I should set it from something in the document I want to extract text from. When should I use true and when false? Best regards, Heike Johannsen -----Ursprüngliche Nachricht----- Von: Andreas Lehmkühler [mailto:[email protected]] Gesendet: Freitag, 1. Oktober 2010 08:59 An: [email protected] Betreff: Re: PDFBox - Problem with fragmented extraction result Hi, Gesendet: Fr, 01. Okt 2010 Von: Heike Johannsen<[email protected]> > Hello everybody! > > Is there any chance that someone can help me with the following problem: > > I'm trying to extract text from a PDF document but what I get as a result is > highly fragmented. > > Is there a way to overcome this? Did you ever try to activate the sorting algo? Try something like this stripper.setSortByPosition( true ); See [1] for further information. BR Andreas Lehmkühler [1] http://svn.apache.org/repos/asf/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/ExtractText.java > > Reproduce with JUnit test: > > @Test > public void testTryThings() throws Exception > { > final String filename = > "http://www.junkers.com/de/pmdb/brochures/Brennwert_7_181_465_853.pdf"; > > final PDDocument document = PDDocument.load(new URL(filename)); > final PDFTextStripper stripper = new PDFTextStripper(); > > final String text = stripper.getText(document); > > System.out.println(text); > > } > > See console output: > > Wärme fürs Leben > Gas-Brennwertheizungen für Etagen, > Ein- und Mehrfamilienhäuser > Energiesparende Behaglichkeit zum Rundum-Wohlfühlen > Gas-Brennwert-Programm > > Für > Bauhe > rr > en > und > R > en > o > vie > re > r > Lieber Leser, > wir bieten Ihnen für jede Wohnsituation und für jeden Komfortbedarf die > passende > Heiz- und Warmwasserlösung. Unsere Auswahl ist daher genauso vielfältig wie > die > verschiedenen Wünsche unserer Kunden. Um Ihnen den Überblick trotzdem > ganz leicht zu machen, haben wir für Sie Piktogramme entworfen - > einprägsame > Abbildungen, die wichtige Produktmerkmale auf einen Blick zeigen. > Was das genau bedeutet, erfahren Sie auf der Innenseite dieser Klappe. > Unser Tipp: Lassen Sie die Leiste aufgeschlagen, wenn Sie sich unsere > Broschüre ansehen. Dann haben Sie alle wichtigen Infos stets vor Augen. > 2 > > Für > Bauhe > rr > en > und > R > en > o > vie > re > r > > > Parts of the output are highly fragmented. With other documents in my > collection, this affects the major part of the text. If there is no setting > that can be made to fix this, do you perhaps have an explanation for this > phenomenon (e.g. the input file having some exotic encoding)? > > Thanks in advance! > > Heike > > --- original Nachricht Ende ----

