Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions docs-website/reference/integrations-api/opendataloader_pdf.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ slug: "/integrations-opendataloader-pdf"
OpenDataLoader PDF converter component.

The component accepts PDF file paths and Haystack ByteStream objects, runs OpenDataLoader PDF extraction, and
returns Haystack Document objects.
returns Haystack Document objects. It can also extract images to a persistent directory and return one image
Document per extracted file.

Java 11 or newer must be installed and available on PATH.

Expand All @@ -22,11 +23,15 @@ Java 11 or newer must be installed and available on PATH.
```python
from haystack_integrations.components.converters.opendataloader_pdf import OpenDataLoaderConverter

converter = OpenDataLoaderConverter(output_format="markdown")
converter = OpenDataLoaderConverter(
output_format="markdown", extract_images=True, image_output_dir="extracted_images"
)
result = converter.run(sources=["report.pdf"], meta={"source": "annual-report"})

documents = result["documents"]
image_documents = result["image_documents"]
print(documents[0].content)
print(documents[0].meta["file_path"])
```

#### __init__
Expand All @@ -35,7 +40,9 @@ print(documents[0].content)
__init__(
*,
output_format: OutputFormat = "markdown",
convert_kwargs: dict[str, Any] | None = None
convert_kwargs: dict[str, Any] | None = None,
extract_images: bool = False,
image_output_dir: str | Path | None = None
) -> None
```

Expand All @@ -46,6 +53,14 @@ Initialize the OpenDataLoader converter.
- **output_format** (<code>OutputFormat</code>) – Format OpenDataLoader should produce.
- **convert_kwargs** (<code>dict\[str, Any\] | None</code>) – Additional arguments passed to `opendataloader_pdf.convert`. See the
[OpenDataLoader PDF Python options](https://opendataloader.org/docs/quick-start-python#convert-options).
The `image_output` and `image_dir` arguments are managed by this component; supplied values are ignored.
- **extract_images** (<code>bool</code>) – Whether to extract images and return them through the `image_documents` output.
- **image_output_dir** (<code>str | Path | None</code>) – Persistent root directory for extracted image files. Each `run()` stores its images
in a unique subdirectory of this directory. Required when `extract_images` is `True`.

**Raises:**

- <code>ValueError</code> – If image extraction is enabled without an output directory.

#### to_dict

Expand Down Expand Up @@ -94,4 +109,5 @@ Convert PDF sources into Haystack Documents.

**Returns:**

- <code>dict\[str, list\[Document\]\]</code> – Dictionary containing the converted Documents.
- <code>dict\[str, list\[Document\]\]</code> – Dictionary containing the converted text Documents and image Documents. Each image Document has the
persistent extracted image path in its `file_path` metadata field.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ slug: "/integrations-opendataloader-pdf"
OpenDataLoader PDF converter component.

The component accepts PDF file paths and Haystack ByteStream objects, runs OpenDataLoader PDF extraction, and
returns Haystack Document objects.
returns Haystack Document objects. It can also extract images to a persistent directory and return one image
Document per extracted file.

Java 11 or newer must be installed and available on PATH.

Expand All @@ -22,11 +23,15 @@ Java 11 or newer must be installed and available on PATH.
```python
from haystack_integrations.components.converters.opendataloader_pdf import OpenDataLoaderConverter

converter = OpenDataLoaderConverter(output_format="markdown")
converter = OpenDataLoaderConverter(
output_format="markdown", extract_images=True, image_output_dir="extracted_images"
)
result = converter.run(sources=["report.pdf"], meta={"source": "annual-report"})

documents = result["documents"]
image_documents = result["image_documents"]
print(documents[0].content)
print(documents[0].meta["file_path"])
```

#### __init__
Expand All @@ -35,7 +40,9 @@ print(documents[0].content)
__init__(
*,
output_format: OutputFormat = "markdown",
convert_kwargs: dict[str, Any] | None = None
convert_kwargs: dict[str, Any] | None = None,
extract_images: bool = False,
image_output_dir: str | Path | None = None
) -> None
```

Expand All @@ -46,6 +53,14 @@ Initialize the OpenDataLoader converter.
- **output_format** (<code>OutputFormat</code>) – Format OpenDataLoader should produce.
- **convert_kwargs** (<code>dict\[str, Any\] | None</code>) – Additional arguments passed to `opendataloader_pdf.convert`. See the
[OpenDataLoader PDF Python options](https://opendataloader.org/docs/quick-start-python#convert-options).
The `image_output` and `image_dir` arguments are managed by this component; supplied values are ignored.
- **extract_images** (<code>bool</code>) – Whether to extract images and return them through the `image_documents` output.
- **image_output_dir** (<code>str | Path | None</code>) – Persistent root directory for extracted image files. Each `run()` stores its images
in a unique subdirectory of this directory. Required when `extract_images` is `True`.

**Raises:**

- <code>ValueError</code> – If image extraction is enabled without an output directory.

#### to_dict

Expand Down Expand Up @@ -94,4 +109,5 @@ Convert PDF sources into Haystack Documents.

**Returns:**

- <code>dict\[str, list\[Document\]\]</code> – Dictionary containing the converted Documents.
- <code>dict\[str, list\[Document\]\]</code> – Dictionary containing the converted text Documents and image Documents. Each image Document has the
persistent extracted image path in its `file_path` metadata field.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ slug: "/integrations-opendataloader-pdf"
OpenDataLoader PDF converter component.

The component accepts PDF file paths and Haystack ByteStream objects, runs OpenDataLoader PDF extraction, and
returns Haystack Document objects.
returns Haystack Document objects. It can also extract images to a persistent directory and return one image
Document per extracted file.

Java 11 or newer must be installed and available on PATH.

Expand All @@ -22,11 +23,15 @@ Java 11 or newer must be installed and available on PATH.
```python
from haystack_integrations.components.converters.opendataloader_pdf import OpenDataLoaderConverter

converter = OpenDataLoaderConverter(output_format="markdown")
converter = OpenDataLoaderConverter(
output_format="markdown", extract_images=True, image_output_dir="extracted_images"
)
result = converter.run(sources=["report.pdf"], meta={"source": "annual-report"})

documents = result["documents"]
image_documents = result["image_documents"]
print(documents[0].content)
print(documents[0].meta["file_path"])
```

#### __init__
Expand All @@ -35,7 +40,9 @@ print(documents[0].content)
__init__(
*,
output_format: OutputFormat = "markdown",
convert_kwargs: dict[str, Any] | None = None
convert_kwargs: dict[str, Any] | None = None,
extract_images: bool = False,
image_output_dir: str | Path | None = None
) -> None
```

Expand All @@ -46,6 +53,14 @@ Initialize the OpenDataLoader converter.
- **output_format** (<code>OutputFormat</code>) – Format OpenDataLoader should produce.
- **convert_kwargs** (<code>dict\[str, Any\] | None</code>) – Additional arguments passed to `opendataloader_pdf.convert`. See the
[OpenDataLoader PDF Python options](https://opendataloader.org/docs/quick-start-python#convert-options).
The `image_output` and `image_dir` arguments are managed by this component; supplied values are ignored.
- **extract_images** (<code>bool</code>) – Whether to extract images and return them through the `image_documents` output.
- **image_output_dir** (<code>str | Path | None</code>) – Persistent root directory for extracted image files. Each `run()` stores its images
in a unique subdirectory of this directory. Required when `extract_images` is `True`.

**Raises:**

- <code>ValueError</code> – If image extraction is enabled without an output directory.

#### to_dict

Expand Down Expand Up @@ -94,4 +109,5 @@ Convert PDF sources into Haystack Documents.

**Returns:**

- <code>dict\[str, list\[Document\]\]</code> – Dictionary containing the converted Documents.
- <code>dict\[str, list\[Document\]\]</code> – Dictionary containing the converted text Documents and image Documents. Each image Document has the
persistent extracted image path in its `file_path` metadata field.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ slug: "/integrations-opendataloader-pdf"
OpenDataLoader PDF converter component.

The component accepts PDF file paths and Haystack ByteStream objects, runs OpenDataLoader PDF extraction, and
returns Haystack Document objects.
returns Haystack Document objects. It can also extract images to a persistent directory and return one image
Document per extracted file.

Java 11 or newer must be installed and available on PATH.

Expand All @@ -22,11 +23,15 @@ Java 11 or newer must be installed and available on PATH.
```python
from haystack_integrations.components.converters.opendataloader_pdf import OpenDataLoaderConverter

converter = OpenDataLoaderConverter(output_format="markdown")
converter = OpenDataLoaderConverter(
output_format="markdown", extract_images=True, image_output_dir="extracted_images"
)
result = converter.run(sources=["report.pdf"], meta={"source": "annual-report"})

documents = result["documents"]
image_documents = result["image_documents"]
print(documents[0].content)
print(documents[0].meta["file_path"])
```

#### __init__
Expand All @@ -35,7 +40,9 @@ print(documents[0].content)
__init__(
*,
output_format: OutputFormat = "markdown",
convert_kwargs: dict[str, Any] | None = None
convert_kwargs: dict[str, Any] | None = None,
extract_images: bool = False,
image_output_dir: str | Path | None = None
) -> None
```

Expand All @@ -46,6 +53,14 @@ Initialize the OpenDataLoader converter.
- **output_format** (<code>OutputFormat</code>) – Format OpenDataLoader should produce.
- **convert_kwargs** (<code>dict\[str, Any\] | None</code>) – Additional arguments passed to `opendataloader_pdf.convert`. See the
[OpenDataLoader PDF Python options](https://opendataloader.org/docs/quick-start-python#convert-options).
The `image_output` and `image_dir` arguments are managed by this component; supplied values are ignored.
- **extract_images** (<code>bool</code>) – Whether to extract images and return them through the `image_documents` output.
- **image_output_dir** (<code>str | Path | None</code>) – Persistent root directory for extracted image files. Each `run()` stores its images
in a unique subdirectory of this directory. Required when `extract_images` is `True`.

**Raises:**

- <code>ValueError</code> – If image extraction is enabled without an output directory.

#### to_dict

Expand Down Expand Up @@ -94,4 +109,5 @@ Convert PDF sources into Haystack Documents.

**Returns:**

- <code>dict\[str, list\[Document\]\]</code> – Dictionary containing the converted Documents.
- <code>dict\[str, list\[Document\]\]</code> – Dictionary containing the converted text Documents and image Documents. Each image Document has the
persistent extracted image path in its `file_path` metadata field.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ slug: "/integrations-opendataloader-pdf"
OpenDataLoader PDF converter component.

The component accepts PDF file paths and Haystack ByteStream objects, runs OpenDataLoader PDF extraction, and
returns Haystack Document objects.
returns Haystack Document objects. It can also extract images to a persistent directory and return one image
Document per extracted file.

Java 11 or newer must be installed and available on PATH.

Expand All @@ -22,11 +23,15 @@ Java 11 or newer must be installed and available on PATH.
```python
from haystack_integrations.components.converters.opendataloader_pdf import OpenDataLoaderConverter

converter = OpenDataLoaderConverter(output_format="markdown")
converter = OpenDataLoaderConverter(
output_format="markdown", extract_images=True, image_output_dir="extracted_images"
)
result = converter.run(sources=["report.pdf"], meta={"source": "annual-report"})

documents = result["documents"]
image_documents = result["image_documents"]
print(documents[0].content)
print(documents[0].meta["file_path"])
```

#### __init__
Expand All @@ -35,7 +40,9 @@ print(documents[0].content)
__init__(
*,
output_format: OutputFormat = "markdown",
convert_kwargs: dict[str, Any] | None = None
convert_kwargs: dict[str, Any] | None = None,
extract_images: bool = False,
image_output_dir: str | Path | None = None
) -> None
```

Expand All @@ -46,6 +53,14 @@ Initialize the OpenDataLoader converter.
- **output_format** (<code>OutputFormat</code>) – Format OpenDataLoader should produce.
- **convert_kwargs** (<code>dict\[str, Any\] | None</code>) – Additional arguments passed to `opendataloader_pdf.convert`. See the
[OpenDataLoader PDF Python options](https://opendataloader.org/docs/quick-start-python#convert-options).
The `image_output` and `image_dir` arguments are managed by this component; supplied values are ignored.
- **extract_images** (<code>bool</code>) – Whether to extract images and return them through the `image_documents` output.
- **image_output_dir** (<code>str | Path | None</code>) – Persistent root directory for extracted image files. Each `run()` stores its images
in a unique subdirectory of this directory. Required when `extract_images` is `True`.

**Raises:**

- <code>ValueError</code> – If image extraction is enabled without an output directory.

#### to_dict

Expand Down Expand Up @@ -94,4 +109,5 @@ Convert PDF sources into Haystack Documents.

**Returns:**

- <code>dict\[str, list\[Document\]\]</code> – Dictionary containing the converted Documents.
- <code>dict\[str, list\[Document\]\]</code> – Dictionary containing the converted text Documents and image Documents. Each image Document has the
persistent extracted image path in its `file_path` metadata field.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ slug: "/integrations-opendataloader-pdf"
OpenDataLoader PDF converter component.

The component accepts PDF file paths and Haystack ByteStream objects, runs OpenDataLoader PDF extraction, and
returns Haystack Document objects.
returns Haystack Document objects. It can also extract images to a persistent directory and return one image
Document per extracted file.

Java 11 or newer must be installed and available on PATH.

Expand All @@ -22,11 +23,15 @@ Java 11 or newer must be installed and available on PATH.
```python
from haystack_integrations.components.converters.opendataloader_pdf import OpenDataLoaderConverter

converter = OpenDataLoaderConverter(output_format="markdown")
converter = OpenDataLoaderConverter(
output_format="markdown", extract_images=True, image_output_dir="extracted_images"
)
result = converter.run(sources=["report.pdf"], meta={"source": "annual-report"})

documents = result["documents"]
image_documents = result["image_documents"]
print(documents[0].content)
print(documents[0].meta["file_path"])
```

#### __init__
Expand All @@ -35,7 +40,9 @@ print(documents[0].content)
__init__(
*,
output_format: OutputFormat = "markdown",
convert_kwargs: dict[str, Any] | None = None
convert_kwargs: dict[str, Any] | None = None,
extract_images: bool = False,
image_output_dir: str | Path | None = None
) -> None
```

Expand All @@ -46,6 +53,14 @@ Initialize the OpenDataLoader converter.
- **output_format** (<code>OutputFormat</code>) – Format OpenDataLoader should produce.
- **convert_kwargs** (<code>dict\[str, Any\] | None</code>) – Additional arguments passed to `opendataloader_pdf.convert`. See the
[OpenDataLoader PDF Python options](https://opendataloader.org/docs/quick-start-python#convert-options).
The `image_output` and `image_dir` arguments are managed by this component; supplied values are ignored.
- **extract_images** (<code>bool</code>) – Whether to extract images and return them through the `image_documents` output.
- **image_output_dir** (<code>str | Path | None</code>) – Persistent root directory for extracted image files. Each `run()` stores its images
in a unique subdirectory of this directory. Required when `extract_images` is `True`.

**Raises:**

- <code>ValueError</code> – If image extraction is enabled without an output directory.

#### to_dict

Expand Down Expand Up @@ -94,4 +109,5 @@ Convert PDF sources into Haystack Documents.

**Returns:**

- <code>dict\[str, list\[Document\]\]</code> – Dictionary containing the converted Documents.
- <code>dict\[str, list\[Document\]\]</code> – Dictionary containing the converted text Documents and image Documents. Each image Document has the
persistent extracted image path in its `file_path` metadata field.
Loading