# outline-pdf-data-structure ## Table of contents - [Table of contents](#table-of-contents) - [Installation](#installation) - [Description](#description) - [Code coverage](#code-coverage) - [Example](#example) - [Documentation](#documentation) - [Concretions](#concretions) - [outlinePdfDataStructure](#----outlinepdfdatastructure) - [Motivation](#motivation) - [Contributing](#contributing) - [Changelog](#changelog) - [1.0.3](#103) - [1.0.2](#102) - [1.0.1](#101) - [1.0.0](#100) - [License](#license) ## Installation ```bash npm install @lillallol/outline-pdf-data-structure ``` ## Description Creates a pdf outline data structure as defined in the pdf specification, from a human readable string representation of the pdf outline. You can then use that data structure to "hydrate" a real pdf outline data structure like it is done in [@lillallol/outline-pdf](https://github.com/lillallol/outline-pdf). ## Code coverage The testing code coverage is around 90%. ## Example ```ts import { outlinePdfDataStructure } from "../"; describe(outlinePdfDataStructure.name, () => { it("returns low level information about the provided outline string representation", () => { expect( outlinePdfDataStructure( ` 1||Document 2|-|Section 1 3|-|Section 2 4|--|Subsection 1 5|-|Section 3 6||Summary `, 6 ) ).toEqual({ outlineRootCount: 6, outlineItems: [ { Title: "Document", Parent: -1, Next: 5, First: 1, Last: 4, Count: 4, Dest: 1 - 1, }, { Title: "Section 1", Parent: 0, Next: 2, Dest: 2 - 1, }, { Title: "Section 2", Parent: 0, Prev: 1, Next: 4, First: 3, Last: 3, Count: 1, Dest: 3 - 1, }, { Title: "Subsection 1", Parent: 2, Dest: 4 - 1, }, { Title: "Section 3", Parent: 0, Prev: 2, Dest: 5 - 1, }, { Title: "Summary", Parent: -1, Prev: 0, Dest: 6 - 1, }, ], }); }); }); ``` ## Documentation
# outlinePdfDataStructureReturnType
```ts export declare type outlinePdfDataStructureReturnType = { /** * @description * It returns a low level programmatic representation of the outline. */ outlineItems: outlineItem[]; /** * @description * The total number of outline nodes. */ outlineRootCount: number; }; ```# outlineItem
```ts export declare type outlineItem = { /** * @description * The title that will be visible in the outline of the pdf for the context * outline node. */ Title: string; /** * @description * The index (of the array that contains all the outline nodes) of the * parent outline node of the context outline node. * * Outline nodes of depth `0` have `-1` for this value. */ Parent: number; /** * @description * The index (of the array that contains all the outline nodes) of the * previous sibling of the context outline node. It is `undefined` for the * case there is no previous sibling. */ Prev?: number; /** * @description * The index (of the array that contains all the outline nodes) of the next * sibling of the context outline node. It is `undefined` for the case there * is no next sibling. */ Next?: number; /** * @description * The index (of the array that contains all the outline nodes) of the first * immediate child of the context outline node. It is `undefined` for the * case there is no immediate child. */ First?: number; /** * @description * The index (of the array that contains all the outline nodes) of the last * immediate child of the context outline node. It is `undefined` for the * case there is no immediate child. */ Last?: number; /** * @description * Total number of outline nodes that are descendants to the context outline * node. */ Count?: number; /** * @description * The page of the pdf that the outline node hyper links to. */ Dest: number; }; ```