Skip to content

Commit ad40437

Browse files
Extract Text: Add missing body parameters
Assisted-by: Codex
1 parent 2e884a7 commit ad40437

3 files changed

Lines changed: 34 additions & 1 deletion

File tree

src/pdfrest/client.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,6 +2283,11 @@ def extract_text(
22832283
file: PdfRestFile | Sequence[PdfRestFile],
22842284
*,
22852285
pages: PdfPageSelection | None = None,
2286+
full_text: Literal["off", "by_page", "document"] = "document",
2287+
preserve_line_breaks: Literal["off", "on"] = "off",
2288+
word_style: Literal["off", "on"] = "off",
2289+
word_coordinates: Literal["off", "on"] = "off",
2290+
output_type: Literal["json", "file"] = "json",
22862291
output: str | None = None,
22872292
extra_query: Query | None = None,
22882293
extra_headers: AnyMapping | None = None,
@@ -2294,6 +2299,11 @@ def extract_text(
22942299
payload: dict[str, Any] = {"files": file}
22952300
if pages is not None:
22962301
payload["pages"] = pages
2302+
payload["full_text"] = full_text
2303+
payload["preserve_line_breaks"] = preserve_line_breaks
2304+
payload["word_style"] = word_style
2305+
payload["word_coordinates"] = word_coordinates
2306+
payload["output_type"] = output_type
22972307
if output is not None:
22982308
payload["output"] = output
22992309

@@ -3196,6 +3206,11 @@ async def extract_text(
31963206
file: PdfRestFile | Sequence[PdfRestFile],
31973207
*,
31983208
pages: PdfPageSelection | None = None,
3209+
full_text: Literal["off", "by_page", "document"] = "document",
3210+
preserve_line_breaks: Literal["off", "on"] = "off",
3211+
word_style: Literal["off", "on"] = "off",
3212+
word_coordinates: Literal["off", "on"] = "off",
3213+
output_type: Literal["json", "file"] = "json",
31993214
output: str | None = None,
32003215
extra_query: Query | None = None,
32013216
extra_headers: AnyMapping | None = None,
@@ -3207,6 +3222,11 @@ async def extract_text(
32073222
payload: dict[str, Any] = {"files": file}
32083223
if pages is not None:
32093224
payload["pages"] = pages
3225+
payload["full_text"] = full_text
3226+
payload["preserve_line_breaks"] = preserve_line_breaks
3227+
payload["word_style"] = word_style
3228+
payload["word_coordinates"] = word_coordinates
3229+
payload["output_type"] = output_type
32103230
if output is not None:
32113231
payload["output"] = output
32123232

src/pdfrest/models/_internal.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,11 @@ class ExtractTextPayload(BaseModel):
343343
BeforeValidator(_int_to_string),
344344
PlainSerializer(_serialize_page_ranges),
345345
] = None
346+
full_text: Literal["off", "by_page", "document"] = "document"
347+
preserve_line_breaks: Literal["off", "on"] = "off"
348+
word_style: Literal["off", "on"] = "off"
349+
word_coordinates: Literal["off", "on"] = "off"
350+
output_type: Literal["json", "file"] = "json"
346351
output: Annotated[
347352
str | None,
348353
Field(serialization_alias="output", min_length=1, default=None),

tests/live/test_live_extract_text.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ def test_live_extract_text_success(
1818
base_url=pdfrest_live_base_url,
1919
) as client:
2020
uploaded = client.files.create_from_paths([resource])[0]
21-
response = client.extract_text(uploaded, output=None)
21+
response = client.extract_text(
22+
uploaded,
23+
output_type="json",
24+
full_text="document",
25+
preserve_line_breaks="on",
26+
word_style="off",
27+
word_coordinates="off",
28+
)
2229

2330
assert isinstance(response, ExtractTextResponse)
2431
assert response.text
@@ -39,4 +46,5 @@ def test_live_extract_text_invalid_pages(
3946
client.extract_text(
4047
uploaded,
4148
extra_body={"pages": "last-1"},
49+
output_type="json",
4250
)

0 commit comments

Comments
 (0)