Skip to main content

Single File Conversions

SwissKnife supports conversion between a wide variety of document formats using the convert command.

Word Documents to PDF

Convert Microsoft Word documents to PDF format:
python solution.py convert document.docx output.pdf
Expected Output:
Converting: /path/to/document.docx to /path/to/output.pdf
Success: Document conversion successful: /path/to/output.pdf
Info: Conversion completed in 2.34 seconds.

Markdown to PowerPoint

Transform Markdown files into PowerPoint presentations:
python solution.py convert report.md presentation.pptx
This is useful for quickly creating slide decks from documentation or meeting notes.

Text to Word Documents

Convert plain text files to formatted Word documents:
python solution.py convert thesis.txt formatted.docx

Excel to PDF

Export Excel spreadsheets as PDF files:
python solution.py convert data.xlsx summary.pdf
Perfect for creating read-only reports from data tables.

Org Mode to LaTeX

Convert Org-mode files to LaTeX format:
python solution.py convert notes.org academic.tex

Batch Document Conversion

Convert entire directories of documents at once using the batch-convert command:
python solution.py batch-convert ./docs ./output .docx .pdf
Expected Output:
Info: Found 15 files with extension .docx
Info: Converting from /path/to/docs to /path/to/output, .docx → .pdf
Converting: document1.docx → document1.pdf
Converting: document2.docx → document2.pdf
...
--------------------------------------------------
Info: Batch conversion completed - Successful: 15
Info: Failed: 0
Info: Output directory: /path/to/output

Common Batch Scenarios

Convert all Markdown files to DOCX:
python solution.py batch-convert ./markdown_docs ./word_docs .md .docx
Convert all text files to PDF:
python solution.py batch-convert ./notes ./pdfs .txt .pdf

Preserving Original Files

By default, conversions may modify the original file during processing. Use the --preserve-original flag to keep the original intact:
python solution.py convert input.docx output.pdf --preserve-original
This creates a temporary copy for conversion, ensuring your source file remains unchanged.

Supported Document Formats

SwissKnife supports conversion between these document formats:
  • PDF - Portable Document Format
  • DOCX/DOC - Microsoft Word
  • TXT - Plain text
  • MD - Markdown
  • EPUB - E-book format
  • PPTX - PowerPoint presentations
  • XLSX - Excel spreadsheets
  • HTML - Web pages
  • TEX - LaTeX documents
  • XML - Extensible Markup Language
  • BIB - BibTeX bibliography
  • JSON - JavaScript Object Notation
  • RST - reStructuredText
  • RTF - Rich Text Format
  • ODT - OpenDocument Text
  • ORG - Org-mode
  • IPYNB - Jupyter Notebooks
  • FB2 - FictionBook
  • ICML - InCopy Markup Language
  • OPML - Outline Processor Markup Language
  • TEXI - Texinfo
  • TEXTILE - Textile markup
  • TYP - Typst
  • MUSE - Muse markup

Tips for Document Conversions

LaTeX Required for PDF Output: When converting documents to PDF, SwissKnife uses LaTeX (specifically XeLaTeX) as the PDF engine. Make sure you have LaTeX installed on your system. See the Installation guide for details.
PDF as Input Not Supported: Due to technical limitations, converting FROM PDF to other formats is not currently supported. PDF can only be used as an output format.
Text Files Use Markdown Format: When converting .txt files, SwissKnife treats the content as Markdown format internally for better formatting preservation.

Performance Considerations

  • Large files (>50MB) may take several minutes to convert
  • PDF generation is slower due to LaTeX compilation
  • Batch conversions process files sequentially, not in parallel
  • Use --preserve-original when working with important source files

Common Use Cases

  1. Academic Writing: Convert Markdown notes to LaTeX or Word documents
  2. Report Generation: Transform Excel data to PDF reports
  3. Documentation: Batch convert Markdown docs to PDF for distribution
  4. Presentations: Create PowerPoint slides from Markdown outlines
  5. E-books: Convert between EPUB and other document formats

Build docs developers (and LLMs) love