rewritable 0.16.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -75,7 +75,7 @@ Embeds the input file's content as the document's initial state. Supported forma
75
75
  - `.csv` — parsed via [`papaparse`](https://www.papaparse.com/) (RFC 4180; handles quoted commas, embedded newlines, escaped quotes, BOM). First row becomes `<thead>`, remaining rows `<tbody>`; every cell is HTML-escaped. Parse warnings print to stderr but don't abort the import.
76
76
  - `.txt` — paragraph-split on blank lines, HTML chars escaped
77
77
  - `.docx` — converted via [`mammoth`](https://github.com/mwilliamson/mammoth.js) to semantic HTML; `href`/`src` URLs are scheme-sanitized (same allow-list as `.md`).
78
- - `.pdf` — reconstructed with **maximum geometry fidelity**: each page is rebuilt as positioned, real (still editable) text at its original coordinates, with the document's rules and boxes drawn from the PDF's own vector operators — so an invoice, form, or statement *looks like the original* while staying a rewritable you can edit with `⌘K`. Bold/italic are recovered from the embedded font names; near-perfect, not pixel-exact (system substitute fonts, black text). A scanned/image-only PDF (no text layer) exits `2` — OCR is not supported. For a model-based alternative, see `--vision` / `--claude`.
78
+ - `.pdf` — reconstructed with **maximum geometry fidelity**: each page is rebuilt as positioned, real (still editable) text at its original coordinates, with the document's rules and boxes drawn from the PDF's own vector operators — so an invoice, form, or statement *looks like the original* while staying a rewritable you can edit with `⌘K`. Bold/italic are recovered from the embedded font names; near-perfect, not pixel-exact (system substitute fonts, black text). It also **exports back to PDF at the source page size, edge-to-edge** (`⌘P` / Save as PDF) — true scale, no double margin. A scanned/image-only PDF (no text layer) exits `2` — OCR is not supported. For a model-based alternative, see `--vision` / `--claude`.
79
79
 
80
80
  Output defaults to `<input-basename>.html` in the input's directory. Conversion is deterministic and offline — no API key, no network.
81
81
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rewritable",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "CLI for re-writeable: emit and import single-file rwa documents.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/import.mjs CHANGED
@@ -283,8 +283,18 @@ async function convertPdf(bytes) {
283
283
  e.exitCode = 2;
284
284
  throw e;
285
285
  }
286
+ // Print at true page size, edge to edge. Two coupled corrections, both print-only
287
+ // (screen rendering is byte-unchanged): (1) the page box is sized in PDF points
288
+ // rendered as CSS px (72→96 dpi), so it draws at 75% of physical size — zoom
289
+ // (96/72, held a hair under 1.33333 so the page never spills to a blank second
290
+ // sheet) scales it back to true size; (2) a per-document @page matching the source
291
+ // page's own size + margin:0 overrides the seed's @page{margin:18mm}, so a page that
292
+ // already carries its own margins isn't double-framed. Points-based @page size keeps
293
+ // this correct for any paper (A4, Letter, …), not just A4.
294
+ const dims = /width:([\d.]+)px;height:([\d.]+)px/.exec(pages[0] || '');
295
+ const printPageRule = dims ? `\n<style>@page{size:${dims[1]}pt ${dims[2]}pt;margin:0}</style>` : '';
286
296
  return {
287
- html: `<article class="rwa-pdf">\n${PDF_PAGE_STYLE}\n<div class="rwa-pdf-doc">\n${pages.join('\n')}\n</div>\n</article>`,
297
+ html: `<article class="rwa-pdf">\n${PDF_PAGE_STYLE}${printPageRule}\n<div class="rwa-pdf-doc">\n${pages.join('\n')}\n</div>\n</article>`,
288
298
  warnings: ['pdf: imported as a geometry-faithful reconstruction (positioned text + rules) — text stays editable but is absolutely positioned'],
289
299
  fidelityInput: { sourceText, pages: pageCount, perPage }, // for the import fidelity loop (import-fidelity.mjs); perPage drives per-page/worst-page scoring
290
300
  };
@@ -315,7 +325,7 @@ const PDF_PAGE_STYLE = `<style>
315
325
  .rwa-pdf-page{position:relative;flex:none;background:#fff;box-shadow:0 1px 5px rgba(0,0,0,.18);overflow:hidden;}
316
326
  .rwa-pdf-t{position:absolute;white-space:pre;line-height:1;color:#000;transform-origin:0 0;}
317
327
  .rwa-pdf-g{position:absolute;}
318
- @media print{.rwa-pdf{background:none}.rwa-pdf-doc{gap:0;padding:0;overflow:visible}.rwa-pdf-page{box-shadow:none}}
328
+ @media print{.rwa-pdf{background:none}.rwa-pdf-doc{gap:0;padding:0;overflow:visible}.rwa-pdf-page{box-shadow:none;zoom:1.3333}}
319
329
  </style>`;
320
330
 
321
331
  function escapePdfText(s) {