How can I render multiple URL's into a single PDF

I'm attempting to open a series of URL's to render the output, then combine into a single PDF using PhantomJS, but I cannot find any documentation on how to do this. I'm just using trial and error, but not getting anywhere - hoping somebody knows how to do this.

I'm not completely set on PhantomJS, so if you know of a better command line, node or JAVA tool that would be better, I'm all ears (or eyes in this case).

Here is the code I have that renders a single page. I've tried replicating the open/render, but it always overwrites the PDF instead of appending to it.

var page = require('webpage').create(),
    system = require('system'),
    fs = require('fs'),
    pages = {
        page1: 'http://localhost/test1.html',
        page2: 'http://localhost/test2.html'
    };

page.paperSize = { 
    format: 'A4',
    orientation: 'portrait',
};

page.settings.dpi = "96";

// this renders a single page and overwrites the existing PDF or creates a new one
page.open('pages.page1', function() {
    setTimeout(function() {
        page.render('capture.pdf');
        phantom.exit();
    }, 5000);
});

PhantomJS renders one web page into one PDF file, so if you can merge several URLs into one html file you could open it in PhantomJS and make a PDF.

But it would be simpler to make several PDFs and then merge them into one with something like pdfkt at the end of the script, launching merge command from PhantomJS child module

链接地址: http://www.djcxy.com/p/46964.html

上一篇: 从分支中提取所有提交,将指定的提交推送到另一个提交

下一篇: 如何将多个URL呈现为单个PDF