Gigahertz to Megahertz Converter

Enter a value and click 'Convert' to see the result.

Please enter a valid positive number for Gigahertz.

'; downloadPdfButton.style.display = 'none'; return; } const mhzValue = ghzValue * 1000; // 1 Gigahertz = 1000 Megahertz resultArea.innerHTML = `

${ghzValue} GHz is equal to ${mhzValue.toFixed(4)} MHz.

`; downloadPdfButton.style.display = 'block'; // Show PDF button after calculation } function clearInputsAndResults() { const ghzInput = document.getElementById('ghzInput'); const resultArea = document.getElementById('resultArea'); const downloadPdfButton = document.getElementById('downloadPdfButton'); if (ghzInput) { ghzInput.value = ''; } if (resultArea) { resultArea.innerHTML = '

Enter a value and click \'Convert\' to see the result.

'; } if (downloadPdfButton) { downloadPdfButton.style.display = 'none'; // Hide PDF button when cleared } } function generatePdf() { // Check if jspdf is available if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined') { alert('PDF generation library not loaded. Please try again.'); console.error('jsPDF library not found.'); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF(); const ghzInput = document.getElementById('ghzInput'); const resultArea = document.getElementById('resultArea'); if (!ghzInput || !resultArea) { console.error('Cannot generate PDF: Input or result elements missing.'); return; } const ghzValue = parseFloat(ghzInput.value); const mhzValue = ghzValue * 1000; const title = "Gigahertz to Megahertz Conversion"; const inputLine = `Input: ${ghzValue} Gigahertz (GHz)`; const outputLine = `Output: ${mhzValue.toFixed(4)} Megahertz (MHz)`; // Set font and size for title doc.setFontSize(22); doc.setTextColor(0, 86, 179); // A shade of blue consistent with the tool's header doc.text(title, 105, 30, { align: 'center' }); // Set font and size for content doc.setFontSize(14); doc.setTextColor(51, 51, 51); // Dark grey for content doc.text(inputLine, 20, 60); doc.text(outputLine, 20, 70); // Add a footer or branding if desired (optional, based on spec) // doc.setFontSize(10); // doc.setTextColor(150, 150, 150); // doc.text("Generated by the GHZ to MHZ Converter", 105, doc.internal.pageSize.height - 20, { align: 'center' }); doc.save("Ghz_to_Mhz_Conversion.pdf"); }
Scroll to Top