คัดลอกรหัสรหัสดังนี้:
<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 ({// ตั้งค่าแอตทริบิวต์เอกสาร
ชื่อเรื่อง: 'ชื่อ',
เรื่อง: 'นี่คือหัวเรื่อง',
ผู้แต่ง: 'Dragon',
คำสำคัญ: 'JavaScript, Web 2.0, Ajax',
ผู้สร้าง: 'meee'
-
doc.settextcolor (0,255,0);
doc.setFontSize (22);
doc.setFont ("เวลา");
doc.setfonttype ("ตัวเอียง");
doc.text (20, 20, 'Hello World!');
doc.settextcolor (255,0,0);
doc.setFontSize (16);
doc.setFont ("helvetica");
doc.setfonttype ("bold");
doc.text (20, 30, 'นี่คือ JavaScript ขนาดไคลเอ็นต์, สูบน้ำ 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'); // ส่งออกโดยตรงไปยังหน้าเว็บใหม่
document.getElementById ("IFRAME123")
-
</script>
</head>
<body>
<iframe id = "iframe123" frameborder = "0"> </iframe>
</body>
</html>