wnabil / ngx-export-as

Angular 2+ / Ionic 2+ HTML/table element to export it as JSON, XML, PNG, CSV, TXT, MS-Word, Ms-Excel, PDF
MIT License
68 stars 40 forks source link

PDFs: Support string input in addition to element ID input #61

Closed zorent-zebra closed 4 years ago

zorent-zebra commented 4 years ago

If you want to create a PDF today, you supply an elementId in the config and the code makes a PDF from the HTML in that element. We have HTML elements where we want a special PDF-view for certain elements which we don't want to appear on the page. We were wondering whether ngx-export-as could accept string content in the HTML.

It looks like html2pdf supports getting content from a string https://github.com/eKoopmans/html2pdf.js#workflow

Could adding this feature to accept a string source element via config be possible? https://github.com/wnabil/ngx-export-as/blob/master/projects/ngx-export-as/src/lib/export-as.service.ts#L135

This would truly help us build what we need.

Thanks!

wnabil commented 4 years ago

Thanks for the note, I released a new version 1.4.2 which includes support for all the available types "pdf only" now, please upgrade

DomEscobar commented 4 years ago

If I run ng build now, i get the error -> Argument of type '{ type: string; elementIdOrContent: string; }' is not assignable to parameter of type 'ExportAsConfig'.

wnabil commented 4 years ago

@DomEscobar import the interface and use it