import { IInfo , IImg , IText , IStyleDefinition , IPermissions , ICustomPageSize , IDocumentNode , IUseFont } from './interfaces' ; import { isBase64 } from './utils/is-base64' ; /**
 * Class that contains the essencial for the document definition
 */ export class DocumentDefinition { private static usedFont : IUseFont ; /**
     * It defines the pdf definition
     */ private definition : any = { content : [ ] } ; constructor ( ) { if ( DocumentDefinition . usedFont ) { this . defaultStyle ( DocumentDefinition . usedFont ) ; } } param fontName public static useFont ( fontName ) { DocumentDefinition . usedFont = { font : fontName } ; } param content public add ( content ) { this . definition . content . push ( content ) ; } example param imgs public images ( imgs ) { const newImgs = { } ; for ( let img in imgs ) { if ( typeof imgs [ img ] === 'string' && isBase64 ( imgs [ img ] as string ) ) { newImgs [ img ] = imgs [ img ] ; } else if ( typeof imgs [ img ] !== 'string' ) { newImgs [ img ] = ( imgs [ img ] as IImg ) . image ; } } this . definition . images = newImgs ; } example param styles public styles ( styles ) { this . definition . styles = styles ; } example param styles public defaultStyle ( styles ) { this . definition . defaultStyle = { ... ( this . definition . defaultStyle || { } ) , ... styles } ; } param header public header ( header ) { this . definition . header = header ; } param footer public footer ( footer ) { this . definition . footer = footer ; } param background public background ( background ) { this . definition . background = background ; } param size public pageSize ( size ) { this . definition . pageSize = size ; } param margin public pageMargins ( margin ) { this . definition . pageMargins = margin ; } param orientation public pageOrientation ( orientation ) { this . definition . pageOrientation = orientation ; } param breakBefore public pageBreakBefore ( breakBefore ) { this . definition . pageBreakBefore = breakBefore ; } param info public info ( info ) { this . definition . info = info ; } param compress public compress ( compress ) { this . definition . compress = compress ; } /**
     * Set a watermark
    */ public watermark ( watermark ) { this . definition . watermark = watermark ; } /**
     * Set a raw content
    */ public rawContent ( content ) { this . definition . content = content ; } param password public userPassword ( password ) { this . definition . userPassword = password ; } param password param permissions public permissions ( password , permissions ) { this . definition . ownerPassword = password ; this . definition . permissions = permissions ; } /**
     * Gets the document definition
     */ public getDefinition ( ) { return this . definition ; } }