word-sys/anyconvert

File Converting Library

Python

3

58 commits

updated Sep 27, 2026

See the code

See what people are saying

SourceMessageScoreDate

Native Document Export (anyconvert) (r/linux)

In recent update on [word-sys's PDF Editor](https://github.com/word-sys/word-sys-pdf-editor) i implemented [anyconvert](https://github.com/word-sys/anyconvert) and removed LibreOffice convert system. Now we gonna use library i created just for this project. So…

4

Sep 27, 2026

README

anyconvert

Python 3.10+ License: GPL-3.0-or-later Downloads

Python document conversion engine

anyconvert converts PDF documents into DOCX, PPTX, ODT, ODP, and TXT using only the Python standard library.


Highlights

  • Dual Layout Engines:
    • Canvas Mode (--mode canvas): 1:1 pixel-accurate positioning. Renders exact coordinates, font families, embedded images, and vector artwork (native DrawingML custom geometries in DOCX, SVG paths in ODT). Ideal for flyers, forms, annotated PDFs, and presentation slides.
    • Flow Mode (--mode flow): Semantic reflowable document reconstruction. Automatically detects headings (H1–H6), bullet/numbered lists, tables, and reflowable paragraphs.
  • Comprehensive PDF Coverage:
    • Classic ASCII xref tables, xref streams (/Type /XRef), and object streams (/Type /ObjStm).
    • Standard PDF Security Revisions 2–6 (RC4 40–128 bit, AES-128, and AES-256 CBC).
    • Decompression filters (FlateDecode with PNG/TIFF predictors, LZWDecode, ASCII85Decode, ASCIIHexDecode, RunLengthDecode).
    • Full typography engine: Type 1, TrueType/OpenType SFNT tables, CFF/Type 2 CharStrings, CIDFonts, ToUnicode CMaps, Adobe Glyph List, and dynamic /Differences encodings.
    • In-memory PNG raster extraction and serializer (ISO/IEC 15948).
  • Standards-Compliant Packaging:
    • OPC (ISO/IEC 29500-2): Generates valid WordprocessingML (.docx) and PresentationML (.pptx) packages with complete [Content_Types].xml and .rels hierarchies.
    • ODF (ISO/IEC 26300): Generates compliant OpenDocument Text (.odt) and Presentation (.odp) archives with uncompressed mimetype headers at byte offset 0.

Supported Format Matrix

Target FormatExtensionFlow ModeCanvas ModeContainer Standard
Microsoft Word.docxSemantic <w:p>, <w:tbl>DrawingML <wps:wsp>, <w:framePr>ISO/IEC 29500-2 (OPC)
Microsoft PowerPoint.pptxReflowable slide textExact coordinate shapes & textISO/IEC 29500-2 (OPC)
OpenDocument Text.odtSemantic <text:p>, <table:table>Positioned <draw:frame>, <draw:path>ISO/IEC 26300 (ODF)
OpenDocument Presentation.odpSlide content boxesCoordinate <draw:frame>ISO/IEC 26300 (ODF)
Plaintext / Markdown.txtFormatted Markdown text2D character-grid layoutUTF-8 Plaintext

Known Issues

  • ODT & PPTX Export Issues:
    • PDF Original Position: If PDF itself is vertical, ODP & PPTX export will be broken due to horizontal size of slides.
    • Known Bug: Shapes or pen markups aren't supported, it will not shown on your presentation.
    • Beta Stage: Project now at v0.1.0 Beta stage, only DOCX and ODT seems to be fully function as wanted.
    • Design Flaw: Project designed to be a PDF to XXX document convert library for word-sys's PDF Editor and mainly designed for DOCX & ODT export, expecting a fully 1:1 export to PPTX & ODP is not possible, for now.

Installation

Install from PyPI:

pip install anyconvert

Or install in editable development mode:

git clone https://github.com/word-sys/anyconvert.git
cd anyconvert
pip install -e .

Command-Line Interface (CLI)

anyconvert provides a standalone command-line tool:

anyconvert [OPTIONS] INPUT_PDF

Options

FlagArgumentDescriptionDefault
-f, --formatdocx|pptx|odt|odp|txtTarget document formatdocx
-o, --outputPATHOutput destination file path{input_basename}.{format}
-m, --modeflow|canvasLayout reconstruction mode (canvas for 1:1 visual match)flow
-p, --passwordSTRINGDecryption password for encrypted PDFs""
-v, --verboseEnable diagnostic loggingFalse
--versionPrint version and exit
-h, --helpShow help message and exit

CLI Examples

1:1 Pixel-Accurate Visual Export (DOCX):

anyconvert flyer.pdf -f docx -m canvas -o flyer.docx

1:1 Pixel-Accurate Visual Export (ODT):

anyconvert document.pdf -f odt -m canvas -o document.odt

Semantic Reflowable Conversion for Editing (DOCX):

anyconvert article.pdf -f docx -m flow -o article.docx

Convert PDF Slides to PowerPoint (PPTX):

anyconvert presentation.pdf -f pptx -m canvas -o presentation.pptx

Convert Encrypted / Password-Protected PDF:

anyconvert secret.pdf -f docx -p "MyPassword123"

Python API

High-Level File Conversion (convert)

from anyconvert import convert, ConversionMode

# Accurate visual export to Word or LibreOffice Writer
convert(
    input_path="input.pdf",
    output_format="docx",
    output_path="output.docx",
    mode=ConversionMode.CANVAS,  # or "canvas"
)

# Semantic reflowable export to OpenDocument Text
convert(
    input_path="input.pdf",
    output_format="odt",
    output_path="output.odt",
    mode=ConversionMode.FLOW,  # or "flow"
)

In-Memory Byte Conversion (convert_bytes)

Ideal for web APIs, AWS Lambda, Cloud Run, and microservices:

from anyconvert import convert_bytes

pdf_bytes = open("document.pdf", "rb").read()

# Convert in-memory without touching disk
docx_bytes = convert_bytes(
    pdf_bytes=pdf_bytes,
    output_format="docx",
    mode="canvas",
)

Document Intermediate Representation (pdf_to_document_ir)

Inspect and manipulate document AST nodes before emitting:

from anyconvert import pdf_to_document_ir

doc_ir = pdf_to_document_ir("document.pdf", mode="canvas")

print(f"Total Pages: {len(doc_ir.pages)}")
print(f"Metadata: {doc_ir.metadata}")

for page in doc_ir.pages:
    print(f"Page {page.page_number} ({page.width}x{page.height} pt): {len(page.blocks)} blocks")

Architecture

[ Raw PDF Bytes / Stream ]
            │
            ▼
[ PDF Lexer & Parser ] ───► [ XRef Resolver & ObjStm Unpacker ]
                                    │
   ┌────────────────────────────────┼────────────────────────────────┐
   ▼                                ▼                                ▼
[ Decryption Engine ]    [ Decompression Filters ]        [ Typography Engine ]
(RC4 / AES-128 / AES-256) (Flate/LZW/ASCII85/PackBits)  (SFNT / CFF / Type 1 / CMap)
   │                                │                                │
   └────────────────────────────────┼────────────────────────────────┘
                                    │
                                    ▼
                    [ Content Stream Interpreter ]
                      (Graphics & Text Evaluator)
                                    │
                                    ▼
                 [ Spatial Indexing & Recursive XY-Cut ]
                                    │
                                    ▼
                      [ Semantic Feature Detectors ]
                     (Headings / Lists / Tables / Flow)
                                    │
                                    ▼
                         [ DocumentIR Builder ]
                                    │
       ┌────────────────────────────┼────────────────────────────┐
       ▼                            ▼                            ▼
[ DOCX Emitter ]             [ PPTX Emitter ]             [ ODT / ODP / TXT ]
  (DrawingML)                  (DrawingML)                  (ISO/IEC 26300)

Development & Verification

Running Tests

python3 -m pytest tests/

Static Type Checking

The codebase enforces 100% strict type safety (mypy --strict):

python3 -m mypy --strict src/ tests/

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details on our architectural principles, development setup, code of conduct, and pull request guidelines.


License

GPL-3.0-or-later. See LICENSE for details.

word-sys/anyconvert

File Converting Library

Python

3

58 commits

updated Sep 27, 2026

See the code

See what people are saying

SourceMessageScoreDate

Native Document Export (anyconvert) (r/linux)

In recent update on [word-sys's PDF Editor](https://github.com/word-sys/word-sys-pdf-editor) i implemented [anyconvert](https://github.com/word-sys/anyconvert) and removed LibreOffice convert system. Now we gonna use library i created just for this project. So…

4

Sep 27, 2026

README

anyconvert

Python 3.10+ License: GPL-3.0-or-later Downloads

Python document conversion engine

anyconvert converts PDF documents into DOCX, PPTX, ODT, ODP, and TXT using only the Python standard library.


Highlights

  • Dual Layout Engines:
    • Canvas Mode (--mode canvas): 1:1 pixel-accurate positioning. Renders exact coordinates, font families, embedded images, and vector artwork (native DrawingML custom geometries in DOCX, SVG paths in ODT). Ideal for flyers, forms, annotated PDFs, and presentation slides.
    • Flow Mode (--mode flow): Semantic reflowable document reconstruction. Automatically detects headings (H1–H6), bullet/numbered lists, tables, and reflowable paragraphs.
  • Comprehensive PDF Coverage:
    • Classic ASCII xref tables, xref streams (/Type /XRef), and object streams (/Type /ObjStm).
    • Standard PDF Security Revisions 2–6 (RC4 40–128 bit, AES-128, and AES-256 CBC).
    • Decompression filters (FlateDecode with PNG/TIFF predictors, LZWDecode, ASCII85Decode, ASCIIHexDecode, RunLengthDecode).
    • Full typography engine: Type 1, TrueType/OpenType SFNT tables, CFF/Type 2 CharStrings, CIDFonts, ToUnicode CMaps, Adobe Glyph List, and dynamic /Differences encodings.
    • In-memory PNG raster extraction and serializer (ISO/IEC 15948).
  • Standards-Compliant Packaging:
    • OPC (ISO/IEC 29500-2): Generates valid WordprocessingML (.docx) and PresentationML (.pptx) packages with complete [Content_Types].xml and .rels hierarchies.
    • ODF (ISO/IEC 26300): Generates compliant OpenDocument Text (.odt) and Presentation (.odp) archives with uncompressed mimetype headers at byte offset 0.

Supported Format Matrix

Target FormatExtensionFlow ModeCanvas ModeContainer Standard
Microsoft Word.docxSemantic <w:p>, <w:tbl>DrawingML <wps:wsp>, <w:framePr>ISO/IEC 29500-2 (OPC)
Microsoft PowerPoint.pptxReflowable slide textExact coordinate shapes & textISO/IEC 29500-2 (OPC)
OpenDocument Text.odtSemantic <text:p>, <table:table>Positioned <draw:frame>, <draw:path>ISO/IEC 26300 (ODF)
OpenDocument Presentation.odpSlide content boxesCoordinate <draw:frame>ISO/IEC 26300 (ODF)
Plaintext / Markdown.txtFormatted Markdown text2D character-grid layoutUTF-8 Plaintext

Known Issues

  • ODT & PPTX Export Issues:
    • PDF Original Position: If PDF itself is vertical, ODP & PPTX export will be broken due to horizontal size of slides.
    • Known Bug: Shapes or pen markups aren't supported, it will not shown on your presentation.
    • Beta Stage: Project now at v0.1.0 Beta stage, only DOCX and ODT seems to be fully function as wanted.
    • Design Flaw: Project designed to be a PDF to XXX document convert library for word-sys's PDF Editor and mainly designed for DOCX & ODT export, expecting a fully 1:1 export to PPTX & ODP is not possible, for now.

Installation

Install from PyPI:

pip install anyconvert

Or install in editable development mode:

git clone https://github.com/word-sys/anyconvert.git
cd anyconvert
pip install -e .

Command-Line Interface (CLI)

anyconvert provides a standalone command-line tool:

anyconvert [OPTIONS] INPUT_PDF

Options

FlagArgumentDescriptionDefault
-f, --formatdocx|pptx|odt|odp|txtTarget document formatdocx
-o, --outputPATHOutput destination file path{input_basename}.{format}
-m, --modeflow|canvasLayout reconstruction mode (canvas for 1:1 visual match)flow
-p, --passwordSTRINGDecryption password for encrypted PDFs""
-v, --verboseEnable diagnostic loggingFalse
--versionPrint version and exit
-h, --helpShow help message and exit

CLI Examples

1:1 Pixel-Accurate Visual Export (DOCX):

anyconvert flyer.pdf -f docx -m canvas -o flyer.docx

1:1 Pixel-Accurate Visual Export (ODT):

anyconvert document.pdf -f odt -m canvas -o document.odt

Semantic Reflowable Conversion for Editing (DOCX):

anyconvert article.pdf -f docx -m flow -o article.docx

Convert PDF Slides to PowerPoint (PPTX):

anyconvert presentation.pdf -f pptx -m canvas -o presentation.pptx

Convert Encrypted / Password-Protected PDF:

anyconvert secret.pdf -f docx -p "MyPassword123"

Python API

High-Level File Conversion (convert)

from anyconvert import convert, ConversionMode

# Accurate visual export to Word or LibreOffice Writer
convert(
    input_path="input.pdf",
    output_format="docx",
    output_path="output.docx",
    mode=ConversionMode.CANVAS,  # or "canvas"
)

# Semantic reflowable export to OpenDocument Text
convert(
    input_path="input.pdf",
    output_format="odt",
    output_path="output.odt",
    mode=ConversionMode.FLOW,  # or "flow"
)

In-Memory Byte Conversion (convert_bytes)

Ideal for web APIs, AWS Lambda, Cloud Run, and microservices:

from anyconvert import convert_bytes

pdf_bytes = open("document.pdf", "rb").read()

# Convert in-memory without touching disk
docx_bytes = convert_bytes(
    pdf_bytes=pdf_bytes,
    output_format="docx",
    mode="canvas",
)

Document Intermediate Representation (pdf_to_document_ir)

Inspect and manipulate document AST nodes before emitting:

from anyconvert import pdf_to_document_ir

doc_ir = pdf_to_document_ir("document.pdf", mode="canvas")

print(f"Total Pages: {len(doc_ir.pages)}")
print(f"Metadata: {doc_ir.metadata}")

for page in doc_ir.pages:
    print(f"Page {page.page_number} ({page.width}x{page.height} pt): {len(page.blocks)} blocks")

Architecture

[ Raw PDF Bytes / Stream ]
            │
            ▼
[ PDF Lexer & Parser ] ───► [ XRef Resolver & ObjStm Unpacker ]
                                    │
   ┌────────────────────────────────┼────────────────────────────────┐
   ▼                                ▼                                ▼
[ Decryption Engine ]    [ Decompression Filters ]        [ Typography Engine ]
(RC4 / AES-128 / AES-256) (Flate/LZW/ASCII85/PackBits)  (SFNT / CFF / Type 1 / CMap)
   │                                │                                │
   └────────────────────────────────┼────────────────────────────────┘
                                    │
                                    ▼
                    [ Content Stream Interpreter ]
                      (Graphics & Text Evaluator)
                                    │
                                    ▼
                 [ Spatial Indexing & Recursive XY-Cut ]
                                    │
                                    ▼
                      [ Semantic Feature Detectors ]
                     (Headings / Lists / Tables / Flow)
                                    │
                                    ▼
                         [ DocumentIR Builder ]
                                    │
       ┌────────────────────────────┼────────────────────────────┐
       ▼                            ▼                            ▼
[ DOCX Emitter ]             [ PPTX Emitter ]             [ ODT / ODP / TXT ]
  (DrawingML)                  (DrawingML)                  (ISO/IEC 26300)

Development & Verification

Running Tests

python3 -m pytest tests/

Static Type Checking

The codebase enforces 100% strict type safety (mypy --strict):

python3 -m mypy --strict src/ tests/

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details on our architectural principles, development setup, code of conduct, and pull request guidelines.


License

GPL-3.0-or-later. See LICENSE for details.

Languages

Python

100.0%