国产探花免费观看_亚洲丰满少妇自慰呻吟_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>

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

圖片精選

主站蜘蛛池模板: 紫金县| 洛南县| 新巴尔虎左旗| 六安市| 嫩江县| 石嘴山市| 错那县| 平乐县| 南溪县| 翼城县| 葵青区| 司法| 时尚| 新平| 昌江| 湘潭市| 吉水县| 闽侯县| 偏关县| 岗巴县| 临沂市| 汉中市| 南靖县| 商南县| 和静县| 兴义市| 定边县| 五原县| 云和县| 炎陵县| 永兴县| 浠水县| 金坛市| 蛟河市| 文化| 台安县| 天门市| 东平县| 新田县| 安义县| 秭归县|