1- import { FontStore } from '../font-store.ts' ;
2- import { ImageStore } from '../image-store.ts' ;
3- import { layoutPages } from '../layout/layout.ts' ;
4- import { readDocumentDefinition } from '../read-document.ts' ;
5- import { renderDocument } from '../render/render-document.ts' ;
6- import { readAs } from '../types.ts' ;
71import type { DocumentDefinition } from './document.ts' ;
2+ import { PdfMaker } from './PdfMaker.ts' ;
83
94/**
105 * Generates a PDF from the given document definition.
@@ -16,11 +11,9 @@ import type { DocumentDefinition } from './document.ts';
1611 * that instance.
1712 */
1813export async function makePdf ( definition : DocumentDefinition ) : Promise < Uint8Array > {
19- const def = readAs ( definition , 'definition' , readDocumentDefinition ) ;
20- const fontStore = new FontStore ( def . fonts ?? [ ] ) ;
21- const imageStore = new ImageStore ( def . images ?? [ ] ) ;
22- const guides = ! ! def . dev ?. guides ;
23- const ctx = { fontStore, imageStore, guides } ;
24- const pages = await layoutPages ( def , ctx ) ;
25- return await renderDocument ( def , pages ) ;
14+ console . warn (
15+ 'makePdf is deprecated. Create an instance of `PdfMaker` and call `makePdf` on that instance.' ,
16+ ) ;
17+ const pdfMaker = new PdfMaker ( ) ;
18+ return await pdfMaker . makePdf ( definition ) ;
2619}
0 commit comments