You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems to me that the builder design pattern is most suitable for this library.
constbrandInvoiceBuilder=newInvoiceBuilder().useStyles(newStyleBulder().withDocument({marginLeft: 30,marginRight: 30,marginTop: 30}).withFonts({ ... }).withHeader({ ... })// or use style objects as well// if you pass style builder, invoice builder will build your styles automatically);// then in any business logicbrandInvoiceBuilder.generate(invoiceData,'path/to/your/invoice.pdf');
If you don't use custom styles, it will generate an invoice with default styles. Also if you use StyleBuilder with no or partial use of its methods, it will create default styles or your styles that have been merged with the default styles
constdefaultInvoiceBuilder=newInvoiceBuilder();// or new InvoiceBuilder().useStyles(new StyleBuilder())defaultInvoiceBuilder.generate(invoiceData,'path/to/your/invoice.pdf');
The text was updated successfully, but these errors were encountered:
Alternatively, we could put StyleBuilder to above level. And also add a Prototype (Clone) design pattern. This makes it possible to generate styles for each brand more conveniently
constgeneralInvoiceBuilder=newInvoiceBuilder().withDocument({marginLeft: 30,marginRight: 30,marginTop: 30}).withFonts({ ... }).withText({ ... })constfooBrandInvoiceBuilder=generalInvoiceBuilder.clone().withHeader({ ... }).withTable({ ... })// fooBrandInvoiceBuilder.generate(data, 'invoice.pdf');constbarBrandInvoiceBuilder=generalInvoiceBuilder.clone().withText({ ... })// will be merged with general text styles.withHeader({ ... });// used default styles for `table`// barBrandInvoiceBuilder.generate(data, 'invoice.pdf');
It seems to me that the builder design pattern is most suitable for this library.
If you don't use custom styles, it will generate an invoice with default styles. Also if you use
StyleBuilder
with no or partial use of its methods, it will create default styles or your styles that have been merged with the default stylesThe text was updated successfully, but these errors were encountered: