Repository navigation
v8.3.0
v8.3.0: 📐 Documents as They Are Laid Out & Four New Writers (XLSX, ODS, PPTX, ODP)
I am pleased to announce the release of officeParser v8.3.0! It writes four more formats: spreadsheets as XLSX and ODS and decks as PPTX and ODP, from any document it reads. And it reads how a document is laid out, not only what it says: its pages and sections, its headers and footers, paragraph spacing, list markers, a slide's shapes and places, and what a spreadsheet hides and how it shows its numbers. The native PDF engine draws all of it, so a document converts to a PDF that looks like its printout.
Warning
Behavior changes
- The default paper format is
'auto'. PDF, DOCX, ODT and LaTeX output use the document's own pages (US Letter, landscape, a slide's size) and margins where it sets them, else A4 with inch margins. Passformat: 'A4'(and amargin) for the old output. csvDelimiterdefaults to'auto': the delimiter is read from the file.- Word, ODT and RTF headers and footers are
headerandfooternodes, one per part, whereauxiliary.headersandauxiliary.footersheld every part's paragraphs in one list. - PDF output leaves out what a printout does: hidden sheet content (
pdfConfig.printHiddenprints it) and speaker notes (pdfConfig.printSpeakerNotes). - A section's start is a
breaknode by default in Word, ODT and RTF documents (with its number and setup), whateverincludeBreakNodessays, so each section's pages, columns, headers and page numbers are kept. In text and Markdown output it shows nothing, and in HTML output it starts a new page in print.
🌟 Key Highlights
1. Four new writers: XLSX, ODS, PPTX and ODP
ast.to('xlsx') and ast.to('ods') write a workbook: a spreadsheet sheet for sheet, its values typed and shown in their number formats, with its merged cells and hidden sheets, rows and columns; any other document as its tables, a sheet each. ast.to('pptx') and ast.to('odp') write a deck: a deck slide for slide with its text boxes, pictures, shapes, tables and speaker notes; a PDF's pages as slides with their text where the page set it; any other document flowed onto slides under its headings. Charts are written as tables of their data. The CLI takes --to=xlsx, --to=ods, --to=pptx and --to=odp, configured by xlsxConfig, odsConfig, pptxConfig and odpConfig.
const ast = await OfficeParser.parseOffice('report.pdf');
const { value: deck } = await ast.to('pptx'); // Uint8Array
const { value: workbook } = await ast.to('xlsx'); // its tables, a sheet each2. Pages, sections, headers and footers
OfficeMetadata.pageSetup holds a document's page (size, margins, header and footer distances, columns, page numbering), and each later section's break carries its own. Headers and footers carry their kind, section and page fields, and the native PDF engine draws each page's own, with its number in its section's format (i, ii, iii for front matter).
3. Floating frames
A text frame or text box beside a document's text (ODT, Word, RTF) is a drawing node with its place, and the native PDF engine sets the text around it.
4. Slides drawn as laid out
PPTX and ODP shapes have their places (bounds) and looks (drawing nodes with ShapeMetadata), slides their backgrounds, and text the size and colour its master gives. The native PDF engine draws each slide as it is designed.
5. Spreadsheets print as they are seen
Hidden sheets, rows and columns are marked, number cells record the text their format shows (CellMetadata.shownText: 19%, €120.00), and merged ranges are read as spans.
6. Paragraph spacing and list markers
ParagraphMetadata.spacing and ListMetadata.marker are read from DOCX, ODT, RTF, HTML and PDF, and written back by the writers.
7. The native PDF engine draws much more
Links, alignment, indents, serif and monospaced text, footnotes at the foot of their page, shaded cells, content-sized columns, pictures in cells and lines, GIF, BMP and SVG pictures, charts with their titles, and Hindi and other Indic scripts shaped with their conjuncts (copied out as written).
🐛 Fixes
- Word justified paragraphs read as justified; nested Word list levels count afresh under each parent.
- PDF: turned text read whole with its angle; look-alike CJK ideographs read as the unified ones; table cells set apart in plain text.
- PPTX text in a theme colour has its colour.
- RTF symbol words (
\emdash,\bulletand others) read as their characters. - HTML reads a page's own stylesheet and the colour in a
backgroundshorthand. - A line or page break inside a paragraph is drawn in the native PDF engine.
- A split table's header row starts every chunk of it in chunked output.
🛠 Getting Started
npm install officeparser@8.3.0🔗 Full Changelog: View v8.3.0 details
🔗 Documentation & Visualizer: officeparser.harshankur.com