# Parsing pdf files

**URL:** <https://www.ruby-forum.com/t/parsing-pdf-files/174216>\
**Category:** Ruby\
**Created:** [August 22, 2009, 6:36pm UTC](https://www.ruby-forum.com/t/parsing-pdf-files/174216 "2009-08-22T18:36:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![arunvoip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e8c25b/32.png) [@arunvoip](https://www.ruby-forum.com/u/arunvoip)\
**Post date:** [August 22, 2009, 6:36pm UTC](https://www.ruby-forum.com/t/parsing-pdf-files/174216/1 "2009-08-22T18:36:27Z")

</div>

hello all,  
Does anyone know a good pdf parser that retains  
formatting  
after its extracted text? I used PDF::Reader, but when you extract text  
you  
just get a stream of characters that are not at all intelligible. When I  
copy a pdf contents from a pdf reader to Gedit text editor in linux it  
retains its format. I’m looking for something like that.

Thanks for any help.

regards,  
Arun K. M S

---

<div class="post-metadata">

**Author:** ![arunvoip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e8c25b/32.png) [@arunvoip](https://www.ruby-forum.com/u/arunvoip)\
**Post date:** [August 22, 2009, 7:09pm UTC](https://www.ruby-forum.com/t/parsing-pdf-files/174216/2 "2009-08-22T19:09:50Z")

</div>

On Sat, Aug 22, 2009 at 12:33 PM, Arun K.[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> hello all,  
> Does anyone know a good pdf parser that retains formatting  
> after its extracted text? I used PDF::Reader, but when you extract text you  
> just get a stream of characters that are not at all intelligible. When I  
> copy a pdf contents from a pdf reader to Gedit text editor in linux it  
> retains its format. I’m looking for something like that.

This doesn’t exist in Ruby, unfortunately.

-greg

---

<div class="post-metadata">

**Author:** ![arunvoip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e8c25b/32.png) [@arunvoip](https://www.ruby-forum.com/u/arunvoip)\
**Post date:** [August 22, 2009, 10:11pm UTC](https://www.ruby-forum.com/t/parsing-pdf-files/174216/3 "2009-08-22T22:11:17Z")

</div>

That’s really very sad ☹

On Sat, Aug 22, 2009 at 10:33 PM, Gregory B.

---

<div class="post-metadata">

**Author:** ![arunvoip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e8c25b/32.png) [@arunvoip](https://www.ruby-forum.com/u/arunvoip)\
**Post date:** [August 22, 2009, 11:12pm UTC](https://www.ruby-forum.com/t/parsing-pdf-files/174216/4 "2009-08-22T23:12:09Z")

</div>

On Sat, Aug 22, 2009 at 4:10 PM, Arun K.[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> That’s really very sad ☹

Looks like you better roll up your sleeves 🙂

---

<div class="post-metadata">

**Author:** ![arunvoip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e8c25b/32.png) [@arunvoip](https://www.ruby-forum.com/u/arunvoip)\
**Post date:** [August 23, 2009, 10:10am UTC](https://www.ruby-forum.com/t/parsing-pdf-files/174216/5 "2009-08-23T10:10:42Z")

</div>

Yeah seeing what can be done 🙂

---

<div class="post-metadata">

**Author:** ![arunvoip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e8c25b/32.png) [@arunvoip](https://www.ruby-forum.com/u/arunvoip)\
**Post date:** [August 24, 2009, 11:52am UTC](https://www.ruby-forum.com/t/parsing-pdf-files/174216/6 "2009-08-24T11:52:22Z")

</div>

Arun,

there is another ruby pdf-extractor:  
[http://scm.ywesee.com/?p=rpdf2txt;a=summary](http://scm.ywesee.com/?p=rpdf2txt;a=summary)

However, it’s largely undocumented, slow, fragile, and its column  
detection algorithm is basic at best. If that does not faze you, give  
it a try and contact me if you have questions. Look at the included  
commandline-tool in ./bin/rpdf2txt for an example.

cheers,  
Hannes

---

<div class="post-metadata">

**Author:** ![arunvoip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e8c25b/32.png) [@arunvoip](https://www.ruby-forum.com/u/arunvoip)\
**Post date:** [August 24, 2009, 12:25pm UTC](https://www.ruby-forum.com/t/parsing-pdf-files/174216/7 "2009-08-24T12:25:51Z")

</div>

You can use [http://pdftohtml.sourceforge.net](http://pdftohtml.sourceforge.net) or use my Ruby wrapper for  
this tool:

> **[GitHub - eterps/pdf-struct: PDF::Extractor is a library that provides high level...](https://github.com/eterps/pdf-struct/tree/master)**
>
> master

Arun K. wrote:

> hello all,  
> Does anyone know a good pdf parser that retains  
> formatting  
> after its extracted text? I used PDF::Reader, but when you extract text  
> you  
> just get a stream of characters that are not at all intelligible. When I  
> copy a pdf contents from a pdf reader to Gedit text editor in linux it  
> retains its format. I’m looking for something like that.
> 
> Thanks for any help.
> 
> regards,  
> Arun K. M S

---

<div class="post-metadata">

**Author:** ![arunvoip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e8c25b/32.png) [@arunvoip](https://www.ruby-forum.com/u/arunvoip)\
**Post date:** [August 24, 2009, 2:23pm UTC](https://www.ruby-forum.com/t/parsing-pdf-files/174216/8 "2009-08-24T14:23:59Z")

</div>

On Mon, Aug 24, 2009 at 6:25 AM, Erik T.[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> You can use [http://pdftohtml.sourceforge.net](http://pdftohtml.sourceforge.net) or use my Ruby wrapper for  
> this tool:
> 
> [GitHub - eterps/pdf-struct: PDF::Extractor is a library that provides high level access to the text objects of a PDF document](http://github.com/eterps/pdf-struct/tree/master)

Very interesting, thanks for posting this.

-greg
