私は昨年夏に開始したプロジェクトに取り組んでいる先生です。私は今、私がHTMLで作成したフォームをPDFに変換しようとしています。最終的に私はこのPDFをmySQLデータベースに保存し、私たちのネットワーク上の指定されたプリンタに印刷したいと思います。jspdfを使用してHTMLをPDFに変換する際に問題が発生しました
問題は何も起こっていないということです。ページが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>
------------ ------------- End 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');
}
)
}
-------------------------終了JS ---------------- -------------------------
ご協力いただきありがとうございます。
-Kenny
ことはできますか? – 4castle
何も起こっていません。ファイルが作成されていません。PDFが作成されたことを示す画面はありません。 – KenWill1978
あなたが提供したものを見ました。 zanはそこにタイプミスがあることを示しています。間違いなくそれを修正します。それ以外にも、 'plugins/from_html.js'を含めて 'doc.fromHTML()'を呼び出す必要があります。定義していないpdfエラーがあります。 ---- 'from_html.js:537 Uncaught TypeError:renderer.pdf.sHashCodeは関数ではありません - これは私が出くわした次の問題です。最初の2つの修正を実装し、ライブラリを更新することをお勧めします。この問題は、新しいバージョンのpdfJSで解決されている可能性があります。がんばろう! – Conceptz