A professional, production-ready PHP application for testing DomPDF HTML-to-PDF conversion with a beautiful, modern interface.
- Gradient Header Design - Professional gradient background with glass effects
- Tabbed Interface - Clean separation between HTML source and PDF preview
- Responsive Layout - Works perfectly on desktop and mobile devices
- Dark Code Editor - Syntax-highlighted HTML editor with line numbers
- Real-time Character Count - Live feedback on content length
- Paper Sizes - A4, A3, Letter, Legal support
- Orientation Control - Portrait and Landscape modes
- Custom Margins - Precise margin control in millimeters
- DPI Settings - 72, 96, 150, 300 DPI options
- Advanced Options - JavaScript, remote content, font subsetting
- Error Handling - Comprehensive error reporting and user feedback
- Loading States - Beautiful loading animations during PDF generation
- Download Management - Timestamped PDF downloads
- Memory Optimization - Efficient handling of large documents
- Security - Secure file handling and input validation
- PHP 7.4 or higher
- Composer
- Web server (Apache/Nginx)
-
Clone or Download the application files to your web server directory
-
Install Dependencies
composer install
-
Configure Web Server
- Ensure your web server can execute PHP files
- Set appropriate permissions for the application directory
- Configure virtual host if needed
-
Access the Application
- Open your browser and navigate to the application URL
- Example:
http://localhost/matdom/
- Enter HTML Content - Paste or type your HTML in the source editor
- Configure Settings - Adjust paper size, orientation, margins, and other options
- Generate PDF - Click "Generate PDF" to create the document
- Download - Use the "Download" button to save the PDF file
- Paper Size: Choose from A4, A3, Letter, or Legal
- Orientation: Select Portrait or Landscape mode
- Set custom margins in millimeters for all four sides
- Range: 0-50mm for precise control
- DPI Quality: Choose from 72 (screen) to 300 (print) DPI
- JavaScript: Enable/disable JavaScript execution
- Remote Content: Allow/block external resources
- Font Subsetting: Optimize font embedding
The application includes a comprehensive sample HTML document that demonstrates:
- Modern CSS styling with gradients and shadows
- Responsive grid layouts
- Professional typography
- Styled tables with hover effects
- Advanced CSS features
- Frontend: Modern HTML5, CSS3, and JavaScript
- Backend: PHP with DomPDF library
- Styling: Tailwind CSS for responsive design
- Icons: Heroicons for consistent iconography
matdom/
βββ index.php # Main application interface
βββ generate_pdf.php # PDF generation handler
βββ composer.json # Dependency management
βββ README.md # Documentation
βββ vendor/ # Composer dependencies
- Input validation and sanitization
- Secure file handling
- Error message sanitization
- Memory limit management
- Chroot directory restrictions
- Efficient memory usage for large documents
- Optimized CSS and JavaScript loading
- Compressed output and caching headers
- Font subsetting for smaller file sizes
The application uses Tailwind CSS classes and custom CSS for styling. You can customize:
- Color schemes and gradients
- Layout and spacing
- Typography and fonts
- Component styling
Default settings can be modified in the JavaScript section:
- Default paper size and orientation
- Margin presets
- DPI settings
- Feature toggles
The modular architecture allows for easy extensions:
- Additional paper sizes
- Custom CSS injection
- Watermark support
- Batch processing
- API integration
PDF Generation Fails
- Check PHP memory limit (recommended: 256M+)
- Verify DomPDF installation via Composer
- Ensure proper file permissions
Styling Issues
- Verify CSS syntax in HTML content
- Check for unsupported CSS properties
- Test with simplified HTML first
Download Problems
- Check browser popup blockers
- Verify server write permissions
- Test with different browsers
The application includes comprehensive error logging:
- PHP errors are logged and displayed safely
- DomPDF-specific errors are captured
- User-friendly error messages
- Chrome/Chromium: Full support
- Firefox: Full support
- Safari: Full support
- Edge: Full support
- Mobile Browsers: Responsive design support
This project is open source and available under the MIT License.
For issues, questions, or contributions, please refer to the project documentation or create an issue in the project repository.