Urgent.News

What's breaking now, across thousands of outlets.

Tech

The black box doesn't delete the text

Draw a black rectangle over a name in a PDF, export the file, then reopen it with pdf.js and call getTextContent() . The name comes back. Word for word, character for character. That was the first thing I ran into when I started building a redaction tool that runs entirely in the browser. A black rectangle is a drawing instruction. It sits on a layer above the page. The text object underneath…

When building a redaction tool that operates entirely in the browser, one quickly encounters the issue of black rectangles failing to remove text from a PDF. A black rectangle is merely a drawing command, sitting atop the page and not affecting the underlying text object. Most tools in this space handle this problem in one of two ways: rewriting the content stream to actually delete the text, or rendering the page to an image and discarding the text layer.

Both approaches work, but they present a problem: after the tool claims completion, it is unclear whether the text was genuinely removed or merely replaced with an image. To address this, I implemented a third approach – a manual check button that the user presses to verify the redaction results.

The character counting mechanism involves utilizing pdf.js to retrieve the text items for a page and converting the coordinates from PDF space to the viewport coordinate system. By iterating through the content items, the tool checks if the coordinates of each text item fall within the specified box dimensions. If so, the length of the text string is added to the total count of characters remaining.

The implications of this process are significant. After redaction, the tool reopens its output and counts the remaining extractable characters. In cases where the text was actually removed, the tool reports zero characters across the pages. However, if the text remains as an image, the tool reports a non-zero character count, misleading the user as to the effectiveness of the redaction. The distinction between these outcomes is crucial, as it directly impacts the user's trust and understanding of the tool's results.

To illustrate, consider a test file with three pages, where one page is marked for redaction. The export process replaces that page with an image, while the other two pages are left unchanged. Upon re-checking the output, the tool correctly identifies 210 extractable characters remaining across two pages. In contrast, if all three pages were marked for redaction, the tool reports 0 extractable characters across three pages.

For a scan file containing no text layer, the check before exporting highlights this absence, avoiding confusion with a zero character count. Similarly, a box drawn over empty whitespace is accurately identified as a "miss" by the check. However, when a box covers a line containing text, such as a fake name and SSN, the tool reports 50 characters as remaining within the marked area.

The competitor analysis revealed that several existing tools share this limitation of reporting a zero character count after redaction, even when the text remains as an image. This lack of transparency undermines the user's trust in the tool's capabilities. My approach of providing clear, actionable feedback on the character count, rather than merely stating "done," encourages users to actively engage with the results and make informed decisions about the redaction process.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Verify XLSX metadata cleanup with Python

An XLSX cleanup report can tell you which fields it changed. For a regression check, I also want to inspect the downloaded file itself.

  • Python script compares original and cleaned XLSX files
  • Inspects XML files containing metadata and properties
  • Alerts user to any unexpected modifications in workbook

How to edit video on a timeline and mix audio by tracks with osFoundry

Friday afternoon and Monday we have to deliver a two-minute product clip. The material is on the laptop, the background music is missing a stronger chorus and a softer pad, and the title tag doesn't…

  • OsFoundry combines chat, agents, files, and creative tools in one desktop app.
  • Video Editor offers multi-track timeline for editing, trimming, and adding titles.
  • Sound Editor enables recording, editing, mixing audio tracks with effects.

I Built StoreToAds: Turning Ecommerce Product Pages Into Ready-to-Use Ads

Hey everyone! I've been working on a new project for a while, and I'm finally happy to say that it's live. It's called StoreToAds. The idea actually came from a pretty simple problem.

  • StoreToAds simplifies ecommerce ad creation
  • Users input product links to generate designs
  • Supports Shopify, Etsy, WooCommerce, Wix, Squarespace, PrestaShop

The Bookshop That Only Opens When It Rains

It was raining the night I found the bookshop. Not the polite kind of rain that mists the pavement — the kind that sends everyone else hurrying home, collars up, umbrellas tilted against the wind.

  • Bookshop opens only during rain.
  • Mira remembers user choices and stories.
  • Orynli offers unique AI connection.

More from Sunday 8 November →