javascript - 以角度将HTML页面导出为pdf
问题描述
导出为并导出 pdf,导出的 pdf 文档不正确,它没有拉伸插入的全红色标记以供参考,附加图像。下面是我的配置:
exportAsConfig: ExportAsConfig = {
type: 'pdf', // the type you want to download
//elementId: 'balance-sheet-preview', // the id of html/table element
elementId: 'contentToConvert', // the id of html/table element
options: { // html-docx-js document options
margins: {
top: '20',
bottom: '5'
},
orientation: 'landscape',
filename: 'engagement.pdf',
image: { type: 'jpeg', quality: 1 },
}
}
调用函数:
export(){
this.exportAsService.save(this.exportAsConfig, 'engagementLetter').subscribe(() => {
// save started
});
}
解决方案
在 google chrom 中,您可以将视图设置为打印并指定要打印的媒体类型,然后添加与打印类型相关的 css 此 css 仅适用于打印心情使用此答案来检查如何切换到打印心情。
推荐阅读
- bazel - 替换和 Java 库生命周期
- excel - VBA:如何根据包含某些字符的相邻单元格删除列?
- javascript - 用 Javascript 比较日期不起作用
- python - 隐蔽到稀疏矩阵 - TypeError:不支持类型转换:(dtype('0'),)
- reactjs - useState 不能正常工作 在函数中使用了几次
- swift - Swift 5.0:如何修复 nw_path_close_fd 无法关闭受保护的 necp fd 4 [9: Bad file descriptor] 错误
- r - 在以列标签为字符向量的函数中使用 dplyr 动词
- javascript - 在 JavaScript 中动态设置多个 CSS 样式以使其应用于节点的最有效方法是什么?
- java - 从特定行从sql中的表获取数据到android studio中的textview
- r - 使用 igraph,如何从入站/出站位置(2 列)生成边缘列表?