跳到正文
DEV Community· Yan·· 2 小時前AI 評分47

In-Tab Tools:在瀏覽器分頁內將 PDF 轉成 Markdown 並移除圖片中繼資料,檔案不離開分頁

Client-side PDF Markdown and metadata stripping: files never leave the tab

AI 導讀

In-Tab Tools 在瀏覽器分頁內處理 PDF 轉 Markdown 和圖片中繼資料移除,選取的檔案不會傳送至伺服器。PDF 工具擷取現有文字層,不支援 OCR,檔案上限為 100 MB;中繼資料移除工具支援 PNG、JPEG 和 WebP,圖片上限為 60 MB。兩項工具均不使用 AI,轉換結果可能需要人工檢查。

正文

Browser based file tools can be useful without sending a document to a service. The design constraint is simple to state and easy to violate: the selected bytes should stay on the device, and the output should be produced by code running in the tab. I built In-Tab Tools around that constraint. Two examples show why “client-side” still requires careful engineering: extracting a PDF's existing text layer, and removing image metadata without damaging the encoded pixels.

PDF to Markdown starts with the text that is already there

A PDF is a page description format, not a structured document. A heading may be represented as positioned glyphs, while a table may be a collection of text runs with no explicit row or column relationships. A browser converter cannot assume that the source contains semantic tags that map neatly to Markdown.

The PDF to Markdown tool uses pdf.js to read the existing text layer. That choice defines the first boundary: this is text extraction, not optical character recognition. A scan that contains only page images has no text layer to extract. Returning an empty Markdown file would look like success while losing the entire document, so scanned PDFs are rejected instead. If a workflow needs OCR, it needs a separate OCR step and should be clear about where that processing happens.

Once text is available, layout rules can turn patterns into useful Markdown. Repeated font sizes or spacing may suggest headings. Indentation and line starts can suggest list items. Monospaced runs can be handled as code-like text. These are deterministic rules: the same extracted layout receives the same treatment, rather than a language model guessing structure from prose.

Tables are a harder case. Column positions can be inconsistent, and line wrapping can make a paragraph resemble multiple cells. A conservative converter should only emit a table when the evidence is good enough. Otherwise, retaining readable text is more honest than manufacturing a grid that implies relationships the source did not establish. This means some tables will need manual cleanup. That limitation is preferable to silently presenting a false structure as faithful conversion.

The tradeoff is predictable. Text PDFs can become a useful starting point for editing, searching, or documenting. Complex layouts, columns, footnotes, and ambiguous tables may need review. A PDF to Markdown conversion is an aid to reuse, not a claim that every page can be reconstructed perfectly.

Metadata removal is separate from image editing

An image file contains more than visible pixels. It may also carry camera details, location fields, editing history, or other metadata blocks. Removing those blocks does not require repainting the image. A browser tool can inspect the container format, identify metadata regions, and produce a cleaned file while retaining the encoded image data.

That inspection differs by format. A PNG is organized into typed chunks. A JPEG is a sequence of markers and segments. WebP uses a RIFF container with chunks. A format-aware parser walks those structures and identifies blocks by type, then can show the user which blocks it found and their byte counts before deletion. This makes the operation inspectable: the person can see the categories being removed instead of trusting an unexplained “clean” button.

After identifying metadata, the tool can copy the encoded image stream and the permitted non-metadata blocks into a new file. Keeping the image stream avoids an extra decode-and-encode cycle, so the operation does not intentionally recompress the picture. Color profiles matter too: stripping them indiscriminately can change how colors appear in software that relies on them. A careful remover keeps ICC profiles while removing the supported metadata blocks.

The phrase “metadata remover” still has limits. It can remove metadata stored in the file structure; it cannot erase information visibly encoded into pixels. A watermark, including pixel-level identifiers such as SynthID, is not an EXIF or XMP block that can be deleted by walking file chunks. Nor should a tool claim to remove formats it does not parse. This implementation supports PNG, JPEG, and WebP, not HEIC; a user with a HEIC image must export a supported format first. The remover has a 60 MB input limit.

What local processing changes

Running these steps in the tab keeps the file transfer out of the tool's processing path. There is no account and no server request carrying the selected document for conversion. That reduces one class of exposure, but it does not make every surrounding risk disappear. A user still needs to consider the browser, device, extensions, and where they save the finished file. “Local” describes the processing boundary, not a guarantee about the entire computer.

Local processing also has practical constraints. Large documents consume device memory and can take longer on older hardware. Browser file APIs and format parsers need careful input handling. A tool should state limits per operation instead of implying that every file size and format is supported. The PDF converter supports files up to 100 MB; the image tools have their own limits, and the metadata remover supports images up to 60 MB.

For a text PDF, a sensible procedure is to check that the document has selectable text, convert it, then compare headings and a few representative pages against the source. For an image, inspect the listed metadata blocks, remove only what is appropriate for the use case, and open the output in the software where it will be used. A cleaned image may preserve its visual encoding while still losing metadata another workflow depended on.

These tools do not use AI or a language model to produce the output. That makes the results easier to reason about: extraction follows the document's text layer and layout rules; metadata removal follows the file's container structure. It also means neither can infer missing text, resolve ambiguous layout perfectly, or remove hidden information embedded in pixels. A useful privacy tool should make those boundaries visible, so users can decide when the browser is enough and when another, more specialized step is needed.

來源:DEV Community · dev.to