Swarmauri document-ingestion tool for downloading PDFs and returning base64-encoded content.
Project description
Swarmauri Tool Download PDF
swarmauri_tool_downloadpdf is a Swarmauri document-ingestion tool for
fetching a PDF from a URL and returning its contents as a base64-encoded
string. It is useful for agent workflows, document capture, API handoffs, and
pipelines that need PDF content in memory without writing directly to disk.
Why Use Swarmauri Tool Download PDF
- Retrieve PDFs from remote URLs inside Swarmauri workflows.
- Keep document transfer in-memory with base64 output.
- Hand off downloaded PDF content to parsers, storage layers, or APIs.
- Surface structured success or error responses from HTTP downloads.
FAQ
What does the tool return on success?
A dictionary withmessageand base64-encodedcontent.
Does it save files to disk?
No. It downloads bytes into memory and returns them encoded as base64.
What input does it expect?
The callable runtime surface currently expects a singleurlstring.
How are download failures reported?
The tool returns anerrorkey with a descriptive message.
Features
- Swarmauri
ToolBaseimplementation registered asDownloadPDFTool. - Fetches PDF bytes with
httpx. - Returns PDF content as base64 for easy transport.
- Avoids filesystem writes in the default flow.
- Supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.
Installation
uv add swarmauri_tool_downloadpdf
pip install swarmauri_tool_downloadpdf
Usage
from swarmauri_tool_downloadpdf import DownloadPDFTool
tool = DownloadPDFTool()
result = tool("https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf")
print(result.keys())
Examples
Decode the returned PDF payload
import base64
from swarmauri_tool_downloadpdf import DownloadPDFTool
tool = DownloadPDFTool()
result = tool("https://example.com/report.pdf")
if "content" in result:
pdf_bytes = base64.b64decode(result["content"])
print(len(pdf_bytes))
Send PDF content to another API
import httpx
from swarmauri_tool_downloadpdf import DownloadPDFTool
tool = DownloadPDFTool()
result = tool("https://example.com/form.pdf")
if "content" in result:
httpx.post("https://api.example.com/upload", json=result)
Use the tool in a Swarmauri collection
from swarmauri_standard.tools.ToolCollection import ToolCollection
from swarmauri_tool_downloadpdf import DownloadPDFTool
tools = ToolCollection(tools=[DownloadPDFTool()])
print(tools)
Related Packages
- swarmauri_parser_pypdf2
- swarmauri_parser_fitzpdf
- swarmauri_parser_pypdftk
- swarmauri_tool_webscraping
Swarmauri Foundations
More Documentation
Best Practices
- Validate and sanitize URLs before downloading untrusted documents.
- Guard against large PDFs if memory pressure matters in your runtime.
- Check for
errorbefore decoding returned content. - Hand base64 output directly to downstream services when possible to avoid unnecessary temporary files.
License
This project is licensed under the Apache-2.0 License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarmauri_tool_downloadpdf-0.11.0.dev1.tar.gz.
File metadata
- Download URL: swarmauri_tool_downloadpdf-0.11.0.dev1.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b9594e56b69433a8dd91275b81cd29daed0f593b82b1870cefcbf0fe3a5b5ce
|
|
| MD5 |
bb64c03edcec4d64515d1c3b1267d7c4
|
|
| BLAKE2b-256 |
dfb01fe1876f58e62842eaf611f6b2ffcb03d2d25e79f737c686399a23b4d876
|
File details
Details for the file swarmauri_tool_downloadpdf-0.11.0.dev1-py3-none-any.whl.
File metadata
- Download URL: swarmauri_tool_downloadpdf-0.11.0.dev1-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bda1628f91fae121a5af12fab37f3a909eab993fbadfd2876e4cbb3d39085edf
|
|
| MD5 |
09b963203136a9905e0693c0d200070f
|
|
| BLAKE2b-256 |
b9e7498dd82ae527a15a55ab383659e302f3183e58000dbee4af74828b1a06cf
|