[英]How do I export the data rendered by react component to pdf?
I have a component view which has images, tables, and list styled with CSS. 我有一个组件视图,其中包含使用CSS样式的图像,表格和列表。 Is there a legit approach to export/save that view to pdf?
是否有合法方法将该视图导出/保存到pdf?
ctrl+p
doesn't really work because it grabs the entire page with navigation etc. I'm thinking to implement print
button which will redirect to another "PrintComponentCleanView" and from there do ctrl+p
. ctrl+p
并不能真正起作用,因为它会通过导航等方式抓取整个页面。我正在考虑实现print
按钮,该按钮将重定向到另一个“ PrintComponentCleanView”,然后从那里进行ctrl+p
。 This is a 2 step process. 这是一个两步过程。 I'm sure there is a better approach to accomplish this.
我敢肯定有更好的方法可以做到这一点。 Any ideas appreciated.
任何想法表示赞赏。
Adding print styles in your existing stylesheet: 在现有样式表中添加打印样式:
@media print
{
.navbar {
display: none;
}
...
}
Adding a different stylesheet for printing: 添加其他样式表进行打印:
<link rel="stylesheet" type="text/css" media="print" href="style.css">
You can then use window.print();
然后可以使用
window.print();
for opening up the Print dialog. 用于打开“打印”对话框。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.