World Hepatitis Day

World Hepatitis Day

Jul 28, 2019

World Hepatitis Day is observed on 28 July of every year, aims to bring the world together to raise the awareness of the global burden of viral hepatitis and bring real change.

Hepatitis B virus is a blood-borne and transmitted sexually by the virus, which is acquired by percutaneous and exposure to blood or other body fluids of an infected person.

loader

`; const remaining_content = ``; generatePDF(title, first_two_paragraphs, remaining_content); // document.getElementById('article-download').classList.add('hidden'); // document.body.classList.remove('overflow-hidden'); Swal.fire({ icon: 'success', title: 'Success!', text: 'Your form has been submitted, and the PDF is downloading. Kindly check your downloads.', confirmButtonColor: '#3085d6' }); } else { // document.getElementById('article-download').classList.add('hidden'); // document.body.classList.remove('overflow-hidden'); Swal.fire({ icon: 'error', title: 'Oops...', text: 'Something went wrong! Kindly contact at info@delveinsight.com' }); } }) .catch(error => { document.getElementById('loadingSpinner').style.display = 'none'; Swal.fire({ icon: 'error', title: 'Submission Failed', text: 'An error occurred. Please try again later.' }); console.error('Error:', error); }); } // function generatePDF() { // const element = document.getElementById('article-page'); // const opt = { // margin: [1, 1, 1, 1], // filename: 'World Hepatitis Day.pdf', // image: { type: 'jpeg', quality: 0.98 }, // html2canvas: { scale: 2, logging: true, dpi: 192, letterRendering: true }, // jsPDF: { unit: 'pt', format: 'letter', orientation: 'portrait' } // }; // html2pdf().from(element).set(opt).save(); // } function generatePDF(postTitle, firstTwoParagraphs, remainingContent) { // 1️⃣ Create HTML string dynamically const htmlContent = `

${postTitle}

${firstTwoParagraphs} ${remainingContent}
`; // 2️⃣ Create a DOM element from the HTML string const articleDownloadContainer = document.createElement('div'); articleDownloadContainer.innerHTML = htmlContent; document.body.appendChild(articleDownloadContainer); const originalElement = document.getElementById('article-download'); const clonedElement = originalElement.cloneNode(true); // ❌ Remove all images clonedElement.querySelectorAll('img').forEach(img => img.remove()); // Remove sidebar const sidebar = clonedElement.querySelector('.hidden.col-span-12.lg\\:col-span-4.lg\\:block'); if (sidebar) sidebar.remove(); // Force full-width on main clone clonedElement.style.width = '100%'; clonedElement.style.maxWidth = '100%'; clonedElement.style.margin = '0'; clonedElement.style.padding = '20px'; clonedElement.style.boxSizing = 'border-box'; clonedElement.style.backgroundColor = 'white'; // Set display to flex to allow content to fill the space clonedElement.style.display = 'flex'; clonedElement.style.flexDirection = 'column'; // 🧠 Force width on all child elements too clonedElement.querySelectorAll('*').forEach(child => { child.style.maxWidth = '100%'; child.style.boxSizing = 'border-box'; }); // Create hidden container const container = document.createElement('div'); container.style.position = 'fixed'; container.style.top = '-9999px'; container.style.left = '0'; container.style.width = '100%'; container.style.zIndex = '-1'; container.appendChild(clonedElement); document.body.appendChild(container); // Add spacer const spacer = document.createElement('div'); spacer.style.height = '60px'; clonedElement.appendChild(spacer); // PDF options const opt = { margin: [50, 40, 70, 40], filename: document.title.trim() + '.pdf', image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, useCORS: true, scrollY: 0, logging: false }, jsPDF: { unit: 'pt', format: 'letter', orientation: 'portrait' }, pagebreak: { mode: ['avoid-all', 'css', 'legacy'] } }; // Generate PDF loadHtml2Pdf(function() { html2pdf() .set(opt) .from(clonedElement) .toPdf() .get('pdf') .then(function (pdf) { const totalPages = pdf.internal.getNumberOfPages(); const pageWidth = pdf.internal.pageSize.getWidth(); const pageHeight = pdf.internal.pageSize.getHeight(); for (let i = 1; i <= totalPages; i++) { pdf.setPage(i); pdf.setFontSize(10); pdf.setTextColor(150); const footerText = "© All rights reserved Delvensight"; const textWidth = pdf.getStringUnitWidth(footerText) * pdf.internal.getFontSize() / pdf.internal.scaleFactor; const x = (pageWidth - textWidth) / 2; const y = pageHeight - 30; pdf.text(footerText, x, y); } }) .save() .then(() => { document.body.removeChild(container); document.body.removeChild(articleDownloadContainer); }); }); } function getFormData(formName) { const form = document.getElementById(formName); const formData = {}; const elements = form.elements; for (let i = 0; i < elements.length; i++) { const element = elements[i]; if (element.name && element.value) { formData[element.name] = element.value; } } return formData; } const stickyButton = document.getElementById('downloadPDFSticky'); if (stickyButton) { stickyButton.addEventListener('click', function () { document.getElementById('pdfModal').classList.remove('hidden'); }); } function loadSwal(callback) { const script = document.createElement('script'); script.src = "https://cdn.jsdelivr.net/npm/sweetalert2@11"; script.onload = callback; document.body.appendChild(script); } function loadHtml2Pdf(callback) { const script = document.createElement('script'); script.src = "https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"; script.integrity = "sha512-GsLlZN/3F2ErC5ifS5QtgpiJtWd43JWSuIgh7mbzZ8zBps+dvLusV+eNQATqgA/HdeKFVgA5v3S/cIrLF7QnIg=="; script.crossOrigin = "anonymous"; script.referrerPolicy = "no-referrer"; script.onload = callback; document.body.appendChild(script); }