For dompdf using many plugin available in wodpress. but if we want to perform any custom code for Dompdf than much of plugin useless therefore we need to use handmade plugin for it.
let me explain you how to use it that
first you need to setup dompdf latest library for github and setup it. you can get library from here
after load it you need to setup it into custom plugin in need to setup that. Copy dompdf directory in the custom plugin . if you not know how to make plugin than you can check here
after made plugin you need to make init function and there need to generate pdf
this way you can easy use custom dompdf library in your custom code