admin管理员组文章数量:1399983
I'm a newbie to AngularJS and using AngularJS for my web app.
On one page of my web app, I'm fetching data from database and displaying in a table. The data is in JSON format. And, since it contains multiple entries of the same type, it's an array.
I want to provide a Download button to the user and a radio button with the options of .pdf and .docx.
The User will select one of the file formats and click on Download button in order to download the data displayed in table into the selected file format on his/her local machine.
How to achieve it? Can someone please guide me in this regard?
Since the code to fetch and display data in table is too big that's why I haven't given any code snippet here.
If you want I can provide you the same.
If you can explain with some pletely working examples for both file formats(.docx and .pdf) in AngularJS it would be really really great to me and other buddies.
Thanks.
I'm a newbie to AngularJS and using AngularJS for my web app.
On one page of my web app, I'm fetching data from database and displaying in a table. The data is in JSON format. And, since it contains multiple entries of the same type, it's an array.
I want to provide a Download button to the user and a radio button with the options of .pdf and .docx.
The User will select one of the file formats and click on Download button in order to download the data displayed in table into the selected file format on his/her local machine.
How to achieve it? Can someone please guide me in this regard?
Since the code to fetch and display data in table is too big that's why I haven't given any code snippet here.
If you want I can provide you the same.
If you can explain with some pletely working examples for both file formats(.docx and .pdf) in AngularJS it would be really really great to me and other buddies.
Thanks.
Share Improve this question edited Apr 3, 2016 at 11:43 PHPLover asked Mar 29, 2016 at 9:49 PHPLoverPHPLover 13k53 gold badges172 silver badges324 bronze badges 3- 2 just google for a javascript library that enable you to easily convert your json data to PDF, something like github./MrRio/jsPDF – Naigel Commented Mar 29, 2016 at 9:52
- 1 the same person also created this github./MrRio/DOCX.js – jcubic Commented Mar 29, 2016 at 9:54
- I'd agree, there's nothing gained from building it yourself unless it's a specialised system, but yours sounds like a very standard way of doing things so it would be far better to use a pre-made system and not waste the time. – GeorgeWL Commented Mar 29, 2016 at 11:30
3 Answers
Reset to default 4 +25There are some few good resources. I use https://mozilla.github.io/pdf.js/ for PDF and https://github./evidenceprime/html-docx-js for docx though it needs some manipulations.
Try these that I could find. This is not supposed to be a list of options but each of them have different functionalities. But it surely does not make sense making your own port for these.
PDF http://pdfkit/ for extended PDF formatting
https://github./tuckerjt07/pdfmake allows for PDF formatting
https://github./Prashanth-Nelli/jsPdfTablePlugin Straight forward simple usage
http://github./MrRio/jsPDF frequently used
DOCx
http://github./MrRio/DOCX.js
https://github./evidenceprime/html-docx-js
Angular UI-Grid has implemented PDF/CSV Export from grid.
Please refer UI-Grid Export Data
They are using Pdfmake to generate PDF of exported data.
just google for a javascript library that enable you to easily convert your json data to PDF, something like http://github./MrRio/jsPDF – Naigel Mar 29 at 9:52
the same person also created this http://github./MrRio/DOCX.js – jcubic Mar 29 at 9:54
I'd agree, there's nothing gained from building it yourself unless it's a specialised system, but yours sounds like a very standard way of doing things so it would be far better to use a pre-made system and not waste the time that could be spent better developing the bespoke parts of the system.
本文标签:
版权声明:本文标题:javascript - How to create and download a file in PDF and docx format which is to be created from the data in table in AngularJS 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744237582a2596629.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论