国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

jsPDF生成pdf后在網頁展示實例

2024-05-06 16:00:01
字體:
來源:轉載
供稿:網友
本文為大家介紹下jsPDF生成pdf后如何在網頁展示,下面有個不錯示例,大家可以參考下

復制代碼 代碼如下:


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>jsPDF</title>
<script type="text/javascript" src="jspdf.js"></script>
<script type="text/javascript">
window.onload=function(){
var doc = new jsPDF();
//var doc = new jsPDF('landscape');//橫排

doc.setProperties({//設置文檔屬性
title: 'Title',
subject: 'This is the subject',
author: 'Dragon',
keywords: 'javascript, web 2.0, ajax',
creator: 'MEEE'
});

doc.setTextColor(0,255,0);
doc.setFontSize(22);
doc.setFont("times");
doc.setFontType("italic");
doc.text(20, 20, 'Hello world!');//添加文字

doc.setTextColor(255,0,0);
doc.setFontSize(16);
doc.setFont("helvetica");
doc.setFontType("bold");
doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.');

doc.addPage();//添加頁

doc.setLineWidth(1);//設置線寬
doc.setDrawColor(0,255,0);//設置畫筆顏色
doc.setFillColor(255,0,0);//設置填充顏色
doc.line(60, 20, 115, 60);//畫線,兩個坐標
doc.rect(100, 50, 20, 30); //畫矩形,左上角坐標,寬度,高度,只有邊框
doc.ellipse(20, 20, 20, 10, 'F');//畫橢圓,中心點坐標,寬度,高度,只有邊
doc.circle(120, 20, 20, 'FD');//畫圓,中心點坐標,半徑,邊框和填充都有
doc.triangle(100, 100, 110, 100, 120, 130, 'FD');

//doc.output('datauri');//直接輸出為新的web頁
document.getElementById("iframe123").src = doc.output('datauristring');//在iframe中顯示
}
</script>
</head>
<body>
<iframe frameborder="0"></iframe>
</body>
</html>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 上蔡县| 南华县| 沿河| 龙南县| 瑞昌市| 德庆县| 通城县| 永平县| 广平县| 卢湾区| 宣汉县| 诏安县| 休宁县| 从化市| 丹寨县| 胶南市| 虎林市| 巴里| 辽源市| 兰州市| 普格县| 滕州市| 美姑县| 新泰市| 南投市| 鄂尔多斯市| 南开区| 绍兴县| 罗源县| 沅陵县| 吴旗县| 陵川县| 玛沁县| 五指山市| 岳池县| 望都县| 淅川县| 沙田区| 峡江县| 会同县| 万宁市|