import subprocess
from config import LIBREOFFICE_PATH
from core.logger import log


def convert_docx_to_pdf(docx_path, output_dir):

    log("📦 Iniciando LibreOffice PDF export")

    command = [
        LIBREOFFICE_PATH,
        '--headless',
        '--convert-to',
        'pdf',
        docx_path,
        '--outdir',
        output_dir
    ]

    subprocess.run(command)

    log("✔ PDF generado")