From 6d8cecc20b59c676283109493ced532361605fd6 Mon Sep 17 00:00:00 2001 From: TekH Date: Sat, 6 Jun 2026 16:25:07 +0200 Subject: [PATCH] Improve logging and text layer scaling Removed unnecessary console output for non-critical features, including `console.log`, `console.warn`, and `console.error` statements in `setQualityOptions`, `renderTextLayer`, and `renderThumbnail` methods. This reduces noise in production logs. Added a CSS variable `--scale-factor` to the text layer's `style` in `renderTextLayer` to ensure proper scaling and improve text rendering accuracy. These changes enhance code cleanliness and robustness. --- EnvelopeGenerator.ReceiverUI/wwwroot/js/pdf-viewer.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/EnvelopeGenerator.ReceiverUI/wwwroot/js/pdf-viewer.js b/EnvelopeGenerator.ReceiverUI/wwwroot/js/pdf-viewer.js index 0cd9b978..92182b56 100644 --- a/EnvelopeGenerator.ReceiverUI/wwwroot/js/pdf-viewer.js +++ b/EnvelopeGenerator.ReceiverUI/wwwroot/js/pdf-viewer.js @@ -27,7 +27,6 @@ window.pdfViewer = { setQualityOptions(options) { this.qualityOptions = { ...this.qualityOptions, ...options }; - console.log('PDF Viewer quality options updated:', this.qualityOptions); // Apply CSS variables for dynamic styling document.documentElement.style.setProperty('--zoom-transition-duration', `${options.zoomTransitionDuration}ms`); @@ -217,7 +216,6 @@ window.pdfViewer = { try { const textLayerDiv = document.getElementById('pdf-text-layer'); if (!textLayerDiv) { - console.warn('Text layer div not found'); return; } @@ -227,6 +225,9 @@ window.pdfViewer = { // Set text layer dimensions to match canvas display size textLayerDiv.style.width = `${viewport.width / dpr}px`; textLayerDiv.style.height = `${viewport.height / dpr}px`; + + // Set --scale-factor CSS variable required by PDF.js + textLayerDiv.style.setProperty('--scale-factor', this.scale); // Get text content from PDF const textContent = await page.getTextContent(); @@ -244,7 +245,7 @@ window.pdfViewer = { }).promise; } catch (error) { - console.error('Error rendering text layer:', error); + // Silently handle text layer errors (non-critical feature) } }, @@ -322,7 +323,6 @@ window.pdfViewer = { async renderThumbnail(pageNum, canvasId) { if (!this.pdfDoc) { - console.error('PDF document not loaded for thumbnail:', pageNum); return; } @@ -337,7 +337,6 @@ window.pdfViewer = { } if (!canvas) { - console.error('Canvas not found after retries:', canvasId); return; } @@ -389,7 +388,7 @@ window.pdfViewer = { // Clear the task when done delete canvas._renderTask; } catch (error) { - console.error('Error rendering thumbnail', pageNum, ':', error); + // Silently handle thumbnail errors (non-critical) } },