ng-pdf-make
This is library creates a bridge to use pdfmake library with your angular 2 implementation.
Notice:
The update 0.1.0 is released to fix some of the issues reported and was updated to continue working with angular 2.x.
The angular 4/6 support will be relased in the future, be pacient.
Install
You can get it on npm:
npm install ng-pdf-make --save
Ready
pdfmake is fully customizable, so for now the options ready to use are:
- Simple text insertion.
- Some Styles for text.
- Basic Columns.
- Basic Tables with custom column width.
- Ordered list with reverse and start properties.
- Unordered list.
- Images from url, with custom width and height properties.
- Download function with custom file name.
- Open function.
- Print function.
- Page properties (Size and orientation).
- Inline text styles using css format.
- Columns widths and styles using css style format.
To do
- Nested tables.
- More customizable tables.
- Nested Lists.
- Margins.
Setup
You'll need to add PdfmakeModule
to your application module.
;
Usage
Use the pdfmake service in your component:
;;
Use tables
To use tables is necesary import some objects to create cells, rows an the table:
;;;
Functions
To use the open, download and print functions you can override the methods in the service or call it directly.
in your view
Open PDFPrint PDFDownload PDF
or
in your controller
openPdf printPdf downloadPDF downloadPdfWithNamecustomName: string
Advance
If you need to use some unimplemented function, you can send the tradicional dictionary document structure to the documentDefinition
attribute in the service.
pdfmake.documentDefinition =
Credits
- pdfmake by @bpampuch and @liborm85
- @jtpdev - Suggestions, features and an alternative library here https://github.com/jtpdev/ng-pdf-make