我是一名教师正在从事去年夏天开始的项目。我现在正在尝试将我在HTML中创建的表单转换为PDF。最后,我希望将此PDF存储在mySQL数据库中并打印到我们网络上的指定打印机。
我遇到的问题是什么都没发生。页面未更改为PDF。我已经看过这个过程的几个例子,代码似乎没有做任何事情。
这是包含表单
的HTML--------------------------开始HTML ------------------- -------------------
<!DOCTYPE html>
<html>
<?php
$img_1 = 'new_checkbox_empty.gif';
?>
<head>
<title>OUSD URF</title>
</head>
<body>
<div id="urfForm">
<center>
<table border="1" width="100%">
<table width="100%">
<tr>
<td><IMG SRC="OUSD_URF_Logo.jpg"></td>
<td>Universal Office Discipline Referral Form</td>
</tr>
</table>
<table width="100%">
<tr>
<td>Student________________________</td>
<td>Grade______</td>
<td>Referring Staff___________________________</td>
<td>Date_________</td>
<td>Time_________</td>
</tr>
</table>
<HR width="100%">
<table border="1" width="100%">
<thead>Pre-referral Interventions (For Minor Behaviors). Before making an office Referral, please complete at least 3 pre-referral interventions.<br>Minor Behaviors may include: Disrespect/non-compliance, Dress code Violation, Electronic Device, Horseplay, Inappropriate language, Inappropriate physical contact, Misuse/destruction of property, Tardy</thead>
<tr>
<td width="33%"><IMG SRC="<?php echo $img_1?>" style="margin: 0px 5px" style="margin: 0px 5px">5-1 Positive Reinforcement</td>
<td width="33%"><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px" style="margin: 0px 5px">Parent Consultation</td>
<td width="33%"><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px" style="margin: 0px 5px">Restorative Conversation</td>
</tr>
<tr>
<td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Buddy Room (15 Minutes Max)</td>
<td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Problem Solving Conference</td>
<td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Reviewed IEP/504</td>
</tr>
<tr>
<td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Behavior Contract</td>
<td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Prompting Desired Behavior</td>
<td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Re-teaching Desired Behavior</td>
</tr>
<tr>
<td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Conflict Mediation</td>
<td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Proximity or Seat change</td>
<td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Reviewed IEP/504</td>
</tr>
<tr>
<td colspan="2"><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Explicitly taught & Rehearsed Rules & Expectations</td>
</tr>
</table>
</table>
</center>
</div>
<br><br>
<a href="javascript:urf2PDF()">Submit Form</a>
<hr />
<script src="jsPDF/jspdf.js"></script>
<script src="jsPDF/jquery.js"></script>
<script src="jsPDF/test.js"></script>
</body>
</html>
-------------------------结束HTML -------------------- --------------------
这是我的js
-----------------------------开始JS ---------------- --------------------
function urf2PDF() {
var doc = new jsPDF('p', 'pt', 'letter');
source = $('#urfForm') [0];
var specialElementHandlers = {
'#bypassme': function(element, renderer){
return true
}
};
margins = {
top: 40,
left: 50,
width: 545
};
pdf.fromHTML(
source
, margins.left
, margins.top
, {
'width" : margins.width
, 'elementHandlers': specialElementHandlers
},
function (dispose) {
pdf.save('urfForm.pdf');
}
)
}
------------------------- End JS -------------------- ---------------------
先感谢您的协助。
-Kenny
答案 0 :(得分:1)
您的'pdf.fromHTML功能标记存在问题。你写了'而不是',这打破了序列。我已经纠正了下面的错误;
function urf2PDF() {
var doc = new jsPDF('p', 'pt', 'letter');
source = $('#urfForm') [0];
var specialElementHandlers = {
'#bypassme': function(element, renderer){
return true
}
};
margins = {
top: 40,
left: 50,
width: 545
};
pdf.fromHTML(
source
, margins.left
, margins.top
, {
"width" : margins.width,
"elementHandlers": specialElementHandlers
},
function (dispose) {
pdf.save('urfForm.pdf');
})
}
你能告诉我们吗?
干杯