dompdf basically acts like a web browser (minus the JS support) that renders a HTML page to PDF. So what you typically want to do is completely generate your HTML document first and then pass that to dompdf for PDF rendering.
The actual steps for generating the PDF once you have the HTML are pretty simple. Let's say you have created your HTML in the script that will also render the PDF. You would do something like this:
<?php
/* lots of code above that creates the HTML document and stores it in the $html variable */
$dompdf = new DOMPDF;
$dompdf->load_html( $html );
$dompdf->render( );
$dompdf->stream( );
?>
Done.
Or let's say you have an external file that already creates your HTML. You can reference that file from within another script that uses dompdf to create the PDF. For example:
<?php
$dompdf = new DOMPDF;
$dompdf->load_html_file( '
http://example.com/some_document.php' );
$dompdf->render( );
$dompdf->stream( );
?>
Done. And that's all there is to it.
There are a lot of things you can do with the underlying rendering engine (CPDF or PDFLib), but you should focus first on understanding how to use dompdf.