简体   繁体   中英

HTML2PDF: Creating multiple PDFs

I'm working with HTML2PDF in a SharePoint / JavaScript environment.

I've been trying to create multiple PDF's with a single click of a button, but only the first PDF will work, and the following ones won't download or even give an error.

Reading other's questions, it looks like I'm missing a flush or cleaning a parameter. Other people are working in PHP, which makes it harder for me to understand their solution...

My code is as follows:

function PPRToPDF(title) {      
    var fileName = title + ".pdf";
    console.log("PPRToPDF - FileName = " + fileName);

    try{
        var pprTab = $("#pprContent").html();
        html2pdf(pprTab, {
            margin:       [.5, .9, .5, .5],
            filename:     fileName,
            html2canvas:  { dpi: 300, letterRendering: true},
            jsPDF:        { unit: 'in', format: 'letter', orientation: 'landscape' }
        });
    } catch(e){
        alert ("in catch block");
    }
}

PS: I've been looking at GitHub and also searched google, but the documentation is sparse for the HTML2PDF library. Links to further documentation would be much appreciated.

Was able to solve this issue myself. I'm using Chrome and one of it's settings blocks multiple downloads. You can get to it via Settings > Advanced > downloads > Privacy and Security Section > Content Settings > Automatic Downloads. From here you will have to enter the Url for the site your using.

An easier approach, once you start downloading, is to click on the download icon next to the bookmark icon on the address bar. Select "Allow Automatic Downloads" and Chrome will do the rest of the work for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM