# ZERO-WHITESPACE PDF Generator API - Usage Examples ## Overview This API generates exact PDFs with zero whitespace and supports both A3 and A4 formats. ## Features - ✅ **Zero Whitespace**: Complete elimination of unwanted spacing - ✅ **Format Options**: A3 (297mm x 420mm) and A4 (210mm x 297mm) - ✅ **Exact Output**: PDFs match HTML exactly without extra pages - ✅ **Advanced HTML Processing**: Removes all unnecessary elements - ✅ **Download Links**: Get direct download URLs for generated PDFs ## API Endpoints ### 1. Generate PDF **POST** `/generate-pdf` #### Request Body (JSON) ```json { "input": "Your HTML content here", "output": "my-property-brochure", "format": "A4", "return_download_link": true } ``` #### Parameters - `input` (required): HTML content to convert to PDF - `output` (optional): Custom filename (without extension) - `format` (optional): "A3" or "A4" (default: "A4") - `return_download_link` (optional): true/false (default: false) #### Response (Download Link) ```json { "success": true, "message": "ZERO-WHITESPACE A4 PDF generated successfully", "download_url": "https://salesforce.tech4biz.io/download/property_brochure_A4_abc123.pdf", "filename": "property_brochure_A4_abc123.pdf", "format": "A4", "file_size_mb": "2.45", "expires_at": "2024-01-15T10:30:00.000Z", "generated_at": "2024-01-08T10:30:00.000Z", "pdf_id": "abc123", "status": "download_ready", "features": ["zero_whitespace", "exact_output", "minimal_margins"] } ``` ### 2. Health Check **GET** `/health` #### Response ```json { "status": "healthy", "timestamp": "2024-01-08T10:30:00.000Z", "version": "9.0.0-zero-whitespace-a3-a4", "supported_formats": ["A3", "A4"], "features": [ "zero_white_spaces", "zero_margins", "advanced_html_preprocessing", "complete_css_reset", "no_extra_pages", "a3_a4_formats", "exact_pdf_output", "download_links", "base64_response", "infinite_timeouts", "format_validation" ] } ``` ## Usage Examples ### Example 1: Generate A4 PDF with Download Link ```bash curl -X POST http://localhost:8000/generate-pdf \ -H "Content-Type: application/json" \ -d '{ "input": "
Beautiful home for sale
", "output": "property-brochure", "format": "A4", "return_download_link": true }' ``` ### Example 2: Generate A3 PDF with Download Link ```bash curl -X POST http://localhost:8000/generate-pdf \ -H "Content-Type: application/json" \ -d '{ "input": "Spacious home with garden
", "output": "large-property", "format": "A3", "return_download_link": true }' ``` ### Example 3: JavaScript/Node.js Usage ```javascript const axios = require('axios'); async function generatePDF(htmlContent, format = 'A4') { try { const response = await axios.post('http://localhost:8000/generate-pdf', { input: htmlContent, format: format, return_download_link: true }); if (response.data.success) { console.log('PDF Generated:', response.data.download_url); return response.data.download_url; } } catch (error) { console.error('Error:', error.response?.data?.error || error.message); } } // Usage const htmlContent = '