如何在Angular 2中将Ag-Grid导出为PDF格式? [英] How to Export Ag-Grid to PDF Format in Angular 2?

查看:79
本文介绍了如何在Angular 2中将Ag-Grid导出为PDF格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Angular 2中使用AG-GRID.我发现只有将网格导出到Excel的选项.

I'm working on AG-GRID in Angular 2. I have found that there is an option only to export the grid into Excel.

如何将网格导出为PDF?

How can I export the grid into PDF?

推荐答案

在保留样式的同时导出为pdf是一项非常棘手的任务,并且有一些选项可以满足您的需求.

Exporting to pdf whilst keeping the styling is a pretty tricky task and there are a few options out there to do what you desire.

  1. html2pdf :这会将html转换为画布,然后从画布转换为图像,然后转换为图像从图片到pdf.问题在于这种实现方式倾向于产生低分辨率的图像.

  1. html2pdf: This converts the html to canvas then from canvas to an image and then from image to pdf. The problem is that this implementation tends to produce a low resolution image.

jsPdf :该库是js的实现,因此不包含页面样式.必须使用 jsPdf 分别添加样式,并且样式有所限制,因此重新创建由 AG_GRID 生成的相当复杂的设计将需要大量的工作.

jsPdf: This library is a js implementation and therefore does not include the page styling. Styles have to be added separately using the jsPdf and it is a bit limited so recreating the quite complex design generated by AG_GRID would require a lot of work.

phantomjs :这是Api提供的屏幕捕获功能的无头弓箭手. rastersize 是实现的示例,可以集成通过创建用于调用phantomjs的队列来将其导入应用程序.

phantomjs: This is a headless bowser which Api provides screen capture capability. rastersize is an example of the implementation, this can be integrated into an app by creating a que for calls to phantomjs.

这篇关于如何在Angular 2中将Ag-Grid导出为PDF格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆