mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
* [@types/pdfmake] Split definitions
pdfmake/index.d.ts will only export the node api.
pdfmake/interfaces.d.ts will contain all data types
pdfmake/build/pdfmake.d.ts will export the browser module api as well as the global namespace object
pdfmake/build/vfs_fonts.d.ts will export the vfs for the browser
* [@types/pdfmake] Add type references for node and pdfkit
* [@types/pdfmake] Remove enums
TypeScript enums exist at runtime and should never be used in type declaration files unless they perfectly describe the behaviour of the JS code (which is highly unlikely). pdfMake only expects string literals, so the enums were modeled as unions of string literals.
* [@types/pdfmake] Overhaul interfaces
All changes were meticulously verified against the official docs, the examples AND the source code. Since the documentation is incomplete, the only real spec I had to work with was the actual implementation, which is less than ideal.
* [@types/pdfmake] Update server and browser api files
The server api exposes a class as single export object. This means the `export =` syntax is necessary for the type definitions, and the consumers must import the module with an `import PdfPrinter = require('pdfmake')` statement.
The browser api expose both a compliant ES6 module and a global 'pdfMake' object, which is why the 'export as namespace' syntax is necessary.
* [@types/pdfmake] Update tests
The examples provided by the pdfMake playground and repository are all copied in pdfmake-playground-examples-tests.ts and pdfmake-examples-test.ts respectively.
The pdfmake-interfaces-tests.ts contains code from the documentation as well as additionnal tests for coverage.
The other files test all different flavors of the api.
* [@types/pdfmake] Add myself as maintainer
* [@types/pdfmake] Layout long union type
* [@types/pdfmake] Add PageBreak union type
* [@types/pdfmake] Add doc comments
* [@types/pdfmake] Fix typo
This commit is contained in:
parent
ef958d9a91
commit
4e2b7278ed
28
types/pdfmake/build/pdfmake.d.ts
vendored
Normal file
28
types/pdfmake/build/pdfmake.d.ts
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
/// <reference lib="dom" />
|
||||
import { BufferOptions, TableLayout, TDocumentDefinitions, TFontDictionary } from '../interfaces';
|
||||
|
||||
export let vfs: TFontDictionary;
|
||||
export let fonts: TFontDictionary;
|
||||
export let tableLayouts: TableLayout;
|
||||
|
||||
export function createPdf(
|
||||
documentDefinitions: TDocumentDefinitions,
|
||||
tableLayouts?: TableLayout,
|
||||
fonts?: TFontDictionary,
|
||||
vfs?: TFontDictionary,
|
||||
): TCreatedPdf;
|
||||
|
||||
export interface TCreatedPdf {
|
||||
download(cb?: () => void, options?: BufferOptions): void;
|
||||
download(defaultFileName: string, cb?: () => void, options?: BufferOptions): void;
|
||||
|
||||
getBlob(cb: (result: Blob) => void, options?: BufferOptions): void;
|
||||
getBase64(cb: (result: string) => void, options?: BufferOptions): void;
|
||||
getBuffer(cb: (result: Buffer) => void, options?: BufferOptions): void;
|
||||
getDataUrl(cb: (result: string) => void, options?: BufferOptions): void;
|
||||
getStream(options?: BufferOptions): PDFKit.PDFDocument; // minimal version 0.1.41
|
||||
open(options?: BufferOptions, win?: Window | null): void;
|
||||
print(options?: BufferOptions, win?: Window | null): void;
|
||||
}
|
||||
|
||||
export as namespace pdfMake;
|
||||
5
types/pdfmake/build/vfs_fonts.d.ts
vendored
Normal file
5
types/pdfmake/build/vfs_fonts.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { TFontDictionary } from '../interfaces';
|
||||
|
||||
export namespace pdfMake {
|
||||
let vfs: TFontDictionary;
|
||||
}
|
||||
290
types/pdfmake/index.d.ts
vendored
290
types/pdfmake/index.d.ts
vendored
@ -5,289 +5,19 @@
|
||||
// Enzo Volkmann <https://github.com/evolkmann>
|
||||
// Andi Pätzold <https://github.com/andipaetzold>
|
||||
// Neal Mummau <https://github.com/nmummau>
|
||||
// Jean-Raphaël Matte <https://github.com/jeralm>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
/// <reference lib="dom" />
|
||||
/// <reference types="pdfkit" />
|
||||
|
||||
declare module "pdfmake/build/vfs_fonts" {
|
||||
let pdfMake: {
|
||||
vfs: any;
|
||||
[name: string]: any;
|
||||
};
|
||||
import { BufferOptions, TDocumentDefinitions, TFontDictionary } from './interfaces';
|
||||
|
||||
// 'export =' syntax forbids any other export.
|
||||
// tslint:disable-next-line: strict-export-declare-modifiers
|
||||
declare class PdfPrinter {
|
||||
constructor(fontDescriptors: TFontDictionary);
|
||||
createPdfKitDocument(docDefinition: TDocumentDefinitions, options?: BufferOptions): PDFKit.PDFDocument;
|
||||
}
|
||||
|
||||
declare module "pdfmake/build/pdfmake" {
|
||||
let vfs: TFontFamily;
|
||||
let fonts: { [name: string]: TFontFamilyTypes };
|
||||
function createPdf(
|
||||
documentDefinitions: TDocumentDefinitions,
|
||||
tableLayouts?: any,
|
||||
fonts?: any,
|
||||
vfs?: any
|
||||
): TCreatedPdf;
|
||||
|
||||
type PageSize =
|
||||
"4A0"|"2A0"|"A0"|"A1"|"A2"|"A3"|"A4"|"A5"|"A6"|"A7"|"A8"|"A9"|"A10"|
|
||||
"B0"|"B1"|"B2"|"B3"|"B4"|"B5"|"B6"|"B7"|"B8"|"B9"|"B10"|
|
||||
"C0"|"C1"|"C2"|"C3"|"C4"|"C5"|"C6"|"C7"|"C8"|"C9"|"C10"|
|
||||
"RA1"|"RA2"|"RA3"|"RA4"|
|
||||
"SRA1"|"SRA2"|"SRA3"|"SRA4"|
|
||||
"EXECUTIVE"|"FOLIO"|"LEGAL"|"LETTER"|"TABLOID";
|
||||
|
||||
type PageOrientation = "portrait" | "landscape";
|
||||
|
||||
type Layout = "noBorders" | "headerLineOnly" | "lightHorizontalLines";
|
||||
|
||||
type Alignment = "left" | "center" | "right";
|
||||
|
||||
type Decoration = "underline" | "lineThrough" | "overline";
|
||||
|
||||
type DecorationStyle = "dashed" | "dotted" | "double" | "wavy";
|
||||
|
||||
type PageBreak = "before" | "after";
|
||||
|
||||
let pdfMake: pdfMakeStatic;
|
||||
|
||||
interface TFontFamily {
|
||||
[fontName: string]: string;
|
||||
}
|
||||
|
||||
interface TFontFamilyTypes {
|
||||
normal?: string;
|
||||
bold?: string;
|
||||
italics?: string;
|
||||
bolditalics?: string;
|
||||
}
|
||||
|
||||
interface TDocumentInformation {
|
||||
/** the title of the document */
|
||||
title?: string;
|
||||
/** the name of the author */
|
||||
author?: string;
|
||||
/** the subject of the document */
|
||||
subject?: string;
|
||||
/** keywords associated with the document */
|
||||
keywords?: string;
|
||||
}
|
||||
|
||||
type TDocumentHeaderFooterFunction = (
|
||||
currentPage: number,
|
||||
pageCount: number,
|
||||
pageSize?: { width: number; height: number }
|
||||
) => any;
|
||||
|
||||
type Margins = number | [number, number] | [number, number, number, number];
|
||||
|
||||
interface Style {
|
||||
/** name of the font */
|
||||
font?: any;
|
||||
/** size of the font in pt */
|
||||
fontSize?: number;
|
||||
fontFeatures?: any;
|
||||
/** whether to use bold text (default: false) */
|
||||
bold?: boolean;
|
||||
/** whether to use italic text (default: false) */
|
||||
italics?: boolean;
|
||||
/** the alignment of the text */
|
||||
alignment?: Alignment;
|
||||
/** the color of the text (color name e.g., ‘blue’ or hexadecimal color e.g., ‘#ff5500’) */
|
||||
color?: string;
|
||||
/** optional space between columns */
|
||||
columnGap?: any;
|
||||
/** the background color of a table cell */
|
||||
fillColor?: string;
|
||||
/** the background opacity of a table cell */
|
||||
fillOpacity?: string;
|
||||
/** the text decoration to applu (‘underline’ or ‘lineThrough’ or ‘overline’) */
|
||||
decoration?: Decoration;
|
||||
/** (‘dashed’ or ‘dotted’ or ‘double’ or ‘wavy’) */
|
||||
decorationStyle?: DecorationStyle;
|
||||
/** the color of the text decoration, see color */
|
||||
decorationColor?: string;
|
||||
/** the background color of the text */
|
||||
background?: any;
|
||||
/** the line height (default: 1) */
|
||||
lineHeight?: number;
|
||||
characterSpacing?: number;
|
||||
noWrap?: boolean;
|
||||
/** the color of the bullets in a buletted list */
|
||||
markerColor?: string;
|
||||
leadingIndent?: any;
|
||||
[additionalProperty: string]: any;
|
||||
}
|
||||
|
||||
type TableRowFunction = (row: number) => number;
|
||||
|
||||
interface TableLayoutFunctions {
|
||||
hLineWidth?: (i: number, node: any) => number;
|
||||
vLineWidth?: (i: number, node: any) => number;
|
||||
hLineColor?: (i: number, node: any) => string;
|
||||
vLineColor?: (i: number, node: any) => string;
|
||||
fillColor?: (i: number, node: any) => string;
|
||||
paddingLeft?: (i: number, node: any) => number;
|
||||
paddingRight?: (i: number, node: any) => number;
|
||||
paddingTop?: (i: number, node: any) => number;
|
||||
paddingBottom?: (i: number, node: any) => number;
|
||||
}
|
||||
|
||||
interface TableCell {
|
||||
text: string;
|
||||
rowSpan?: number;
|
||||
colSpan?: number;
|
||||
fillColor?: string;
|
||||
border?: [boolean, boolean, boolean, boolean];
|
||||
}
|
||||
|
||||
interface Table {
|
||||
body: Content[][] | TableCell[][];
|
||||
dontBreakRows?: boolean;
|
||||
headerRows?: number;
|
||||
heights?: Array<string | number> | TableRowFunction;
|
||||
layout?: string | TableLayoutFunctions;
|
||||
widths?: Array<string | number>;
|
||||
}
|
||||
|
||||
interface Content {
|
||||
layout?: Layout;
|
||||
style?: string | string[];
|
||||
margin?: Margins;
|
||||
text?: string | string[] | Content[];
|
||||
columns?: Content[];
|
||||
stack?: Content[];
|
||||
image?: string;
|
||||
svg?: string;
|
||||
width?: string | number;
|
||||
height?: string | number;
|
||||
fit?: [number, number];
|
||||
pageBreak?: PageBreak;
|
||||
alignment?: Alignment;
|
||||
table?: Table;
|
||||
/** to treat a paragraph as a bulleted list, set an array of items under the ul key */
|
||||
ul?: Content[];
|
||||
/** for numbered lists set the ol key */
|
||||
ol?: Content[];
|
||||
qr?: string;
|
||||
toc?: TableOfContent;
|
||||
tocItem?: boolean | string | string[];
|
||||
[additionalProperty: string]: any;
|
||||
}
|
||||
|
||||
interface TableOfContent {
|
||||
id?: string;
|
||||
title: Content;
|
||||
}
|
||||
|
||||
interface TDocumentDefinitions {
|
||||
background?: string | ((currentPage: number, pageSize: PageSize) => string | Content | null);
|
||||
compress?: boolean;
|
||||
content: string | Content | Array<string | Content>;
|
||||
defaultStyle?: Style;
|
||||
footer?: TDocumentHeaderFooterFunction | Content | string;
|
||||
header?: TDocumentHeaderFooterFunction | Content | string;
|
||||
images?: { [key: string]: string };
|
||||
info?: TDocumentInformation;
|
||||
pageBreakBefore?: (
|
||||
currentNode?: CurrentNode,
|
||||
followingNodesOnPage?: any,
|
||||
nodesOnNextPage?: any,
|
||||
previousNodesOnPage?: any
|
||||
) => boolean;
|
||||
pageMargins?: Margins;
|
||||
pageOrientation?: PageOrientation;
|
||||
pageSize?: PageSize | { width: number; height: number };
|
||||
styles?: Style;
|
||||
watermark?: Watermark;
|
||||
}
|
||||
|
||||
interface CurrentNode {
|
||||
id: string;
|
||||
headlineLevel: string;
|
||||
text: string | string[] | Content[];
|
||||
ul: Content[];
|
||||
ol: Content[];
|
||||
table: Table;
|
||||
image: string;
|
||||
qr: string;
|
||||
canvas: string;
|
||||
columns: Content[];
|
||||
style: string | string[];
|
||||
pageOrientation: PageOrientation;
|
||||
pageNumbers: number[];
|
||||
pages: number;
|
||||
stack: boolean;
|
||||
startPosition: {
|
||||
pageNumber: number;
|
||||
pageOrientation: PageOrientation;
|
||||
left: number;
|
||||
right: number;
|
||||
verticalRatio: number;
|
||||
horizontalRatio: number;
|
||||
};
|
||||
}
|
||||
|
||||
interface Pagesize {
|
||||
height: number;
|
||||
width: number;
|
||||
orientation: PageOrientation;
|
||||
}
|
||||
|
||||
interface Page {
|
||||
items: any[];
|
||||
pageSize: Pagesize;
|
||||
}
|
||||
|
||||
interface BufferOptions {
|
||||
autoPrint?: boolean;
|
||||
}
|
||||
|
||||
type CreatedPdfDownloadParams = (
|
||||
defaultFileName?: string,
|
||||
cb?: () => void,
|
||||
options?: BufferOptions
|
||||
) => void;
|
||||
|
||||
type CreatedPdfOpenPrintParams = (
|
||||
options?: BufferOptions,
|
||||
win?: Window | null
|
||||
) => void;
|
||||
|
||||
type CreatedPdfBufferParams = (
|
||||
cb: (result: any, pages: Page[]) => void,
|
||||
options?: BufferOptions
|
||||
) => void;
|
||||
|
||||
interface TCreatedPdf {
|
||||
download: CreatedPdfDownloadParams;
|
||||
getBlob: CreatedPdfBufferParams;
|
||||
getBase64: CreatedPdfBufferParams;
|
||||
getBuffer: CreatedPdfBufferParams;
|
||||
getDataUrl: CreatedPdfBufferParams;
|
||||
getStream: CreatedPdfBufferParams; // minimal version 0.1.41
|
||||
open: CreatedPdfOpenPrintParams;
|
||||
print: CreatedPdfOpenPrintParams;
|
||||
}
|
||||
|
||||
interface pdfMakeStatic {
|
||||
vfs: TFontFamily;
|
||||
fonts: { [name: string]: TFontFamilyTypes };
|
||||
createPdf(documentDefinitions: TDocumentDefinitions): TCreatedPdf;
|
||||
}
|
||||
|
||||
interface Watermark {
|
||||
/** watermark text */
|
||||
text?: string;
|
||||
/** color of text */
|
||||
color?: string;
|
||||
/** opacity of text */
|
||||
opacity?: number;
|
||||
/** bold style of text */
|
||||
bold?: boolean;
|
||||
/** italics style of text */
|
||||
italics?: true;
|
||||
/** own font size of text (ideal size is calculated automatically) (minimal version: 0.1.60) */
|
||||
fontSize?: number;
|
||||
/** angle of text rotation (minimal version: 0.1.60) */
|
||||
angle?: number;
|
||||
}
|
||||
}
|
||||
export = PdfPrinter;
|
||||
|
||||
462
types/pdfmake/interfaces.d.ts
vendored
Normal file
462
types/pdfmake/interfaces.d.ts
vendored
Normal file
@ -0,0 +1,462 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="pdfkit" />
|
||||
|
||||
export type PageSize = PredefinedPageSize | CustomPageSize;
|
||||
|
||||
export interface CustomPageSize {
|
||||
width: number;
|
||||
height: number | 'auto';
|
||||
}
|
||||
|
||||
export type PredefinedPageSize =
|
||||
| '4A0' | '2A0'
|
||||
| 'A0' | 'A1' | 'A2' | 'A3' | 'A4' | 'A5' | 'A6' | 'A7' | 'A8' | 'A9' | 'A10'
|
||||
| 'B0' | 'B1' | 'B2' | 'B3' | 'B4' | 'B5' | 'B6' | 'B7' | 'B8' | 'B9' | 'B10'
|
||||
| 'C0' | 'C1' | 'C2' | 'C3' | 'C4' | 'C5' | 'C6' | 'C7' | 'C8' | 'C9' | 'C10'
|
||||
| 'RA1' | 'RA2' | 'RA3' | 'RA4'
|
||||
| 'SRA1' | 'SRA2' | 'SRA3' | 'SRA4'
|
||||
| 'EXECUTIVE' | 'FOLIO' | 'LEGAL' | 'LETTER' | 'TABLOID';
|
||||
|
||||
export type PageOrientation = 'portrait' | 'landscape';
|
||||
|
||||
export type PageBreak = 'before' | 'after';
|
||||
|
||||
export type Size =
|
||||
| number // absolute
|
||||
| 'auto'
|
||||
| '*'
|
||||
| string; // percentage
|
||||
|
||||
export interface TFontDictionary {
|
||||
[fontName: string]: TFontFamilyTypes;
|
||||
}
|
||||
|
||||
export interface TFontFamilyTypes {
|
||||
normal?: string;
|
||||
bold?: string;
|
||||
italics?: string;
|
||||
bolditalics?: string;
|
||||
}
|
||||
|
||||
export interface TDocumentInformation {
|
||||
/** the title of the document */
|
||||
title?: string;
|
||||
/** the name of the author */
|
||||
author?: string;
|
||||
/** the subject of the document */
|
||||
subject?: string;
|
||||
/** keywords associated with the document */
|
||||
keywords?: string;
|
||||
creator?: string;
|
||||
producer?: string;
|
||||
creationDate?: Date;
|
||||
modDate?: Date;
|
||||
trapped?: string;
|
||||
}
|
||||
|
||||
export type DynamicContent = (
|
||||
currentPage: number,
|
||||
pageCount: number,
|
||||
pageSize: ContextPageSize,
|
||||
) => Content | null | undefined;
|
||||
|
||||
export type DynamicBackground = (currentPage: number, pageSize: ContextPageSize) => Content | null | undefined;
|
||||
|
||||
export type Margins = number | [number, number] | [number, number, number, number];
|
||||
|
||||
export type Decoration = 'underline' | 'lineThrough' | 'overline';
|
||||
export type DecorationStyle = 'dashed' | 'dotted' | 'double' | 'wavy';
|
||||
|
||||
export type Alignment = 'left' | 'right' | 'justify' | 'center';
|
||||
|
||||
export type DynamicRowSize = (row: number) => number | 'auto';
|
||||
|
||||
export interface CustomTableLayout {
|
||||
hLineWidth?: DynamicLayout<number>;
|
||||
vLineWidth?: DynamicLayout<number>;
|
||||
hLineColor?: string | DynamicLayout<string>;
|
||||
vLineColor?: string | DynamicLayout<string>;
|
||||
hLineStyle?: DynamicLayout<LineStyle>;
|
||||
vLineStyle?: DynamicLayout<LineStyle>;
|
||||
fillColor?: string | DynamicLayout<string>;
|
||||
paddingLeft?: number | DynamicLayout<number>;
|
||||
paddingRight?: number | DynamicLayout<number>;
|
||||
paddingTop?: DynamicLayout<number>;
|
||||
paddingBottom?: DynamicLayout<number>;
|
||||
fillOpacity?: number | DynamicLayout<number>;
|
||||
defaultBorder?: boolean;
|
||||
}
|
||||
|
||||
export type DynamicLayout<T> = (rowIndex: number, node: ContentTable, columnIndex: number) => T | null | undefined;
|
||||
|
||||
export interface LineStyle {
|
||||
dash?: {
|
||||
length: number;
|
||||
space?: number;
|
||||
};
|
||||
}
|
||||
|
||||
export type TableCell =
|
||||
| {} // Used when another cell spans over this cell
|
||||
| (Content & {
|
||||
rowSpan?: number;
|
||||
colSpan?: number;
|
||||
border?: [boolean, boolean, boolean, boolean];
|
||||
borderColor?: [string, string, string, string];
|
||||
fillOpacity?: number;
|
||||
});
|
||||
|
||||
export interface Table {
|
||||
body: TableCell[][];
|
||||
widths?: Size[];
|
||||
heights?: number | number[] | DynamicRowSize;
|
||||
headerRows?: number;
|
||||
dontBreakRows?: boolean;
|
||||
keepWithHeaderRows?: number;
|
||||
layout?: TableLayout;
|
||||
}
|
||||
|
||||
export type PredefinedTableLayout = 'noBorders' | 'headerLineOnly' | 'lightHorizontalLines';
|
||||
export type TableLayout = PredefinedTableLayout | CustomTableLayout;
|
||||
|
||||
export interface Style {
|
||||
/** name of the font */
|
||||
font?: string;
|
||||
/** size of the font in pt */
|
||||
fontSize?: number;
|
||||
fontFeatures?: PDFKit.Mixins.OpenTypeFeatures[];
|
||||
/** the line height (default: 1) */
|
||||
lineHeight?: number;
|
||||
/** whether to use bold text (default: false) */
|
||||
bold?: boolean;
|
||||
/** whether to use italic text (default: false) */
|
||||
italics?: boolean;
|
||||
/** the alignment of the text */
|
||||
alignment?: Alignment;
|
||||
/** the color of the text (color name e.g., ‘blue’ or hexadecimal color e.g., ‘#ff5500’) */
|
||||
color?: string;
|
||||
/** the background color of the text */
|
||||
background?: string;
|
||||
/** the color of the bullets in a buletted list */
|
||||
markerColor?: string;
|
||||
/** the text decoration to applu (‘underline’ or ‘lineThrough’ or ‘overline’) */
|
||||
decoration?: Decoration;
|
||||
/** (‘dashed’ or ‘dotted’ or ‘double’ or ‘wavy’) */
|
||||
decorationStyle?: DecorationStyle;
|
||||
/** the color of the text decoration, see color */
|
||||
decorationColor?: string;
|
||||
margin?: Margins;
|
||||
preserveLeadingSpaces?: boolean;
|
||||
opacity?: number;
|
||||
characterSpacing?: number;
|
||||
leadingIndent?: number;
|
||||
// Table-cell properties:
|
||||
noWrap?: boolean;
|
||||
/** the background color of a table cell */
|
||||
fillColor?: string;
|
||||
/** the background opacity of a table cell */
|
||||
fillOpacity?: number;
|
||||
/** optional space between columns */
|
||||
columnGap?: Size;
|
||||
// These properties appear in the documentation but don't do anything:
|
||||
// tableCellPadding?: unknown;
|
||||
// cellBorder?: unknown;
|
||||
// headerCellBorder?: unknown;
|
||||
// oddRowCellBorder?: unknown;
|
||||
// evenRowCellBorder?: unknown;
|
||||
// tableBorder?: unknown;
|
||||
}
|
||||
|
||||
export type Content =
|
||||
| string
|
||||
| ArrayOfContent
|
||||
| ContentText
|
||||
| ContentColumns
|
||||
| ContentStack
|
||||
| ContentUnorderedList
|
||||
| ContentOrderedList
|
||||
| ContentTable
|
||||
| ContentAnchor
|
||||
| ContentPageReference
|
||||
| ContentTextReference
|
||||
| ContentToc
|
||||
| ContentTocItem
|
||||
| ContentImage
|
||||
| ContentSvg
|
||||
| ContentQr
|
||||
| ContentCanvas;
|
||||
|
||||
// not exported, only used to prevent Content from circularly referencing itself
|
||||
interface ArrayOfContent extends Array<Content> {}
|
||||
|
||||
export interface ContentText extends ContentLink, ContentBase {
|
||||
text: Content;
|
||||
}
|
||||
|
||||
export interface ContentColumns extends ContentBase {
|
||||
columns: Column[];
|
||||
}
|
||||
|
||||
export interface ContentStack extends ContentBase {
|
||||
stack: Content[];
|
||||
}
|
||||
|
||||
/** for numbered lists set the ol key */
|
||||
export interface ContentOrderedList extends ContentBase {
|
||||
ol: OrderedListElement[];
|
||||
type?: OrderedListType;
|
||||
markerColor?: string;
|
||||
separator?: string | [string, string];
|
||||
reversed?: boolean;
|
||||
start?: number;
|
||||
}
|
||||
|
||||
/** to treat a paragraph as a bulleted list, set an array of items under the ul key */
|
||||
export interface ContentUnorderedList extends ContentBase {
|
||||
ul: UnorderedListElement[];
|
||||
type?: UnorderedListType;
|
||||
markerColor?: string;
|
||||
}
|
||||
|
||||
export interface ContentCanvas extends ContentBase {
|
||||
canvas: CanvasElement[];
|
||||
}
|
||||
|
||||
export interface ContentSvg extends ContentBase {
|
||||
svg: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
fit?: [number, number];
|
||||
}
|
||||
|
||||
export interface ContentImage extends ContentLink, ContentBase {
|
||||
image: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
fit?: [number, number];
|
||||
}
|
||||
|
||||
export interface ContentTable extends ContentBase {
|
||||
table: Table;
|
||||
layout?: TableLayout;
|
||||
}
|
||||
|
||||
export interface ContentAnchor extends ContentBase {
|
||||
text: string | ContentAnchor;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface ContentTocItem extends ContentBase {
|
||||
text: string | ContentTocItem;
|
||||
tocItem: boolean | string | string[];
|
||||
tocStyle?: string | string[] | Style;
|
||||
tocNumberStyle?: string | string[] | Style;
|
||||
tocMargin?: Margins;
|
||||
}
|
||||
|
||||
export interface ContentPageReference extends ContentBase {
|
||||
pageReference: string;
|
||||
}
|
||||
|
||||
export interface ContentTextReference extends ContentBase {
|
||||
textReference: string;
|
||||
}
|
||||
|
||||
export interface ContentToc extends ContentBase {
|
||||
toc: TableOfContent;
|
||||
}
|
||||
|
||||
export interface ContentQr extends ContentBase {
|
||||
qr: string;
|
||||
foreground?: string;
|
||||
fit?: number;
|
||||
version?: number;
|
||||
eccLevel?: 'L' | 'M' | 'Q' | 'H';
|
||||
mode?: 'numeric' | 'alphanumeric' | 'octet';
|
||||
mask?: number;
|
||||
}
|
||||
|
||||
export interface ContentBase extends Style {
|
||||
style?: string | string[] | Style;
|
||||
absolutePosition?: { x: number; y: number };
|
||||
relativePosition?: { x: number; y: number };
|
||||
pageBreak?: PageBreak;
|
||||
pageOrientation?: PageOrientation;
|
||||
headlineLevel?: number;
|
||||
}
|
||||
|
||||
export interface ContentLink {
|
||||
link?: string;
|
||||
linkToPage?: number;
|
||||
linkToDestination?: string;
|
||||
}
|
||||
|
||||
export interface TableOfContent {
|
||||
title?: Content;
|
||||
textMargin?: Margins;
|
||||
textStyle?: string | string[] | Style;
|
||||
numberStyle?: string | string[] | Style;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export type Column = Content & {
|
||||
width?: Size;
|
||||
};
|
||||
|
||||
export type OrderedListType = 'lower-alpha' | 'upper-alpha' | 'lower-roman' | 'upper-roman' | 'none';
|
||||
export type OrderedListElement = Content & {
|
||||
counter?: number;
|
||||
listType?: OrderedListType;
|
||||
};
|
||||
|
||||
export type UnorderedListType = 'square' | 'circle' | 'none';
|
||||
export type UnorderedListElement = Content & {
|
||||
listType?: UnorderedListType;
|
||||
};
|
||||
|
||||
export type CanvasElement = CanvasRect | CanvasPolyline | CanvasLine | CanvasEllipse;
|
||||
|
||||
export interface CanvasRect extends CanvasLineElement, CanvasFilledElement {
|
||||
type: 'rect';
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
r?: number;
|
||||
}
|
||||
|
||||
export interface CanvasPolyline extends CanvasLineElement, CanvasFilledElement {
|
||||
type: 'polyline';
|
||||
points: Array<{ x: number; y: number }>;
|
||||
closePath?: boolean;
|
||||
lineCap?: 'round' | 'square';
|
||||
}
|
||||
|
||||
export interface CanvasLine extends CanvasLineElement {
|
||||
type: 'line';
|
||||
x1: number;
|
||||
y1: number;
|
||||
x2: number;
|
||||
y2: number;
|
||||
lineCap?: 'round' | 'square';
|
||||
}
|
||||
|
||||
export interface CanvasEllipse extends CanvasLineElement, CanvasFilledElement {
|
||||
type: 'ellipse';
|
||||
x: number;
|
||||
y: number;
|
||||
r1: number;
|
||||
r2?: number;
|
||||
}
|
||||
|
||||
export interface CanvasFilledElement {
|
||||
color?: string;
|
||||
fillOpacity?: number;
|
||||
linearGradient?: string[];
|
||||
}
|
||||
|
||||
export interface CanvasLineElement {
|
||||
lineWidth?: number;
|
||||
lineColor?: string;
|
||||
dash?: {
|
||||
length: number;
|
||||
space?: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface StyleDictionary {
|
||||
[name: string]: Style;
|
||||
}
|
||||
|
||||
export type PDFVersion = '1.3' | '1.4' | '1.5' | '1.6' | '1.7' | '1.7ext3';
|
||||
|
||||
export interface Watermark {
|
||||
/** watermark text */
|
||||
text: string;
|
||||
/** opacity of text */
|
||||
opacity?: number;
|
||||
/** angle of text rotation (minimal version: 0.1.60) */
|
||||
angle?: number;
|
||||
font?: string;
|
||||
/** own font size of text (ideal size is calculated automatically) (minimal version: 0.1.60) */
|
||||
fontSize?: number;
|
||||
/** color of text */
|
||||
color?: string;
|
||||
/** bold style of text */
|
||||
bold?: boolean;
|
||||
/** italics style of text */
|
||||
italics?: boolean;
|
||||
}
|
||||
|
||||
export interface TDocumentDefinitions {
|
||||
content: Content;
|
||||
background?: DynamicBackground | Content;
|
||||
compress?: boolean;
|
||||
defaultStyle?: Style;
|
||||
footer?: DynamicContent | Content;
|
||||
header?: DynamicContent | Content;
|
||||
images?: { [key: string]: string };
|
||||
info?: TDocumentInformation;
|
||||
pageBreakBefore?: (
|
||||
currentNode: Node,
|
||||
followingNodesOnPage: Node[],
|
||||
nodesOnNextPage: Node[],
|
||||
previousNodesOnPage: Node[],
|
||||
) => boolean;
|
||||
pageMargins?: Margins;
|
||||
pageOrientation?: PageOrientation;
|
||||
pageSize?: PageSize;
|
||||
styles?: StyleDictionary;
|
||||
userPassword?: string;
|
||||
ownerPassword?: string;
|
||||
permissions?: PDFKit.DocumentPermissions;
|
||||
version?: PDFVersion;
|
||||
watermark?: string | Watermark;
|
||||
}
|
||||
|
||||
export interface Node {
|
||||
text?: Content;
|
||||
ul?: UnorderedListElement[];
|
||||
ol?: OrderedListElement[];
|
||||
table?: Table;
|
||||
image?: string;
|
||||
qr?: string;
|
||||
canvas?: CanvasElement;
|
||||
svg?: string;
|
||||
columns?: Column[];
|
||||
id?: string;
|
||||
headlineLevel?: number;
|
||||
style?: string | string[] | Style;
|
||||
pageBreak?: PageBreak;
|
||||
pageOrientation?: PageOrientation;
|
||||
pageNumbers: number[];
|
||||
pages: number;
|
||||
stack: boolean;
|
||||
startPosition: {
|
||||
pageNumber: number;
|
||||
pageOrientation: PageOrientation;
|
||||
pageInnerHeight: number;
|
||||
pageInnerWidth: number;
|
||||
left: number;
|
||||
top: number;
|
||||
verticalRatio: number;
|
||||
horizontalRatio: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ContextPageSize {
|
||||
height: number;
|
||||
width: number;
|
||||
orientation: PageOrientation;
|
||||
}
|
||||
|
||||
export interface BufferOptions {
|
||||
fontLayoutCache?: boolean;
|
||||
bufferPages?: boolean;
|
||||
tableLayouts?: TableLayout;
|
||||
autoPrint?: boolean;
|
||||
progressCallback?: (progress: number) => void;
|
||||
}
|
||||
|
||||
// disable automatic exporting
|
||||
export {};
|
||||
File diff suppressed because it is too large
Load Diff
2508
types/pdfmake/test/pdfmake-examples-tests.ts
Normal file
2508
types/pdfmake/test/pdfmake-examples-tests.ts
Normal file
File diff suppressed because it is too large
Load Diff
20
types/pdfmake/test/pdfmake-global-tests.ts
Normal file
20
types/pdfmake/test/pdfmake-global-tests.ts
Normal file
@ -0,0 +1,20 @@
|
||||
const fonts = {
|
||||
Roboto: {
|
||||
normal: 'Roboto-Regular.ttf',
|
||||
bold: 'Roboto-Medium.ttf',
|
||||
italics: 'Roboto-Italic.ttf',
|
||||
bolditalics: 'Roboto-MediumItalic.ttf',
|
||||
},
|
||||
};
|
||||
|
||||
pdfMake.fonts = fonts;
|
||||
|
||||
const dd = {
|
||||
content: 'Hello world!',
|
||||
};
|
||||
|
||||
// $ExpectType TCreatedPdf
|
||||
pdfMake.createPdf(dd);
|
||||
|
||||
// $ExpectType TCreatedPdf
|
||||
pdfMake.createPdf(dd, {}, fonts);
|
||||
14
types/pdfmake/test/pdfmake-import-default-tests.ts
Normal file
14
types/pdfmake/test/pdfmake-import-default-tests.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import pdfMake from "pdfmake/build/pdfmake";
|
||||
import pdfFonts from "pdfmake/build/vfs_fonts";
|
||||
|
||||
pdfMake.vfs = pdfFonts.pdfMake.vfs;
|
||||
|
||||
const dd = {
|
||||
content: 'Hello world!'
|
||||
};
|
||||
|
||||
// $ExpectType TCreatedPdf
|
||||
pdfMake.createPdf(dd);
|
||||
|
||||
// $ExpectType TCreatedPdf
|
||||
pdfMake.createPdf(dd, {}, fonts);
|
||||
238
types/pdfmake/test/pdfmake-interfaces-tests.ts
Normal file
238
types/pdfmake/test/pdfmake-interfaces-tests.ts
Normal file
@ -0,0 +1,238 @@
|
||||
import {
|
||||
Content,
|
||||
ContentImage,
|
||||
ContentOrderedList,
|
||||
ContentSvg,
|
||||
ContentUnorderedList,
|
||||
TDocumentDefinitions,
|
||||
} from 'pdfmake/interfaces';
|
||||
|
||||
const createContent: () => Content = () => 'allo';
|
||||
const content: Content = createContent();
|
||||
|
||||
if (typeof content !== 'string' && 'stack' in content) {
|
||||
// $ExpectType ContentStack
|
||||
content;
|
||||
}
|
||||
|
||||
const staticBackground: TDocumentDefinitions = {
|
||||
content: 'Content',
|
||||
background: 'Static Background',
|
||||
};
|
||||
|
||||
const noCompress: TDocumentDefinitions = {
|
||||
content: 'Content',
|
||||
compress: false,
|
||||
};
|
||||
|
||||
const documentMetadata: TDocumentDefinitions = {
|
||||
info: {
|
||||
title: 'awesome Document',
|
||||
author: 'john doe',
|
||||
subject: 'subject of document',
|
||||
keywords: 'keywords for document',
|
||||
creator: 'pdfmake',
|
||||
producer: 'pdfmake',
|
||||
creationDate: new Date('1970-01-01'),
|
||||
modDate: new Date('2020-02-29'),
|
||||
trapped: 'true',
|
||||
},
|
||||
content: 'This is an sample PDF printed with pdfMake',
|
||||
};
|
||||
|
||||
const dynamicHeaderFooter: TDocumentDefinitions = {
|
||||
footer: (currentPage, pageCount) => `${currentPage} of ${pageCount}`,
|
||||
header: (currentPage, pageCount, pageSize) => [
|
||||
// you can apply any logic and return any valid pdfmake element
|
||||
{ text: 'simple text', alignment: currentPage % 2 ? 'left' : 'right' },
|
||||
{ canvas: [{ type: 'rect', x: 170, y: 32, w: pageSize.width - 170, h: 40 }] },
|
||||
],
|
||||
content: 'This is an sample PDF printed with pdfMake',
|
||||
};
|
||||
|
||||
const staticHeaderFooter: TDocumentDefinitions = {
|
||||
header: 'simple text',
|
||||
footer: {
|
||||
columns: ['Left part', { text: 'Right part', alignment: 'right' }],
|
||||
},
|
||||
content: 'This is an sample PDF printed with pdfMake',
|
||||
};
|
||||
|
||||
const pageOrientation: TDocumentDefinitions = {
|
||||
pageOrientation: 'portrait',
|
||||
content: [
|
||||
{ text: 'Text on Portrait' },
|
||||
{ text: 'Text on Landscape', pageOrientation: 'landscape', pageBreak: 'before' },
|
||||
{ text: 'Text on Landscape 2', pageOrientation: 'portrait', pageBreak: 'after' },
|
||||
{ text: 'Text on Portrait 2' },
|
||||
],
|
||||
};
|
||||
|
||||
const autoPageHeight: TDocumentDefinitions = {
|
||||
pageSize: {
|
||||
width: 595.28,
|
||||
height: 'auto',
|
||||
},
|
||||
content: 'This is an sample PDF printed with pdfMake',
|
||||
};
|
||||
|
||||
const pageBreakBefore: TDocumentDefinitions = {
|
||||
content: [
|
||||
{ text: '1 Headline', headlineLevel: 1 },
|
||||
'Some long text of variable length ...',
|
||||
{ text: '2 Headline', headlineLevel: 1 },
|
||||
'Some long text of variable length ...',
|
||||
{ text: '3 Headline', headlineLevel: 1 },
|
||||
'Some long text of variable length ...',
|
||||
],
|
||||
pageBreakBefore: (currentNode, followingNodesOnPage, nodesOnNextPage, previousNodesOnPage) =>
|
||||
currentNode.headlineLevel === 1 && followingNodesOnPage.length === 0,
|
||||
};
|
||||
|
||||
const qrCodes: TDocumentDefinitions = {
|
||||
content: [
|
||||
{ qr: 'text in QR' },
|
||||
{ qr: 'text in QR', foreground: 'red', background: 'yellow' },
|
||||
{ qr: 'text in QR', fit: 500 },
|
||||
{ qr: 'text in QR', version: -1 },
|
||||
{ qr: 'text in QR', version: 1 },
|
||||
{ qr: 'text in QR', version: 40 },
|
||||
{ qr: 'text in QR', eccLevel: 'L' },
|
||||
{ qr: 'text in QR', eccLevel: 'M' },
|
||||
{ qr: 'text in QR', eccLevel: 'Q' },
|
||||
{ qr: 'text in QR', eccLevel: 'H' },
|
||||
{ qr: 'text in QR', mode: 'numeric' },
|
||||
{ qr: 'text in QR', mode: 'alphanumeric' },
|
||||
{ qr: 'text in QR', mode: 'octet' },
|
||||
{ qr: 'text in QR', mask: -1 },
|
||||
{ qr: 'text in QR', mask: 0 },
|
||||
{ qr: 'text in QR', mask: 7 },
|
||||
],
|
||||
};
|
||||
|
||||
const watermark: TDocumentDefinitions = {
|
||||
watermark: {
|
||||
text: 'test watermark',
|
||||
color: 'blue',
|
||||
opacity: 0.3,
|
||||
bold: true,
|
||||
italics: false,
|
||||
font: 'Roboto',
|
||||
fontSize: 15,
|
||||
angle: 30,
|
||||
},
|
||||
content: ['...'],
|
||||
};
|
||||
|
||||
const fontsUsage: TDocumentDefinitions = {
|
||||
content: [
|
||||
{ text: 'First paragraph', font: 'Times' },
|
||||
{
|
||||
text: 'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
|
||||
},
|
||||
],
|
||||
defaultStyle: {
|
||||
font: 'Helvetica',
|
||||
},
|
||||
};
|
||||
|
||||
const securityVersion: TDocumentDefinitions = {
|
||||
content: 'Content',
|
||||
userPassword: 'hunter2',
|
||||
permissions: {
|
||||
printing: 'lowResolution',
|
||||
},
|
||||
version: '1.5',
|
||||
};
|
||||
|
||||
const allPageSizes: TDocumentDefinitions[] = [
|
||||
{ content, pageSize: '4A0' },
|
||||
{ content, pageSize: '2A0' },
|
||||
{ content, pageSize: 'A0' },
|
||||
{ content, pageSize: 'A1' },
|
||||
{ content, pageSize: 'A2' },
|
||||
{ content, pageSize: 'A3' },
|
||||
{ content, pageSize: 'A4' },
|
||||
{ content, pageSize: 'A5' },
|
||||
{ content, pageSize: 'A6' },
|
||||
{ content, pageSize: 'A7' },
|
||||
{ content, pageSize: 'A8' },
|
||||
{ content, pageSize: 'A9' },
|
||||
{ content, pageSize: 'A10' },
|
||||
{ content, pageSize: 'B0' },
|
||||
{ content, pageSize: 'B1' },
|
||||
{ content, pageSize: 'B2' },
|
||||
{ content, pageSize: 'B3' },
|
||||
{ content, pageSize: 'B4' },
|
||||
{ content, pageSize: 'B5' },
|
||||
{ content, pageSize: 'B6' },
|
||||
{ content, pageSize: 'B7' },
|
||||
{ content, pageSize: 'B8' },
|
||||
{ content, pageSize: 'B9' },
|
||||
{ content, pageSize: 'B10' },
|
||||
{ content, pageSize: 'C0' },
|
||||
{ content, pageSize: 'C1' },
|
||||
{ content, pageSize: 'C2' },
|
||||
{ content, pageSize: 'C3' },
|
||||
{ content, pageSize: 'C4' },
|
||||
{ content, pageSize: 'C5' },
|
||||
{ content, pageSize: 'C6' },
|
||||
{ content, pageSize: 'C7' },
|
||||
{ content, pageSize: 'C8' },
|
||||
{ content, pageSize: 'C9' },
|
||||
{ content, pageSize: 'C10' },
|
||||
{ content, pageSize: 'RA1' },
|
||||
{ content, pageSize: 'RA2' },
|
||||
{ content, pageSize: 'RA3' },
|
||||
{ content, pageSize: 'RA4' },
|
||||
{ content, pageSize: 'SRA1' },
|
||||
{ content, pageSize: 'SRA2' },
|
||||
{ content, pageSize: 'SRA3' },
|
||||
{ content, pageSize: 'SRA4' },
|
||||
{ content, pageSize: 'EXECUTIVE' },
|
||||
{ content, pageSize: 'FOLIO' },
|
||||
{ content, pageSize: 'LEGAL' },
|
||||
{ content, pageSize: 'LETTER' },
|
||||
{ content, pageSize: 'TABLOID' },
|
||||
];
|
||||
|
||||
let ol: ContentOrderedList = {
|
||||
ol: ['1', '2', '3'],
|
||||
markerColor: 'blue',
|
||||
};
|
||||
ol = { ol: ['1'], type: 'lower-alpha' };
|
||||
ol = { ol: ['1'], type: 'upper-alpha' };
|
||||
ol = { ol: ['1'], type: 'lower-roman' };
|
||||
ol = { ol: ['1'], type: 'upper-roman' };
|
||||
ol = { ol: ['1'], type: 'none' };
|
||||
|
||||
let ul: ContentUnorderedList = {
|
||||
ul: ['1', '2', '3'],
|
||||
markerColor: 'blue',
|
||||
};
|
||||
|
||||
ul = { ul: ['1'], type: 'square' };
|
||||
ul = { ul: ['1'], type: 'circle' };
|
||||
ul = { ul: ['1'], type: 'none' };
|
||||
|
||||
const svg1: ContentSvg = {
|
||||
svg: 'test',
|
||||
width: 5,
|
||||
height: 5,
|
||||
};
|
||||
|
||||
const svg2: ContentSvg = {
|
||||
svg: 'test',
|
||||
fit: [50, 50],
|
||||
};
|
||||
|
||||
const image1: ContentImage = {
|
||||
image: 'test',
|
||||
width: 5,
|
||||
height: 5,
|
||||
};
|
||||
|
||||
const image2: ContentImage = {
|
||||
image: 'test',
|
||||
fit: [50, 50],
|
||||
};
|
||||
46
types/pdfmake/test/pdfmake-module-browser-tests.ts
Normal file
46
types/pdfmake/test/pdfmake-module-browser-tests.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import pdfFonts = require('pdfmake/build/vfs_fonts');
|
||||
import pdfMake = require('pdfmake/build/pdfmake');
|
||||
import { BufferOptions } from 'pdfmake/interfaces';
|
||||
|
||||
pdfMake.vfs = pdfFonts.pdfMake.vfs;
|
||||
|
||||
const dd = {
|
||||
content: 'Hello world!'
|
||||
};
|
||||
|
||||
const options: BufferOptions = {
|
||||
fontLayoutCache: true,
|
||||
bufferPages: true
|
||||
};
|
||||
|
||||
pdfMake.createPdf(dd).download();
|
||||
pdfMake.createPdf(dd).download('defaultFileName');
|
||||
pdfMake.createPdf(dd).download('defaultFileName', () => {
|
||||
console.log('Download finished');
|
||||
});
|
||||
pdfMake.createPdf(dd).download('defaultFileName', undefined, options);
|
||||
pdfMake.createPdf(dd).download(() => {
|
||||
console.log('Download finished');
|
||||
});
|
||||
pdfMake.createPdf(dd).download(() => {
|
||||
console.log('Download finished');
|
||||
}, options);
|
||||
|
||||
pdfMake.createPdf(dd).open();
|
||||
pdfMake.createPdf(dd).open(options);
|
||||
const win = window.open('', '_blank');
|
||||
pdfMake.createPdf(dd).open({}, win);
|
||||
pdfMake.createPdf(dd).open({}, window);
|
||||
|
||||
pdfMake.createPdf(dd).print();
|
||||
pdfMake.createPdf(dd).print(options);
|
||||
pdfMake.createPdf(dd).print({}, win);
|
||||
pdfMake.createPdf(dd).print({}, window);
|
||||
|
||||
const pdfDocGenerator = pdfMake.createPdf(dd);
|
||||
pdfDocGenerator.getDataUrl((dataUrl) => {
|
||||
const targetElement = document.querySelector('#iframeContainer');
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.src = dataUrl;
|
||||
targetElement!.appendChild(iframe);
|
||||
});
|
||||
33
types/pdfmake/test/pdfmake-module-server-tests.ts
Normal file
33
types/pdfmake/test/pdfmake-module-server-tests.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import PdfPrinter = require('pdfmake');
|
||||
import {
|
||||
BufferOptions,
|
||||
TDocumentDefinitions,
|
||||
TFontDictionary,
|
||||
} from 'pdfmake/interfaces';
|
||||
|
||||
const fonts: TFontDictionary = {
|
||||
Roboto: {
|
||||
normal: 'fonts/Roboto-Regular.ttf',
|
||||
bold: 'fonts/Roboto-Medium.ttf',
|
||||
italics: 'fonts/Roboto-Italic.ttf',
|
||||
bolditalics: 'fonts/Roboto-MediumItalic.ttf',
|
||||
},
|
||||
};
|
||||
|
||||
const printer = new PdfPrinter(fonts);
|
||||
|
||||
const dd: TDocumentDefinitions = {
|
||||
content: 'Hello world!',
|
||||
};
|
||||
|
||||
const options: BufferOptions = {
|
||||
fontLayoutCache: true,
|
||||
bufferPages: true,
|
||||
tableLayouts: 'noBorders',
|
||||
autoPrint: true,
|
||||
progressCallback: progress =>
|
||||
console.log('Creating pdf: ', progress * 100, '%...'),
|
||||
};
|
||||
|
||||
// $ExpectType PDFDocument
|
||||
printer.createPdfKitDocument(dd, options);
|
||||
1438
types/pdfmake/test/pdfmake-playground-examples-tests.ts
Normal file
1438
types/pdfmake/test/pdfmake-playground-examples-tests.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -19,6 +19,12 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"pdfmake-tests.ts"
|
||||
"test/pdfmake-interfaces-tests.ts",
|
||||
"test/pdfmake-playground-examples-tests.ts",
|
||||
"test/pdfmake-examples-tests.ts",
|
||||
"test/pdfmake-global-tests.ts",
|
||||
"test/pdfmake-import-default-tests.ts",
|
||||
"test/pdfmake-module-browser-tests.ts",
|
||||
"test/pdfmake-module-server-tests.ts"
|
||||
]
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user