Install
openclaw skills install docx-to-pdfConvert Word documents (.docx) to PDF format while preserving embedded images, formatting, and document structure. Use when user needs to convert Word files to PDF, batch convert documents, or maintain visual fidelity when converting DOCX files with images, tables, and complex formatting.
openclaw skills install docx-to-pdfThis skill converts Word documents (.docx) to PDF format, preserving embedded images, formatting, tables, and document structure.
Use this skill when you need to:
Best for: Complex documents, highest fidelity, cross-platform Requirements: LibreOffice installed Pros: Free, handles complex formatting well, excellent image support Cons: Requires LibreOffice installation
Best for: Programmatic conversion, custom formatting Requirements: Python with specific libraries Pros: Highly customizable, no external dependencies Cons: More complex setup, may miss some formatting
Best for: Text-heavy documents, simple conversion Requirements: Pandoc installed Pros: Fast, widely available Cons: Limited image support, basic formatting
Best for: Quick conversions, good image support Requirements: Python with docx2pdf library Pros: Easy setup, good for most documents Cons: May struggle with very complex layouts
Convert document.docx to PDF
Convert all .docx files in current directory to PDF
Convert report.docx to PDF and name it monthly-report.pdf
# Install LibreOffice
sudo apt-get install libreoffice
# Or on macOS
brew install --cask libreoffice
# Or on Windows
# Download from libreoffice.org
# Install required libraries
pip install python-docx reportlab pillow
# Or use docx2pdf
pip install docx2pdf
# Install pandoc
sudo apt-get install pandoc
# Or on macOS
brew install pandoc
# Single file conversion
libreoffice --headless --convert-to pdf document.docx
# Specify output directory
libreoffice --headless --convert-to pdf --outdir ./pdfs document.docx
# Batch convert
for file in *.docx; do
libreoffice --headless --convert-to pdf "$file"
done
from docx import Document
from docx2pdf import convert
# Convert with images preserved
convert("document.docx", "output.pdf")
# Basic conversion (limited image support)
pandoc document.docx -o output.pdf
# With better formatting
pandoc document.docx -o output.pdf --pdf-engine=xelatex
# Increase LibreOffice memory (Linux)
soffice --headless -accept="socketsocket,host=localhost,port=2002;urp;" -nologo -nodefault -nofirststartwizard -nolockcheck -norestore -nocrashreport -nocrashreport -headless -invisible -convert-to pdf -nocrashreport -outdir /output /input
# Or split large document into parts before conversion
# Export with specific settings
libreoffice --headless --convert-to pdf:writer_pdf_Export --infilter="writer_pdf_Export" document.docx
import os
from docx2pdf import convert
def convert_folder(input_dir, output_dir):
os.makedirs(output_dir, exist_ok=True)
for file in os.listdir(input_dir):
if file.endswith('.docx'):
input_path = os.path.join(input_dir, file)
output_path = os.path.join(output_dir, file.replace('.docx', '.pdf'))
convert(input_path, output_path)
print(f"Converted: {file}")
convert_folder('./docs', './pdfs')
Before final conversion:
For detailed conversion options and troubleshooting: