GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - becpg/becpg-transform-markdown: Alfresco transformer that converts PDF, Office, HTML and image files to Markdown, ready for AI assistants and Chef AI in beCPG.

BranchesTags
Open more actions menu

Latest commit

 

History

85 Commits
85 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.mvn/wrapper
.mvn/wrapper
 
 
src
src
 
 
.dockerignore
.dockerignore
 
 
.gitignore
.gitignore
 
 
.maven-dockerignore
.maven-dockerignore
 
 
AGENTS.md
AGENTS.md
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CITATION.cff
CITATION.cff
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
LICENSE
LICENSE
 
 
MIGRATION.md
MIGRATION.md
 
 
NOTICE
NOTICE
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
THIRD-PARTY-LICENSES.md
THIRD-PARTY-LICENSES.md
 
 
cloudbuild.delivery.yaml
cloudbuild.delivery.yaml
 
 
cloudbuild.yaml
cloudbuild.yaml
 
 
deployment.yml
deployment.yml
 
 
mvnw
mvnw
 
 
mvnw.cmd
mvnw.cmd
 
 
pom.xml
pom.xml
 
 
release.sh
release.sh
 
 
run.sh
run.sh
 
 

Repository files navigation

beCPG Markdown Transformer for Alfresco

Java 17 Spring Boot Docker License: LGPL v3

An Alfresco T-Engine that converts PDF, Office documents, HTML, and images to Markdown using MarkItDown, pymupdf4llm with RapidOCR, and Markdown to PDF using md2pdf.


Table of Contents

  • Features
  • Supported Transformations
  • Getting Started
  • API Reference
  • Docker Deployment
  • Testing
  • Contributing
  • Security
  • License

Features

  • Bidirectional conversion: PDF/Office/HTML/Images to Markdown and Markdown to PDF
  • Dockerized: Ready-to-use Docker container with all dependencies
  • Alfresco integration: Native T-Engine for Alfresco Content Services
  • Lightweight: Uses MarkItDown and pymupdf4llm instead of heavy ML-based pipelines
  • OCR: Extract the text of images, scanned PDFs and PDFs with outlined text (printer proofs) with RapidOCR
  • Extensible: Easy to add new transformation capabilities

Overview

This project provides an Alfresco Content Services (ACS) transformer that converts a wide variety of document types into Markdown format using four lightweight Python libraries:

  • MarkItDown (MIT License) - Converts Office documents, HTML and CSV to Markdown
  • pymupdf4llm (AGPL-3.0) - Converts PDF documents and images to Markdown
  • RapidOCR (Apache-2.0) - OCR engine used by pymupdf4llm for pages without a text layer
  • md2pdf (MIT License) - Converts Markdown to PDF

The transformer runs inside a Docker container and can be integrated into Alfresco as a local transformer.


Supported Transformations

MarkItDown: Documents to Markdown

The following source formats are converted to text/markdown (or text/x-markdown):

Source MIME Type
Word (.docx) application/vnd.openxmlformats-officedocument.wordprocessingml.document
Excel (.xlsx) application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
PowerPoint (.pptx) application/vnd.openxmlformats-officedocument.presentationml.presentation
HTML text/html
XHTML application/xhtml+xml
CSV text/csv

pymupdf4llm: PDF and Images to Markdown

The following source formats are converted to text/markdown (or text/x-markdown):

Source MIME Type
PDF application/pdf
PNG image/png
JPEG image/jpeg
TIFF image/tiff
BMP image/bmp

Images, and PDF pages without a text layer (scans, text converted to outlines in printer proofs), are read by OCR with RapidOCR. PDF pages that already have a readable text layer (at least 100 characters) are not OCRed, even when they hold a logo or a picture, and are converted as before.

OCR runs on the CPU and takes about 10 to 20 seconds per page with 2 threads. Each OCR conversion uses about 1 GB of memory, so the number of PyMuPDF4LLM conversions running at the same time is limited: the next requests wait for a free slot, up to the conversion timeout, then fail with 503. With the defaults (2 conversions, 2 OCR threads each), 6 simultaneous OCR requests peak at about 1.7 GiB for the whole container, against 3.8 GiB without the limit. The property can also be set with the TRANSFORM_CORE_PYMUPDF4LLM_MAX_CONCURRENT environment variable.

Property Default Description
transform.core.pymupdf4llm.max.concurrent 2 Maximum number of PyMuPDF4LLM conversions (PDF and images) running at the same time. Allow about 1 GB of container memory per conversion
transform.core.pymupdf4llm.timeout.ms 900000 Maximum duration of one conversion, and maximum wait for a free conversion slot

OCR is configured with these environment variables:

Variable Default Description
PYMUPDF4LLM_OCR_ENABLED true Set to false to disable OCR: images and pages without a text layer then give an empty Markdown
PYMUPDF4LLM_OCR_DPI 300 Resolution at which pages are rendered for OCR. Lower it to speed up OCR, at the cost of small text
PYMUPDF4LLM_OCR_MAX_PAGES 20 Maximum number of pages OCRed per document; the next pages without a text layer are skipped. 0 removes the limit
PYMUPDF4LLM_OCR_THREADS 2 CPU threads used by each OCR conversion. Without a limit, ONNX Runtime would start one thread per CPU core of the host

md2pdf: Markdown to PDF

Source Target Description
text/markdown application/pdf Convert Markdown documents to PDF

Getting Started

Build and run the Docker Image

To create the transformer Docker image, run:

./run.sh build

This uses alfresco-base-java and installs Python 3.10 with MarkItDown, pymupdf4llm, RapidOCR and md2pdf via pip. RapidOCR ships its ONNX models, so OCR needs no download at runtime.

To run the image:

./run.sh start
  • Port 8090 is for transformations

To enable remote debugging locally, start the container with:

docker compose -f target/docker-compose.yml run -p 8099:8099 -e JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=*:8099" becpg-transform-markdown

Example of request to transform a PDF file to Markdown:

curl --location --request POST 'http://localhost:8090/transform' \
--form 'file=@"/path/to/sample.pdf"' \
--form 'sourceMimetype="application/pdf"' \
--form 'targetMimetype="text/markdown"'

Register with Alfresco

You can declare the Docker service as follow in a docker-compose.yml file:

  becpg-transform-markdown:
    image: becpg/becpg-transform-markdown:1.0.6
    ports:
      - "8090:8090"
    environment:
      - SERVER_PORT=8090
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8090/live"]
      interval: 30s
      timeout: 10s
      retries: 5

Add the following JVM property to your Alfresco instance:

-DlocalTransform.becpg-transform-markdown.url=http://localhost:8090/

This allows Alfresco to discover and use the transformer.


API Reference

Health Check

GET http://localhost:8090/live

Transform Document

POST http://localhost:8090/transform

Parameters:

Parameter Type Required Description
file File Yes Source file to transform
sourceMimetype String Yes MIME type of source file
targetMimetype String Yes Desired output MIME type

Example:

curl --location --request POST 'http://localhost:8090/transform' \
  --form 'file=@"/path/to/document.pdf"' \
  --form 'sourceMimetype="application/pdf"' \
  --form 'targetMimetype="text/markdown"'

Testing

Unit / Integration tests

Run integration tests (requires MarkItDown and pymupdf4llm installed locally):

mvn test

Run a specific test:

mvn test -Dtest=MarkitdownTransformerIT

Docker integration tests

The DockerTransformIT builds a Docker image, starts a container, and verifies every supported transformation end-to-end. It is a parameterized test covering all 24 source/target combinations from the config (12 unique transformations, each with both text/markdown and text/x-markdown targets). It also checks that the text of a synthetic food label is extracted by OCR from a PDF with outlined text, a PNG and a TIFF, and that 6 simultaneous OCR conversions all succeed while the container memory peak stays under 3.5 GiB.

mvn package -DskipTests
mvn test -Dtest=DockerTransformIT

Output files are written to src/test/resources/output/ for manual inspection.


Contributing

We welcome contributions! Please see our Contributing Guidelines and Code of Conduct for details.


Security

For security-related issues, please see our Security Policy.


License

  • This project is licensed under the GNU Lesser General Public License v3.0 - see the LICENSE file for details.
  • This project uses MarkItDown and md2pdf, licensed under the MIT License.
  • This project uses pymupdf4llm, licensed under the AGPL-3.0 License.
  • This project uses RapidOCR, licensed under the Apache-2.0 License.
  • Base image from Alfresco Docker Base Java

Acknowledgments

  • beCPG - The open source PLM solution
  • MarkItDown - Microsoft's lightweight document-to-Markdown converter
  • pymupdf4llm - PDF and image to Markdown conversion
  • RapidOCR - OCR engine
  • md2pdf - Markdown to PDF conversion
  • Alfresco - The open content services platform

Made with care by the beCPG team

About

Alfresco transformer that converts PDF, Office, HTML and image files to Markdown, ready for AI assistants and Chef AI in beCPG.

www.becpg.net/plm-software/ai/

Topics

aialfrescobecpgdockerdocument-conversionllmmarkdownragt-engine

Resources

Readme
LGPL-3.0 license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

4 stars

Watchers

4 watching

Forks

3 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.