CoolFace
Apppublic

vietlethe/CV_parser

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
docx_utils.py15 linesDownload Raw Back to root
1import os2import subprocess3from logger import logger4 5def convert_docx_to_pdf(input_path):6    logger.info(f"Converting DOCX file to PDF: {input_path}")7    output_path = input_path.replace('.docx', '.pdf')8    try:9        subprocess.run(['soffice', '--headless', '--convert-to', 'pdf', '--outdir', os.path.dirname(input_path), input_path], check=True)10        logger.info(f"Converted DOCX to PDF: {output_path}")11        return output_path12    except subprocess.CalledProcessError as e:13        logger.error(f"Error converting DOCX to PDF: {e}")14        raise RuntimeError(f"Conversion failed: {e}")15