11486 sujets

JavaScript, DOM et API Web HTML5

Bonjour,

Je souhaite afficher dans un pdf telechargeable un tableau presente sur la page.
Le code suivant fonctionne mais il répète les titres de colonnes à chaque nouvelle page et de surcroit suoerpose avec la premiere ligne :

<script type="text/javascript">
function genererpdf() {
var pdf = new jsPDF('p', 'pt', [1000, 800], true, 8, 1, false, false);
source = $('#content')[0];

// source can be HTML-formatted string, or a reference
// to an actual DOM element from which the text will be scraped.

// we support special element handlers. Register them with jQuery-style
// ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
// There is no support for any other type of selectors
// (class, of compound) at this time.
specialElementHandlers = {
// element with id of "bypass" - jQuery style selector
'#content': function (element, renderer) {
// true = "handled elsewhere, bypass text extraction"
return true
}
};
margins = {
top: 20,
bottom: 10,
left: 40,
right: 40,
width: 800,
height: 500,
};
// all coords and widths are in jsPDF instance's declared units
// 'inches' in this case
pdf.setFontSize(12);
pdf.fromHTML(
source, // HTML string or DOM elem ref.
margins.left, // x coord
margins.top, { // y coord
'width': margins.width, // max width of content on PDF
'elementHandlers': specialElementHandlers
},

function (dispose) {
// dispose: object with X, Y of the last line add to the PDF
// this allow the insertion of new lines after html
pdf.save('Test.pdf');
}, margins

);
}
</script>

Merci d'avance pour l'aide !
J'ai cherché comment ne pas repeter l'entete mais je n'ai pas trouvé