Skip to main content

AlcheMark AI - PDF to Markdown conversion with rich metadata and element analysis

Project description

AlcheMark AI.

AlcheMark AI Logo

AlcheMark is a lightweight PDF to Markdown, alchemical-inspired toolkit that transmutes PDF documents into structured Markdown pages—complete with rich metadata and markdown element annotations—empowering you to uncover insights page by page.

Installation

# Install from PyPI
pip install alchemark-ai

# Or install from source
git clone https://github.com/matthsena/AlcheMark-ai.git
cd AlcheMark-ai
pip install -e .

Usage

from alchemark_ai import pdf2md

# Convert PDF to markdown
results = pdf2md("path/to/document.pdf", process_images=True)

# Each result is a FormattedResult object with the structure:
# {
#   "metadata": {
#     "file_path": str,       # Path to the PDF file
#     "page": int,            # Page number
#     "page_count": int,      # Total number of pages
#     "text_length": int,     # Length of the extracted text
#     "processed_timestamp": float  # Processing timestamp
#   },
#   "elements": {
#     "tables": List[Table],  # Tables extracted from the page
#     "images": List[Image],  # Images extracted from the page
#     "titles": List[str],    # Titles/headers detected
#     "lists": List[str],     # List items detected
#     "links": List[Link]     # Links with text and URL
#   },
#   "text": str,              # Markdown text content
#   "tokens": int,            # Number of tokens in the text
#   "language": str           # Detected language
# }

# Access the markdown text of the first page
markdown_text = results[0].text

# Get metadata for the first page
page_number = results[0].metadata.page
total_pages = results[0].metadata.page_count

# Check elements detected in the page
tables_count = len(results[0].elements.tables)
images_count = len(results[0].elements.images)

Overview

AlcheMark AI provides a seamless solution for converting PDF documents into well-structured Markdown format. The tool not only extracts the text content but also analyzes and catalogs various elements like tables, images, headings, lists, and links while tracking token counts for LLM compatibility.

Key Features

  • PDF to Markdown Conversion: Transform PDF documents into clean, organized Markdown
  • Rich Metadata Extraction: Preserve document metadata including title, author, creation date
  • Element Analysis: Automatic detection and counting of markdown elements (headings, lists, links)
  • Table & Image Support: Extract and format tables and images from PDFs
  • Token Counting: Built-in token counting using tiktoken for LLM integration
  • Structured Output: Get page-by-page results with detailed metadata

Extracted Data Fields

Field Type Description
metadata.file_path str Path to the original PDF file
metadata.page int Current page number
metadata.page_count int Total number of pages in the document
metadata.text_length int Character count of the extracted text
metadata.processed_timestamp float Unix timestamp when the page was processed
elements.tables List[Table] Tables extracted from the page with their structure preserved
elements.images List[Image] Images extracted from the page with their metadata
elements.titles List[str] Headings and titles detected in the page
elements.lists List[str] List items (ordered and unordered) found in the page
elements.links List[Link] Hyperlinks with their display text and target URLs
text str The complete markdown text content of the page
tokens int Token count for the page (useful for LLM context planning)
language str Detected language of the page content

Use Cases

  • Convert research papers to markdown for easier reference
  • Transform documentation into markdown for integration with wikis
  • Prepare PDF content for processing with Large Language Models
  • Create searchable and analyzable versions of PDF libraries

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alchemark_ai-0.1.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alchemark_ai-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file alchemark_ai-0.1.0.tar.gz.

File metadata

  • Download URL: alchemark_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for alchemark_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 433dd86193d4f384fe014f4e66115e8f068029b43cd5b900625283ecde034723
MD5 657bf59b729d866a9189b8a4eae1f2df
BLAKE2b-256 1265ef936402025cc5b2060716abeb2c0b106c83fb3f03a1592b661e30029904

See more details on using hashes here.

File details

Details for the file alchemark_ai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: alchemark_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for alchemark_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fc7103d03f0f25c55bac7878e795f328c7076ab990d4bd31ef8e779758e72c98
MD5 3e8d0610b82475ef999c54f055dd44aa
BLAKE2b-256 f06f6e9007ff03cddcf850ab683f5bb7e1ad2dc0bd89a4cd9997ffcccd740768

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page