Skip to content

feat: multi-page PDF support and real-time redaction preview#3

Draft
ambadi565 with Copilot wants to merge 2 commits into
mainfrom
copilot/future-scope-analysis
Draft

feat: multi-page PDF support and real-time redaction preview#3
ambadi565 with Copilot wants to merge 2 commits into
mainfrom
copilot/future-scope-analysis

Conversation

Copilot AI commented Feb 28, 2026

Copy link
Copy Markdown

Implements two items from the project's planned future scope: processing all pages of a PDF during OCR/detection, and eliminating canvas flicker in the review modal when toggling entity masks.

Multi-page PDF support

SecureUploader.tsx — replaces the single-page pdfDimRef with a per-page pdfDimsRef: Record<number, {width, height}> and iterates all PDF pages:

for (let pageIdx = 0; pageIdx < pageCount; pageIdx++) {
    const { imageBuffer, width, height, canvas: pageCanvas } =
        await renderPDFPageToImage(parsed.buffer, pageIdx);
    pdfDimsRef.current[pageIdx] = { width, height };
    // Use the first page canvas as the preview image shown in the review modal
    if (pageIdx === 0) imageDataUrl = pageCanvas.toDataURL();
    const pageResult = await pool.runOCR(imageBuffer, 'image/png', pageIdx);
    words.push(...pageResult.words);
}

pdfProcessor.tsredactPDF now accepts pageDimensions: Record<number, {width, height}> instead of a single imageWidth/imageHeight, scaling each entity's bounding box to its own page's coordinate space.

layer1.tsmergeWordBBoxes derives pageIndex from the matched words' bounding boxes rather than a fixed parameter, ensuring entities are attributed to the correct page.

Real-time redaction preview

ReviewModal.tsx — splits the single effect that reloaded the image on every entity toggle into two:

  • Image load (useEffect on imageDataUrl): renders image to canvas once, stores HTMLImageElement in imgRef
  • Overlay redraw (useEffect on localEntities/scale): redraws only bounding boxes over the cached image

This eliminates the visible flicker when toggling individual entity masks.

Pre-existing build fixes

The project had 8 TypeScript compilation errors. Resolved all to bring the build to a passing state: missing PIIType entries in TYPE_LABELS/TYPE_COLORS, missing message field on OCRResponse, missing canvas property in pdfjs-dist RenderParameters, unused imports, and a PSM type mismatch in the OCR worker.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: ambadi565 <229596064+ambadi565@users.noreply.github.com>
Copilot AI changed the title [WIP] Analyze future scope for project feat: multi-page PDF support and real-time redaction preview Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants