From 06549c0d0290a2cf5109ae2e3ed9315af1ef6721 Mon Sep 17 00:00:00 2001 From: Kodjo Sossouvi Date: Tue, 30 Sep 2025 22:58:46 +0200 Subject: [PATCH] Working on pdf creation --- src/worker/tasks/common/converter_utils.py | 28 ---------------------- 1 file changed, 28 deletions(-) diff --git a/src/worker/tasks/common/converter_utils.py b/src/worker/tasks/common/converter_utils.py index 27251dd..5696575 100644 --- a/src/worker/tasks/common/converter_utils.py +++ b/src/worker/tasks/common/converter_utils.py @@ -4,8 +4,6 @@ from pathlib import Path import magic # python-magic -from tasks.common.pdf_converter import TextToPdfConverter, ImageToPdfConverter, WordToPdfConverter - class UnsupportedFileTypeError(Exception): """Exception raised when a file type is not supported.""" @@ -74,29 +72,3 @@ def compress_pdf(input_pdf: str, output_pdf: str, quality: str = "ebook") -> Non raise RuntimeError(f"Ghostscript failed with return code {result.returncode}") -def convert_to_pdf(filepath: str, output_dir: str = ".") -> str: - """ - Convert any supported file to PDF. - - Args: - filepath (str): Path to the input file. - output_dir (str): Directory to save the output PDF. - - Returns: - str: Path to the generated PDF. - - Raises: - UnsupportedFileTypeError: If the input file type is not supported. - """ - file_type = detect_file_type(filepath) - - if file_type == "text": - converter = TextToPdfConverter(filepath, output_dir=output_dir) - elif file_type == "image": - converter = ImageToPdfConverter(filepath, output_dir=output_dir) - elif file_type == "word": - converter = WordToPdfConverter(filepath, output_dir=output_dir) - else: - raise ValueError(f"Unsupported file type: {file_type}") - - return converter.convert()