Repository: jsvine/pdfplumber

Issue #10: Is there a way to get something similar to pdftotext's layout?
Created: 2016-03-15T07:12:17Z
Is there an option similar to pdftotext's -layout flag, which "maintain[s] original physical layout"?  I understand that's probably up to the pdfminer engine...
Here's what I mean:
Original PDF
http://www.supremecourt.gov/oral_arguments/argument_transcripts/07-1315.pdf

pdftotext with -layout
$ curl -O http://www.supremecourt.gov/oral_arguments/argument_transcripts/07-1315.pdf
$ pdftotext -f 1 -l 1 -layout 07-1315.pdf -
Output:
                        Official - Subject to Final Review


 1      IN THE SUPREME COURT OF THE UNITED STATES

 2   - - - - - - - - - - - - - - - - - x

 3   MICHAEL A. KNOWLES,                            :

 4   WARDEN,                                        :

 5              Petitioner                          :

 6         v.                                       :        No. 07-1315

 7   ALEXANDRE MIRZAYANCE.                          :

 8   - - - - - - - - - - - - - - - - - x

 9                              Washington, D.C.

10                              Tuesday, January 13, 2009

11

12                  The above-entitled matter came on for oral

13   argument before the Supreme Court of the United States

14   at 1:01 p.m.

15   APPEARANCES:

16   STEVEN E. MERCER, ESQ., Deputy Attorney General, Los

17     Angeles, Cal.; on behalf of the Petitioner.

18   CHARLES M. SEVILLA, ESQ., San Diego, Cal.; on behalf

19     of the Respondent.

20

21

22

23

24

25


                                        1

                           Alderson Reporting Company

pdfminer
import pdfplumber
import requests
fname = "/tmp/whatev.pdf"
resp = requests.get("http://www.supremecourt.gov/oral_arguments/argument_transcripts/07-1315.pdf")
with open(fname, 'wb') as f:
      f.write(resp.content)
pdf = pdfplumber.open(fname)
print(pdf.pages[0].extract_text())
Output:
Official - Subject to Final Review 
1 IN THE SUPREME COURT OF THE UNITED STATES 
2 - - - - - - - - - - - - - - - - - x 
3 MICHAEL A. KNOWLES,               : 
4 WARDEN,                           :
5  Petitioner            :
6  v.                         :  No. 07-1315 
7 ALEXANDRE MIRZAYANCE.             : 
8 - - - - - - - - - - - - - - - - - x
9  Washington, D.C.
10  Tuesday, January 13, 2009
11
12  The above-entitled matter came on for oral 
13 argument before the Supreme Court of the United States 
14 at 1:01 p.m. 
15 APPEARANCES: 
16 STEVEN E. MERCER, ESQ., Deputy Attorney General, Los
17  Angeles, Cal.; on behalf of the Petitioner. 
18 CHARLES M. SEVILLA, ESQ., San Diego, Cal.; on behalf
19  of the Respondent. 
20
21
22
23
24
25
1


Alderson Reporting Company

Duplicate issue #295: Issue : Can't able to extract line spacing between  paragraph
Created: 2020-10-20T13:13:35Z
While extracting text from the pdf using extract.text() . It could not able to extract line spacing between paragraph . It merges the paragraph into one .
NOTE :
1 . I have tried with different x_tolerance and y_tolerance ranging from -10 to 10 .
2 . I also tried by cropping the pdf page .
Nothing worked :( .
Example of want it happens (No need to read see the structure) :
say pdf :
The Middle Ages saw a huge rise in popularity of annual Shrovetide football matches throughout Europe, particularly in England. An early reference to a ball game played in Britain comes from the 9th century Historia Brittonum, which describes "a party of boys ... playing at ball".[30] References to a ball game played in northern
France known as La Soule or Choule, in which the ball was propelled by hands, feet, and sticks,[31] date from the 12th century.[32]he early forms of football played in England, sometimes referred to as "mob football", would be played in towns or between neighbouring villages, involving an unlimited number of players on opposing teams who would clash en masse,[33] struggling to move an item.
The first detailed description of what was almost certainly football in England was given by William FitzStephen in about 1174–1183. He described the activities of London youths during the annual festival of Shrove Tuesday:
Extracted as :
The Middle Ages saw a huge rise in popularity of annual Shrovetide football matches throughout Europe, particularly in England. An early reference to a ball game played in Britain comes from the 9th century Historia Brittonum, which describes "a party of boys ... playing at ball".[30] References to a ball game played in northern
France known as La Soule or Choule, in which the ball was propelled by hands, feet, and sticks,[31] date from the 12th century.[32]he early forms of football played in England, sometimes referred to as "mob football", would be played in towns or between neighbouring villages, involving an unlimited number of players on opposing teams who would clash en masse,[33] struggling to move an item.
The first detailed description of what was almost certainly football in England was given by William FitzStephen in about 1174–1183. He described the activities of London youths during the annual festival of Shrove Tuesday:

Closing comment (2020-10-20T13:19:25Z): Thanks for your interesting in the library, @kkarthikvk. Right now, .extract_text(...) does not add spacing other than to separate lines. This is definitely something we'd like to improve in the future. I have an idea for how to implement this, but have not found the time yet to properly test it. Closing this issue as a practical duplicate of #10 to keep the discussion / progress updates in one place.