Marker PDF to MD

approved

by L3N0X

Convert PDFs to rich Markdown, including images and ocr using the marker api

β˜… 89 stars↓ 17,505 downloadsUpdated 9mo agoMIT
View on GitHub

title-banner

Maintenance GitHub issues GitHub Release GitHub License

🌟 Introduction

Welcome to this Obsidian PDF to Markdown Converter! This plugin brings the power of advanced PDF conversion directly into your Obsidian vault. By leveraging the capabilities of Marker through a self-hosted API, the hosted solution on datalab.to, or the powerful MistralAI OCR capabilities, this plugin offers a seamless way to transform your PDFs into rich, formatted Markdown files, with support for tables, formulas and more!

[!IMPORTANT] This plugin requires a Marker API endpoint, a paid account for datalab, the python api of marker, or a free MistralAI API key to work. Without an endpoint, the application can't convert anything.

You can find the related repositories and services here:

πŸš€ Features

  • OCR Capabilities: Convert scanned PDFs to rich markdown
  • Formula Detection: Accurately captures and converts mathematical formulas
  • Table Extraction: Preserves table structures in your Markdown output
  • Image Handling: Extracts and saves images from your PDFs and includes them in the markdown
  • Batch Processing: Convert multiple PDFs at once by selecting files with Alt + Click (Note: Processing multiple files may take considerable time depending on their size and complexity)
  • Mobile Compatibility: Works on both desktop and mobile Obsidian apps
  • Flexible Output: Choose between full content extraction or specific elements (text/images)
  • Smart Folder Integration: If a folder with the PDF's name already exists, the plugin will ask if you want to integrate the new files into the existing folder

πŸ›  Why This Plugin?

  1. Superior Extraction: Utilizes the Marker project's advanced AI model or MistralAI's powerful OCR for high-quality conversions
  2. Mobile Accessibility: Unlike many converters, this works seamlessly on mobile devices (when the API is accessible)
  3. Customizable: Tailor the conversion process to your specific needs
  4. Obsidian Integration: Converts PDFs directly within your Obsidian environment

β™₯️ Support the Project

If you enjoy this plugin, feel free to star the repository and share it with others! When you want to support the development, consider buying me a coffee:

πŸ“‹ Requirements

To use this plugin, you'll need:

  1. A working Obsidian installation
  2. Access to a Marker API endpoint (self-hosted or paid service or python api) OR a free MistralAI API key

πŸ”§ Setup

  1. Install the plugin in your Obsidian vault
  2. Choose your conversion method:
    • MistralAI: Get a free API key from console.mistral.ai/api-keys
    • Datalab.to: Sign up for a paid account
    • Self-hosted Marker API: Set up Docker on a machine with a solid GPU/CPU
    • Python API: Run the Python server when needed
  3. Configure your chosen endpoint/API key in the plugin settings

Which solution should I use?

SolutionProsCons
MistralAI (recommended)Completely free, excellent results in testing, easy setup with just an API keyUploads your files to Mistral's servers (stored for at least 24h)
Hosted on datalab.toNo setup required, fast and reliable, supports the developer and is easily accessible from anywhereCosts a few dollars
Self-Hosted via DockerFull control over the conversion process, no costs for the APIRequires a powerful machine, Setup can be complex for beginners
Self-Hosted via PythonEasy to set up, no Docker requiredNot all features available

[!NOTE] MistralAI Privacy Consideration: When using the MistralAI endpoint, your PDFs will be uploaded to Mistral's servers for processing. These files are stored for at least 24 hours. If you have sensitive documents, consider using a self-hosted solution instead.

🧾 Usage

You can convert PDFs to Markdown in multiple ways:

  1. Single PDF file: Right-click on a PDF file in the file explorer and select "Convert to MD" from the context menu
  2. Multiple PDF files: Select multiple PDF files with Alt + Click and right-click to convert them all at once
  3. PDF file in editor: After opening a PDF file in the editor, click on the three dots in the top right corner and select "Convert to MD"
  4. Use the command palette: Open the command palette and search for "Convert PDF to MD" (only works if a PDF file is open)

Folder Integration: If a folder with the same name as your PDF already exists, the plugin will ask if you want to integrate the new files into this existing folder. This allows you to update or add to already converted documents.

βš™οΈ Settings

SettingDefaultDescription
API Endpoint'selfhosted'Select the API endpoint to use: 'Datalab', 'Selfhosted', 'Python API', or 'MistralAI'
Marker API Endpoint'localhost:8000'The endpoint to use for the Marker API. Only shown when 'Selfhosted' is selected as the API endpoint.
Python API Endpoint'localhost:8001'The endpoint to use for the Python API. Only shown when 'Python API' is selected as the API endpoint.
Datalab API Key-Enter your Datalab API key. Only shown when 'Datalab' is selected as the API endpoint.
MistralAI API Key-Enter your MistralAI API key. Only shown when 'MistralAI' is selected as the API endpoint.
Languages'en'The languages to use if OCR is needed, separated by commas. Only shown when 'Datalab' is selected as the API endpoint.
Force OCRfalseForce OCR (Activate this when auto-detect often fails, make sure to set the correct languages). Only shown when 'Datalab' is selected as the API endpoint.
PaginatefalseAdd horizontal rules between each page. Available for both Datalab and MistralAI endpoints.
Image Limit0Maximum number of images to extract (0 for no limit). Only shown when 'MistralAI' is selected.
Image Minimum Size0Minimum height and width of images to extract (0 for no minimum). Only shown when 'MistralAI' is selected.
Move PDF to FolderfalseMove the PDF to the folder after conversion.
Create Asset SubfoldertrueCreate an asset subfolder for images.
Extract Content'all'Select the content to extract from the PDF. Options: 'Extract everything', 'Text Only', 'Images Only'.
Write MetadatafalseWrite metadata as frontmatter in the Markdown file.
Delete Original PDFfalseDelete the original PDF after conversion.

πŸ™ Acknowledgements

This plugin wouldn't be possible without the incredible work of:

  • Marker Project: The AI model powering the conversions
  • Marker API: The API that enables self-hosting of the conversion service
  • MistralAI: For providing the free OCR capabilities

A huge thank you to these projects for their contributions to the community!

πŸ› Troubleshooting

If you encounter issues related to the plugin itself, please open an issue in this repository. For problems with the conversion process or API, please refer to the Marker and Marker API repositories.

[!NOTE] When converting multiple files at once, be patient as the process can take a significant amount of time depending on the size and complexity of your PDFs. For very large batches, consider processing them in smaller groups.

🀝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.


Happy converting! πŸ“šβž‘οΈπŸ“


Star History Chart

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.