"use client"; import React, { useState } from "react"; import Navbar from "../../components/Navbar"; import Footer from "../../components/Footer"; import Button from "../../components/Button"; import Link from "next/link"; export default function Home() { const [file, setFile] = useState(null); const [downloadUrl, setDownloadUrl] = useState(""); const [loading, setLoading] = useState(false); const handleFileChange = (event: React.ChangeEvent) => { if (event.target.files && event.target.files.length > 0) { setFile(event.target.files[0]); setDownloadUrl(""); } }; const convertToPdf = async () => { if (!file) { alert("No file selected"); return; } const formData = new FormData(); formData.append("file", file); setLoading(true); try { const response = await fetch( process.env.backend_url + "/api/libre-convert", { method: "POST", body: formData, }, ); if (!response.ok) { return new Error(`Error: ${response.statusText}`); } const blob = await response.blob(); const url = window.URL.createObjectURL(blob); setDownloadUrl(url); } catch (error) { console.error("Error while converting:", error); alert("Error while converting"); } finally { setLoading(false); } }; return (

doc-to-pdf

Input Format Output Format
docx pdf
doc pdf
odt pdf
{downloadUrl ? (
); }