import React, { useState, useRef, useEffect, useCallback } from 'react'; import { Upload, FileText, Image, FileSpreadsheet, File, Download, Merge, Scissors, RotateCw, Lock, Unlock, FileDown, ChevronRight, X, Loader2, Smartphone, Zap, Shield, Check, Star, Menu, ArrowRight, Globe, FileImage, FileCode, FileArchive, Music, Video, BookOpen, Palette, Type, Grid3x3, Layers, Eye, EyeOff, AlignLeft, Code, FileJson, FileX, Hash, Binary, ChevronDown, MessageCircle, HelpCircle, Users, Lightbulb } from 'lucide-react'; const ConvertMyPDFNow = () => { const [selectedTool, setSelectedTool] = useState(null); const [files, setFiles] = useState([]); const [processing, setProcessing] = useState(false); const [dragActive, setDragActive] = useState(false); const [convertedFiles, setConvertedFiles] = useState([]); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); const [activeDropdown, setActiveDropdown] = useState(null); const [forumMinimized, setForumMinimized] = useState(false); const fileInputRef = useRef(null); const dropdownTimeoutRef = useRef(null); // SEO-optimized tool configurations with URL slugs const tools = [ // PDF Conversions { id: 'pdf-to-word', slug: 'pdf-to-word-converter', name: 'PDF to Word', from: 'PDF', to: 'DOCX', icon: FileText, accept: '.pdf', outputMime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }, { id: 'pdf-to-excel', slug: 'pdf-to-excel-converter', name: 'PDF to Excel', from: 'PDF', to: 'XLSX', icon: FileSpreadsheet, accept: '.pdf', outputMime: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }, { id: 'pdf-to-ppt', slug: 'pdf-to-powerpoint-converter', name: 'PDF to PowerPoint', from: 'PDF', to: 'PPTX', icon: FileImage, accept: '.pdf', outputMime: 'application/vnd.openxmlformats-officedocument.presentationml.presentation' }, { id: 'pdf-to-jpg', slug: 'pdf-to-jpg-converter', name: 'PDF to JPG', from: 'PDF', to: 'JPG', icon: Image, accept: '.pdf', outputMime: 'image/jpeg' }, { id: 'pdf-to-png', slug: 'pdf-to-png-converter', name: 'PDF to PNG', from: 'PDF', to: 'PNG', icon: Image, accept: '.pdf', outputMime: 'image/png' }, { id: 'pdf-to-txt', slug: 'pdf-to-text-converter', name: 'PDF to Text', from: 'PDF', to: 'TXT', icon: Type, accept: '.pdf', outputMime: 'text/plain' }, { id: 'pdf-to-html', slug: 'pdf-to-html-converter', name: 'PDF to HTML', from: 'PDF', to: 'HTML', icon: Code, accept: '.pdf', outputMime: 'text/html' }, // To PDF Conversions { id: 'word-to-pdf', slug: 'word-to-pdf-converter', name: 'Word to PDF', from: 'DOCX', to: 'PDF', icon: FileText, accept: '.doc,.docx', outputMime: 'application/pdf' }, { id: 'excel-to-pdf', slug: 'excel-to-pdf-converter', name: 'Excel to PDF', from: 'XLSX', to: 'PDF', icon: FileSpreadsheet, accept: '.xls,.xlsx', outputMime: 'application/pdf' }, { id: 'ppt-to-pdf', slug: 'powerpoint-to-pdf-converter', name: 'PowerPoint to PDF', from: 'PPTX', to: 'PDF', icon: FileImage, accept: '.ppt,.pptx', outputMime: 'application/pdf' }, { id: 'jpg-to-pdf', slug: 'jpg-to-pdf-converter', name: 'JPG to PDF', from: 'JPG', to: 'PDF', icon: Image, accept: '.jpg,.jpeg', outputMime: 'application/pdf' }, { id: 'png-to-pdf', slug: 'png-to-pdf-converter', name: 'PNG to PDF', from: 'PNG', to: 'PDF', icon: Image, accept: '.png', outputMime: 'application/pdf' }, { id: 'txt-to-pdf', slug: 'text-to-pdf-converter', name: 'Text to PDF', from: 'TXT', to: 'PDF', icon: Type, accept: '.txt', outputMime: 'application/pdf' }, { id: 'html-to-pdf', slug: 'html-to-pdf-converter', name: 'HTML to PDF', from: 'HTML', to: 'PDF', icon: Code, accept: '.html,.htm', outputMime: 'application/pdf' }, // Image Conversions { id: 'jpg-to-png', slug: 'jpg-to-png-converter', name: 'JPG to PNG', from: 'JPG', to: 'PNG', icon: Image, accept: '.jpg,.jpeg', outputMime: 'image/png' }, { id: 'png-to-jpg', slug: 'png-to-jpg-converter', name: 'PNG to JPG', from: 'PNG', to: 'JPG', icon: Image, accept: '.png', outputMime: 'image/jpeg' }, { id: 'webp-to-jpg', slug: 'webp-to-jpg-converter', name: 'WebP to JPG', from: 'WebP', to: 'JPG', icon: Image, accept: '.webp', outputMime: 'image/jpeg' }, { id: 'webp-to-png', slug: 'webp-to-png-converter', name: 'WebP to PNG', from: 'WebP', to: 'PNG', icon: Image, accept: '.webp', outputMime: 'image/png' }, { id: 'bmp-to-jpg', slug: 'bmp-to-jpg-converter', name: 'BMP to JPG', from: 'BMP', to: 'JPG', icon: Image, accept: '.bmp', outputMime: 'image/jpeg' }, { id: 'tiff-to-jpg', slug: 'tiff-to-jpg-converter', name: 'TIFF to JPG', from: 'TIFF', to: 'JPG', icon: Image, accept: '.tif,.tiff', outputMime: 'image/jpeg' }, // Document Conversions { id: 'docx-to-txt', slug: 'word-to-text-converter', name: 'Word to Text', from: 'DOCX', to: 'TXT', icon: Type, accept: '.doc,.docx', outputMime: 'text/plain' }, { id: 'rtf-to-pdf', slug: 'rtf-to-pdf-converter', name: 'RTF to PDF', from: 'RTF', to: 'PDF', icon: FileText, accept: '.rtf', outputMime: 'application/pdf' }, { id: 'odt-to-pdf', slug: 'odt-to-pdf-converter', name: 'ODT to PDF', from: 'ODT', to: 'PDF', icon: FileText, accept: '.odt', outputMime: 'application/pdf' }, { id: 'csv-to-excel', slug: 'csv-to-excel-converter', name: 'CSV to Excel', from: 'CSV', to: 'XLSX', icon: FileSpreadsheet, accept: '.csv', outputMime: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }, { id: 'json-to-csv', slug: 'json-to-csv-converter', name: 'JSON to CSV', from: 'JSON', to: 'CSV', icon: FileJson, accept: '.json', outputMime: 'text/csv' }, // PDF Tools { id: 'merge-pdf', slug: 'merge-pdf-files', name: 'Merge PDF', type: 'tool', icon: Merge, accept: '.pdf', multiple: true }, { id: 'split-pdf', slug: 'split-pdf-pages', name: 'Split PDF', type: 'tool', icon: Scissors, accept: '.pdf' }, { id: 'compress-pdf', slug: 'compress-pdf-file', name: 'Compress PDF', type: 'tool', icon: FileDown, accept: '.pdf' }, { id: 'rotate-pdf', slug: 'rotate-pdf-pages', name: 'Rotate PDF', type: 'tool', icon: RotateCw, accept: '.pdf' }, { id: 'protect-pdf', slug: 'password-protect-pdf', name: 'Protect PDF', type: 'tool', icon: Lock, accept: '.pdf' }, { id: 'unlock-pdf', slug: 'unlock-pdf-password', name: 'Unlock PDF', type: 'tool', icon: Unlock, accept: '.pdf' }, // Additional Formats { id: 'epub-to-pdf', slug: 'epub-to-pdf-converter', name: 'EPUB to PDF', from: 'EPUB', to: 'PDF', icon: BookOpen, accept: '.epub', outputMime: 'application/pdf' }, { id: 'mobi-to-pdf', slug: 'mobi-to-pdf-converter', name: 'MOBI to PDF', from: 'MOBI', to: 'PDF', icon: BookOpen, accept: '.mobi', outputMime: 'application/pdf' }, { id: 'azw3-to-pdf', slug: 'azw3-to-pdf-converter', name: 'AZW3 to PDF', from: 'AZW3', to: 'PDF', icon: BookOpen, accept: '.azw3', outputMime: 'application/pdf' }, { id: 'fb2-to-pdf', slug: 'fb2-to-pdf-converter', name: 'FB2 to PDF', from: 'FB2', to: 'PDF', icon: BookOpen, accept: '.fb2', outputMime: 'application/pdf' }, ]; // Group tools by category for better organization const toolCategories = { 'Popular Conversions': tools.slice(0, 7), 'Convert to PDF': tools.filter(t => t.to === 'PDF' && t.from !== 'PDF'), 'Convert from PDF': tools.filter(t => t.from === 'PDF'), 'Image Conversions': tools.filter(t => ['JPG', 'PNG', 'WebP', 'BMP', 'TIFF'].includes(t.from) && t.to !== 'PDF'), 'PDF Tools': tools.filter(t => t.type === 'tool'), 'Document Conversions': tools.filter(t => ['DOCX', 'RTF', 'ODT', 'CSV', 'JSON'].includes(t.from) && !['PDF'].includes(t.to)), 'E-Book Conversions': tools.filter(t => ['EPUB', 'MOBI', 'AZW3', 'FB2'].includes(t.from)) }; // Navigation categories for dropdown menus const navCategories = { 'PDF Tools': { icon: FileText, tools: tools.filter(t => t.type === 'tool') }, 'From PDF': { icon: ArrowRight, tools: tools.filter(t => t.from === 'PDF') }, 'To PDF': { icon: ArrowRight, tools: tools.filter(t => t.to === 'PDF' && t.from !== 'PDF') }, 'Images': { icon: Image, tools: tools.filter(t => ['JPG', 'PNG', 'WebP', 'BMP', 'TIFF'].includes(t.from) || ['JPG', 'PNG', 'WebP'].includes(t.to)) }, 'Documents': { icon: FileText, tools: tools.filter(t => ['DOCX', 'RTF', 'ODT', 'CSV', 'JSON', 'TXT', 'HTML'].includes(t.from) || ['DOCX', 'TXT', 'HTML', 'CSV'].includes(t.to)) }, 'E-Books': { icon: BookOpen, tools: tools.filter(t => ['EPUB', 'MOBI', 'AZW3', 'FB2'].includes(t.from)) } }; // Handle dropdown hover const handleMouseEnter = (category) => { if (dropdownTimeoutRef.current) { clearTimeout(dropdownTimeoutRef.current); } setActiveDropdown(category); }; const handleMouseLeave = () => { dropdownTimeoutRef.current = setTimeout(() => { setActiveDropdown(null); }, 300); }; // Simulate file conversion (client-side) const simulateConversion = useCallback(async (file, tool) => { // Create a mock converted file const convertedContent = `This is a converted ${tool.to || 'processed'} file from ${file.name}`; const blob = new Blob([convertedContent], { type: tool.outputMime || 'application/octet-stream' }); const extension = tool.to ? `.${tool.to.toLowerCase()}` : '_processed.pdf'; const convertedFileName = file.name.replace(/\.[^/.]+$/, extension); return { blob, name: convertedFileName, size: blob.size, type: tool.outputMime || 'application/octet-stream' }; }, []); // Process files const processFiles = useCallback(async () => { if (!selectedTool || files.length === 0) return; setProcessing(true); setConvertedFiles([]); try { const results = []; for (const file of files) { // Simulate processing delay await new Promise(resolve => setTimeout(resolve, 800)); const converted = await simulateConversion(file, selectedTool); results.push(converted); // Auto-download each file const url = URL.createObjectURL(converted.blob); const link = document.createElement('a'); link.href = url; link.download = converted.name; document.body.appendChild(link); link.click(); document.body.removeChild(link); URL.revokeObjectURL(url); } setConvertedFiles(results); // Show success message setTimeout(() => { alert(`Successfully converted ${results.length} file(s)!`); setFiles([]); setConvertedFiles([]); }, 500); } catch (error) { console.error('Conversion error:', error); alert('An error occurred during conversion. Please try again.'); } finally { setProcessing(false); } }, [selectedTool, files, simulateConversion]); // Handle file drag and drop const handleDrag = useCallback((e) => { e.preventDefault(); e.stopPropagation(); if (e.type === "dragenter" || e.type === "dragover") { setDragActive(true); } else if (e.type === "dragleave") { setDragActive(false); } }, []); const handleDrop = useCallback((e) => { e.preventDefault(); e.stopPropagation(); setDragActive(false); if (e.dataTransfer.files && e.dataTransfer.files[0]) { handleFiles(e.dataTransfer.files); } }, []); const handleFiles = useCallback((fileList) => { if (!selectedTool) return; const acceptedTypes = selectedTool.accept?.split(',') || []; const newFiles = Array.from(fileList).filter(file => { const fileExtension = '.' + file.name.split('.').pop().toLowerCase(); return acceptedTypes.some(type => fileExtension === type.trim()); }); if (newFiles.length === 0) { alert(`Please select files of type: ${acceptedTypes.join(', ')}`); return; } if (selectedTool.multiple) { setFiles(prev => [...prev, ...newFiles]); } else { setFiles(newFiles.slice(0, 1)); } }, [selectedTool]); // Scroll handler for header useEffect(() => { const handleScroll = () => { const header = document.getElementById('main-header'); if (header) { if (window.scrollY > 20) { header.classList.add('shadow-md', 'bg-white'); } else { header.classList.remove('shadow-md', 'bg-white'); } } }; window.addEventListener('scroll', handleScroll); return () => window.removeEventListener('scroll', handleScroll); }, []); // Auto-refresh forum messages simulation useEffect(() => { if (!forumMinimized) { const interval = setInterval(() => { // Simulate new messages by updating timestamps const forumElement = document.querySelector('.forum-timestamps'); if (forumElement) { // This would be replaced with real-time updates in production } }, 60000); // Update every minute return () => clearInterval(interval); } }, [forumMinimized]); return (
Free Online File Converter
Convert PDF to Word, Excel, JPG, and more. Merge, compress, and edit PDFs online. No software download required. 100% free and secure.
{/* Quick stats for trust */}{selectedTool.from && selectedTool.to ? `Convert ${selectedTool.from} files to ${selectedTool.to} format` : `Process your PDF files`}
Drop your {selectedTool.accept} files here
or
Max file size: 100MB • Secure upload
{file.name}
{(file.size / 1024 / 1024).toFixed(2)} MB
Conversion Complete!
Your files have been converted and downloaded automatically.
{selectedTool.from && selectedTool.to ? ( <> Our free online {selectedTool.name} tool allows you to convert {selectedTool.from} files to {selectedTool.to} format instantly. No software installation required - works directly in your browser. All file conversions are processed securely and files are automatically deleted after processing. > ) : ( <> Use our {selectedTool.name} tool to process your PDF files quickly and securely. This tool works entirely in your browser with no file uploads to external servers, ensuring your documents remain private and secure. > )}
All file transfers are encrypted with SSL. Files are automatically deleted after processing.
Compatible with all devices - desktop, tablet, and mobile. No app download needed.
Powered by advanced algorithms for instant file conversion. No waiting, no queues.
Sarah M.
Just converted 50 PDFs in batch mode! Amazing speed 🚀
2 min ago
Tech Support
New feature: E-book conversions now live! 📚
15 min ago
Pro Tip
Hold Shift to select multiple files at once! 🎯
Pinned