Pdf to Word Converter
Looking for a reliable way to convert your PDFs to editable Word documents? Our app makes it easy and fast.
50000000) { // 50MB limit echo "Sorry, your file is too large."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // If everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["pdfFile"]["tmp_name"], $target_file)) { // LibreOffice (Heavy) - Not installed in Docker // $commandHigh = 'libreoffice --headless --infilter="writer_pdf_import" --convert-to docx --outdir '.escapeshellarg($target_dir).' '.escapeshellarg($target_file); // AbiWord (Light) - Installed in Docker // Note: running from current directory due to path issues $commandFast = 'abiword --to=docx '.escapeshellarg($target_file); // Force use of AbiWord regardless of user selection since it is the only one available $command = $commandFast; shell_exec($command); // echo $command; // Debugging $fileName = basename($_FILES["pdfFile"]["name"]); $path_parts = pathinfo($fileName); $filename_without_extension = $path_parts['filename']; $tempDocxPath = $target_dir.$filename_without_extension. '.docx'; if (file_exists($tempDocxPath)) { header('Content-Description: File Transfer'); header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); header('Content-Disposition: attachment; filename="' . basename($tempDocxPath) . '"'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($tempDocxPath)); // Clear output buffer ob_clean(); flush(); // Read the file and output its contents readfile($tempDocxPath); unlink($target_file); unlink($tempDocxPath); echo ""; exit; } else { unlink($target_file); unlink($tempDocxPath); $message = "Conversion failed. Please check if LibreOffice is correctly installed on the server."; $isError = true; } } else { // unlink($target_file); // unlink($tempDocxPath); echo "Sorry, there was an error uploading your file."; } } } ?>
Looking for a reliable way to convert your PDFs to editable Word documents? Our app makes it easy and fast.
Widi Firmansyah