579 lines
18 KiB
HTML
579 lines
18 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>PDF Download Popup Interface</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Arial', sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
min-height: 100vh;
|
|
padding: 20px;
|
|
}
|
|
|
|
.container {
|
|
max-width: 800px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
}
|
|
|
|
.header {
|
|
text-align: center;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.header h1 {
|
|
font-size: 2.5rem;
|
|
margin-bottom: 10px;
|
|
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
|
|
}
|
|
|
|
.header p {
|
|
font-size: 1.1rem;
|
|
opacity: 0.9;
|
|
}
|
|
|
|
.form-container {
|
|
background: rgba(255, 255, 255, 0.1);
|
|
backdrop-filter: blur(10px);
|
|
border-radius: 20px;
|
|
padding: 30px;
|
|
margin-bottom: 30px;
|
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
label {
|
|
display: block;
|
|
margin-bottom: 8px;
|
|
font-weight: bold;
|
|
font-size: 1.1rem;
|
|
}
|
|
|
|
textarea {
|
|
width: 100%;
|
|
min-height: 200px;
|
|
padding: 15px;
|
|
border: none;
|
|
border-radius: 10px;
|
|
background: rgba(255, 255, 255, 0.9);
|
|
color: #333;
|
|
font-size: 14px;
|
|
resize: vertical;
|
|
font-family: 'Courier New', monospace;
|
|
}
|
|
|
|
.button-group {
|
|
display: flex;
|
|
gap: 15px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.btn {
|
|
padding: 12px 25px;
|
|
border: none;
|
|
border-radius: 25px;
|
|
font-size: 1rem;
|
|
font-weight: bold;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
text-decoration: none;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.btn-primary {
|
|
background: linear-gradient(45deg, #4CAF50, #45a049);
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
|
|
}
|
|
|
|
.btn-secondary {
|
|
background: linear-gradient(45deg, #2196F3, #1976D2);
|
|
color: white;
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 5px 15px rgba(33, 150, 243, 0.4);
|
|
}
|
|
|
|
.btn:disabled {
|
|
opacity: 0.6;
|
|
cursor: not-allowed;
|
|
transform: none !important;
|
|
}
|
|
|
|
/* Popup Modal Styles */
|
|
.modal {
|
|
display: none;
|
|
position: fixed;
|
|
z-index: 1000;
|
|
left: 0;
|
|
top: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: rgba(0, 0, 0, 0.8);
|
|
backdrop-filter: blur(5px);
|
|
}
|
|
|
|
.modal-content {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
margin: 5% auto;
|
|
padding: 30px;
|
|
border-radius: 20px;
|
|
width: 90%;
|
|
max-width: 600px;
|
|
position: relative;
|
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
|
|
}
|
|
|
|
.close {
|
|
color: white;
|
|
float: right;
|
|
font-size: 28px;
|
|
font-weight: bold;
|
|
cursor: pointer;
|
|
position: absolute;
|
|
top: 15px;
|
|
right: 20px;
|
|
transition: color 0.3s ease;
|
|
}
|
|
|
|
.close:hover {
|
|
color: #ff6b6b;
|
|
}
|
|
|
|
.modal-header {
|
|
text-align: center;
|
|
margin-bottom: 25px;
|
|
}
|
|
|
|
.modal-header h2 {
|
|
font-size: 2rem;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.modal-body {
|
|
text-align: center;
|
|
}
|
|
|
|
.download-info {
|
|
background: rgba(255, 255, 255, 0.1);
|
|
border-radius: 15px;
|
|
padding: 20px;
|
|
margin: 20px 0;
|
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
}
|
|
|
|
.download-info h3 {
|
|
margin-bottom: 15px;
|
|
color: #4CAF50;
|
|
}
|
|
|
|
.download-link {
|
|
background: rgba(255, 255, 255, 0.9);
|
|
color: #333;
|
|
padding: 15px;
|
|
border-radius: 10px;
|
|
word-break: break-all;
|
|
font-family: 'Courier New', monospace;
|
|
font-size: 12px;
|
|
margin: 10px 0;
|
|
border: 2px solid #4CAF50;
|
|
}
|
|
|
|
.file-details {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
|
gap: 15px;
|
|
margin: 20px 0;
|
|
}
|
|
|
|
.file-detail {
|
|
background: rgba(255, 255, 255, 0.1);
|
|
padding: 15px;
|
|
border-radius: 10px;
|
|
text-align: center;
|
|
}
|
|
|
|
.file-detail .label {
|
|
font-size: 0.9rem;
|
|
opacity: 0.8;
|
|
margin-bottom: 5px;
|
|
}
|
|
|
|
.file-detail .value {
|
|
font-size: 1.1rem;
|
|
font-weight: bold;
|
|
color: #4CAF50;
|
|
}
|
|
|
|
.loading {
|
|
display: none;
|
|
text-align: center;
|
|
margin: 20px 0;
|
|
}
|
|
|
|
.spinner {
|
|
border: 4px solid rgba(255, 255, 255, 0.3);
|
|
border-radius: 50%;
|
|
border-top: 4px solid #4CAF50;
|
|
width: 40px;
|
|
height: 40px;
|
|
animation: spin 1s linear infinite;
|
|
margin: 0 auto 15px;
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% { transform: rotate(0deg); }
|
|
100% { transform: rotate(360deg); }
|
|
}
|
|
|
|
.error {
|
|
background: rgba(255, 107, 107, 0.2);
|
|
border: 1px solid #ff6b6b;
|
|
color: #ff6b6b;
|
|
padding: 15px;
|
|
border-radius: 10px;
|
|
margin: 15px 0;
|
|
text-align: center;
|
|
}
|
|
|
|
.success {
|
|
background: rgba(76, 175, 80, 0.2);
|
|
border: 1px solid #4CAF50;
|
|
color: #4CAF50;
|
|
padding: 15px;
|
|
border-radius: 10px;
|
|
margin: 15px 0;
|
|
text-align: center;
|
|
}
|
|
|
|
.copy-btn {
|
|
background: linear-gradient(45deg, #FF9800, #F57C00);
|
|
color: white;
|
|
border: none;
|
|
padding: 8px 15px;
|
|
border-radius: 20px;
|
|
cursor: pointer;
|
|
font-size: 0.9rem;
|
|
margin-left: 10px;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.copy-btn:hover {
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 3px 10px rgba(255, 152, 0, 0.4);
|
|
}
|
|
|
|
.copy-btn.copied {
|
|
background: linear-gradient(45deg, #4CAF50, #45a049);
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.container {
|
|
padding: 10px;
|
|
}
|
|
|
|
.modal-content {
|
|
margin: 10% auto;
|
|
padding: 20px;
|
|
width: 95%;
|
|
}
|
|
|
|
.button-group {
|
|
flex-direction: column;
|
|
}
|
|
|
|
.btn {
|
|
width: 100%;
|
|
justify-content: center;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="header">
|
|
<h1>🚀 PDF Generator</h1>
|
|
<p>Generate PDFs with download links - No size restrictions!</p>
|
|
</div>
|
|
|
|
<div class="form-container">
|
|
<div class="form-group">
|
|
<label for="htmlContent">📝 HTML Content:</label>
|
|
<textarea id="htmlContent" placeholder="Enter your HTML content here...">
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Sample Property Brochure</title>
|
|
<style>
|
|
body { font-family: Arial, sans-serif; margin: 20px; }
|
|
.header { background: linear-gradient(45deg, #667eea, #764ba2); color: white; padding: 20px; text-align: center; border-radius: 10px; }
|
|
.content { margin: 20px 0; }
|
|
.property-details { background: #f5f5f5; padding: 15px; border-radius: 8px; margin: 15px 0; }
|
|
.price { font-size: 24px; font-weight: bold; color: #4CAF50; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="header">
|
|
<h1>🏠 Luxury Property</h1>
|
|
<p>Beautiful 3-Bedroom Villa with Ocean View</p>
|
|
</div>
|
|
|
|
<div class="content">
|
|
<div class="property-details">
|
|
<h2>Property Details</h2>
|
|
<p><strong>Location:</strong> Dubai Marina, UAE</p>
|
|
<p><strong>Type:</strong> 3-Bedroom Villa</p>
|
|
<p><strong>Size:</strong> 2,500 sq ft</p>
|
|
<p><strong>Features:</strong> Ocean View, Private Pool, Garden</p>
|
|
</div>
|
|
|
|
<div class="price">
|
|
Price: AED 2,500,000
|
|
</div>
|
|
|
|
<p>This stunning property offers modern living with breathtaking ocean views. Perfect for families looking for luxury and comfort.</p>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
</textarea>
|
|
</div>
|
|
|
|
<div class="button-group">
|
|
<button class="btn btn-primary" onclick="generatePDF()">
|
|
🚀 Generate PDF with Download Link
|
|
</button>
|
|
<button class="btn btn-secondary" onclick="testAPI()">
|
|
🔍 Test API Connection
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="loading" class="loading">
|
|
<div class="spinner"></div>
|
|
<p>🔄 Generating PDF... Please wait</p>
|
|
</div>
|
|
|
|
<div id="error" class="error" style="display: none;"></div>
|
|
<div id="success" class="success" style="display: none;"></div>
|
|
</div>
|
|
|
|
<!-- Download Popup Modal -->
|
|
<div id="downloadModal" class="modal">
|
|
<div class="modal-content">
|
|
<span class="close" onclick="closeModal()">×</span>
|
|
|
|
<div class="modal-header">
|
|
<h2>🎉 PDF Ready for Download!</h2>
|
|
<p>Your PDF has been generated successfully</p>
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
<div class="download-info">
|
|
<h3>📄 Download Information</h3>
|
|
|
|
<div class="file-details">
|
|
<div class="file-detail">
|
|
<div class="label">File Name</div>
|
|
<div class="value" id="fileName">-</div>
|
|
</div>
|
|
<div class="file-detail">
|
|
<div class="label">File Size</div>
|
|
<div class="value" id="fileSize">-</div>
|
|
</div>
|
|
<div class="file-detail">
|
|
<div class="label">Generated</div>
|
|
<div class="value" id="generatedAt">-</div>
|
|
</div>
|
|
<div class="file-detail">
|
|
<div class="label">Expires</div>
|
|
<div class="value" id="expiresAt">-</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div style="margin: 20px 0;">
|
|
<label>🔗 Download Link:</label>
|
|
<div class="download-link" id="downloadLink">-</div>
|
|
<button class="copy-btn" onclick="copyToClipboard()">📋 Copy Link</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="button-group">
|
|
<a id="downloadBtn" class="btn btn-primary" href="#" target="_blank">
|
|
📥 Download PDF
|
|
</a>
|
|
<button class="btn btn-secondary" onclick="openInNewTab()">
|
|
🔗 Open in New Tab
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const API_BASE_URL = 'https://salesforce.tech4biz.io';
|
|
|
|
function showLoading() {
|
|
document.getElementById('loading').style.display = 'block';
|
|
document.getElementById('error').style.display = 'none';
|
|
document.getElementById('success').style.display = 'none';
|
|
}
|
|
|
|
function hideLoading() {
|
|
document.getElementById('loading').style.display = 'none';
|
|
}
|
|
|
|
function showError(message) {
|
|
hideLoading();
|
|
const errorDiv = document.getElementById('error');
|
|
errorDiv.textContent = message;
|
|
errorDiv.style.display = 'block';
|
|
}
|
|
|
|
function showSuccess(message) {
|
|
hideLoading();
|
|
const successDiv = document.getElementById('success');
|
|
successDiv.textContent = message;
|
|
successDiv.style.display = 'block';
|
|
}
|
|
|
|
async function generatePDF() {
|
|
const htmlContent = document.getElementById('htmlContent').value.trim();
|
|
|
|
if (!htmlContent) {
|
|
showError('❌ Please enter HTML content');
|
|
return;
|
|
}
|
|
|
|
showLoading();
|
|
|
|
try {
|
|
const response = await fetch(`${API_BASE_URL}/generate-pdf`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
input: htmlContent,
|
|
return_download_link: true
|
|
})
|
|
});
|
|
|
|
const result = await response.json();
|
|
|
|
if (result.success) {
|
|
showDownloadModal(result);
|
|
showSuccess('✅ PDF generated successfully!');
|
|
} else {
|
|
showError(`❌ PDF generation failed: ${result.error || result.message}`);
|
|
}
|
|
|
|
} catch (error) {
|
|
showError(`❌ Network error: ${error.message}`);
|
|
}
|
|
}
|
|
|
|
function showDownloadModal(result) {
|
|
// Populate modal with result data
|
|
document.getElementById('fileName').textContent = result.filename || 'Unknown';
|
|
document.getElementById('fileSize').textContent = result.file_size_mb ? `${result.file_size_mb} MB` : 'Unknown';
|
|
document.getElementById('generatedAt').textContent = formatDate(result.generated_at);
|
|
document.getElementById('expiresAt').textContent = formatDate(result.expires_at);
|
|
|
|
const downloadLink = result.download_url;
|
|
document.getElementById('downloadLink').textContent = downloadLink;
|
|
document.getElementById('downloadBtn').href = downloadLink;
|
|
|
|
// Show modal
|
|
document.getElementById('downloadModal').style.display = 'block';
|
|
}
|
|
|
|
function closeModal() {
|
|
document.getElementById('downloadModal').style.display = 'none';
|
|
}
|
|
|
|
function copyToClipboard() {
|
|
const downloadLink = document.getElementById('downloadLink').textContent;
|
|
navigator.clipboard.writeText(downloadLink).then(() => {
|
|
const copyBtn = document.querySelector('.copy-btn');
|
|
const originalText = copyBtn.textContent;
|
|
copyBtn.textContent = '✅ Copied!';
|
|
copyBtn.classList.add('copied');
|
|
|
|
setTimeout(() => {
|
|
copyBtn.textContent = originalText;
|
|
copyBtn.classList.remove('copied');
|
|
}, 2000);
|
|
}).catch(err => {
|
|
console.error('Failed to copy: ', err);
|
|
alert('Failed to copy link to clipboard');
|
|
});
|
|
}
|
|
|
|
function openInNewTab() {
|
|
const downloadLink = document.getElementById('downloadLink').textContent;
|
|
window.open(downloadLink, '_blank');
|
|
}
|
|
|
|
function formatDate(dateString) {
|
|
if (!dateString) return 'Unknown';
|
|
const date = new Date(dateString);
|
|
return date.toLocaleString();
|
|
}
|
|
|
|
async function testAPI() {
|
|
showLoading();
|
|
|
|
try {
|
|
const response = await fetch(`${API_BASE_URL}/health`);
|
|
const result = await response.json();
|
|
|
|
if (response.ok) {
|
|
showSuccess(`✅ API is healthy! Version: ${result.version}`);
|
|
} else {
|
|
showError('❌ API health check failed');
|
|
}
|
|
|
|
} catch (error) {
|
|
showError(`❌ API connection failed: ${error.message}`);
|
|
}
|
|
}
|
|
|
|
// Close modal when clicking outside
|
|
window.onclick = function(event) {
|
|
const modal = document.getElementById('downloadModal');
|
|
if (event.target === modal) {
|
|
closeModal();
|
|
}
|
|
}
|
|
|
|
// Close modal with Escape key
|
|
document.addEventListener('keydown', function(event) {
|
|
if (event.key === 'Escape') {
|
|
closeModal();
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|