| 1 |
.\" Copyright 1997-2025 Glyph & Cog, LLC |
| 2 |
.TH pdftotext 1 "14 Nov 2025" |
| 3 |
.SH NAME |
| 4 |
pdftotext \- Portable Document Format (PDF) to text converter |
| 5 |
(version 4.06) |
| 6 |
.SH SYNOPSIS |
| 7 |
.B pdftotext |
| 8 |
[options] |
| 9 |
.RI [ PDF-file |
| 10 |
.RI [ text-file ]] |
| 11 |
.SH DESCRIPTION |
| 12 |
.B Pdftotext |
| 13 |
converts Portable Document Format (PDF) files to plain text. |
| 14 |
.PP |
| 15 |
Pdftotext reads the PDF file, |
| 16 |
.IR PDF-file , |
| 17 |
and writes a text file, |
| 18 |
.IR text-file . |
| 19 |
If |
| 20 |
.I text-file |
| 21 |
is not specified, pdftotext converts |
| 22 |
.I file.pdf |
| 23 |
to |
| 24 |
.IR file.txt . |
| 25 |
If |
| 26 |
.I text-file |
| 27 |
is \'-', the text is sent to stdout. |
| 28 |
.SH CONFIGURATION FILE |
| 29 |
Pdftotext reads a configuration file at startup. It first tries to |
| 30 |
find the user's private config file, ~/.xpdfrc. If that doesn't |
| 31 |
exist, it looks for a system-wide config file, typically /etc/xpdfrc |
| 32 |
(but this location can be changed when pdftotext is built). See the |
| 33 |
.BR xpdfrc (5) |
| 34 |
man page for details. |
| 35 |
.SH OPTIONS |
| 36 |
Many of the following options can be set with configuration file |
| 37 |
commands. These are listed in square brackets with the description of |
| 38 |
the corresponding command line option. |
| 39 |
.TP |
| 40 |
.BI \-f " number" |
| 41 |
Specifies the first page to convert. |
| 42 |
.TP |
| 43 |
.BI \-l " number" |
| 44 |
Specifies the last page to convert. |
| 45 |
.TP |
| 46 |
.B \-layout |
| 47 |
Maintain (as best as possible) the original physical layout of the |
| 48 |
text. The default is to \'undo' physical layout (columns, |
| 49 |
hyphenation, etc.) and output the text in reading order. If the |
| 50 |
.B \-fixed |
| 51 |
option is given, character spacing within each line will be determined |
| 52 |
by the specified character pitch. |
| 53 |
.TP |
| 54 |
.B \-simple |
| 55 |
Similar to |
| 56 |
.BR \-layout , |
| 57 |
but optimized for simple one-column pages. This mode will do a better |
| 58 |
job of maintaining horizontal spacing, but it will only work properly |
| 59 |
with a single column of text. |
| 60 |
.TP |
| 61 |
.B \-simple2 |
| 62 |
Similar to |
| 63 |
.BR \-simple , |
| 64 |
but handles slightly rotated text (e.g., OCR output) better. Only works |
| 65 |
for pages with a single column of text. |
| 66 |
.TP |
| 67 |
.B \-table |
| 68 |
Table mode is similar to physical layout mode, but optimized for |
| 69 |
tabular data, with the goal of keeping rows and columns aligned (at |
| 70 |
the expense of inserting extra whitespace). If the |
| 71 |
.B \-fixed |
| 72 |
option is given, character spacing within each line will be determined |
| 73 |
by the specified character pitch. |
| 74 |
.TP |
| 75 |
.B \-lineprinter |
| 76 |
Line printer mode uses a strict fixed-character-pitch and -height |
| 77 |
layout. That is, the page is broken into a grid, and characters are |
| 78 |
placed into that grid. If the grid spacing is too small for the |
| 79 |
actual characters, the result is extra whitespace. If the grid |
| 80 |
spacing is too large, the result is missing whitespace. The grid |
| 81 |
spacing can be specified using the |
| 82 |
.B \-fixed |
| 83 |
and |
| 84 |
.B \-linespacing |
| 85 |
options. |
| 86 |
If one or both are not given on the command line, pdftotext will |
| 87 |
attempt to compute appropriate value(s). |
| 88 |
.TP |
| 89 |
.B \-raw |
| 90 |
Keep the text in content stream order. Depending on how the PDF file |
| 91 |
was generated, this may or may not be useful. |
| 92 |
.TP |
| 93 |
.BI \-fixed " number" |
| 94 |
Specify the character pitch (character width), in points, for physical |
| 95 |
layout, table, or line printer mode. This is ignored in all other |
| 96 |
modes. |
| 97 |
.TP |
| 98 |
.BI \-linespacing " number" |
| 99 |
Specify the line spacing, in points, for line printer mode. This is |
| 100 |
ignored in all other modes. |
| 101 |
.TP |
| 102 |
.B \-clip |
| 103 |
Text which is hidden because of clipping is removed before doing |
| 104 |
layout, and then added back in. This can be helpful for tables where |
| 105 |
clipped (invisible) text would overlap the next column. |
| 106 |
.TP |
| 107 |
.B \-nodiag |
| 108 |
Diagonal text, i.e., text that is not close to one of the 0, 90, 180, |
| 109 |
or 270 degree axes, is discarded. This is useful to skip watermarks |
| 110 |
drawn on top of body text, etc. |
| 111 |
.TP |
| 112 |
.BI \-enc " encoding-name" |
| 113 |
Sets the encoding to use for text output. The |
| 114 |
.I encoding\-name |
| 115 |
must be defined with the unicodeMap command (see |
| 116 |
.BR xpdfrc (5)). |
| 117 |
The encoding name is case-sensitive. This defaults to "Latin1" (which |
| 118 |
is a built-in encoding). |
| 119 |
.RB "[config file: " textEncoding ] |
| 120 |
.TP |
| 121 |
.BI \-eol " unix | dos | mac" |
| 122 |
Sets the end-of-line convention to use for text output. |
| 123 |
.RB "[config file: " textEOL ] |
| 124 |
.TP |
| 125 |
.B \-nopgbrk |
| 126 |
Don't insert a page breaks (form feed character) at the end of each |
| 127 |
page. |
| 128 |
.RB "[config file: " textPageBreaks ] |
| 129 |
.TP |
| 130 |
.B \-bom |
| 131 |
Insert a Unicode byte order marker (BOM) at the start of the text |
| 132 |
output. |
| 133 |
.TP |
| 134 |
.BI \-marginl " number" |
| 135 |
Specifies the left margin, in points. Text in the left margin (i.e., |
| 136 |
within that many points of the left edge of the page) is discarded. |
| 137 |
The default value is zero. |
| 138 |
.TP |
| 139 |
.BI \-marginr " number" |
| 140 |
Specifies the right margin, in points. Text in the right margin |
| 141 |
(i.e., within that many points of the right edge of the page) is |
| 142 |
discarded. The default value is zero. |
| 143 |
.TP |
| 144 |
.BI \-margint " number" |
| 145 |
Specifies the top margin, in points. Text in the top margin (i.e., |
| 146 |
within that many points of the top edge of the page) is discarded. |
| 147 |
The default value is zero. |
| 148 |
.TP |
| 149 |
.BI \-marginb " number" |
| 150 |
Specifies the bottom margin, in points. Text in the bottom margin |
| 151 |
(i.e., within that many points of the bottom edge of the page) is |
| 152 |
discarded. The default value is zero. |
| 153 |
.TP |
| 154 |
.BI \-opw " password" |
| 155 |
Specify the owner password for the PDF file. Providing this will |
| 156 |
bypass all security restrictions. |
| 157 |
.TP |
| 158 |
.BI \-upw " password" |
| 159 |
Specify the user password for the PDF file. |
| 160 |
.TP |
| 161 |
.B \-verbose |
| 162 |
Print a status message (to stdout) before processing each page. |
| 163 |
.RB "[config file: " printStatusInfo ] |
| 164 |
.TP |
| 165 |
.B \-q |
| 166 |
Don't print any messages or errors. |
| 167 |
.RB "[config file: " errQuiet ] |
| 168 |
.TP |
| 169 |
.BI \-cfg " config-file" |
| 170 |
Read |
| 171 |
.I config-file |
| 172 |
in place of ~/.xpdfrc or the system-wide config file. |
| 173 |
.TP |
| 174 |
.B \-listencodings |
| 175 |
List all available text output encodings, then exit. |
| 176 |
.TP |
| 177 |
.B \-v |
| 178 |
Print copyright and version information, then exit. |
| 179 |
.TP |
| 180 |
.B \-h |
| 181 |
Print usage information, then exit. |
| 182 |
.RB ( \-help |
| 183 |
and |
| 184 |
.B \-\-help |
| 185 |
are equivalent.) |
| 186 |
.SH BUGS |
| 187 |
Some PDF files contain fonts whose encodings have been mangled beyond |
| 188 |
recognition. There is no way (short of OCR) to extract text from |
| 189 |
these files. |
| 190 |
.SH EXIT CODES |
| 191 |
The Xpdf tools use the following exit codes: |
| 192 |
.TP |
| 193 |
0 |
| 194 |
No error. |
| 195 |
.TP |
| 196 |
1 |
| 197 |
Error opening a PDF file. |
| 198 |
.TP |
| 199 |
2 |
| 200 |
Error opening an output file. |
| 201 |
.TP |
| 202 |
3 |
| 203 |
Error related to PDF permissions. |
| 204 |
.TP |
| 205 |
98 |
| 206 |
Out of memory. |
| 207 |
.TP |
| 208 |
99 |
| 209 |
Other error. |
| 210 |
.SH AUTHOR |
| 211 |
The pdftotext software and documentation are copyright 1996-2025 Glyph |
| 212 |
& Cog, LLC. |
| 213 |
.SH "SEE ALSO" |
| 214 |
.BR xpdf (1), |
| 215 |
.BR pdftops (1), |
| 216 |
.BR pdftohtml (1), |
| 217 |
.BR pdfinfo (1), |
| 218 |
.BR pdffonts (1), |
| 219 |
.BR pdfdetach (1), |
| 220 |
.BR pdftoppm (1), |
| 221 |
.BR pdftopng (1), |
| 222 |
.BR pdfimages (1), |
| 223 |
.BR xpdfrc (5) |
| 224 |
.br |
| 225 |
.B http://www.xpdfreader.com/ |