<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[PDFFields Engineering]]></title><description><![CDATA[PDFFields Engineering]]></description><link>https://pdffields.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Dec 2026 21:42:16 GMT</lastBuildDate><atom:link href="https://pdffields.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Converting US Bank & Credit Card PDF Statements to QuickBooks .QBO in TypeScript (INTU.BID Table, OFX 1.02 & Sign Inversion)]]></title><description><![CDATA[If you have ever helped a US small business or CPA firm close year-end books in QuickBooks Online or QuickBooks Desktop, you have probably hit the same…]]></description><link>https://pdffields.hashnode.dev/converting-us-bank-credit-card-pdf-statements-to-quickbooks-qbo-in-typescript-intu-bid-table-ofx-1-02-sign-inversion</link><guid isPermaLink="true">https://pdffields.hashnode.dev/converting-us-bank-credit-card-pdf-statements-to-quickbooks-qbo-in-typescript-intu-bid-table-ofx-1-02-sign-inversion</guid><category><![CDATA[TypeScript]]></category><category><![CDATA[quickbooks]]></category><category><![CDATA[pdf]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Ezra Winslow]]></dc:creator><pubDate>Fri, 04 Dec 2026 12:59:00 GMT</pubDate><content:encoded><![CDATA[<p>If you have ever helped a US small business or CPA firm close year-end books in QuickBooks Online or QuickBooks Desktop, you have probably hit the same wall: online banking portals cap direct Web Connect (<code>.QBO</code>) downloads at 90 days (or drop <code>.QBO</code> entirely in favor of monthly PDFs), leaving prior quarters locked inside PDF statements.</p>
<p>When you try to generate a <code>.QBO</code> file yourself, QuickBooks does not fail with helpful validation messages. Instead, you hit opaque errors like <strong>Error OL-222</strong>, <strong>Error OL-332</strong>, credit card charges importing into a Checking asset register, or every purchase showing up backwards as a payment.</p>
<p>This guide breaks down the exact OFX 1.02 SGML specification QuickBooks expects, the verified <code>INTU.BID</code> codes for the 8 largest US business banks, and the TypeScript patterns we use inside <a href="https://www.pdffields.com/pdf-to-qbo">PDFFields</a> to convert single and 12-month PDF statements 100% locally in the browser via WebAssembly (with zero server uploads).</p>
<hr />
<h2>1. Checking vs. Credit Card Envelopes (<code>&lt;BANKMSGSRSV1&gt;</code> vs. <code>&lt;CREDITCARDMSGSRSV1&gt;</code>)</h2>
<p>The #1 bug in generic PDF-to-QBO scripts is writing <code>&lt;BANKMSGSRSV1&gt;</code> for every statement.</p>
<p>QuickBooks inspects the OFX message wrapper to decide which Chart of Accounts register types are eligible during import:</p>
<ul>
<li><strong>Checking &amp; Savings statements</strong> must use <code>&lt;BANKMSGSRSV1&gt;</code>, <code>&lt;STMTTRNRS&gt;</code>, <code>&lt;STMTRS&gt;</code>, and <code>&lt;BANKACCTFROM&gt;</code> with <code>&lt;BANKID&gt;</code> (9-digit ABA routing number) and <code>&lt;ACCTTYPE&gt;CHECKING</code> (or <code>SAVINGS</code>).</li>
<li><strong>Credit Card statements</strong> (Amex, Capital One Spark, Chase Sapphire/Ink, CitiBusiness, Bank of America Business Advantage) must use <code>&lt;CREDITCARDMSGSRSV1&gt;</code>, <code>&lt;CCSTMTTRNRS&gt;</code>, <code>&lt;CCSTMTRS&gt;</code>, and <code>&lt;CCACCTFROM&gt;</code> with <strong>no</strong> <code>&lt;BANKID&gt;</code> or <code>&lt;ACCTTYPE&gt;</code>.</li>
</ul>
<p>If you emit <code>&lt;BANKMSGSRSV1&gt;</code> for an Amex or Capital One Spark PDF, QuickBooks forces you to connect it to a Checking asset account instead of a Credit Card liability account.</p>
<hr />
<h2>2. Verified <code>INTU.BID</code> Institution Codes for 8 Major US Banks</h2>
<p>QuickBooks Desktop validates <code>&lt;INTU.BID&gt;</code> against its local <code>fidir.txt</code> financial institution directory before allowing a Web Connect import. Using an unknown or expired FID triggers an immediate rejection.</p>
<p>Here are the 8 US bank presets we ship and test against QuickBooks Online and QuickBooks Desktop:</p>
<table>
<thead>
<tr>
<th>US Financial Institution</th>
<th><code>INTU.BID</code></th>
<th>Routing <code>&lt;BANKID&gt;</code></th>
<th>Default OFX Type</th>
<th>Pre-Configured Local Converter</th>
</tr>
</thead>
<tbody><tr>
<td><strong>Wells Fargo</strong> (also universal QBD fallback)</td>
<td><code>3000</code></td>
<td><code>121000248</code></td>
<td><code>CHECKING</code></td>
<td><a href="https://www.pdffields.com/wells-fargo-statement-to-qbo">Wells Fargo PDF to .QBO</a></td>
</tr>
<tr>
<td><strong>Chase</strong></td>
<td><code>10898</code></td>
<td><code>021000021</code></td>
<td><code>CHECKING</code></td>
<td><a href="https://www.pdffields.com/chase-statement-to-qbo">Chase PDF to .QBO</a></td>
</tr>
<tr>
<td><strong>Bank of America</strong></td>
<td><code>5959</code></td>
<td><code>026009593</code></td>
<td><code>CHECKING</code></td>
<td><a href="https://www.pdffields.com/bank-of-america-statement-to-qbo">Bank of America PDF to .QBO</a></td>
</tr>
<tr>
<td><strong>American Express</strong></td>
<td><code>3101</code></td>
<td><code>000000000</code></td>
<td><code>CREDITCARD</code></td>
<td><a href="https://www.pdffields.com/amex-statement-to-qbo">Amex PDF to .QBO</a></td>
</tr>
<tr>
<td><strong>Capital One</strong> (Spark, Venture, 360)</td>
<td><code>1009</code></td>
<td><code>051405515</code></td>
<td><code>CREDITCARD</code></td>
<td><a href="https://www.pdffields.com/capital-one-statement-to-qbo">Capital One PDF to .QBO</a></td>
</tr>
<tr>
<td><strong>Citibank</strong> (CitiBusiness, Costco Visa)</td>
<td><code>24909</code></td>
<td><code>021000089</code></td>
<td><code>CREDITCARD</code></td>
<td><a href="https://www.pdffields.com/citibank-statement-to-qbo">Citibank PDF to .QBO</a></td>
</tr>
<tr>
<td><strong>PNC Bank</strong> (Business, Virtual Wallet)</td>
<td><code>6209</code></td>
<td><code>043000096</code></td>
<td><code>CHECKING</code></td>
<td><a href="https://www.pdffields.com/pnc-statement-to-qbo">PNC Bank PDF to .QBO</a></td>
</tr>
<tr>
<td><strong>U.S. Bank</strong> (Business Checking, Triple Cash)</td>
<td><code>6812</code></td>
<td><code>091000022</code></td>
<td><code>CHECKING</code></td>
<td><a href="https://www.pdffields.com/us-bank-statement-to-qbo">U.S. Bank PDF to .QBO</a></td>
</tr>
</tbody></table>
<blockquote>
<p><strong>Tip for older QuickBooks Desktop builds:</strong> If an older Desktop installation ships with a stale <code>fidir.txt</code> and rejects a valid bank-specific FID, switching <code>&lt;INTU.BID&gt;</code> to <code>3000</code> (Wells Fargo's universal active FID) lets the file pass validation. You still map the Web Connect import to your actual Chart of Accounts register inside Bank Feeds.</p>
</blockquote>
<hr />
<h2>3. Fixing Flipped Credit Card Charges &amp; Payments (<code>Invert signs +/-</code>)</h2>
<p>Most US credit card issuers (Amex, Capital One Spark, Chase Ink, Citibank) print <strong>new purchases as positive numbers</strong> (<code>$248.50</code>) and <strong>payments or statement credits as negative numbers</strong> (<code>-$4,210.00</code>).</p>
<p>QuickBooks <code>.QBO</code> registers typically expect the opposite sign convention on credit card feeds: negative <code>&lt;TRNAMT&gt;</code> (<code>-248.50</code>, <code>&lt;TRNTYPE&gt;DEBIT</code>) for charges and positive <code>&lt;TRNAMT&gt;</code> (<code>4210.00</code>, <code>&lt;TRNTYPE&gt;CREDIT</code>) for payments.</p>
<p>Rather than guessing silently and risking double-inversion on banks that already print signed columns, we keep sign inversion an explicit, pure transformation right before serialization:</p>
<pre><code class="language-ts">export interface BankLedgerRow {
  date: string;
  description: string;
  amount: number;
  balance?: number;
  pageIndex: number;
}

export interface BankLedgerResult {
  detected: boolean;
  transactionCount: number;
  totalDeposits: number;
  totalWithdrawals: number;
  netChange: number;
  pagesMerged: number;
  rows: BankLedgerRow[];
}

function round2(n: number): number {
  const rounded = Math.round(n * 100) / 100;
  return Object.is(rounded, -0) ? 0 : rounded;
}

export function invertBankLedgerSigns(ledger: BankLedgerResult): BankLedgerResult {
  let totalDeposits = 0;
  let totalWithdrawals = 0;

  const rows = ledger.rows.map((row) =&gt; {
    const amount = round2(-row.amount);
    if (amount &gt; 0) totalDeposits += amount;
    else if (amount &lt; 0) totalWithdrawals += Math.abs(amount);
    return { ...row, amount };
  });

  totalDeposits = round2(totalDeposits);
  totalWithdrawals = round2(totalWithdrawals);

  return {
    ...ledger,
    totalDeposits,
    totalWithdrawals,
    netChange: round2(totalDeposits - totalWithdrawals),
    rows
  };
}
</code></pre>
<p>In the UI, a user inspects the live preview totals (<code>Total Deposits</code> vs <code>Total Withdrawals</code>), ticks <strong>Invert signs (+/-)</strong> if purchases are showing up as credits, sees the totals flip immediately, and downloads a clean <code>.QBO</code> or QuickBooks CSV.</p>
<hr />
<h2>4. Preventing QuickBooks Error OL-222: SGML Sanitization &amp; Deterministic <code>FITID</code>s</h2>
<p>Two subtle bugs trigger <code>OL-222</code> or duplicate ledger rows when importing multi-month catch-up files:</p>
<ol>
<li><strong>Unescaped ampersands (<code>&amp;</code>) and angle brackets (<code>&lt;</code>, <code>&gt;</code>) inside merchant names</strong> (for example, <code>AT&amp;T *BILL PAYMENT</code> or <code>BARNES &amp; NOBLE</code>). Because OFX 1.02 is SGML-based, raw <code>&amp;</code> inside <code>&lt;NAME&gt;</code> breaks QuickBooks' parser. Always escape <code>&amp;</code> to <code>&amp;amp;</code>, strip <code>&lt;</code> and <code>&gt;</code>, collapse whitespace, and cap <code>&lt;NAME&gt;</code> at 32 characters (and <code>&lt;MEMO&gt;</code> at 255 characters).</li>
<li><strong>Non-deterministic <code>&lt;FITID&gt;</code> values</strong> (<code>Math.random()</code> or <code>Date.now()</code>). QuickBooks deduplicates overlapping Web Connect imports strictly by <code>&lt;FITID&gt;</code>. If a user re-imports a month or merges 12 monthly PDFs with statement-boundary overlaps, random <code>FITID</code>s duplicate every transaction.</li>
</ol>
<p>Using a fast FNV-1a hash of <code>(dtPosted | amount | description | occurrenceIndex)</code> keeps every <code>&lt;FITID&gt;</code> deterministic and collision-free across re-exports:</p>
<pre><code class="language-ts">function sanitizeOfxField(value: string, maxLen: number): string {
  return value
    .replace(/[\r\n\t]+/g, ' ')
    .replace(/[&lt;&gt;]/g, '')
    .replace(/&amp;/g, '&amp;amp;')
    .trim()
    .slice(0, maxLen);
}

function stableFitId(row: BankLedgerRow, index: number, dtPosted: string): string {
  const input = `${dtPosted}|${row.amount.toFixed(2)}|${row.description}|${index}`;
  let h = 2166136261;
  for (let i = 0; i &lt; input.length; i++) {
    h ^= input.charCodeAt(i);
    h = Math.imul(h, 16777619);
  }
  return `${dtPosted}${(h &gt;&gt;&gt; 0).toString(16).padStart(8, '0')}`;
}
</code></pre>
<hr />
<h2>5. Why Browser-Local Parsing Matters for Bank Statements</h2>
<p>Bank statements contain full account numbers, ACH routing trails, payroll disbursements, vendor relationships, and personal spend. Sending 12 months of client bank PDFs to a third-party cloud conversion server creates unnecessary compliance and breach exposure.</p>
<p>Using <code>pdfjs-dist</code> text-coordinate clustering and pure TypeScript OFX/XLSX builders directly inside browser RAM means <strong>zero bytes of the PDF ever leave the user's device</strong>.</p>
<p>You can test the full converter (including 12-month year-end batch merging, all 8 US bank <code>INTU.BID</code> presets, 1-click credit card sign inversion, and multi-sheet <code>.xlsx</code> export) directly on your own statement before subscribing at <strong><a href="https://www.pdffields.com/pdf-to-qbo">pdffields.com/pdf-to-qbo</a></strong>.</p>
]]></content:encoded></item><item><title><![CDATA[How to Verify PDF Redactions Cannot Be Reversed (Canvas RGBA + %%EOF Audit in TypeScript)]]></title><description><![CDATA[Every few months, a high-profile court filing, FOIA release, or vendor contract leaks confidential data because someone "redacted" a PDF by drawing opaque…]]></description><link>https://pdffields.hashnode.dev/how-to-verify-pdf-redactions-cannot-be-reversed-canvas-rgba-eof-audit-in-typescript</link><guid isPermaLink="true">https://pdffields.hashnode.dev/how-to-verify-pdf-redactions-cannot-be-reversed-canvas-rgba-eof-audit-in-typescript</guid><category><![CDATA[TypeScript]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Security]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Ezra Winslow]]></dc:creator><pubDate>Thu, 03 Dec 2026 13:44:47 GMT</pubDate><content:encoded><![CDATA[<p>Every few months, a high-profile court filing, FOIA release, or vendor contract leaks confidential data because someone "redacted" a PDF by drawing opaque black rectangles over sensitive text. To the human eye, the page looks blacked out. Inside the PDF byte stream, the original characters are still sitting intact underneath the rectangle and can be extracted with <code>Ctrl+A</code>, <code>Ctrl+C</code>, or two lines of Python.</p>
<p>When we built the local redaction auditor for <a href="https://www.pdffields.com/pdf-redaction-checker">PDFFields</a> (and our zero-permission <a href="https://addons.mozilla.org/en-US/firefox/addon/pdffields-redaction-checker/">Firefox Add-on on Mozilla Add-ons</a>), we wanted a deterministic check that runs 100% inside the user's browser without ever uploading confidential PDFs to a server.</p>
<p>Here are the four concrete failure modes that make PDF redactions reversible, and the exact browser-local TypeScript techniques that detect and eliminate all four.</p>
<h2>Failure Mode 1: Hidden Text Under Black Boxes (Canvas RGBA Luminance Audit)</h2>
<p>Most broken redactions happen in Apple Preview, Word-to-PDF exports, or generic PDF annotators where a user draws a filled black rectangle or black highlighter over text instead of removing the underlying text operators (<code>Tj</code> / <code>TJ</code>).</p>
<p>Checking only vector annotation boxes misses painted path operators (<code>re f</code>) baked directly into the page content stream. A reliable way to catch both is combining <code>pdfjs-dist</code> text item bounding boxes with actual rendered pixel luminance on an offscreen HTML5 <code>&lt;canvas&gt;</code>:</p>
<pre><code class="language-ts">export interface RedactionLeak {
  page: number;
  text: string;
  avgLuminance: number;
  bbox: { x: number; y: number; w: number; h: number };
}

export async function scanPageForDarkCoveredText(
  page: PDFPageProxy,
  pageNumber: number,
  scale = 1.5
): Promise&lt;RedactionLeak[]&gt; {
  const viewport = page.getViewport({ scale });
  const canvas = document.createElement('canvas');
  canvas.width = Math.ceil(viewport.width);
  canvas.height = Math.ceil(viewport.height);

  const ctx = canvas.getContext('2d', { willReadFrequently: true });
  if (!ctx) return [];

  await page.render({ canvasContext: ctx, viewport }).promise;
  const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
  const textContent = await page.getTextContent();
  const leaks: RedactionLeak[] = [];

  for (const rawItem of textContent.items) {
    if (!('str' in rawItem) || !rawItem.str.trim()) continue;
    const tx = pdfjsLib.Util.transform(viewport.transform, rawItem.transform);
    const x = Math.max(0, Math.floor(tx[4]));
    const h = Math.max(6, Math.ceil(Math.hypot(tx[2], tx[3])));
    const y = Math.max(0, Math.floor(tx[5] - h));
    const w = Math.max(4, Math.ceil(rawItem.width * scale));

    // Sample pixel luminance across the rendered text bounding box
    let lumSum = 0;
    let samples = 0;
    const stepX = Math.max(1, Math.floor(w / 8));
    const stepY = Math.max(1, Math.floor(h / 4));

    for (let py = y; py &lt; Math.min(canvas.height, y + h); py += stepY) {
      for (let px = x; px &lt; Math.min(canvas.width, x + w); px += stepX) {
        const idx = (py * canvas.width + px) * 4;
        const lum = 0.2126 * imageData[idx] + 0.7152 * imageData[idx + 1] + 0.0722 * imageData[idx + 2];
        lumSum += lum;
        samples++;
      }
    }

    const avgLuminance = samples &gt; 0 ? lumSum / samples : 255;
    // Standard dark ink on white paper averages &gt; 180 luminance;
    // text buried under a solid dark redaction box averages &lt; 45.
    if (samples &gt; 0 &amp;&amp; avgLuminance &lt; 45) {
      leaks.push({
        page: pageNumber,
        text: rawItem.str.trim(),
        avgLuminance: Math.round(avgLuminance),
        bbox: { x, y, w, h }
      });
    }
  }
  return leaks;
}
</code></pre>
<p>Why this threshold works so cleanly in practice: normal black text printed on a white background leaves roughly 75% to 88% white background pixels inside its bounding box, producing an average luminance well above <code>170</code>. When a solid black rectangle covers that text, almost every pixel inside the bounding box drops near <code>0</code>, pushing average luminance below <code>45</code> (and white-on-black intentional headers can be filtered cleanly by comparing against page-wide dark banner bands).</p>
<h2>Failure Mode 2: Unapplied <code>/Subtype /Redact</code> Annotations</h2>
<p>In Adobe Acrobat and several enterprise editors, marking text for redaction creates a <code>/Redact</code> annotation dictionary on the page. Until the user explicitly clicks <strong>Apply Redactions</strong>, that annotation is only a visual overlay instruction. Anyone opening the file in a different viewer, or parsing <code>page.getAnnotations()</code>, can hide or strip the annotation and read the full text underneath:</p>
<pre><code class="language-ts">const annotations = await page.getAnnotations();
const unappliedRedacts = annotations.filter(
  (annot) =&gt; annot.subtype === 'Redact' || annot.subtype === 'Square'
);
</code></pre>
<p>Flagging every <code>/Subtype /Redact</code> annotation immediately catches drafts that were saved and emailed before redactions were burned in.</p>
<h2>Failure Mode 3: Incremental Save Revisions (<code>%%EOF</code> History)</h2>
<p>ISO 32000 supports incremental updates so PDF editors can append modified objects to the end of a file instead of rewriting the entire file from scratch. Each incremental save appends a new cross-reference table and a new <code>%%EOF</code> marker.</p>
<p>If a tool saves a redacted page as an incremental update without rewriting and garbage-collecting the file, the prior unredacted stream can still exist in the earlier byte range of the <code>.pdf</code> file. Scanning the raw <code>Uint8Array</code> directly in the browser reveals multi-revision history in milliseconds:</p>
<pre><code class="language-ts">export function countIncrementalRevisions(pdfBytes: Uint8Array): number {
  const text = new TextDecoder('latin1').decode(pdfBytes);
  const matches = text.match(/%%EOF/g);
  return matches ? matches.length : 0;
}
</code></pre>
<p>A freshly rewritten clean PDF contains exactly one <code>%%EOF</code> marker. Two or more <code>%%EOF</code> markers mean the file carries appended revision history that must be scrubbed before distribution.</p>
<h2>Failure Mode 4: Hidden <code>/Info</code> and XMP Metadata Streams</h2>
<p>Even when every redacted page is clean visually, PDF files routinely carry author names, original draft titles, internal client matter numbers, software toolchains, and edit timestamps inside the classic <code>/Info</code> dictionary and the XML <code>/Metadata</code> (XMP) packet. Inspecting <code>pdfDoc.getMetadata()</code> surfaces both dictionaries immediately.</p>
<h2>The Only 100% Permanent Fix: 200 DPI Page Rasterization + Fresh Container Rebuild</h2>
<p>Trying to surgically delete individual character glyphs from a complex PDF content stream is notoriously brittle (shared font subsets, clipped Form XObjects, overlapping kerning arrays, or Form <code>/AcroForm</code> widget appearance streams can survive partial deletion).</p>
<p>The deterministic way to guarantee a redacted page cannot be reversed is to:</p>
<ol>
<li>Render the finalized page with solid opaque black redaction masks onto a 200 DPI offscreen canvas.</li>
<li>Encode the flattened pixels into a fresh image stream.</li>
<li>Build a brand-new single-revision (<code>1</code> <code>%%EOF</code>) PDF container with empty <code>/Info</code> metadata and zero <code>/Metadata</code> XMP packets.</li>
</ol>
<p>Because the output page contains only flattened raster pixels, there is literally no hidden text layer, no unapplied <code>/Redact</code> annotation, and no incremental revision history left to recover.</p>
<h2>Try It Locally (Zero Server Upload)</h2>
<p>If you want to inspect a sensitive PDF right now without uploading it to a third-party server:</p>
<ul>
<li><strong>Web Auditor &amp; One-Click 200 DPI Repair</strong>: <a href="https://www.pdffields.com/pdf-redaction-checker">PDFFields Free PDF Redaction Leak Checker</a> (runs locally in browser memory; audits dark-covered hidden text, unapplied <code>/Redact</code> annotations, <code>%%EOF</code> revision count, and hidden <code>/Info</code>/XMP metadata).</li>
<li><strong>Firefox Extension (Zero Permissions)</strong>: <a href="https://addons.mozilla.org/en-US/firefox/addon/pdffields-redaction-checker/">PDFFields Local PDF Redaction Leak Checker on Mozilla Add-ons</a>: audit local PDFs right from your Firefox toolbar with zero host permissions and zero network calls.</li>
<li><strong>Standalone Permanent Redactor</strong>: <a href="https://www.pdffields.com/redact-pdf">PDFFields Permanent PDF Redactor</a> (auto-detects SSNs, emails, US phone numbers, and account numbers locally before 200 DPI rasterization).</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Why Credit Card PDF Statements Import Backwards Into QuickBooks .QBO (And How to Emit Clean OFX 1.02 in TypeScript)]]></title><description><![CDATA[If you have ever converted an American Express, Chase Sapphire, Capital One, Bank of America, or Citibank credit card PDF statement into a QuickBooks Web…]]></description><link>https://pdffields.hashnode.dev/why-credit-card-pdf-statements-import-backwards-into-quickbooks-qbo-and-how-to-emit-clean-ofx-1-02-in-typescript</link><guid isPermaLink="true">https://pdffields.hashnode.dev/why-credit-card-pdf-statements-import-backwards-into-quickbooks-qbo-and-how-to-emit-clean-ofx-1-02-in-typescript</guid><category><![CDATA[quickbooks]]></category><category><![CDATA[pdf]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Ezra Winslow]]></dc:creator><pubDate>Wed, 02 Dec 2026 14:22:54 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0be039a65870ef3310ffc6/80efc11e-6464-4fd6-adb4-a2c4a3258c3b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you have ever converted an American Express, Chase Sapphire, Capital One, Bank of America, or Citibank credit card PDF statement into a QuickBooks Web Connect (<code>.QBO</code>) file and imported it into QuickBooks Online or QuickBooks Desktop, you have probably hit one of two frustrating failures:</p>
<ol>
<li><strong>QuickBooks tries to link your credit card file to a Checking account</strong> instead of a Credit Card liability register.</li>
<li><strong>Every purchase imports backwards as a payment</strong>, and every autopay payment imports as a charge, flipping your entire reconciliation balance upside down.</li>
</ol>
<p>Both bugs come straight from two quirks of the OFX 1.02 SGML specification that QuickBooks Web Connect enforces strictly. Here is how both problems happen and how we implemented a clean, 100% browser-local credit card <code>.QBO</code> generator in TypeScript for <a href="https://www.pdffields.com/pdf-to-qbo?utm_source=hashnode&amp;utm_medium=canonical&amp;utm_campaign=cc_qbo_signs">PDFFields (<code>/pdf-to-qbo</code>)</a>.</p>
<hr />
<h2>Bug 1: Emitting <code>&lt;BANKMSGSRSV1&gt;</code> Instead of <code>&lt;CREDITCARDMSGSRSV1&gt;</code></h2>
<p>Generic CSV-to-QBO scripts wrap every statement in the checking/savings bank envelope (<code>&lt;BANKMSGSRSV1&gt;</code> / <code>&lt;STMTTRNRS&gt;</code> / <code>&lt;BANKACCTFROM&gt;</code> with <code>&lt;BANKID&gt;</code> and <code>&lt;ACCTTYPE&gt;CHECKING</code>). QuickBooks reads that outer wrapper before asking which register to link, so it refuses to let you map the import to a Credit Card liability account.</p>
<p>For credit card statements, QuickBooks expects the dedicated credit card message set without <code>&lt;BANKID&gt;</code> or <code>&lt;ACCTTYPE&gt;</code>:</p>
<pre><code class="language-xml">&lt;CREDITCARDMSGSRSV1&gt;
&lt;CCSTMTTRNRS&gt;
&lt;TRNUID&gt;1001
&lt;STATUS&gt;
&lt;CODE&gt;0
&lt;SEVERITY&gt;INFO
&lt;/STATUS&gt;
&lt;CCSTMTRS&gt;
&lt;CURDEF&gt;USD
&lt;CCACCTFROM&gt;
&lt;ACCTID&gt;4821
&lt;/CCACCTFROM&gt;
&lt;BANKTRANLIST&gt;
&lt;DTSTART&gt;20261101120000
&lt;DTEND&gt;20261130120000
&lt;STMTTRN&gt;
&lt;TRNTYPE&gt;DEBIT
&lt;DTPOSTED&gt;20261102120000
&lt;TRNAMT&gt;-142.50
&lt;FITID&gt;20261102_N14250_0_8f1c9a
&lt;NAME&gt;AWS CLOUD SERVICES
&lt;/STMTTRN&gt;
&lt;/BANKTRANLIST&gt;
&lt;LEDGERBAL&gt;
&lt;BALAMT&gt;-142.50
&lt;DTASOF&gt;20261130120000
&lt;/LEDGERBAL&gt;
&lt;/CCSTMTRS&gt;
&lt;/CCSTMTTRNRS&gt;
&lt;/CREDITCARDMSGSRSV1&gt;
</code></pre>
<p>You also need a valid <code>&lt;INTU.BID&gt;</code> bank identifier inside <code>&lt;SONRS&gt;</code> or QuickBooks Desktop throws <strong>Error OL-222</strong>. Here are the verified US institution presets we ship in <code>src/lib/pdf/quickbooks.ts</code>:</p>
<table>
<thead>
<tr>
<th>Institution</th>
<th><code>INTU.BID</code></th>
<th>Routing / Bank ID</th>
</tr>
</thead>
<tbody><tr>
<td>American Express</td>
<td><code>3101</code></td>
<td><code>000000000</code></td>
</tr>
<tr>
<td>Chase</td>
<td><code>10898</code></td>
<td><code>021000021</code></td>
</tr>
<tr>
<td>Bank of America</td>
<td><code>5959</code></td>
<td><code>026009593</code></td>
</tr>
<tr>
<td>Capital One</td>
<td><code>1009</code></td>
<td><code>051405515</code></td>
</tr>
<tr>
<td>Citibank</td>
<td><code>24909</code></td>
<td><code>021000089</code></td>
</tr>
<tr>
<td>U.S. Bank</td>
<td><code>6812</code></td>
<td><code>091000022</code></td>
</tr>
<tr>
<td>PNC Bank</td>
<td><code>6209</code></td>
<td><code>043000096</code></td>
</tr>
<tr>
<td>Wells Fargo (Universal QuickBooks default)</td>
<td><code>3000</code></td>
<td><code>121000248</code></td>
</tr>
</tbody></table>
<hr />
<h2>Bug 2: Inverted Sign Conventions on US Credit Card PDFs</h2>
<p>Most US checking statements print withdrawals as negative (<code>-$142.50</code>) and deposits as positive (<code>+$500.00</code>). Most US <strong>credit card</strong> PDFs do the exact opposite: purchases appear as positive numbers (<code>$142.50</code>) because they increase the card balance owed, while payments and refunds appear as negative numbers (<code>-$500.00</code> or <code>$500.00 CR</code>).</p>
<p>QuickBooks Web Connect (<code>.QBO</code>) and QuickBooks Online 3-column CSV imports (<code>Date,Description,Amount</code>) use a single cash-flow sign convention across both checking and credit card registers:</p>
<ul>
<li><strong>Money spent (purchases/charges):</strong> Negative <code>&lt;TRNAMT&gt;-142.50</code> with <code>&lt;TRNTYPE&gt;DEBIT</code></li>
<li><strong>Money returned (payments/refunds/credits):</strong> Positive <code>&lt;TRNAMT&gt;500.00</code> with <code>&lt;TRNTYPE&gt;CREDIT</code></li>
</ul>
<p>If you feed raw parsed credit card PDF amounts straight into <code>&lt;TRNAMT&gt;</code>, every charge imports as a credit/payment.</p>
<p>The fix is a pure, deterministic ledger sign inversion pass right before serialization (and reflected live in the review KPI strip before export so the bookkeeper sees totals flip immediately):</p>
<pre><code class="language-ts">export interface BankLedgerRow {
  date: string;
  description: string;
  amount: number;
  balance?: number;
  pageIndex: number;
}

export interface BankLedgerResult {
  detected: boolean;
  transactionCount: number;
  totalDeposits: number;
  totalWithdrawals: number;
  netChange: number;
  pagesMerged: number;
  rows: BankLedgerRow[];
}

function round2(n: number): number {
  const rounded = Math.round(n * 100) / 100;
  return Object.is(rounded, -0) ? 0 : rounded;
}

export function invertBankLedgerSigns(ledger: BankLedgerResult): BankLedgerResult {
  let totalDeposits = 0;
  let totalWithdrawals = 0;
  const rows = ledger.rows.map((row) =&gt; {
    const amount = round2(-row.amount);
    if (amount &gt; 0) totalDeposits += amount;
    else if (amount &lt; 0) totalWithdrawals += Math.abs(amount);
    return { ...row, amount };
  });
  totalDeposits = round2(totalDeposits);
  totalWithdrawals = round2(totalWithdrawals);
  return {
    ...ledger,
    totalDeposits,
    totalWithdrawals,
    netChange: round2(totalDeposits - totalWithdrawals),
    rows
  };
}
</code></pre>
<p>When <code>invertSigns: true</code> is passed to <code>bankLedgerToQbo</code> or <code>bankLedgerToQuickBooksCsv</code>:</p>
<ul>
<li><code>+$142.50</code> (<code>AWS CLOUD SERVICES</code>) becomes <code>&lt;TRNTYPE&gt;DEBIT</code> + <code>&lt;TRNAMT&gt;-142.50</code></li>
<li><code>-$500.00</code> (<code>AUTOPAY PAYMENT THANK YOU</code>) becomes <code>&lt;TRNTYPE&gt;CREDIT</code> + <code>&lt;TRNAMT&gt;500.00</code></li>
<li>Every <code>&lt;FITID&gt;</code> is hashed deterministically from the posted date, final signed amount, normalized payee text, and row index so re-importing overlapping statement ranges never creates duplicate entries in QuickBooks.</li>
</ul>
<hr />
<h2>Zero-Upload Privacy for Financial Statements</h2>
<p>Uploading client bank or corporate Amex statements to a third-party cloud converter introduces unnecessary security and compliance exposure. By running PDF text-coordinate extraction (<code>pdfjs-dist</code>), running-balance verification, sign inversion, multi-month duplicate removal, and OFX 1.02 <code>.QBO</code> assembly directly in browser RAM, raw financial PDFs never touch an external server.</p>
<hr />
<h2>Try It on Your Own Credit Card or Bank Statement PDF</h2>
<p>You can test local transaction extraction, running-balance checking, Credit Card <code>&lt;CREDITCARDMSGSRSV1&gt;</code> mode, <code>INTU.BID</code> selection, and the one-click <strong>Invert signs (+/-)</strong> toggle directly in your browser on:</p>
<ul>
<li><a href="https://www.pdffields.com/pdf-to-qbo?utm_source=hashnode&amp;utm_medium=canonical&amp;utm_campaign=cc_qbo_signs">PDF to QuickBooks .QBO Converter (<code>/pdf-to-qbo</code>)</a></li>
<li><a href="https://www.pdffields.com/amex-statement-to-qbo?utm_source=hashnode&amp;utm_medium=canonical&amp;utm_campaign=cc_qbo_signs">American Express PDF to QuickBooks .QBO (Pre-configured INTU.BID 3101 CREDITCARD)</a></li>
<li><a href="https://www.pdffields.com/chase-statement-to-qbo?utm_source=hashnode&amp;utm_medium=canonical&amp;utm_campaign=cc_qbo_signs">Chase Statement PDF to QuickBooks .QBO (INTU.BID 10898)</a></li>
</ul>
<p>If you are closing 2026 books across a full year, the same page also includes a browser-local <strong>Year-End Batch Merge</strong> that combines 2 to 12 monthly PDF statements into one deduplicated <code>.QBO</code>, QuickBooks <code>.CSV</code>, or multi-sheet <code>.xlsx</code> workbook.</p>
]]></content:encoded></item><item><title><![CDATA[Why Text-Only PDF Diff Misses Hidden Contract Edits (And How Dual Text + Pixel Redline Catches Both in the Browser)]]></title><description><![CDATA[If you review vendor MSAs, commercial leases, or client SOWs in PDF form, you have probably tried running pdftotext on two versions and piping the output…]]></description><link>https://pdffields.hashnode.dev/why-text-only-pdf-diff-misses-hidden-contract-edits-and-how-dual-text-pixel-redline-catches-both-in-the-browser</link><guid isPermaLink="true">https://pdffields.hashnode.dev/why-text-only-pdf-diff-misses-hidden-contract-edits-and-how-dual-text-pixel-redline-catches-both-in-the-browser</guid><category><![CDATA[pdf]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[webdev]]></category><category><![CDATA[LegalTech]]></category><dc:creator><![CDATA[Ezra Winslow]]></dc:creator><pubDate>Wed, 02 Dec 2026 13:52:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0be039a65870ef3310ffc6/44c9993e-b73f-401b-a972-88137c17cc1e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you review vendor MSAs, commercial leases, or client SOWs in PDF form, you have probably tried running <code>pdftotext</code> on two versions and piping the output into <code>diff</code>. For clean Word exports where only a paragraph changed, that works. For real-world counterparty revisions, text-only diff fails silently in three expensive ways:</p>
<ol>
<li><strong>Vector and graphic changes leave zero text footprint.</strong> A checked indemnification box, a crossed-out fee schedule, a swapped signature block, or an altered engineering schematic produces identical text streams across v1 and v2.</li>
<li><strong>Flattened or scanned replacement pages return empty strings.</strong> When someone prints page 7, edits a number, scans it back in, and re-inserts it into the PDF, a text-only diff sees missing text or nothing at all.</li>
<li><strong>PDF <code>TJ</code>/<code>Tj</code> content streams are not guaranteed to follow visual reading order.</strong> Re-saving a PDF from macOS Preview, DocuSign, or Adobe Acrobat can shuffle object ordering without changing a single visible word, flooding a naive line diff with false positives.</li>
</ol>
<p>To catch both silent word swaps (<code>30 days</code> to <code>90 days</code>, <code>$1,500</code> to <code>$15,000</code>) and visual/scanned edits without uploading NDA-protected contracts to a remote server, we built a dual-engine browser comparator for <a href="https://www.pdffields.com/compare-pdf?utm_source=hashnode&amp;utm_medium=canonical&amp;utm_campaign=compare_pdf">PDFFields (<code>/compare-pdf</code>)</a>.</p>
<p>Here is how both layers work together in TypeScript using <code>pdfjs-dist</code> and <code>pdf-lib</code>.</p>
<hr />
<h2>Layer 1: Prefix/Suffix-Trimmed Word LCS with a Quadratic Guard</h2>
<p>Line-based diffing breaks down on PDFs because line wraps shift the moment a counterparty inserts two words in a paragraph. Word-level tokenization solves line-wrap noise, but running a full <code>O(n * m)</code> Longest Common Subsequence (LCS) table over two 4,000-word contract pages allocates <code>16,000,000</code> cells and freezes the browser main thread.</p>
<p>Two simple optimizations make word-level LCS instantaneous in the browser:</p>
<ol>
<li><strong>Trim matching prefix and suffix tokens first.</strong> Most contract pages change only a single clause. Peeling equal tokens from both ends usually collapses a 600-word page down to a 25-word slice before DP ever runs.</li>
<li><strong>Use a flat <code>Uint32Array</code> with a hard <code>n * m &lt;= 360_000</code> cap</strong>, falling back to a bounded 40-word lookahead diff if an entire dense page was rewritten from scratch.</li>
</ol>
<pre><code class="language-ts">export type DiffOp = 'equal' | 'added' | 'removed';

export interface DiffSegment {
  op: DiffOp;
  text: string;
}

export function diffWordTexts(leftText: string, rightText: string): DiffSegment[] {
  const a = leftText.trim().split(/\s+/).filter(Boolean);
  const b = rightText.trim().split(/\s+/).filter(Boolean);

  let prefixLen = 0;
  const minLen = Math.min(a.length, b.length);
  while (prefixLen &lt; minLen &amp;&amp; a[prefixLen] === b[prefixLen]) {
    prefixLen++;
  }

  let suffixLen = 0;
  while (
    suffixLen &lt; minLen - prefixLen &amp;&amp;
    a[a.length - 1 - suffixLen] === b[b.length - 1 - suffixLen]
  ) {
    suffixLen++;
  }

  const midA = a.slice(prefixLen, a.length - suffixLen);
  const midB = b.slice(prefixLen, b.length - suffixLen);
  const middle = lcsDiffSlice(midA, midB); // flat Uint32Array DP when midA.length * midB.length &lt;= 360_000

  const combined: DiffSegment[] = [];
  if (prefixLen &gt; 0) combined.push({ op: 'equal', text: a.slice(0, prefixLen).join(' ') });
  combined.push(...middle);
  if (suffixLen &gt; 0) combined.push({ op: 'equal', text: a.slice(a.length - suffixLen).join(' ') });
  return combined;
}
</code></pre>
<p>Once segments are computed, adjacent <code>removed</code> + <code>added</code> segments collapse into structured <code>modified</code> change cards with 6 words of leading and trailing context (<code>beforeContext</code>, <code>removedText</code>, <code>addedText</code>, <code>afterContext</code>). That structured list lets a reviewer jump straight to Clause 4.2 without scrolling through 19 unchanged pages, and exports cleanly to an RFC 4180 CSV audit trail.</p>
<hr />
<h2>Layer 2: Luminance-Directional Pixel Redline Overlay</h2>
<p>Even a perfect word diff misses scanned pages, altered checkboxes, resized logos, and shifted tables. The second pass renders page <code>N</code> of both PDFs onto offscreen HTML5 canvases at <code>1.4x</code> scale, normalizes both frames to <code>max(leftWidth, rightWidth) x max(leftHeight, rightHeight)</code> on a <code>#FFFFFF</code> background, and walks the raw <code>ImageData</code> RGBA buffers pixel by pixel.</p>
<p>A subtle detail makes pixel overlays dramatically easier to read than a generic magenta diff mask: <strong>directionality via perceptual luminance</strong>.</p>
<ul>
<li>Compute the Manhattan RGB delta: <code>delta = |lr - rr| + |lg - rg| + |lb - rb|</code>.</li>
<li>Ignore sub-pixel anti-aliasing jitter below <code>delta &lt;= 45</code>, and soften unchanged pixels <code>58%</code> toward white so the background text stays readable as a faint blueprint.</li>
<li>When <code>delta &gt; 45</code>, compare perceptual luminance (<code>0.299R + 0.587G + 0.114B</code>):<ul>
<li><strong>Darker in original (<code>leftLum &lt; rightLum</code>)</strong>: ink was removed -&gt; paint <strong>crimson (<code>#C8232C</code>)</strong>.</li>
<li><strong>Darker in revised (<code>rightLum &lt;= leftLum</code>)</strong>: ink was added -&gt; paint <strong>blueprint cobalt (<code>#1652E1</code>)</strong>.</li>
</ul>
</li>
</ul>
<pre><code class="language-ts">for (let p = 0; p &lt; totalPixels; p++) {
  const idx = p * 4;
  const lr = lData[idx], lg = lData[idx + 1], lb = lData[idx + 2];
  const rr = rData[idx], rg = rData[idx + 1], rb = rData[idx + 2];

  const delta = Math.abs(lr - rr) + Math.abs(lg - rg) + Math.abs(lb - rb);

  if (delta &gt; 45) {
    diffPixelCount++;
    const leftLum = 0.299 * lr + 0.587 * lg + 0.114 * lb;
    const rightLum = 0.299 * rr + 0.587 * rg + 0.114 * rb;
    if (leftLum &lt; rightLum) {
      // Removed ink -&gt; Crimson #C8232C
      oData[idx] = 200; oData[idx + 1] = 35; oData[idx + 2] = 44; oData[idx + 3] = 255;
    } else {
      // Added ink -&gt; Cobalt #1652E1
      oData[idx] = 22; oData[idx + 1] = 82; oData[idx + 2] = 225; oData[idx + 3] = 255;
    }
  } else {
    const lum = Math.round(0.299 * lr + 0.587 * lg + 0.114 * lb);
    const softened = Math.min(255, Math.round(lum + (255 - lum) * 0.58));
    oData[idx] = softened; oData[idx + 1] = softened; oData[idx + 2] = softened; oData[idx + 3] = 255;
  }
}
</code></pre>
<p>With this single loop, a swapped <code>$1,500</code> vs <code>$15,000</code> on a scanned exhibit lights up immediately with the old digits in crimson and the new digits in cobalt, while an added checkmark inside a flat checkbox box glows bright cobalt on a pale grey sheet.</p>
<hr />
<h2>Layer 3: Generating a Shareable Redline Report Without Uploading the Contract</h2>
<p>Legal and finance teams rarely need to send raw screenshots back to opposing counsel. They need two artifacts:</p>
<ol>
<li><strong>A Redline Summary PDF</strong> built locally with <code>pdf-lib</code> listing the KPI summary (pages compared, changed pages, added/removed words) and every clause-level diff card grouped by page.</li>
<li><strong>A Change-Log CSV</strong> (<code>Page,Change ID,Type,Before Context,Removed (Original),Added (Revised),After Context</code>) that drops straight into a deal-review spreadsheet or compliance ticket.</li>
</ol>
<p>Because <code>pdfjs-dist</code>, canvas pixel diffing, and <code>pdf-lib</code> all execute locally inside the browser tab, neither v1 nor v2 ever leaves the reviewer's machine.</p>
<hr />
<h2>Try It on Your Own PDF Pair</h2>
<p>You can run both the word-level diff and the visual pixel overlay directly in your browser (with zero file upload) on our <a href="https://www.pdffields.com/compare-pdf?utm_source=hashnode&amp;utm_medium=canonical&amp;utm_campaign=compare_pdf">Compare PDF tool</a>. Drop in any two PDF revisions, or click the built-in sample lease pair to see hidden fee and termination-notice swaps highlighted in seconds.</p>
<p>If you are also auditing outbound contracts or court filings before sharing them, check out our companion browser-local <a href="https://www.pdffields.com/pdf-redaction-checker?utm_source=hashnode&amp;utm_medium=canonical&amp;utm_campaign=compare_pdf">PDF Redaction Leak Checker</a> to verify no selectable text remains hidden underneath black boxes.</p>
]]></content:encoded></item><item><title><![CDATA[The 2026 Year-End Local PDF Handbook: QuickBooks .QBO, Redaction Audits, Contract Diffs, and Fillable Forms Without Cloud Uploads]]></title><description><![CDATA[Every December, small business owners, bookkeepers, solo attorneys, and office administrators hit the same six PDF bottlenecks at once: twelve months of…]]></description><link>https://pdffields.hashnode.dev/the-2026-year-end-local-pdf-handbook-quickbooks-qbo-redaction-audits-contract-diffs-and-fillable-forms-without-cloud-uploads</link><guid isPermaLink="true">https://pdffields.hashnode.dev/the-2026-year-end-local-pdf-handbook-quickbooks-qbo-redaction-audits-contract-diffs-and-fillable-forms-without-cloud-uploads</guid><category><![CDATA[pdf]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Productivity]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Ezra Winslow]]></dc:creator><pubDate>Tue, 01 Dec 2026 12:13:04 GMT</pubDate><content:encoded><![CDATA[<p>Every December, small business owners, bookkeepers, solo attorneys, and office administrators hit the same six PDF bottlenecks at once: twelve months of monthly bank statement PDFs waiting for QuickBooks reconciliation, confidential client records that need verified redaction, revised vendor contracts for the new year, Word intake forms that refuse to stay fillable when saved as PDF, intake PDFs clients cannot fill out on their phone, and signed agreements that need flattening before archiving.</p>
<p>Most people assume they have only two choices: pay $240 to $360 a year for Adobe Acrobat Pro (with early cancellation fees on annual commitments), or upload sensitive financial and legal documents to free cloud PDF converters.</p>
<p>Modern browsers give you a third option: running the full PDF parser, canvas rasterizer, word-level diff engine, and OFX/AcroForm writer directly inside your browser tab's local RAM with zero file uploads.</p>
<p>Here is the practical engineering and workflow checklist for all six year-end jobs.</p>
<p>Watch the 30-second browser-local studio walkthrough: <a href="https://www.youtube.com/watch?v=kTMUi-qRZtc">https://www.youtube.com/watch?v=kTMUi-qRZtc</a></p>
<hr />
<h2>1. Reconciling 12 Months of Bank &amp; Credit Card PDFs Into QuickBooks .QBO and Excel</h2>
<p>Direct bank feeds in QuickBooks Online and QuickBooks Desktop usually cap historical pull windows, and banks like Chase, Bank of America, Wells Fargo, and American Express only offer archived statements beyond 12 to 18 months as PDFs.</p>
<p>Three technical failures cause almost every manual import headache:</p>
<ol>
<li><strong>Multi-line ACH descriptions break naive CSV conversions.</strong> When a wire or ACH memo wraps onto two or three lines in a PDF table, generic converters spawn orphan rows with blank dates and <code>#VALUE!</code> cells.</li>
<li><strong>Wrong OFX envelopes misroute credit card statements.</strong> QuickBooks Web Connect <code>.QBO</code> files are OFX 1.02 SGML payloads. A checking or savings statement must use <code>&lt;BANKMSGSRSV1&gt;</code> and <code>&lt;STMTRS&gt;</code>, while an American Express or Chase business credit card statement must use <code>&lt;CREDITCARDMSGSRSV1&gt;</code> and <code>&lt;CCSTMTRS&gt;</code>. Using the bank envelope on a credit card forces QuickBooks to map charges into a Bank asset register instead of a Credit Card liability register.</li>
<li><strong>Missing bank IDs (<code>INTU.BID</code>) and unstable <code>FITID</code> keys cause rejections or duplicates.</strong> QuickBooks validates the institution code (<code>10898</code> for Chase, <code>5959</code> for Bank of America, <code>3000</code> for Wells Fargo, <code>3101</code> for American Express) and deduplicates overlapping date ranges using deterministic <code>&lt;FITID&gt;</code> hashes.</li>
</ol>
<p>Before trusting any extracted register, always verify running balance math (<code>Beginning Balance + Total Credits - Total Debits = Ending Balance</code> to <code>$0.00</code> difference).</p>
<p>You can run local extraction, balance verification, Checking/Credit Card <code>.QBO</code> generation, and merged multi-month YTD Excel export right in your browser (zero uploads, zero bank logins):</p>
<ul>
<li><a href="https://www.pdffields.com/pdf-to-qbo?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=year_end_handbook">PDF to QuickBooks .QBO Converter</a></li>
<li><a href="https://www.pdffields.com/bank-statement-to-excel?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=year_end_handbook">Bank Statement PDF to Excel Converter</a></li>
<li>Dedicated bank presets: <a href="https://www.pdffields.com/chase-statement-to-qbo?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=year_end_handbook">Chase</a>, <a href="https://www.pdffields.com/bank-of-america-statement-to-qbo?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=year_end_handbook">Bank of America</a>, <a href="https://www.pdffields.com/wells-fargo-statement-to-qbo?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=year_end_handbook">Wells Fargo</a>, and <a href="https://www.pdffields.com/amex-statement-to-qbo?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=year_end_handbook">American Express</a>.</li>
</ul>
<hr />
<h2>2. Checking If a "Redacted" PDF Still Leaks Hidden Text Beneath Black Boxes</h2>
<p>Drawing a black rectangle over an SSN, bank account number, or client name in Preview, Word, or basic PDF editors does not delete the text object from the PDF content stream. Anyone who receives the file can drag across the black box, press <code>Ctrl+C</code>, and paste the supposedly redacted text straight into Notepad.</p>
<p>Even when text is properly removed, three secondary leaks routinely survive:</p>
<ul>
<li><strong>Unapplied <code>/Redact</code> annotations</strong> that visually cover text without burning through the page stream.</li>
<li><strong>Document <code>/Info</code> and XMP XML metadata</strong> exposing the original author name, internal file path, software version, and edit timestamps.</li>
<li><strong>Incremental <code>%%EOF</code> PDF save revisions</strong> that preserve earlier unredacted byte snapshots inside the same file.</li>
</ul>
<p>A genuine redaction fix rasterizes affected pages cleanly (200 DPI) so no selectable text glyphs survive under black boxes, strips <code>/Info</code> and XMP metadata dictionaries, and rewrites a clean single-revision PDF.</p>
<p>Run a free local leak scan on any PDF before sharing it externally:
<a href="https://www.pdffields.com/pdf-redaction-checker?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=year_end_handbook">Free Local PDF Redaction Leak Checker</a></p>
<hr />
<h2>3. Comparing Two Revised Contract PDFs Locally Without Cloud Uploads</h2>
<p>When a counterparty returns a "minor revision" of a Master Service Agreement, lease, NDA, or vendor quote, visual skimming easily misses a single changed number (<code>Net 30</code> changed to <code>Net 90</code>, or a liability cap reduced from <code>$50,000</code> to <code>$5,000</code>).</p>
<p>Relying strictly on text comparison is not enough either: scanned exhibits, updated fee tables embedded as images, and shifted signature blocks will not show up in a pure text diff. Combining a word-level longest common subsequence (LCS) redline with a local RGBA pixel overlay catches both text edits and visual layout changes without ever uploading a confidential agreement to a remote server.</p>
<p>Test Page 1 free on your own PDFs locally:
<a href="https://www.pdffields.com/compare-pdf?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=year_end_handbook">Local PDF Comparison &amp; Redline Diff</a></p>
<hr />
<h2>4. Turning Word or Google Doc Forms Into Real Interactive Fillable PDFs</h2>
<p>Exporting a form from Microsoft Word or Google Docs using Save as PDF flattens underlines and Unicode checkboxes into static vector ink. Recipients end up printing the form, filling it out by hand, and photographing it with their phone.</p>
<p>Standard ISO 32000 AcroForm fields (text inputs, date boxes, checkboxes, radio groups, dropdown menus, and signature fields) work natively inside macOS Preview, Windows Edge, Chrome, Firefox, and Adobe Reader without forcing recipients to install special software.</p>
<p>Build and test AcroForm fields directly in your browser:
<a href="https://www.pdffields.com/fillable-pdf?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=year_end_handbook">Interactive Fillable PDF Builder</a></p>
<hr />
<h2>5. Turning Existing Intake PDFs Into Mobile-Friendly Web Form Links</h2>
<p>When clients open a PDF intake form, waiver, or lease on an iPhone or Android device, tiny AcroForm boxes are frustrating to tap. Instead of rebuilding your existing PDF from scratch in Typeform or Jotform, you can map interactive fields directly over your exact PDF layout and publish a shareable <code>/f/</code> web form link. Respondents fill and sign cleanly on any mobile browser with zero login or app download, and you export every submission as a completed PDF plus CSV.</p>
<p>Preview field mapping on your own PDF free before publishing:
<a href="https://www.pdffields.com/pdf-to-web-form?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=year_end_handbook">Convert Any PDF to a Mobile Web Form Link</a></p>
<hr />
<h2>6. Flattening Completed PDFs and Scrubbing Hidden Metadata Before Archiving</h2>
<p>Once a client returns a completed fillable form or signed agreement, leaving active AcroForm widgets unlocked means anyone opening the PDF later can silently change numbers, dates, or checkbox selections.</p>
<p>Flattening bakes form field values and annotations permanently into the page content stream (either preserving selectable vector text or baking a 200 DPI raster lock), while metadata scrubbing removes <code>/Author</code>, <code>/Creator</code>, <code>/Producer</code>, XMP packets, and trailing incremental revisions.</p>
<p>Inspect fields, metadata tags, and revision counts free locally:
<a href="https://www.pdffields.com/flatten-pdf?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=year_end_handbook">Local PDF Flattener &amp; Metadata Scrubber</a></p>
<hr />
<h2>One Browser-Local Studio vs $240/yr Adobe Acrobat Pro</h2>
<p>We built <a href="https://www.pdffields.com/adobe-acrobat-alternative?utm_source=hashnode&amp;utm_medium=post&amp;utm_campaign=year_end_handbook">PDFFields</a> so solo operators, bookkeepers, and small teams can run every workflow above in one browser tab with zero file uploads (except when you explicitly choose to publish a hosted <code>/f/</code> web form link).</p>
<p>You can test every tool on your own PDF free before paying. Clean exports unlock on Solo at $4.99/mo flat or $39/yr, and Pro Batch Merge (for combining up to 12 monthly bank statement PDFs into one reconciled YTD Excel workbook or <code>.QBO</code> file plus unlimited unbranded hosted form links) is $19/mo or $119/yr. Cancel anytime in one click, backed by a 14-day full refund guarantee.</p>
]]></content:encoded></item><item><title><![CDATA[How to Turn Any Existing PDF Into a Mobile-Friendly Web Form Link (Without Rebuilding the Form in Typeform or Jotform)]]></title><description><![CDATA[If you have ever emailed an interactive AcroForm PDF to a client on an iPhone or Android device, you already know how the story ends: they open the PDF…]]></description><link>https://pdffields.hashnode.dev/how-to-turn-any-existing-pdf-into-a-mobile-friendly-web-form-link-without-rebuilding-the-form-in-typeform-or-jotform</link><guid isPermaLink="true">https://pdffields.hashnode.dev/how-to-turn-any-existing-pdf-into-a-mobile-friendly-web-form-link-without-rebuilding-the-form-in-typeform-or-jotform</guid><category><![CDATA[webdev]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[pdf]]></category><category><![CDATA[Productivity]]></category><category><![CDATA[SaaS]]></category><dc:creator><![CDATA[Ezra Winslow]]></dc:creator><pubDate>Mon, 30 Nov 2026 17:19:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0be039a65870ef3310ffc6/b5dd9ea5-0ae6-4431-a7b1-d02cf3144523.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you have ever emailed an interactive AcroForm PDF to a client on an iPhone or Android device, you already know how the story ends: they open the PDF inside Gmail or Apple Mail's built-in previewer, type into the fields, tap Share, and email you back a completely blank PDF. Or worse, they print the PDF, fill it out in pen, take four skewed photos on a kitchen counter, and text them back as <code>.HEIC</code> files.</p>
<p>Rebuilding an existing legal, medical, HR, or client-intake PDF from scratch inside Typeform, Google Forms, or Jotform throws away your original document layout. When compliance or a counterparty requires answers stamped onto the exact original PDF layout, you end up copying form responses back onto the PDF manually.</p>
<p>This post walks through the architecture we built for <a href="https://www.pdffields.com/pdf-to-web-form?utm_source=article&amp;utm_medium=canonical&amp;utm_campaign=pdf_to_web_form">PDFFields (<code>/pdf-to-web-form</code>)</a> to turn any existing PDF into a shareable mobile web form link (<code>/f/...</code>) that collects both clean CSV rows and stamped, flattened PDFs on the original layout.</p>
<hr />
<h2>1. The Core Problem: PDF Coordinate Space vs. Responsive Mobile Viewports</h2>
<p>A PDF page uses a fixed 72 DPI coordinate system with its origin <code>(0, 0)</code> at the <strong>bottom-left</strong> corner of the page. HTML, CSS, and browser Canvas APIs use a variable-DPI viewport with <code>(0, 0)</code> at the <strong>top-left</strong> corner.</p>
<p>If you store field rectangles in raw PDF points (<code>xPt, yPt, wPt, hPt</code>) or fixed pixels, overlays drift the moment a respondent opens the form on a 390px iPhone screen versus a 1440px desktop monitor.</p>
<p>The clean solution is storing every form field in <strong>page-normalized top-left coordinates</strong> <code>[0, 1]</code>:</p>
<pre><code class="language-ts">export interface NormalizedRect {
  x: number; // 0..1 from left edge
  y: number; // 0..1 from top edge
  width: number; // 0..1 of page width
  height: number; // 0..1 of page height
}

export function normalizedToPdfPoints(
  rect: NormalizedRect,
  pageWidthPt: number,
  pageHeightPt: number
) {
  const width = rect.width * pageWidthPt;
  const height = rect.height * pageHeightPt;
  const x = rect.x * pageWidthPt;
  // Flip Y axis from top-left HTML space to bottom-left PDF space
  const y = pageHeightPt - (rect.y + rect.height) * pageHeightPt;
  return { x, y, width, height };
}
</code></pre>
<p>Storing normalized coordinates unlocks two things at once:</p>
<ol>
<li><strong>Pixel-accurate live overlays on any screen</strong>: On desktop, fields sit directly over the rendered PDF canvas via percentage CSS positioning. On mobile (<code>390px</code> width), the same ordered field schema renders as a clean vertical stack of native HTML <code>&lt;input&gt;</code>, <code>&lt;textarea&gt;</code>, <code>&lt;select&gt;</code>, checkbox, date, and touch-canvas signature controls so nobody has to pinch-zoom a 612pt PDF page.</li>
<li><strong>Exact round-trip back to ISO 32000 AcroForm PDFs</strong>: The same field schema exports both a standard offline fillable PDF (using <code>pdf-lib</code> widgets) and a live web link.</li>
</ol>
<hr />
<h2>2. Authoring Fields Locally Before Anything Leaves the Browser</h2>
<p>Privacy matters most when teams prepare contracts, W-9s, onboarding packets, or lease applications. In our studio architecture:</p>
<ul>
<li>Opening a PDF, rendering pages with <code>pdfjs-dist</code>, placing text/checkbox/radio/dropdown/date/signature fields, filling and signing, redacting at 200 DPI, flattening metadata, and converting tables to Excel or QuickBooks <code>.QBO</code> all execute <strong>100% locally inside the visitor's browser</strong> with zero file uploads.</li>
<li>Only when the author explicitly clicks <strong>Publish Fillable Link</strong> is the template PDF and normalized field layout uploaded to the server to mint a shareable <code>/f/&lt;slug&gt;</code> URL.</li>
</ul>
<p>That boundary is explicit and verifiable in browser DevTools Network tab: no document leaves the device during local editing, redaction, or AcroForm authoring.</p>
<hr />
<h2>3. Turning Web Submissions Back Into Stamped PDFs + RFC-4180 CSV</h2>
<p>When a respondent opens <code>/f/&lt;slug&gt;</code> on Safari, Chrome, Edge, or Firefox:</p>
<ol>
<li>They require <strong>zero account creation and zero PDF app installs</strong>.</li>
<li>Each field validates required flags, radio-group exclusivity, dropdown choices, and drawn/typed signature data URLs.</li>
<li>On submit, the structured field values (plus signature image payload) are stored in Cloudflare D1 linked to that form slug.</li>
<li>From the author's dashboard, every submission can be exported in two formats:<ul>
<li><strong>Stamped &amp; flattened PDF</strong> mapped back onto the exact original template PDF via <code>normalizedToPdfPoints(...)</code>, baking text, checkmarks, and PNG signature strokes cleanly into the PDF page so every viewer renders them identically.</li>
<li><strong>Bulk CSV</strong> across all respondents for instant import into Excel, Google Sheets, or a CRM.</li>
</ul>
</li>
</ol>
<p>Because checkboxes and ink signatures are rendered onto the PDF page at export time instead of relying on Viewer-dependent AcroForm appearance streams (<code>/AP</code>), the resulting filled PDF opens cleanly in Apple Preview, Chrome PDF Viewer, Adobe Reader, and court/HR portals alike.</p>
<hr />
<h2>4. When to Use an Offline Fillable PDF vs. a Hosted Web Link</h2>
<table>
<thead>
<tr>
<th>Requirement</th>
<th>Offline Fillable PDF (ISO 32000)</th>
<th>Hosted Web Form Link (<code>/f/...</code>)</th>
</tr>
</thead>
<tbody><tr>
<td>Respondents on iPhone / Android</td>
<td>Often breaks in mobile mail previewers</td>
<td>Native touch inputs + finger signature</td>
</tr>
<tr>
<td>Collect 20+ client responses into CSV</td>
<td>Requires manual extraction per file</td>
<td>1-click CSV + individual filled PDFs</td>
</tr>
<tr>
<td>Strict zero-server airgapped workflow</td>
<td>100% local in-browser</td>
<td>Template stored on server when published</td>
</tr>
<tr>
<td>Exact original PDF layout preserved</td>
<td>Yes</td>
<td>Yes (both CSV and stamped original PDF)</td>
</tr>
</tbody></table>
<p>With <a href="https://www.pdffields.com/pdf-to-web-form?utm_source=article&amp;utm_medium=canonical&amp;utm_campaign=pdf_to_web_form">PDFFields</a>, you author the fields once and export <strong>either or both</strong>: download the offline ISO 32000 <code>.pdf</code> locally, or publish a live <code>/f/...</code> web link (up to 5 hosted links on Solo at <code>$4.99/mo</code> or <code>$39/yr</code>, and unlimited unbranded hosted links on Pro at <code>$19/mo</code> or <code>$119/yr</code>).</p>
<p>You can test the full AcroForm mapper right now on your own PDF or the built-in 2-page Client Services Intake Form sample at <a href="https://www.pdffields.com/pdf-to-web-form?utm_source=article&amp;utm_medium=canonical&amp;utm_campaign=pdf_to_web_form">https://www.pdffields.com/pdf-to-web-form</a>.</p>
]]></content:encoded></item><item><title><![CDATA[How to Compare Two PDFs for Differences Locally (Word Redline + Pixel Diff Without Cloud Uploads)]]></title><description><![CDATA[When a vendor, landlord, or counterparty emails back a revised PDF saying "just a few minor edits," checking the changes usually forces an awkward…]]></description><link>https://pdffields.hashnode.dev/how-to-compare-two-pdfs-for-differences-locally-word-redline-pixel-diff-without-cloud-uploads</link><guid isPermaLink="true">https://pdffields.hashnode.dev/how-to-compare-two-pdfs-for-differences-locally-word-redline-pixel-diff-without-cloud-uploads</guid><category><![CDATA[pdf]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[cybersecurity]]></category><dc:creator><![CDATA[Ezra Winslow]]></dc:creator><pubDate>Sun, 29 Nov 2026 20:23:38 GMT</pubDate><content:encoded><![CDATA[<p>When a vendor, landlord, or counterparty emails back a revised PDF saying "just a few minor edits," checking the changes usually forces an awkward trade-off: pay <code>$239.88/year</code> for Adobe Acrobat Pro, manually squint at two windows side by side, or upload confidential NDAs and financial exhibits to a free cloud PDF diff website.</p>
<p>Even worse, many popular online PDF diff checkers only extract raw text. If someone modifies a scanned invoice figure, swaps a signature block, alters a diagram, or shifts table alignment without changing the text layer, a text-only diff reports zero differences.</p>
<p>Combining <strong>word-level LCS redline diffing</strong> with <strong>canvas RGBA pixel-overlay diffing</strong> directly inside the browser solves both problems with zero server uploads.</p>
<h2>Why Text-Only PDF Diff Misses Real Contract Changes</h2>
<p>A PDF file can change in two independent ways:</p>
<ol>
<li><strong>Text stream edits</strong>: Dollar amounts (<code>$12,500</code> to <code>$14,800</code>), payment windows (<code>Net 30</code> to <code>Net 60</code>), liability caps (<code>$250,000</code> to <code>$50,000</code>), governing law (<code>California</code> to <code>Delaware</code>), or inserted clauses. These require a structured word-level redline and clickable change log so reviewers can audit every single phrase.</li>
<li><strong>Visual and raster edits</strong>: Scanned pages with no text layer, embedded charts, signature images, stamps, or subtle numeric edits baked into flat images. Catching those requires rendering both pages to identical offscreen canvases and comparing every RGBA pixel.</li>
</ol>
<h2>Building Both Engines 100% Locally in TypeScript</h2>
<p>Modern browsers can run the entire pipeline on the user's device via <code>pdf.js</code> and <code>pdf-lib</code> with zero bytes leaving the browser tab.</p>
<h3>1. Reading-Order Text Extraction + Fast Word LCS Diff</h3>
<p>Raw <code>pdf.js</code> text items arrive in PDF stream order, which is not always reading order. Grouping items by vertical baseline (<code>y</code> descending within a <code>4pt</code> tolerance) and sorting horizontally (<code>x</code> ascending) reconstructs clean paragraphs before running prefix/suffix-trimmed word-level Longest Common Subsequence (LCS) diffing:</p>
<pre><code class="language-ts">export function diffWordTexts(leftText: string, rightText: string) {
  const a = leftText.trim().split(/\s+/).filter(Boolean);
  const b = rightText.trim().split(/\s+/).filter(Boolean);

  let prefix = 0;
  const minLen = Math.min(a.length, b.length);
  while (prefix &lt; minLen &amp;&amp; a[prefix] === b[prefix]) prefix++;

  let suffix = 0;
  while (
    suffix &lt; minLen - prefix &amp;&amp;
    a[a.length - 1 - suffix] === b[b.length - 1 - suffix]
  ) {
    suffix++;
  }

  // Only run DP on the genuinely changed middle slice
  return computeMiddleLcs(
    a.slice(prefix, a.length - suffix),
    b.slice(prefix, b.length - suffix)
  );
}
</code></pre>
<p>Trimming matching prefixes and suffixes first means even a 20-page contract with 6 localized edits diffs in milliseconds without blocking the UI thread.</p>
<h3>2. Pixel-Level Visual Overlay Diff</h3>
<p>For visual verification, render Page <code>N</code> of both PDFs onto matching offscreen HTML <code>&lt;canvas&gt;</code> elements (normalizing canvas width and height if page sizes differ), then inspect each RGBA pixel pair:</p>
<pre><code class="language-ts">const delta =
  Math.abs(lr - rr) + Math.abs(lg - rg) + Math.abs(lb - rb);

if (delta &gt; 45) {
  const leftLum = 0.299 * lr + 0.587 * lg + 0.114 * lb;
  const rightLum = 0.299 * rr + 0.587 * rg + 0.114 * rb;
  if (leftLum &lt; rightLum) {
    // Removed original ink -&gt; Redaction Crimson (#C8232C)
  } else {
    // Added revised ink -&gt; Blueprint Cobalt (#1652E1)
  }
} else {
  // Unchanged background -&gt; desaturated neutral gray so redlines stand out
}
</code></pre>
<p>The threshold <code>delta &gt; 45</code> filters out subpixel antialiasing noise while immediately lighting up altered digits, moved clauses, swapped signatures, and scanned invoice edits.</p>
<h2>Walkthrough Video</h2>
<p>Watch the 45-second browser-local walkthrough: <a href="https://www.youtube.com/watch?v=EJfb1h18AbM">https://www.youtube.com/watch?v=EJfb1h18AbM</a></p>
<h2>Try It Free on Your Own Two PDFs (Zero Uploads)</h2>
<p>We shipped this complete Text Redline Diff, Visual Pixel Overlay, Side-by-Side Viewer, and Redline Audit Report PDF generator at <a href="https://www.pdffields.com/compare-pdf?utm_source=article&amp;utm_medium=canonical&amp;utm_campaign=compare_pdf">PDFFields Compare Two PDFs</a>.</p>
<ul>
<li><strong>Free full inspection on your own PDFs</strong>: Drop two PDF versions (or click the built-in 2-page Master Services Agreement sample pair with 6 hidden redlines) and inspect every word change, clickable change log entry, and visual pixel overlay locally with zero file uploads.</li>
<li><strong>Export clean Redline Report PDF &amp; CSV</strong>: Generate a clean audit report PDF or structured <code>.CSV</code> change log to share with legal, finance, or procurement stakeholders.</li>
<li><strong>Need to lock or audit the final signed contract too?</strong> Use our local <a href="https://www.pdffields.com/flatten-pdf?utm_source=article&amp;utm_medium=canonical&amp;utm_campaign=compare_pdf">Flatten PDF &amp; Metadata Scrubber</a> and <a href="https://www.pdffields.com/pdf-redaction-checker?utm_source=article&amp;utm_medium=canonical&amp;utm_campaign=compare_pdf">PDF Redaction Leak Checker</a> directly in the same browser-local workspace.</li>
</ul>
<p>Originally published at <a href="https://www.pdffields.com/compare-pdf">pdffields.com/compare-pdf</a>.</p>
]]></content:encoded></item><item><title><![CDATA[How to Flatten a PDF and Remove Hidden Metadata Without Uploading Confidential Files]]></title><description><![CDATA[Every week, people fill out a W-9, sign a vendor onboarding packet, or annotate a contract, hit Save, and email the PDF assuming the document is locked…]]></description><link>https://pdffields.hashnode.dev/how-to-flatten-a-pdf-and-remove-hidden-metadata-without-uploading-confidential-files</link><guid isPermaLink="true">https://pdffields.hashnode.dev/how-to-flatten-a-pdf-and-remove-hidden-metadata-without-uploading-confidential-files</guid><category><![CDATA[pdf]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[cybersecurity]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Ezra Winslow]]></dc:creator><pubDate>Sun, 29 Nov 2026 20:05:08 GMT</pubDate><content:encoded><![CDATA[<p>Every week, people fill out a W-9, sign a vendor onboarding packet, or annotate a contract, hit Save, and email the PDF assuming the document is locked. Two hours later, a client opens it in Apple Preview and sees blank form boxes, or worse, someone clicks into a field and alters a dollar figure or extracts the author's laptop username and edit history straight from the file bytes.</p>
<p>Knowing how to flatten a PDF properly, and when vector AcroForm flattening is not enough, requires looking at what actually lives inside a PDF file.</p>
<h2>Why "Save" Leaves Your PDF Editable and Leaky</h2>
<p>A filled PDF is rarely a static page. Behind the scenes, three separate structures often stay active after you click Save:</p>
<ol>
<li><strong>Interactive <code>/AcroForm</code> and <code>/Widget</code> annotations</strong>: Text inputs, checkboxes, dropdowns, and radio buttons live in an interactive annotation layer floating on top of the static page stream. Different viewers (Apple Preview, Chrome PDFium, Adobe Acrobat Reader, court e-filing portals) render unflattened <code>/Widget</code> appearances inconsistently, and anyone opening the file can modify the values.</li>
<li><strong>Embedded <code>/Info</code> dictionary and catalog XMP <code>/Metadata</code> XML</strong>: Office suites and PDF readers write <code>/Author</code>, <code>/Creator</code>, <code>/Producer</code>, <code>/Title</code>, <code>/Subject</code>, <code>/Keywords</code>, <code>/CreationDate</code>, and <code>/ModDate</code> into both the classic trailer <code>/Info</code> dictionary and a separate root catalog XMP XML packet. Deleting <code>/Author</code> in a basic document properties panel frequently leaves the duplicate XMP XML stream intact.</li>
<li><strong>Incremental <code>%%EOF</code> save history</strong>: When a PDF editor performs an incremental save, it appends changes after the prior <code>%%EOF</code> marker rather than rebuilding the file from scratch. A PDF with 2 or more <code>%%EOF</code> trailers can still preserve earlier field values, previous metadata, and pre-redaction objects inside the raw file bytes.</li>
</ol>
<h2>Vector Flatten vs. Full-Page 200 DPI Image Flatten</h2>
<p>Most guides lump both flattening techniques together, even though they solve different engineering problems:</p>
<table>
<thead>
<tr>
<th>Method</th>
<th>What changes</th>
<th>Text selectable?</th>
<th>Best use case</th>
</tr>
</thead>
<tbody><tr>
<td><strong>Vector AcroForm Flatten</strong></td>
<td>Calls <code>form.flatten()</code> to burn <code>/Widget</code> appearances into static page drawing commands and strips <code>/AcroForm</code> + leftover annotations</td>
<td>Yes (crisp vector text, small file)</td>
<td>Filled W-9s, HR forms, rental agreements, tax packets</td>
</tr>
<tr>
<td><strong>Full-Page 200 DPI Image Flatten</strong></td>
<td>Pre-flattens form appearances, rasterizes each page at 200 DPI, and rebuilds a clean single-revision PDF with zero editable layers</td>
<td>No (pure flat image per page)</td>
<td>Signed contracts, marked-up reviews, court e-filing, maximum lock</td>
</tr>
</tbody></table>
<h3>Why "Print to PDF" Often Breaks Forms</h3>
<p>The classic workaround, printing to Microsoft Print to PDF or macOS Save as PDF, introduces silent defects:</p>
<ul>
<li>Page boxes get rescaled to fit printer margins, clipping wide tables or shrinking legal-size pages.</li>
<li>Uncommitted AcroForm widgets and checkbox checkmarks can disappear in macOS Preview or Adobe Reader DC (which disables Print to PDF altogether on macOS).</li>
<li>The OS print spooler stamps fresh metadata (<code>/Producer: macOS Quartz PDFContext</code> or <code>Microsoft: Print To PDF</code>) right back into the output file.</li>
</ul>
<h2>Building a 100% Browser-Local PDF Flattener and Metadata Scrubber</h2>
<p>You do not need a cloud upload server or a <code>$240/yr</code> desktop suite to inspect, flatten, and sanitize PDFs. Modern browsers can run the entire pipeline locally using <code>pdf-lib</code> and <code>pdf.js</code> with zero bytes leaving the user's device.</p>
<h3>Step 1: Inspect Interactive Fields, Metadata, and <code>%%EOF</code> Revisions Locally</h3>
<p>Before mutating anything, scan the local <code>Uint8Array</code> to count real risks:</p>
<pre><code class="language-ts">import { PDFDocument, PDFName } from 'pdf-lib';

export function countPdfRevisions(bytes: Uint8Array): number {
  const latin1 = new TextDecoder('latin1').decode(bytes);
  const matches = latin1.match(/%%EOF/g);
  return matches ? matches.length : 1;
}

export async function inspectPdf(bytes: Uint8Array) {
  const doc = await PDFDocument.load(bytes, {
    ignoreEncryption: true,
    updateMetadata: false,
  });
  const form = doc.getForm();
  const fieldCount = form.getFields().length;
  const hasXmp = Boolean(doc.catalog.lookup(PDFName.of('Metadata')));
  const revisions = countPdfRevisions(bytes);
  return { fieldCount, hasXmp, revisions };
}
</code></pre>
<h3>Step 2: Scrub Both <code>/Info</code> AND Catalog XMP <code>/Metadata</code></h3>
<p>Clearing <code>doc.setAuthor('')</code> alone leaves the catalog XMP XML stream behind. You must remove both:</p>
<pre><code class="language-ts">export function scrubAllMetadata(doc: PDFDocument): void {
  doc.setTitle('');
  doc.setAuthor('');
  doc.setSubject('');
  doc.setKeywords([]);
  doc.setProducer('');
  doc.setCreator('');

  // Clear trailer /Info dictionary entries completely
  const infoRef = doc.context.trailerInfo.Info;
  if (infoRef) {
    doc.context.delete(infoRef);
    delete doc.context.trailerInfo.Info;
  }

  // Delete the root catalog XMP /Metadata stream
  const xmpRef = doc.catalog.get(PDFName.of('Metadata'));
  if (xmpRef) {
    doc.catalog.delete(PDFName.of('Metadata'));
    doc.context.delete(xmpRef);
  }
}
</code></pre>
<h3>Step 3: One Subtle Gotcha with 200 DPI Raster Flattening</h3>
<p>If you render an interactive AcroForm PDF straight through <code>pdf.js</code> onto an HTML <code>&lt;canvas&gt;</code> using <code>annotationMode: 2</code> (<code>ENABLE_FORMS</code>), form widget text is rendered into a separate DOM overlay layer rather than painted directly onto the 2D canvas. Your flattened image will come out with empty boxes!</p>
<p>The reliable fix is a two-stage local pass:</p>
<ol>
<li>Run <code>pdf-lib</code> <code>form.flatten({ updateFieldAppearances: true })</code> first so every text value, dropdown selection, and checkbox checkmark becomes part of the page's static PDF graphics stream.</li>
<li>Render the pre-flattened bytes onto a 200 DPI canvas via <code>pdf.js</code> with <code>annotationMode: 1</code> (<code>ENABLE</code>, which also paints sticky notes, highlights, and freehand ink annotations directly onto the canvas), embed each rendered page into a fresh <code>PDFDocument</code>, scrub metadata, and save with <code>updateFieldAppearances: false</code> to produce a single <code>1 %%EOF</code> file.</li>
</ol>
<h2>Walkthrough Video</h2>
<p>Watch the 45-second browser-local walkthrough: <a href="https://www.youtube.com/watch?v=FpFixZDjVsE">https://www.youtube.com/watch?v=FpFixZDjVsE</a></p>
<h2>Try It Directly in Your Browser (Zero Uploads)</h2>
<p>We built this full inspection, Vector Flatten, 200 DPI Image Flatten, and metadata scrubbing engine into <a href="https://www.pdffields.com/flatten-pdf?utm_source=article&amp;utm_medium=canonical&amp;utm_campaign=flatten_pdf">PDFFields Flatten PDF</a>.</p>
<ul>
<li><strong>Free instant diagnostic</strong>: Drop any PDF (or load our built-in 10-field W-9 sample) to inspect every AcroForm field, annotation, <code>/Info</code> and XMP metadata tag, and <code>%%EOF</code> revision count locally with zero uploads.</li>
<li><strong>Free before-and-after flattened preview</strong>: Switch between Vector Flatten and 200 DPI Full-Page Image Flatten and verify <code>0 editable fields</code>, <code>0 metadata tags</code>, and <code>1 %%EOF revision</code> before exporting.</li>
<li><strong>Need to audit blacked-out redactions first?</strong> Pair it with our free local <a href="https://www.pdffields.com/pdf-redaction-checker?utm_source=article&amp;utm_medium=canonical&amp;utm_campaign=flatten_pdf">PDF Redaction Leak Checker</a> to make sure no hidden characters remain underneath black rectangles.</li>
</ul>
<p>Originally published at <a href="https://www.pdffields.com/flatten-pdf">pdffields.com/flatten-pdf</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Why Microsoft Word's Save-As-PDF Breaks Form Fields (and How to Create a Fillable PDF From Word Without Adobe Acrobat)]]></title><description><![CDATA[If you have ever built a clean intake form, HR onboarding packet, or client agreement in Microsoft Word using Developer tab Content Controls or Legacy Form…]]></description><link>https://pdffields.hashnode.dev/why-microsoft-word-s-save-as-pdf-breaks-form-fields-and-how-to-create-a-fillable-pdf-from-word-without-adobe-acrobat</link><guid isPermaLink="true">https://pdffields.hashnode.dev/why-microsoft-word-s-save-as-pdf-breaks-form-fields-and-how-to-create-a-fillable-pdf-from-word-without-adobe-acrobat</guid><category><![CDATA[pdf]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Productivity]]></category><dc:creator><![CDATA[Ezra Winslow]]></dc:creator><pubDate>Sun, 29 Nov 2026 16:46:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0be039a65870ef3310ffc6/853ae89e-0ad1-42d4-a284-d4bd77d289a0.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you have ever built a clean intake form, HR onboarding packet, or client agreement in Microsoft Word using Developer tab Content Controls or Legacy Form Fields, clicked <strong>File &gt; Save As &gt; PDF</strong>, and opened the result in Chrome, Apple Preview, or Adobe Acrobat Reader, you already know what happens next: every single text box, checkbox, and dropdown turns into dead static ink.</p>
<p>Recipients cannot click inside the fields. Worse, if they email the <code>.docx</code> file back instead, Microsoft Word shifts table margins, wraps lines across page breaks, and alters fonts between Windows, macOS, and Google Docs.</p>
<p>This is not a user mistake. It is a structural mismatch between how Office Open XML (<code>.docx</code>) encodes form controls and how ISO 32000-1 PDF specifies interactive <code>/AcroForm</code> widgets.</p>
<hr />
<h2>Why Word and Google Docs Strip Form Controls on PDF Export</h2>
<p>Inside a <code>.docx</code> archive (<code>word/document.xml</code>), Microsoft Word represents interactive fields using Structured Document Tags (<code>&lt;w:sdt&gt;</code> with <code>&lt;w:text/&gt;</code>, <code>&lt;w:checkbox&gt;</code>, or <code>&lt;w:dropDownList&gt;</code>) or legacy field codes (<code>FORMTEXT</code>, <code>FORMCHECKBOX</code>).</p>
<p>When Word's built-in PDF writer (or Google Docs' Skia PDF export pipeline) exports the document to PDF, it renders the page purely as visual drawing commands inside each page's content stream (<code>BT ... Tj ET</code> text operators and vector path rectangles). It does <strong>not</strong> emit a PDF <code>/AcroForm</code> root dictionary or <code>/Subtype /Widget</code> annotation objects into the page <code>/Annots</code> array.</p>
<p>To make a PDF genuinely fillable across Adobe Reader, Chrome PDFium, Edge, Firefox pdf.js, and Apple Preview, the PDF itself must contain real ISO 32000 interactive field dictionaries:</p>
<pre><code class="language-text">12 0 obj
&lt;&lt;
  /Type /Annot
  /Subtype /Widget
  /FT /Tx                         % Text field (/Btn for checkbox/radio, /Ch for dropdown, /Sig for signature)
  /T (employee_full_name)         % Unique field identifier
  /Rect [72 640 310 662]          % Exact PDF point coordinates (bottom-left origin)
  /DA (/Helv 11 Tf 0 g)           % Default appearance string
  /MK &lt;&lt; /BC [0.85 0.87 0.91] &gt;&gt;  % Subtle border color
&gt;&gt;
endobj
</code></pre>
<p>Because Word and Google Docs omit these widget objects entirely, the resulting PDF looks right visually, yet contains zero interactive inputs.</p>
<hr />
<h2>Three Common Traps When Adding Fillable Fields After Exporting From Word</h2>
<p>When people realize Word cannot export interactive PDF forms, they typically hit three real-world pitfalls:</p>
<h3>1. Duplicate Checkbox Names Toggling Together</h3>
<p>In ISO 32000 PDFs, checkboxes (<code>/FT /Btn</code>) that share the same <code>/T</code> field name belong to the same logical group. Checking "Yes" on row 1 accidentally checks row 4 and row 9 because the editor duplicated the widget without generating unique field names. Every independent checkbox must have a distinct <code>/T</code> identifier, while mutually exclusive radio buttons must share a parent <code>/FT /Btn</code> field with the <code>/Radio</code> bit (<code>1 &lt;&lt; 15</code>) set and distinct <code>/AP /N</code> appearance state names.</p>
<h3>2. Missing Appearance Streams Across macOS Preview and Chrome</h3>
<p>Older form builders rely on setting <code>/NeedAppearances true</code> in the root <code>/AcroForm</code> dictionary and letting each PDF viewer guess how to draw text inside a box. That flag was deprecated in PDF 2.0 and causes notorious cross-viewer bugs: text looks fine in Apple Preview, then appears blank when opened in Adobe Acrobat Reader or printed. Generating explicit <code>/AP /N</code> normal appearance streams at save time guarantees identical rendering everywhere.</p>
<h3>3. Uploading Sensitive HR, Legal, or Tax Forms to Cloud Converters</h3>
<p>Most free "convert Word to fillable PDF" web tools upload your document to a remote server to process it. For W-9s, employee direct deposit authorizations, patient intake packets, or NDAs, uploading client documents to an unverified cloud backend creates unnecessary data exposure.</p>
<hr />
<h2>The Reliable 3-Step Workflow: Word or Google Docs to Universal Fillable PDF</h2>
<p>Watch the 45-second browser-local walkthrough first: <a href="https://www.youtube.com/watch?v=NzBc8eaV198">https://www.youtube.com/watch?v=NzBc8eaV198</a></p>
<p>The cleanest engineering approach separates <strong>visual layout</strong> (which Word and Google Docs excel at) from <strong>interactive AcroForm layer construction</strong> (which belongs in the PDF itself):</p>
<h3>Step 1: Lock Your Visual Layout First</h3>
<p>Design your form, tables, headers, logos, and checkbox labels cleanly in Microsoft Word or Google Docs. Leave clear blank lines or open rectangular boxes where recipients should type, check, or sign. Export the finished layout as a standard PDF:</p>
<ul>
<li><strong>Microsoft Word:</strong> <code>File &gt; Save As &gt; PDF</code> (or <code>File &gt; Export &gt; Create PDF/XPS</code>)</li>
<li><strong>Google Docs:</strong> <code>File &gt; Download &gt; PDF Document (.pdf)</code></li>
</ul>
<p>Your margins, pagination, and fonts are now locked permanently across Windows, macOS, and mobile viewers.</p>
<h3>Step 2: Add ISO 32000 AcroForm Fields Locally in Your Browser</h3>
<p>Open your exported PDF in a browser-local AcroForm editor such as <a href="https://www.pdffields.com/fillable-pdf?utm_source=dev_article&amp;utm_medium=referral&amp;utm_campaign=word_to_fillable">PDFFields Fillable PDF Creator</a>. Because parsing and PDF writing run locally in browser memory using client-side JavaScript (<code>pdf.js</code> for rendering and <code>pdf-lib</code> for low-level object manipulation), your document never leaves your machine by default.</p>
<p>From there:</p>
<ol>
<li>Run <strong>Auto-Detect Fields</strong> to scan underlines, table cells, and box primitives and convert them into interactive AcroForm fields in one click.</li>
<li>Drop or fine-tune <strong>Text inputs</strong>, <strong>Multiline areas</strong>, <strong>Checkboxes</strong> (automatically assigned unique <code>/T</code> names so checking one never toggles another), <strong>Radio groups</strong>, <strong>Dropdowns</strong>, <strong>Date fields</strong>, and <strong>Signature blocks</strong>.</li>
<li>Drag fields into exact alignment with snap guides and test typing right inside the canvas before exporting.</li>
</ol>
<h3>Step 3: Export a Universal Fillable PDF or Publish a Hosted Fillable Link</h3>
<p>Save your finished interactive PDF with explicit appearance streams so recipients can fill and save it in Adobe Reader, Chrome, Edge, Safari, or Apple Preview without installing anything.</p>
<p>If your recipients are filling out the form on phones or tablets where desktop PDF viewers feel clunky, you can also publish a hosted web form link so respondents complete the exact fields in any mobile browser and receive the completed PDF cleanly.</p>
<hr />
<h2>Bonus: Locking Completed Forms With True PDF Flattening</h2>
<p>Once a recipient returns a filled and signed PDF contract, application, or tax form, its <code>/AcroForm</code> fields are still editable by anyone who opens the file.</p>
<p>Before archiving or filing a completed document, <strong>flatten the PDF</strong>. True flattening draws every filled <code>/V</code> field value and signature appearance stream directly onto the underlying page content stream and removes the interactive <code>/Widget</code> annotations and <code>/AcroForm</code> dictionary. The text remains crisp and searchable, while the form fields can no longer be silently edited downstream.</p>
<p>You can fill, sign, whiteout, and flatten completed PDFs locally at <a href="https://www.pdffields.com/fill-and-sign?utm_source=dev_article&amp;utm_medium=referral&amp;utm_campaign=word_to_fillable">PDFFields Fill, Sign &amp; Flatten</a>.</p>
<hr />
<h2>Try It on Your Own Exported Word PDF</h2>
<p>You do not need a $239.88/year Adobe Acrobat Pro contract just to turn a Word or Google Docs template into a clean fillable PDF.</p>
<p>At <a href="https://www.pdffields.com/fillable-pdf?utm_source=dev_article&amp;utm_medium=referral&amp;utm_campaign=word_to_fillable">PDFFields</a>, you can open your own exported PDF locally in the browser, run auto-detection, place and resize every AcroForm field, and verify the result free before paying. When you are ready for clean, unwatermarked exports, plans are transparent flat subscriptions ($4.99/mo Solo or $39/yr Solo; $19/mo Pro or $119/yr Pro) with 1-click cancellation and a 14-day full refund guarantee.</p>
]]></content:encoded></item><item><title><![CDATA[Inside QuickBooks .QBO Files: OFX 1.02 SGML, INTU.BID Codes, and Deterministic FITIDs for US Bank PDFs]]></title><description><![CDATA[If you have ever tried converting archived PDF bank or credit card statements into a QuickBooks Web Connect (.QBO) file, you have probably hit one of…]]></description><link>https://pdffields.hashnode.dev/inside-quickbooks-qbo-files-ofx-1-02-sgml-intu-bid-codes-and-deterministic-fitids-for-us-bank-pdfs</link><guid isPermaLink="true">https://pdffields.hashnode.dev/inside-quickbooks-qbo-files-ofx-1-02-sgml-intu-bid-codes-and-deterministic-fitids-for-us-bank-pdfs</guid><category><![CDATA[TypeScript]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[fintech]]></category><category><![CDATA[pdf]]></category><dc:creator><![CDATA[Ezra Winslow]]></dc:creator><pubDate>Sun, 29 Nov 2026 13:17:16 GMT</pubDate><content:encoded><![CDATA[<p>If you have ever tried converting archived PDF bank or credit card statements into a QuickBooks Web Connect (<code>.QBO</code>) file, you have probably hit one of Intuit's opaque import errors:</p>
<ul>
<li><em>"QuickBooks is unable to verify the Financial Institution Information for this download."</em></li>
<li><em>"QuickBooks cannot read the file you uploaded."</em></li>
<li>Duplicate transactions showing up every time a multi-month statement overlaps by a day or two.</li>
</ul>
<p>A <code>.QBO</code> file is not XML, and it is not generic OFX 2.x. QuickBooks Desktop and QuickBooks Online expect <strong>SGML-based OFX 1.02</strong> with a strict header block, CRLF (<code>\r\n</code>) line endings, an Intuit-recognized <code>&lt;INTU.BID&gt;</code> financial institution code, and different statement wrappers for bank accounts versus credit cards.</p>
<p>Here is the exact structure we implemented client-side in TypeScript for <a href="https://www.pdffields.com/bank-statement-to-excel">PDFFields</a> so bank statements never have to be uploaded to a cloud converter.</p>
<hr />
<h2>1. The OFX 1.02 Header and Sign-On Block</h2>
<p>QuickBooks parses <code>.QBO</code> files using an older SGML header followed by a blank line and the <code>&lt;OFX&gt;</code> root element. Notice that leaf tags do <strong>not</strong> have closing tags (<code>&lt;CODE&gt;0</code>, not <code>&lt;CODE&gt;0&lt;/CODE&gt;</code>), while container tags do (<code>&lt;/STATUS&gt;</code>).</p>
<pre><code class="language-text">OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE

&lt;OFX&gt;
&lt;SIGNONMSGSRSV1&gt;
&lt;SONRS&gt;
&lt;STATUS&gt;
&lt;CODE&gt;0
&lt;SEVERITY&gt;INFO
&lt;/STATUS&gt;
&lt;DTSERVER&gt;20261129120000
&lt;LANGUAGE&gt;ENG
&lt;INTU.BID&gt;3000
&lt;/SONRS&gt;
&lt;/SIGNONMSGSRSV1&gt;
</code></pre>
<p>Two details that commonly break QuickBooks Desktop imports:</p>
<ol>
<li><strong>Line endings</strong>: Use <code>\r\n</code> (CRLF), not bare <code>\n</code>.</li>
<li><strong>USASCII / Charset 1252 sanitization</strong>: Strip non-ASCII characters (smart quotes, non-breaking spaces, em dashes) and XML/SGML control characters (<code>&lt;</code>, <code>&gt;</code>, <code>&amp;</code>) from <code>&lt;NAME&gt;</code> and <code>&lt;MEMO&gt;</code> before writing the file. QuickBooks also enforces a <strong>32-character cap on <code>&lt;NAME&gt;</code></strong> and <strong>255 characters on <code>&lt;MEMO&gt;</code></strong>.</li>
</ol>
<hr />
<h2>2. INTU.BID Reference Table for Major US Banks</h2>
<p>QuickBooks validates <code>&lt;INTU.BID&gt;</code> against Intuit's internal financial institution directory (<code>fidir.txt</code>). If you pass an unlisted ID, or a bank ID that does not support Web Connect for the chosen account type, QuickBooks rejects the entire file before showing a single transaction.</p>
<p>Here are the <code>INTU.BID</code> and ABA routing <code>BANKID</code> defaults we use across our US bank statement converters:</p>
<table>
<thead>
<tr>
<th>Institution</th>
<th><code>&lt;INTU.BID&gt;</code></th>
<th>Default <code>&lt;BANKID&gt;</code></th>
<th>Statement Wrapper</th>
<th>Browser-Local Converter</th>
</tr>
</thead>
<tbody><tr>
<td>Wells Fargo (Universal QuickBooks default)</td>
<td><code>3000</code></td>
<td><code>121000248</code></td>
<td><code>&lt;BANKMSGSRSV1&gt;</code></td>
<td><a href="https://www.pdffields.com/wells-fargo-statement-to-qbo">Wells Fargo PDF to .QBO</a></td>
</tr>
<tr>
<td>Chase</td>
<td><code>10898</code></td>
<td><code>021000021</code></td>
<td><code>&lt;BANKMSGSRSV1&gt;</code> or <code>&lt;CREDITCARDMSGSRSV1&gt;</code></td>
<td><a href="https://www.pdffields.com/chase-statement-to-qbo">Chase PDF to .QBO</a></td>
</tr>
<tr>
<td>Bank of America</td>
<td><code>5959</code></td>
<td><code>026009593</code></td>
<td><code>&lt;BANKMSGSRSV1&gt;</code> or <code>&lt;CREDITCARDMSGSRSV1&gt;</code></td>
<td><a href="https://www.pdffields.com/bank-of-america-statement-to-qbo">Bank of America PDF to .QBO</a></td>
</tr>
<tr>
<td>American Express</td>
<td><code>3101</code></td>
<td><em>(omitted for CC)</em></td>
<td><code>&lt;CREDITCARDMSGSRSV1&gt;</code></td>
<td><a href="https://www.pdffields.com/amex-statement-to-qbo">Amex PDF to .QBO</a></td>
</tr>
<tr>
<td>Capital One</td>
<td><code>1009</code></td>
<td><code>051405515</code></td>
<td><code>&lt;BANKMSGSRSV1&gt;</code> or <code>&lt;CREDITCARDMSGSRSV1&gt;</code></td>
<td><a href="https://www.pdffields.com/pdf-to-qbo">Generic PDF to .QBO</a></td>
</tr>
<tr>
<td>Citibank</td>
<td><code>24909</code></td>
<td><code>021000089</code></td>
<td><code>&lt;BANKMSGSRSV1&gt;</code> or <code>&lt;CREDITCARDMSGSRSV1&gt;</code></td>
<td><a href="https://www.pdffields.com/pdf-to-qbo">Generic PDF to .QBO</a></td>
</tr>
<tr>
<td>U.S. Bank</td>
<td><code>6812</code></td>
<td><code>091000022</code></td>
<td><code>&lt;BANKMSGSRSV1&gt;</code></td>
<td><a href="https://www.pdffields.com/pdf-to-qbo">Generic PDF to .QBO</a></td>
</tr>
<tr>
<td>PNC Bank</td>
<td><code>6209</code></td>
<td><code>043000096</code></td>
<td><code>&lt;BANKMSGSRSV1&gt;</code></td>
<td><a href="https://www.pdffields.com/pdf-to-qbo">Generic PDF to .QBO</a></td>
</tr>
</tbody></table>
<p>When a smaller regional bank or credit union does not have an active Intuit Web Connect <code>INTU.BID</code>, using <code>3000</code> (Wells Fargo) is a widely used fallback because QuickBooks lets you map the imported feed to any local register account inside your Chart of Accounts after upload.</p>
<hr />
<h2>3. Checking/Savings vs. Credit Card Wrappers</h2>
<p>A subtle failure mode happens when you convert an American Express or Chase Sapphire PDF statement using a <code>&lt;BANKMSGSRSV1&gt;</code> checking wrapper. QuickBooks will refuse to attach the file to a Credit Card register in your Chart of Accounts.</p>
<p>Credit card <code>.QBO</code> files must use <code>&lt;CREDITCARDMSGSRSV1&gt;</code>, <code>&lt;CCSTMTTRNRS&gt;</code>, <code>&lt;CCSTMTRS&gt;</code>, and <code>&lt;CCACCTFROM&gt;</code> (with no <code>&lt;BANKID&gt;</code> or <code>&lt;ACCTTYPE&gt;</code>):</p>
<pre><code class="language-text">&lt;CREDITCARDMSGSRSV1&gt;
&lt;CCSTMTTRNRS&gt;
&lt;TRNUID&gt;1001
&lt;STATUS&gt;
&lt;CODE&gt;0
&lt;SEVERITY&gt;INFO
&lt;/STATUS&gt;
&lt;CCSTMTRS&gt;
&lt;CURDEF&gt;USD
&lt;CCACCTFROM&gt;
&lt;ACCTID&gt;4821
&lt;/CCACCTFROM&gt;
&lt;BANKTRANLIST&gt;
&lt;DTSTART&gt;20261001120000
&lt;DTEND&gt;20261031120000
&lt;STMTTRN&gt;
&lt;TRNTYPE&gt;DEBIT
&lt;DTPOSTED&gt;20261004120000
&lt;TRNAMT&gt;-612.40
&lt;FITID&gt;20261004-61240-a1f9c204-0
&lt;NAME&gt;AWS CLOUD SERVICES US-EAST
&lt;/STMTTRN&gt;
&lt;/BANKTRANLIST&gt;
&lt;LEDGERBAL&gt;
&lt;BALAMT&gt;-14643.62
&lt;DTASOF&gt;20261031120000
&lt;/LEDGERBAL&gt;
&lt;/CCSTMTRS&gt;
&lt;/CCSTMTTRNRS&gt;
&lt;/CREDITCARDMSGSRSV1&gt;
</code></pre>
<p>By contrast, checking and savings statements wrap the transaction list in <code>&lt;BANKMSGSRSV1&gt;</code> -&gt; <code>&lt;STMTTRNRS&gt;</code> -&gt; <code>&lt;STMTRS&gt;</code> -&gt; <code>&lt;BANKACCTFROM&gt;</code> (containing <code>&lt;BANKID&gt;</code>, <code>&lt;ACCTID&gt;</code>, and <code>&lt;ACCTTYPE&gt;CHECKING</code> or <code>SAVINGS</code>).</p>
<p>Also pay close attention to <strong>sign convention</strong>: in OFX, money leaving your account (a checking withdrawal or a credit card purchase) must have a negative <code>&lt;TRNAMT&gt;</code> (<code>-612.40</code>) and <code>&lt;TRNTYPE&gt;DEBIT</code>. Deposits, refunds, and credit card payments are positive (<code>+500.00</code>) with <code>&lt;TRNTYPE&gt;CREDIT</code>. Many credit card PDFs print purchases as positive numbers and payments with a minus sign or <code>CR</code> suffix, so you need to normalize signs explicitly during PDF extraction.</p>
<hr />
<h2>4. Deterministic FITIDs and Multi-Month Overlap Deduplication</h2>
<p>QuickBooks uses <code>&lt;FITID&gt;</code> (Financial Institution Transaction ID) to prevent duplicate entries if you accidentally upload the same statement twice.</p>
<p>If your generator emits random UUIDs or plain sequential integers (<code>1</code>, <code>2</code>, <code>3</code>), re-exporting or overlapping two monthly statements will create duplicates in QuickBooks. Instead, compute a deterministic <code>&lt;FITID&gt;</code> from <code>(dtPosted, amountCents, normalizedDescriptionHash, sameDayOccurrenceIndex)</code>.</p>
<p>That handles two real-world edge cases cleanly:</p>
<ol>
<li><strong>Same-day legitimate repeats</strong>: Buying two <code>$4.75</code> coffees or running two identical <code>$150.00</code> wire fees on the same day inside one statement gets occurrence indices <code>-0</code> and <code>-1</code>, so both transactions survive.</li>
<li><strong>Cross-statement boundary overlaps</strong>: When merging 2 to 12 monthly PDFs for year-end reconciliation, if a transaction from <code>10/31</code> appears at the bottom of October's PDF and again at the top of November's PDF, both share the same <code>(date, amount, normalizedDescription)</code> key across different source files, allowing automated deduplication before the <code>.QBO</code> or multi-sheet <code>.xlsx</code> is written.</li>
</ol>
<hr />
<h2>5. Catching Parsing Errors Before Import: Running-Balance Verification</h2>
<p>Before generating <code>.QBO</code> or Excel output from a PDF bank statement, the single highest-leverage integrity check is verifying the statement's own running balance column:</p>
<pre><code class="language-ts">// For each consecutive pair of transactions with a printed Balance column:
const expected = round2(prevBalance + curr.amount);
const diff = round2(curr.balance - expected);
const matches = Math.abs(diff) &lt;= 0.01;
</code></pre>
<p>If a PDF statement lists transactions in reverse chronological order (newest first), check <code>prevBalance - prev.amount === curr.balance</code> as well and auto-detect the sort direction. When <code>17/17</code> consecutive rows verify to the penny, you know no line item was dropped, merged, or mis-signed by the PDF text extractor.</p>
<hr />
<h2>Try It Locally in Your Browser</h2>
<p>You can test the full client-side PDF table parser, running-balance verifier, and <code>.QBO</code> / <code>.xlsx</code> generator on a built-in 2-page sample bank statement, a 3-month quarterly pack, or your own local PDF at <a href="https://www.pdffields.com/bank-statement-to-excel">PDFFields Bank Statement Converter</a>. Everything runs locally in your browser with <code>pdf.js</code> and TypeScript so raw bank statement bytes never leave your device.</p>
<p>30-second studio walkthrough on YouTube: <a href="https://www.youtube.com/watch?v=kTMUi-qRZtc">https://www.youtube.com/watch?v=kTMUi-qRZtc</a></p>
]]></content:encoded></item><item><title><![CDATA[How to Build and Extract Interactive AcroForm PDFs Locally in the Browser with pdf-lib and pdf.js]]></title><description><![CDATA[Most web apps that "make a PDF fillable" work by uploading your contract, W-9, or tenant application to a remote server, running a desktop PDF library in a…]]></description><link>https://pdffields.hashnode.dev/how-to-build-and-extract-interactive-acroform-pdfs-locally-in-the-browser-with-pdf-lib-and-pdf-js</link><guid isPermaLink="true">https://pdffields.hashnode.dev/how-to-build-and-extract-interactive-acroform-pdfs-locally-in-the-browser-with-pdf-lib-and-pdf-js</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[pdf]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Ezra Winslow]]></dc:creator><pubDate>Sun, 29 Nov 2026 09:14:24 GMT</pubDate><content:encoded><![CDATA[<p>Most web apps that "make a PDF fillable" work by uploading your contract, W-9, or tenant application to a remote server, running a desktop PDF library in a worker container, and handing back a download link. For HR forms, tax packets, and legal agreements, uploading the document in the first place is often a non-starter.</p>
<p>When we built the browser-local <a href="https://www.pdffields.com/fillable-pdf">PDFFields Fillable PDF Builder</a>, our goal was to keep the entire AcroForm pipeline (inspecting existing fields, drawing new text/checkbox/radio/dropdown widgets, flattening filled values, and extracting populated AcroForm data into Excel) running 100% client-side with <code>pdf.js</code> and <code>pdf-lib</code>.</p>
<p>Here are the four concrete engineering problems we hit and how we solved them.</p>
<h2>1. Bridging Top-Left Browser Coordinates and Bottom-Left PDF Points</h2>
<p>Browser canvases and pointer events put <code>(0, 0)</code> at the <strong>top-left</strong> in CSS pixels. PDF pages put <code>(0, 0)</code> at the <strong>bottom-left</strong> in typographic points (<code>1 pt = 1/72 inch</code>, so US Letter is <code>612 x 792 pt</code>).</p>
<p>If you store widget positions in screen pixels, zooming the viewport or rendering at different devicePixelRatio values breaks every box. Instead, we keep every field normalized in <code>[0..1]</code> top-left coordinates in the editor state and convert only at the <code>pdf-lib</code> boundary:</p>
<pre><code class="language-ts">export interface NormalizedRect {
  x: number; // 0..1 from left edge
  y: number; // 0..1 from top edge
  w: number; // 0..1 width fraction
  h: number; // 0..1 height fraction
}

export function normalizedToPdfPoints(
  rect: NormalizedRect,
  pageWidthPts: number,
  pageHeightPts: number
) {
  const x = rect.x * pageWidthPts;
  const width = rect.w * pageWidthPts;
  const height = rect.h * pageHeightPts;
  // Flip Y axis: PDF origin is bottom-left, so subtract (top + height) from page height
  const y = pageHeightPts - (rect.y + rect.h) * pageHeightPts;
  return { x, y, width, height };
}

export function pdfPointsToNormalized(
  pdfRect: { x: number; y: number; width: number; height: number },
  pageWidthPts: number,
  pageHeightPts: number
): NormalizedRect {
  return {
    x: pdfRect.x / pageWidthPts,
    y: 1 - (pdfRect.y + pdfRect.height) / pageHeightPts,
    w: pdfRect.width / pageWidthPts,
    h: pdfRect.height / pageHeightPts
  };
}
</code></pre>
<p>Keeping a deterministic round-trip (<code>pdfPointsToNormalized(normalizedToPdfPoints(r)) === r</code>) also makes it straightforward to inspect PDFs that already contain AcroForm widgets, edit them on the canvas, and write them back cleanly without drifting a few points every save.</p>
<h2>2. Inspecting Existing AcroForm Widgets Across Multi-Page PDFs</h2>
<p>Many PDFs already have broken or half-finished interactive forms. In <code>pdf-lib</code>, a single <code>PDFField</code> can own multiple widget annotations (for example, radio button options placed across different coordinates or pages), and each widget points back to its parent page through an indirect object reference (<code>widget.P()</code>).</p>
<p>To map every existing widget cleanly onto the right canvas page without scanning every page's <code>/Annots</code> array repeatedly, we build a reference lookup table once per document:</p>
<pre><code class="language-ts">const pages = pdfDoc.getPages();
const pageRefToIndex = new Map&lt;string, number&gt;();
pages.forEach((p, idx) =&gt; {
  pageRefToIndex.set(p.ref.toString(), idx);
});

const form = pdfDoc.getForm();
for (const pdfField of form.getFields()) {
  const widgets = pdfField.acroField.getWidgets();
  widgets.forEach((widget) =&gt; {
    const pRef = widget.P();
    const pageIndex = pRef &amp;&amp; pageRefToIndex.has(pRef.toString())
      ? pageRefToIndex.get(pRef.toString())!
      : 0;
    const rect = widget.getRectangle();
    // Convert rect -&gt; NormalizedRect for pageIndex
  });
}
</code></pre>
<p>We also clamp font size proportionally to widget height (<code>Math.min(baseFontSize, Math.max(8, rect.height * 0.62))</code>) when synthesizing dropdowns and single-line text boxes. Without that clamp, an <code>11pt</code> default font inside a tight <code>14pt</code> tax form box clips vertically in macOS Preview and Chrome's built-in PDF viewer.</p>
<h2>3. Keeping Radio Groups, Checkboxes, and Duplicate Names Valid</h2>
<p>Two subtle bugs show up immediately in Acrobat Reader and Apple Preview if you generate AcroForm dictionaries naively:</p>
<ol>
<li><strong>Duplicate field names link widgets together:</strong> In PDF AcroForm specs, two text fields given the same name (<code>"date"</code>) become linked mirrors of the same value. Typing into the tenant signature date silently overwrites the landlord date on page 4. We normalize and deduplicate every non-radio field name (<code>date</code>, <code>date_2</code>, <code>date_3</code>) via <code>makeUniqueFieldName</code>.</li>
<li><strong>Radio buttons are the opposite:</strong> All options in a mutually exclusive choice (<code>Yes</code> / <code>No</code>, <code>Individual</code> / <code>LLC</code> / <code>S-Corp</code>) MUST share one <code>PDFRadioGroup</code> with distinct export values (<code>optValue</code>), added via <code>group.addOptionToPage(optValue, page, rect)</code>.</li>
</ol>
<h2>4. Why Filled AcroForm PDFs Break Standard PDF-to-Excel Converters</h2>
<p>Here is a bug we caught directly from real user files in our <a href="https://www.pdffields.com/pdf-to-excel">PDF to Excel converter</a>:</p>
<p>Someone drops a filled-in 7-page interactive form PDF (for example an IRS W-9, vendor onboarding packet, or insurance application with hundreds of AcroForm fields) expecting all the typed answers in Excel. Standard text-layer extractors call <code>page.getTextContent()</code>, which reads static page labels (<code>"Name"</code>, <code>"TIN"</code>, <code>"Address"</code>) and completely misses widget field values stored in the annotation dictionary!</p>
<p>In <code>pdf.js</code>, filled widget values live inside <code>await page.getAnnotations()</code> with <code>subtype === 'Widget'</code>. Walking those annotations across every page, filtering out unchecked boxes (<code>fieldValue === 'Off'</code>) and unselected radio widgets, deduplicating per <code>(pageIndex, fieldName, value)</code>, and sorting top-to-bottom by PDF <code>rect[3]</code> (descending Y) produces a clean structured <strong><code>Form Fields</code></strong> worksheet (<code>Page | Field Name | Value</code>) right alongside any static tables detected on the page:</p>
<pre><code class="language-ts">for (const annot of annotations) {
  if (annot.subtype !== 'Widget') continue;
  const fieldName = (annot.fieldName || annot.alternativeText || '').trim();
  if (!fieldName) continue;

  if (annot.fieldType === 'Btn') {
    const val = String(annot.fieldValue ?? '').trim();
    if (!val || val.toLowerCase() === 'off') continue;
    if (annot.radioButton &amp;&amp; annot.buttonValue &amp;&amp; String(annot.buttonValue) !== val) continue;
    // Checked box or selected radio option
  } else {
    // Text or Choice widget value
  }
}
</code></pre>
<h2>Try It Locally (Network Tab Open)</h2>
<p>You can test the full AcroForm builder, Fill &amp; Sign flattening, and AcroForm-to-Excel extraction right in your browser without creating an account:</p>
<ul>
<li><a href="https://www.pdffields.com/fillable-pdf">Fillable PDF Builder (AcroForm editor)</a></li>
<li><a href="https://www.pdffields.com/fill-and-sign">Fill and Sign PDF locally</a></li>
<li><a href="https://www.pdffields.com/pdf-to-excel">PDF to Excel &amp; Filled AcroForm Extractor</a></li>
<li><a href="https://www.pdffields.com/adobe-acrobat-alternative">PDFFields vs. Adobe Acrobat comparison</a></li>
</ul>
<p>Open DevTools Network before dropping a file and you will see zero PDF bytes leave your browser.</p>
]]></content:encoded></item><item><title><![CDATA[Converting 12 Months of PDF Bank Statements to QuickBooks .QBO Locally in the Browser]]></title><description><![CDATA[Every December, bookkeepers, CPAs, and small business owners hit the same wall: QuickBooks bank feeds only pull the last 90 days, or a client hands over 12…]]></description><link>https://pdffields.hashnode.dev/converting-12-months-of-pdf-bank-statements-to-quickbooks-qbo-locally-in-the-browser</link><guid isPermaLink="true">https://pdffields.hashnode.dev/converting-12-months-of-pdf-bank-statements-to-quickbooks-qbo-locally-in-the-browser</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[fintech]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Ezra Winslow]]></dc:creator><pubDate>Sun, 29 Nov 2026 08:27:35 GMT</pubDate><content:encoded><![CDATA[<p>Every December, bookkeepers, CPAs, and small business owners hit the same wall: QuickBooks bank feeds only pull the last 90 days, or a client hands over 12 monthly Chase, Bank of America, Wells Fargo, or American Express PDF statements right before year-end close.</p>
<p>Most online PDF-to-QBO converters require uploading raw bank statements (complete with account numbers, payroll deposits, and vendor payments) to a third-party server and charge $30 to $60 per month. While building <a href="https://www.pdffields.com/">PDFFields</a>, I built a 100% browser-local TypeScript pipeline using <code>pdf.js</code> that extracts multi-page transaction tables, verifies running-balance math, deduplicates overlapping statement dates across 12 monthly PDFs, and emits QuickBooks Web Connect (<code>.QBO</code>) files without transmitting a single byte off the user's machine.</p>
<p>Here are the subtle parts of the OFX 1.02 / <code>.QBO</code> format and US bank statement parsing that trip up most implementations.</p>
<h2>1. Checking/Savings vs Credit Card <code>.QBO</code> wrappers</h2>
<p>A <code>.QBO</code> file is not XML. QuickBooks Online and QuickBooks Desktop expect <strong>OFX 1.02 SGML</strong> with an unclosed-tag header block (<code>OFXHEADER:100</code>, <code>DATA:OFXSGML</code>, <code>VERSION:102</code>) plus an Intuit-specific <code>&lt;INTU.BID&gt;</code> tag inside <code>&lt;SONRS&gt;</code>.</p>
<p>One of the most common QuickBooks import errors (<code>OL-221</code> or routing a credit card into a checking register) comes from using <code>&lt;BANKMSGSRSV1&gt;</code> for credit card statements. Credit card accounts require <code>&lt;CREDITCARDMSGSRSV1&gt;</code>, <code>&lt;CCSTMTTRNRS&gt;</code>, <code>&lt;CCSTMTRS&gt;</code>, and <code>&lt;CCACCTFROM&gt;</code> (with no <code>&lt;BANKID&gt;</code> routing number):</p>
<pre><code class="language-ts">const statementBlock =
  accountType === 'CREDITCARD'
    ? [
        '&lt;CREDITCARDMSGSRSV1&gt;',
        '&lt;CCSTMTTRNRS&gt;',
        '&lt;TRNUID&gt;1001',
        '&lt;STATUS&gt;&lt;CODE&gt;0&lt;SEVERITY&gt;INFO&lt;/STATUS&gt;',
        '&lt;CCSTMTRS&gt;',
        `&lt;CURDEF&gt;${currency}`,
        '&lt;CCACCTFROM&gt;',
        `&lt;ACCTID&gt;${accountId}`,
        '&lt;/CCACCTFROM&gt;',
        '&lt;BANKTRANLIST&gt;',
        `&lt;DTSTART&gt;${dtStart}120000`,
        `&lt;DTEND&gt;${dtEnd}120000`,
        ...txBlocks,
        '&lt;/BANKTRANLIST&gt;',
        '&lt;LEDGERBAL&gt;',
        `&lt;BALAMT&gt;${ledgerBal.toFixed(2)}`,
        `&lt;DTASOF&gt;${dtEnd}120000`,
        '&lt;/LEDGERBAL&gt;',
        '&lt;/CCSTMTRS&gt;',
        '&lt;/CCSTMTTRNRS&gt;',
        '&lt;/CREDITCARDMSGSRSV1&gt;'
      ]
    : [
        '&lt;BANKMSGSRSV1&gt;',
        '&lt;STMTTRNRS&gt;',
        '&lt;TRNUID&gt;1001',
        '&lt;STATUS&gt;&lt;CODE&gt;0&lt;SEVERITY&gt;INFO&lt;/STATUS&gt;',
        '&lt;STMTRS&gt;',
        `&lt;CURDEF&gt;${currency}`,
        '&lt;BANKACCTFROM&gt;',
        `&lt;BANKID&gt;${bankId}`,
        `&lt;ACCTID&gt;${accountId}`,
        `&lt;ACCTTYPE&gt;${accountType}`,
        '&lt;/BANKACCTFROM&gt;',
        '&lt;BANKTRANLIST&gt;',
        `&lt;DTSTART&gt;${dtStart}120000`,
        `&lt;DTEND&gt;${dtEnd}120000`,
        ...txBlocks,
        '&lt;/BANKTRANLIST&gt;',
        '&lt;LEDGERBAL&gt;',
        `&lt;BALAMT&gt;${ledgerBal.toFixed(2)}`,
        `&lt;DTASOF&gt;${dtEnd}120000`,
        '&lt;/LEDGERBAL&gt;',
        '&lt;/STMTRS&gt;',
        '&lt;/STMTTRNRS&gt;',
        '&lt;/BANKMSGSRSV1&gt;'
      ];
</code></pre>
<p>And if a user's local credit union is not in Intuit's current FID directory (<code>fidir.txt</code>), setting <code>&lt;INTU.BID&gt;3000</code> (Wells Fargo) is widely accepted by QuickBooks Desktop and QuickBooks Online during manual register mapping. We include 8 major US bank presets (<code>3000</code> Wells Fargo, <code>10898</code> Chase, <code>5959</code> Bank of America, <code>1009</code> Capital One, <code>24909</code> Citibank, <code>6812</code> U.S. Bank, <code>6209</code> PNC, <code>3101</code> American Express).</p>
<h2>2. Deterministic <code>FITID</code> generation to prevent duplicate imports</h2>
<p>QuickBooks uses each transaction's <code>&lt;FITID&gt;</code> (Financial Institution Transaction ID) to detect duplicates when overlapping date ranges are imported. Random UUIDs or simple sequential integers (<code>1, 2, 3</code>) break duplicate detection if you re-export or combine an overlapping statement.</p>
<p>Instead, we compute a deterministic FNV-1a hash from the normalized posted date, fixed-2-decimal signed amount, payee description, and intra-batch occurrence index:</p>
<pre><code class="language-ts">function stableFitId(row: BankLedgerRow, index: number, dtPosted: string): string {
  const input = `${dtPosted}|${row.amount.toFixed(2)}|${row.description}|${index}`;
  let h = 2166136261;
  for (let i = 0; i &lt; input.length; i++) {
    h ^= input.charCodeAt(i);
    h = Math.imul(h, 16777619);
  }
  return `${dtPosted}${(h &gt;&gt;&gt; 0).toString(16).padStart(8, '0')}`;
}
</code></pre>
<h2>3. Running-balance reconciliation catches PDF parsing errors automatically</h2>
<p>Coordinate-based PDF table parsing works well across digital bank statements, but silently missing one line item or flipping a debit sign is catastrophic in accounting. Whenever a statement includes a <code>Running Balance</code> or <code>Ending Balance</code> column, we check arithmetic continuity across every consecutive pair of rows:</p>
<p><code>previousBalance + currentRow.amount === currentRow.balance</code> (within <code>$0.02</code> rounding tolerance).</p>
<p>There is one important twist: some US bank statements list transactions oldest-first (ascending), while others list newest-first (descending). Our <code>reconcileBankLedger</code> pass tests <strong>both</strong> directions automatically and picks the order with the highest verified step ratio, then flags any row whose balance delta exceeds <code>$0.02</code> before the user ever downloads the <code>.QBO</code> or <code>.xlsx</code> file.</p>
<h2>4. Merging 12 monthly PDF statements for year-end close</h2>
<p>Single-month conversion is only half the workflow in December. Real clients send 12 separate monthly PDFs (<code>jan-2026.pdf</code> through <code>dec-2026.pdf</code>), often with boundary transactions repeated on the last day of month <code>N</code> and the first day of month <code>N+1</code>, and often using <code>MM/DD</code> dates with no year printed on transaction rows.</p>
<p>In our multi-PDF batch merger (<code>batchStatements.ts</code>), we:</p>
<ol>
<li>Infer the statement year from each PDF's filename or header period when transaction rows only print <code>MM/DD</code>.</li>
<li>Reconcile each monthly PDF independently so you see a per-statement green check or mismatch badge.</li>
<li>Sort all rows chronologically across all files (<code>YYYY-MM-DD</code>) and remove exact cross-file boundary duplicates (<code>sortKey + fixed amount + normalized description</code>) while keeping genuine same-day duplicate charges inside the <em>same</em> statement file intact.</li>
<li>Export a single combined <code>.QBO</code> Web Connect file, a 3-column QuickBooks CSV, or a multi-sheet <code>.xlsx</code> workbook (with a <code>Year-End Summary</code> tab, <code>Combined Ledger</code> tab, and one tab per source statement).</li>
</ol>
<h2>30-Second Demo</h2>
<p>Watch the 30-second client-side walkthrough on YouTube: <a href="https://www.youtube.com/watch?v=kTMUi-qRZtc">PDFFields: Convert PDF Bank Statements to Excel &amp; QuickBooks .QBO Locally</a></p>
<h2>Try it right in your browser (with a 3-Month Sample Pack)</h2>
<p>You can test single-statement <code>.QBO</code> conversion or the multi-PDF batch merger right now with zero signup at <a href="https://www.pdffields.com/pdf-to-qbo"><strong>pdffields.com/pdf-to-qbo</strong></a> (click <strong>"Try 3-Month Sample Pack"</strong> to watch three Q4 2026 PDF statements parse, reconcile, deduplicate, and merge locally in your browser), or use the Excel &amp; CSV workbench at <a href="https://www.pdffields.com/bank-statement-to-excel"><strong>pdffields.com/bank-statement-to-excel</strong></a>.</p>
]]></content:encoded></item><item><title><![CDATA[How We Detect Broken PDF Redactions in the Browser Using Canvas RGBA Luminance Sampling]]></title><description><![CDATA[A surprising number of "redacted" PDFs shared in legal discovery, real estate packets, HR files, and government disclosures still contain the original text…]]></description><link>https://pdffields.hashnode.dev/how-we-detect-broken-pdf-redactions-in-the-browser-using-canvas-rgba-luminance-sampling</link><guid isPermaLink="true">https://pdffields.hashnode.dev/how-we-detect-broken-pdf-redactions-in-the-browser-using-canvas-rgba-luminance-sampling</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[Security]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Ezra Winslow]]></dc:creator><pubDate>Sun, 29 Nov 2026 08:25:24 GMT</pubDate><content:encoded><![CDATA[<p>A surprising number of "redacted" PDFs shared in legal discovery, real estate packets, HR files, and government disclosures still contain the original text underneath a black rectangle. Anyone can press <code>Ctrl+A</code>, copy, and paste the hidden Social Security numbers, bank account digits, or contract terms straight into Notepad.</p>
<p>This happens because drawing a black shape or highlight annotation in Preview, Word, or basic PDF editors adds a graphics operator on top of the existing PDF content stream without removing the underlying text glyphs. Even worse, incremental PDF saves leave prior revisions intact between earlier <code>%%EOF</code> markers, and document <code>/Info</code> dictionaries still carry the original title, author, and subject strings.</p>
<p>While building <a href="https://www.pdffields.com/">PDFFields</a>, I wanted a client-side diagnostic tool where anyone could drop a sensitive PDF into a browser tab, verify zero bytes leave their machine (inspectable in DevTools Network), and catch broken redactions in seconds. Here is the exact detection pipeline we shipped at <a href="https://www.pdffields.com/pdf-redaction-checker">pdffields.com/pdf-redaction-checker</a>.</p>
<h2>Why inspecting PDF vector operators alone is brittle</h2>
<p>My first instinct was to parse raw PDF content streams (<code>re</code>, <code>f</code>, <code>rg</code>) and intersect every filled black rectangle with every <code>Tj</code>/<code>TJ</code> text operator. That breaks quickly on real-world PDFs:</p>
<ul>
<li>Rotated or nested Form XObjects (<code>Do</code>) carry compound current transformation matrices (CTMs).</li>
<li>Redaction shapes are often drawn inside PDF annotations (<code>/Annot</code>) rather than the page content stream.</li>
<li>People frequently cover text with opaque whiteout rectangles, dark navy boxes, or raster stamps rather than pure <code>#000000</code>.</li>
</ul>
<p>Rendering the page once to an offscreen HTML5 <code>&lt;canvas&gt;</code> with <code>pdf.js</code> solves all of those coordinate, clipping, z-order, and annotation-flattening edge cases automatically. We already have the exact final pixels a human sees, alongside the exact text items returned by <code>page.getTextContent()</code>.</p>
<h2>Step 1: Sampling rendered RGBA pixels behind every text bounding box</h2>
<p>Normal readable text on paper has high luminance contrast: dark ink strokes mixed with bright background pixels inside the glyph bounding box (typically <code>stdDev</code> between <code>25</code> and <code>110</code>, with a dark pixel fraction between <code>0.08</code> and <code>0.35</code>).</p>
<p>When intact text sits underneath an opaque black rectangle, almost every pixel inside its bounding box is uniformly dark (<code>darkFraction &gt;= 0.85</code>, very low luminance standard deviation). When intact text sits underneath an opaque whiteout or solid-color cover, the entire bounding box collapses to near-zero luminance variance (<code>stdDev &lt; 3.5</code>).</p>
<p>Here is the core pixel sampler from our TypeScript module (<code>redactionAudit.ts</code>):</p>
<pre><code class="language-ts">export interface PixelSurface {
  data: Uint8ClampedArray;
  width: number;
  height: number;
}

function sampleBoxPixels(surface: PixelSurface, rect: NormalizedRect) {
  const { data, width, height } = surface;
  const rawX0 = Math.floor(rect.x * width);
  const rawY0 = Math.floor(rect.y * height);
  const rawX1 = Math.ceil((rect.x + rect.w) * width);
  const rawY1 = Math.ceil((rect.y + rect.h) * height);

  // Inset by 1px on boxes &gt;= 6x5 to ignore anti-aliased border halos
  const insetX = rawX1 - rawX0 &gt;= 6 ? 1 : 0;
  const insetY = rawY1 - rawY0 &gt;= 5 ? 1 : 0;
  const x0 = Math.max(0, Math.min(width - 1, rawX0 + insetX));
  const y0 = Math.max(0, Math.min(height - 1, rawY0 + insetY));
  const x1 = Math.max(x0 + 1, Math.min(width, rawX1 - insetX));
  const y1 = Math.max(y0 + 1, Math.min(height, rawY1 - insetY));

  const totalPixels = (x1 - x0) * (y1 - y0);
  const stride = totalPixels &lt;= 6000 ? 1 : Math.ceil(Math.sqrt(totalPixels / 6000));

  let count = 0;
  let darkCount = 0;
  let sumLum = 0;
  let sumLumSq = 0;

  for (let y = y0; y &lt; y1; y += stride) {
    for (let x = x0; x &lt; x1; x += stride) {
      const idx = (y * width + x) * 4;
      const r = data[idx] ?? 255;
      const g = data[idx + 1] ?? 255;
      const b = data[idx + 2] ?? 255;
      const lum = 0.299 * r + 0.587 * g + 0.114 * b;
      const spread = Math.max(r, g, b) - Math.min(r, g, b);
      if (lum &lt;= 48 &amp;&amp; spread &lt;= 30) {
        darkCount++;
      }
      sumLum += lum;
      sumLumSq += lum * lum;
      count++;
    }
  }

  const mean = sumLum / count;
  const variance = Math.max(0, sumLumSq / count - mean * mean);
  return {
    sampleCount: count,
    darkFraction: darkCount / count,
    stdDev: Math.sqrt(variance)
  };
}
</code></pre>
<p>A few small details mattered in practice to eliminate false positives:</p>
<ol>
<li><strong>1px inset</strong>: Anti-aliased edges around a black rectangle introduce bright fringe pixels on thin 10pt text boxes. Insetting by 1 pixel when the box is at least <code>6x5</code> keeps the sample strictly inside the covered region.</li>
<li><strong>Neutral dark check (<code>spread &lt;= 30</code>)</strong>: Requiring <code>max(r,g,b) - min(r,g,b) &lt;= 30</code> alongside <code>lum &lt;= 48</code> separates true neutral black boxes from saturated dark-blue table headers with white text (which also have high <code>stdDev</code> because of the white glyph strokes).</li>
<li><strong>White-on-black intentional headers</strong>: Because real readable white text on a black banner mixes luminance <code>~0</code> and <code>~255</code>, its <code>stdDev</code> stays high (<code>&gt; 45</code>) even though <code>darkFraction</code> is elevated. Checking both <code>darkFraction</code> and low <code>stdDev</code> together cleanly separates readable inverse headers from fake black redactions.</li>
</ol>
<h2>Step 2: Catching unapplied <code>/Redact</code> annotations and multi-revision <code>%%EOF</code> leaks</h2>
<p>Visual pixel cover is only one failure mode. Two structural PDF leaks are just as common:</p>
<ol>
<li><strong>Unapplied <code>/Redact</code> annotations</strong>: Users mark areas in Acrobat with the Redact tool and save the file without clicking "Apply". The <code>/Subtype /Redact</code> annotation sits in <code>page.getAnnotations()</code>, visibly outlined or shaded, while the text stream underneath is completely untouched.</li>
<li><strong>Incremental revision history (<code>%%EOF</code>)</strong>: PDF supports append-only incremental saves. If someone saves a redaction incrementally, earlier pre-redaction objects can survive earlier in the byte stream. Scanning raw bytes for <code>%%EOF</code> markers bounded by whitespace or EOF immediately flags files with <code>revisionCount &gt; 1</code>:</li>
</ol>
<pre><code class="language-ts">export function countPdfRevisions(bytes: Uint8Array): number {
  if (!bytes || bytes.length &lt; 5) return 0;
  let count = 0;
  const end = bytes.length - 4;
  for (let i = 0; i &lt; end; i++) {
    if (
      bytes[i] === 0x25 &amp;&amp; // %
      bytes[i + 1] === 0x25 &amp;&amp; // %
      bytes[i + 2] === 0x45 &amp;&amp; // E
      bytes[i + 3] === 0x4f &amp;&amp; // O
      bytes[i + 4] === 0x46 // F
    ) {
      const next = bytes[i + 5];
      const nextIsBoundary =
        next === undefined || next === 0x0a || next === 0x0d || next === 0x20 || next === 0x09;
      if (nextIsBoundary) {
        count++;
        i += 4;
      }
    }
  }
  return count;
}
</code></pre>
<ol start="3">
<li><strong><code>/Info</code> metadata leaks</strong>: Reading <code>pdfDoc.getTitle()</code>, <code>getAuthor()</code>, <code>getSubject()</code>, <code>getKeywords()</code>, <code>getCreator()</code>, and <code>getProducer()</code> via <code>pdf-lib</code> frequently turns up client names or internal matter numbers that were never cleared.</li>
</ol>
<h2>Step 3: Repairing leaked pages permanently (not just hiding them)</h2>
<p>When leaks are detected, the only way to guarantee zero recoverable characters on affected pages inside a browser-only pipeline is to <strong>rasterize</strong> the affected pages at 200 DPI with solid black redaction boxes baked into the pixels, rebuild a fresh single-revision PDF via <code>pdf-lib</code>, wipe all <code>/Info</code> fields, and run a post-export text-layer verification confirming <code>0</code> remaining characters inside every redacted bounding box.</p>
<p>We also publish an explicit Audit Scope disclosure right in the UI: the checker flags covered text, unapplied <code>/Redact</code> annotations, <code>/Info</code> metadata, and multi-revision <code>%%EOF</code> trailers, and explicitly notes that embedded file attachments, raw XMP XML packets, or hidden bitmap layers underneath vector shapes should also be checked when handling high-stakes legal filings.</p>
<h2>Try it on a broken sample or your own PDF</h2>
<p>You can test the full client-side checker (including a built-in broken-redaction sample PDF with hidden SSNs and account numbers underneath black rectangles) with no account required at <strong><a href="https://www.pdffields.com/pdf-redaction-checker">pdffields.com/pdf-redaction-checker</a></strong>. Open your browser's Network tab while scanning to confirm zero document bytes ever leave your machine.</p>
<p>If you need to draw new permanent redactions from scratch (with local SSN, email, phone, and account-number pattern detection), the full studio is at <a href="https://www.pdffields.com/redact-pdf">pdffields.com/redact-pdf</a>.</p>
]]></content:encoded></item></channel></rss>