Streaming Services vs. Cable TV Cost Comparison
Streaming Services Costs
Your Streaming Subscriptions:
Other Streaming-Related Costs:
Cable TV Costs
Comparison Summary
Please fill in your costs on the previous tabs. The summary will be calculated here.
Both options have similar costs.
"; } sccComparisonOutputDiv.innerHTML = `Cost Comparison
Streaming Services
Total Monthly Cost: ${sccFormat(totalStreamingMonthlyCost)}
Total Annual Cost: ${sccFormat(totalStreamingAnnualCost)}
Cable TV
Total Monthly Cost: ${sccFormat(totalCableMonthlyCost)}
Total Annual Cost: ${sccFormat(totalCableAnnualCost)}
${comparisonText}
`;
sccDownloadPdfButtonElem.style.display = 'inline-block';
}
async function sccDownloadPDF() {
const { jsPDF } = window.jspdf;
if (typeof html2canvas === 'undefined' || typeof jsPDF === 'undefined') {
alert('Error: PDF generation libraries not loaded.'); return;
}
// Recalculate all costs to ensure fresh data for PDF
let streamingMonthlyBreakdown = [];
let totalStreamingMonthlyForPDF = 0;
const serviceRows = sccStreamingServicesListDiv.querySelectorAll('.scc-streaming-service-row');
serviceRows.forEach(row => {
const nameInput = row.querySelector('input[type="text"]');
const costInput = row.querySelector('input[type="number"]');
const name = nameInput ? nameInput.value : "Unknown Service";
const cost = (costInput && costInput.value) ? (parseFloat(costInput.value) || 0) : 0;
streamingMonthlyBreakdown.push({name: name, cost: cost});
totalStreamingMonthlyForPDF += cost;
});
const streamingInternetPDF = sccGetNum('sccStreamingInternet');
const streamingDevicesAnnualPDF = sccGetNum('sccStreamingDevicesAnnual', true); // Monthly
const streamingOtherMonthlyPDF = sccGetNum('sccStreamingOtherMonthly');
totalStreamingMonthlyForPDF += streamingInternetPDF + streamingDevicesAnnualPDF + streamingOtherMonthlyPDF;
const totalStreamingAnnualForPDF = totalStreamingMonthlyForPDF * 12;
let cableMonthlyBreakdown = [];
const cablePackagePDF = sccGetNum('sccCablePackageMonthly');
const cableAddonsPDF = sccGetNum('sccCableAddonsMonthly');
const cableInternetPDF = sccGetNum('sccCableInternetMonthly');
const cableBoxRentalPDF = sccGetNum('sccCableBoxRentalMonthly');
const cableSetupAnnualPDF = sccGetNum('sccCableSetupAnnualized', true); // Monthly
const cableOtherFeesPDF = sccGetNum('sccCableOtherFeesMonthly');
let totalCableMonthlyForPDF = cablePackagePDF + cableAddonsPDF + cableInternetPDF + cableBoxRentalPDF + cableSetupAnnualPDF + cableOtherFeesPDF;
const totalCableAnnualForPDF = totalCableMonthlyForPDF * 12;
cableMonthlyBreakdown.push({name: "Base Package", cost: cablePackagePDF});
if(cableAddonsPDF > 0) cableMonthlyBreakdown.push({name: "Add-on Packages", cost: cableAddonsPDF});
cableMonthlyBreakdown.push({name: "Internet", cost: cableInternetPDF});
cableMonthlyBreakdown.push({name: "Equipment Rental", cost: cableBoxRentalPDF});
if(cableSetupAnnualPDF > 0) cableMonthlyBreakdown.push({name: "Annualized Setup (monthly)", cost: cableSetupAnnualPDF});
if(cableOtherFeesPDF > 0) cableMonthlyBreakdown.push({name: "Other Monthly Fees", cost: cableOtherFeesPDF});
const monthlyDifferencePDF = totalStreamingMonthlyForPDF - totalCableMonthlyForPDF;
let comparisonTextPDF = "";
if (monthlyDifferencePDF < 0) comparisonTextPDF = `Streaming is ${sccFormat(Math.abs(monthlyDifferencePDF))} cheaper per month.`;
else if (monthlyDifferencePDF > 0) comparisonTextPDF = `Cable TV is ${sccFormat(monthlyDifferencePDF)} cheaper per month.`;
else comparisonTextPDF = "Both options have similar monthly costs.";
const pdfContentWrapper = document.createElement('div');
pdfContentWrapper.className = 'scc-pdf-content-wrapper';
let streamingHTML = `Streaming Services Monthly Costs:
`; streamingMonthlyBreakdown.forEach(s => streamingHTML += `${s.name}: ${sccFormat(s.cost)}
`);
streamingHTML += `Internet (Streaming): ${sccFormat(streamingInternetPDF)}
`;
streamingHTML += `Annualized Devices (monthly): ${sccFormat(streamingDevicesAnnualPDF)}
`;
if(streamingOtherMonthlyPDF > 0) streamingHTML += `Other Monthly: ${sccFormat(streamingOtherMonthlyPDF)}
`;
streamingHTML += `Total Streaming Monthly: ${sccFormat(totalStreamingMonthlyForPDF)}
`;
streamingHTML += `Total Streaming Annual: ${sccFormat(totalStreamingAnnualForPDF)}
`;
let cableHTML = `Cable TV Monthly Costs:
`; cableMonthlyBreakdown.forEach(c => cableHTML += `${c.name}: ${sccFormat(c.cost)}
`);
cableHTML += `Total Cable TV Monthly: ${sccFormat(totalCableMonthlyForPDF)}
`;
cableHTML += `Total Cable TV Annual: ${sccFormat(totalCableAnnualForPDF)}
`;
pdfContentWrapper.innerHTML = `
Streaming vs. Cable TV Cost Analysis
${streamingHTML}
${cableHTML}
Overall Comparison
${comparisonTextPDF}
Annual Difference: ${sccFormat(totalStreamingAnnualForPDF - totalCableAnnualForPDF)} (Streaming - Cable)
Report generated on: ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}
`; document.body.appendChild(pdfContentWrapper); try { const canvas = await html2canvas(pdfContentWrapper, { scale: 2, useCORS: true, backgroundColor: '#ffffff' }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgProps = pdf.getImageProperties(imgData); const ratio = Math.min((pdfWidth - 40) / imgProps.width, (pdfHeight - 40) / imgProps.height); pdf.addImage(imgData, 'PNG', (pdfWidth - imgProps.width * ratio) / 2, 20, imgProps.width * ratio, imgProps.height * ratio); pdf.save('Streaming_vs_Cable_Cost_Comparison.pdf'); } catch (error) { console.error("Error during PDF generation:", error); alert("An error occurred while generating the PDF."); } finally { document.body.removeChild(pdfContentWrapper); } }