@openworkbook/pdf 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OpenWorkbook contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,45 @@
1
- # Temporary Holding Version
1
+ # @openworkbook/pdf
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Direct PDF export for [OpenWorkbook](https://openworkbook.netlify.app) workbooks: a vector, text-selectable PDF of one sheet, several
4
+ sheets or the whole workbook, in the browser and in Node.js (Next.js route handlers, Server Actions), with no print
5
+ dialog, no headless browser and no canvas. Dependencies: `@openworkbook/core` and `fflate`. MIT.
6
+
7
+ ```ts
8
+ import { exportPdf, pdfResponse, downloadPdf } from '@openworkbook/pdf';
9
+
10
+ const bytes = exportPdf(workbook, { sheets: 'all', title: 'Q3 report' }); // Uint8Array
11
+ export async function GET() { return pdfResponse(book, 'report.pdf'); } // Next.js route handler
12
+ downloadPdf(workbook, 'report.pdf'); // browser
13
+ ```
14
+
15
+ In the Studio: `<Studio pdf={pdf} />` with `import * as pdf from '@openworkbook/pdf'` enables File, Export to PDF.
16
+
17
+ ## What it does
18
+
19
+ - **Same pages as printing**: each sheet's page setup (paper, orientation, margins, scale and fit to page, print
20
+ areas, print titles, manual page breaks, page order, centring, first page number, gridlines, headings, black and
21
+ white, draft) through core's `layoutPrintPages`, the pagination of the print helpers and Print Preview.
22
+ - **Same drawing as the grid**: cells are painted by a page painter that follows the grid's rules and reuses its
23
+ helpers; charts, shapes, text effects, pictures (PNG, JPEG, SVG; GIF, WebP and BMP are converted to PNG in a browser by the asynchronous export), barcodes, slicers, timelines, ink and sparklines
24
+ are drawn by the grid's `ObjectPainter` through a PDF implementation of the canvas 2D context, so they stay vector.
25
+ - **Text**: the 14 standard PDF fonts with their metrics when no font file is given; embedded TrueType / OpenType
26
+ fonts as subset CID fonts with ToUnicode maps (selectable and searchable), fallback fonts for missing characters,
27
+ bidi reordering and Arabic shaping. Characters no font can draw are reported, never dropped silently.
28
+ - **Document**: clickable cell and object links (web and internal), one bookmark per sheet, document properties,
29
+ header / footer codes with formatting and pictures (`&G`), odd / even / first-page headers and footers, notes and comments (as displayed or at the end), optional AES-256 encryption
30
+ (PDF 2.0 security handler, user / owner passwords, permissions).
31
+ - **Warnings** for everything that is approximated or left out.
32
+
33
+ ## Documentation
34
+
35
+ - [PDF export](https://openworkbook.netlify.app/features/pdf-export): guide, options, fonts, fidelity table, warnings, limitations
36
+ - [API: @openworkbook/pdf](https://openworkbook.netlify.app/reference/api-pdf)
37
+
38
+ ## Tests
39
+
40
+ `pnpm test` runs the unit tests (writer, encryption with known-answer tests of SHA-2 and AES, fonts and subsetting
41
+ with a synthetic TrueType font, bidi and Arabic shaping, pagination equality with `sheetPrintLayout`, page geometry
42
+ for every paper size, header / footer codes, links, pictures, Unicode, options). `test/oracle.local.test.ts`
43
+ additionally opens the output with PyMuPDF, poppler (`pdftotext`, `pdfinfo`) and Ghostscript (and, on macOS, PDFKit
44
+ for encrypted files) and extracts the text back with real fonts when those tools and fonts are installed; it skips
45
+ otherwise.
@@ -0,0 +1,19 @@
1
+ # Third-party notices: @openworkbook/pdf
2
+
3
+ `@openworkbook/pdf` is released under the MIT licence (see `LICENSE`). Its dependencies are `@openworkbook/core`
4
+ (see the notices of that package) and `fflate` (MIT).
5
+
6
+ ## Font metrics: Adobe Core 14 AFM files
7
+
8
+ The advance widths, ascenders and descenders of the standard PDF fonts (Helvetica, Times, Courier) were taken from
9
+ the Adobe Core 14 font metrics (AFM) files and stored in a compact form. No font program is included.
10
+
11
+ Copyright (c) 1985, 1987, 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.
12
+
13
+ This file and the 14 PostScript(R) AFM files it accompanies may be used, copied, and distributed for any purpose and
14
+ without charge, with or without modification, provided that all copyright notices are retained; that the AFM files
15
+ are not distributed without this file; and that all modifications to this file or any of the AFM files are
16
+ prominently noted in the modified file(s), and all modified AFM files are renamed.
17
+
18
+ Modification note: only the widths of the WinAnsi codes 32 to 255 and the ascender / descender values are kept, in a
19
+ different file format.