Black page after 7 pages
See original GitHub issueHi, I readed each post like mine but you don’t give answers so I try.
Here is my code to generate a pdf with multiple pages. Each page take the content of a div it’s class is ‘une_page’ : `$(‘#printPDF’).click(function () { var pdf = new jsPDF(‘portrait’); var pdfName = $(this).data(‘titre’);
var options = {};
var $divs = $('.une_page') //jQuery object of all the myDivClass divs
var numRecursionsNeeded = $divs.length -1; //the number of times we need to call addHtml (once per div)
var currentRecursion=0;
//Found a trick for using addHtml more than once per pdf. Call addHtml in the callback function of addHtml recursively.
function recursiveAddHtmlAndSave(currentRecursion, totalRecursions){
//Once we have done all the divs save the pdf
if(currentRecursion==totalRecursions){
pdf.save(pdfName);
}else{
currentRecursion++;
pdf.addPage();
//$('.myDivClass')[currentRecursion] selects one of the divs out of the jquery collection as a html element
//addHtml requires an html element. Not a string like fromHtml.
pdf.addHTML($('.une_page')[currentRecursion], 0, 0, options, function(){
console.log(currentRecursion);
recursiveAddHtmlAndSave(currentRecursion, totalRecursions)
});
}
}
pdf.addHTML($('.une_page')[currentRecursion], 0, 0, options, function(){
console.log(currentRecursion);
recursiveAddHtmlAndSave(currentRecursion, numRecursionsNeeded);
});
});`
It works fine but after the 6th page, everything is black.
Can you please help me ?
Thanks a lot.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
Insert a blank page - Microsoft Support
To put a blank page into your Word document, place the cursor where you want the new page to begin and then click...
Read more >How to Delete a Blank Page in Word - Lifewire
In the Navigation pane on the left, select the blank page from the list of pages. Once it's highlighted, press the delete/backspace key,...
Read more >3 ways to delete unwanted blank page in Word [2007/2010 ...
Delete page in wordThis video also answers some of the queries below:Delete blank page in wordfind how many pages you have in wordNavigation ......
Read more >Word Tips: Modifying Page Numbers in Word - GCF Global
Modifying page numbers with section breaks Here's an overview of the steps you need to follow. These steps should work for Word 2007,...
Read more >Help with page numbering please! - CreativePro Network
What do I do with the blank pages or am I missing something?? ... I much prefer to put a 10 – 20%...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Problem solved.
I just hide elements when it’s added so canvas limit is never reached.
Here is my solution if it can helps someone : `$(‘#getPDF’).click(function () { var pdf = new jsPDF(‘portrait’); var pdfName = $(this).data(‘titre’); var options = {}; var $divs = $(‘.une_page’) //jQuery object of all the myDivClass divs var numRecursionsNeeded = $divs.length -1; //the number of times we need to call addHtml (once per div) var currentRecursion=0;
@yannsainty you saved my day. Good solution, thanks.