jspdf - 如何添加图像
问题描述
如何添加图像
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Create PDF</title>
<header>
<script src="../js/jspdf/jsPDF-1.3.2/examples/js/jquery/jquery-1.7.1.min.js"></script>
<script src="../js/jspdf/jsPDF-1.3.2/examples/js/jquery/jquery-ui-1.8.17.custom.min.js"></script>
<script src="../js/jspdf/jsPDF-1.3.2/jspdf.js"></script>
<script type="text/javascript" src="../js/jspdf/jsPDF-1.3.2/plugins/addimage.js"></script>
<script type="text/javascript" src="../js/jspdf/jsPDF-1.3.2/plugins/from_html.js"></script>
<script type="text/javascript" src="../js/jspdf/jsPDF-1.3.2/plugins/ie_below_9_shim.js"></script>
<script type="text/javascript" src="../js/jspdf/jsPDF-1.3.2/plugins/svg.js"></script>
<script type="text/javascript" src="../js/jspdf/jsPDF-1.3.2/plugins/split_text_to_size.js"></script>
<script type="text/javascript" src="../js/jspdf/jsPDF-1.3.2/plugins/standard_fonts_metrics.js"></script>
<script type="text/javascript" src="../js/jspdf/jsPDF-1.3.2/plugins/autoprint.js"></script>
</head>
<body>
<script>
var doc = new jsPDF();
var name = "Doe, John"
doc.setFontType("normal");
doc.setFontSize(12);
doc.addImage('../PDF/HEADER.jpg', "JPEG", 50, 0, 180, 180);
doc.text(20,20,'Name: '+ name);
doc.autoPrint();
window.open(doc.output('bloburl'), '_blank');
</script>
</body>
</html>
我收到提供的数据不是 JPEG
我认为它需要以某种方式进行转换,但无论我尝试什么都行不通。我很难过
谢谢
解决方案
推荐阅读
- ios - UICollectionViewCell sizeForItemAt 值以某种方式恢复为 fitItemSize?
- c# - 从 oracle sql devloper 中的 NCLOB 数据类型列复制时数据丢失/被截断
- r - 为什么 lapply(file_list, function(i){} 不起作用?
- ethereum - addr.transfer(1 ether) 的可靠性错误
- sharepoint - 从 SharePoint 列表提取到 Power BI 的数据不正确
- .net-core - DisplayAttribute 在 Dotnet Core 伙伴类中不起作用
- java - 如何使用 Hibernate 检索 SQL 错误消息
- node.js - 如何运行另一个 .js 文件的内容?
- java - 我想使用 eclipse java 代码连接到 Sql Developer Database
- rust - 没有为 impl 实现特征 std::ops::Try