Download docx_utils.py from vietlethe/CV_parser: direct link, hf CLI and curl.
- Browser
- Download file 603 Bytes
-
https://huggingface.co/spaces/vietlethe/CV_parser/resolve/main/docx_utils.py
- Command line
-
hf download hf://spaces/vietlethe/CV_parser/docx_utils.py
-
curl -L -o docx_utils.py https://huggingface.co/spaces/vietlethe/CV_parser/resolve/main/docx_utils.py
603 Bytes
| import os | |
| import subprocess | |
| from logger import logger | |
| def convert_docx_to_pdf(input_path): | |
| logger.info(f"Converting DOCX file to PDF: {input_path}") | |
| output_path = input_path.replace('.docx', '.pdf') | |
| try: | |
| subprocess.run(['soffice', '--headless', '--convert-to', 'pdf', '--outdir', os.path.dirname(input_path), input_path], check=True) | |
| logger.info(f"Converted DOCX to PDF: {output_path}") | |
| return output_path | |
| except subprocess.CalledProcessError as e: | |
| logger.error(f"Error converting DOCX to PDF: {e}") | |
| raise RuntimeError(f"Conversion failed: {e}") | |