フォーマットに問題があります。私のHTMLテーブルのヘッダーは両側にありますが、それはとてもひどいですPicture bellow)。 そして、私はPDFファイルにページ番号を挿入したくない(私はそれを行う方法を知らない)。 (MySQLからの値を持つ)HTMLテーブルからPDFへフォーマットしたい(ページ番号、2ページ目が悪い)
私のJavascriptの
function makePDF() {
var pdf = new jsPDF('l', 'pt', 'letter');
source = $('#PDF')[0];
specialElementHandlers = {
'#bypassme': function(element, renderer) {
return true
}
};
margins = {
top: 80,
bottom: 60,
left: 40,
width: 522
};
pdf.fromHTML(
source,
margins.left,
margins.top, {
'width': margins.width,
'elementHandlers': specialElementHandlers
},
function(dispose) {
$Titel=document.getElementById('TitelPDF').value;
if(! $Titel==""){
document.getElementById("TitelPDF").style.borderColor="";
$TitelPDF=$Titel+'.pdf';
pdf.save($TitelPDF);
} else {
alert("Insert a Title");
document.getElementById("TitelPDF").style.borderColor="red";
}
}
, margins);
}
マイHTMLテーブル
<?php $statement = $pdo->prepare("SELECT * FROM person");
$statement->execute(array());
echo '<style type="text/css"> table, td, th { width: 55em; border-collapse: collapse;
background: white; color: black; border: 1px solid #333; } </style>';
echo '<table id="table">';
echo'<thead>';
echo'<tr id="tr">';
echo "<th>". "Vorname". "</th>";
echo "<th>". "Nachname". "</th>";
echo "<th>". "Ortschaft". "</th>";
echo "<th>". "Tel_Mobil". "</th>";
echo "<th>". "Mail". "</th>";
echo "<th>". "AHV". "</th>";
echo "</tr>";
echo'</thead>';
echo'<tbody>';
while($row = $statement->fetch()) {
echo '<tr id="tr">';
echo "<td>". $row['Vorname']."</td>";
echo "<td>" .$row['Nachname']."</td>";
echo "<td>" .$row['Ortschaft']."</td>";
echo "<td>" .$row['Tel_Mobil']."</td>";
echo "<td>" .$row['Mail']."</td>";
echo "<td>" .$row['AHV']."</td>";
}
echo'</tr>';
echo'</tbody>';
echo '</table><br>';
echo '<form action="../html/Navigation.html" method="post"> <input type="Submit" name="zurück" value="zurück"> </form>';
}
?>
これはページの番号付けに役立つかもしれません:http://stackoverflow.com/questions/25989285/adding-a-fixed-header-footer-for-each-page-jspdf – PaulF
ありがとうございますが、私はこれを組み立てることができません私のスクリプト:(私はどこでもaddPage()を持っていません。 –
フッター要素を使用し、addPageを使用しない答えをさらに見ましたか(さらにリンクしましたか) – PaulF