All the code you should need is in the issue that I opened here:
http://groups.google.com/group/dompdf/browse_thread/thread/a39c007e4da5bde
Apply the patch to the dompdf class. Add my extended dompdf class to
your project. Use this block of code:
$doc = new DOMDocument();
$doc->loadHTML($html);
$dompdf = new DOMPDF_ext();
// Get the style section out of the HTML
$styles = $doc->getElementsByTagName('style');
$style = $styles->item(0);
// Get all the divs with class page (separate pages)
$xpath = new DOMXPath($doc);
$pages = $xpath->query('//div[contains(@class, "page")]');
// insert each page individually
foreach($pages as $page) {
$html = $doc->saveXML($style) . $doc->saveXML($page);
$dompdf->insert_html($html);
}
$dompdf->stream($document_name . '.pdf');
Where $html is the full HTML of the PDFs you want to generate. Each
page should be in a div with class page. That's how this code knows to
break up the HTML.