How to create custome pdf file of my invioice in wordpress

Assuming you’re creating this as a plugin and you’ve saved the dompdf directory within your plugin directory you can include it with the following.

// wp-content/plugins/yourplugin/yourplugin.php
// Set up paths to include DOMPDF
$plugin_path = plugin_dir_path( __FILE__ );
define( 'YOURPLUGIN_DOMPDF', $plugin_path . 'dompdf/' );

// Set up directory to save PDF
$upload_dir = wp_upload_dir();
define( 'YOURPLUGIN_UPLOAD_DIR', $upload_dir['basedir'] . '/invoices');
define( 'YOURPLUGIN_UPLOAD_URL', $upload_dir['baseurl'] . '/invoices');

include( YOURPLUGIN_DOMPDF . 'autoload.inc.php' );
use Dompdf\Dompdf;
use Dompdf\Options;

function yourplugin_order_invoice_pdf(){
  // validate and sanitize your input 
  $options = new Options();
  $options->set('isRemoteEnabled', true);
  $dompdf = new Dompdf($options);

  if ( ! $html = yourplugin_generate_invoice_html( $order_id ) ) {
    return;
  }

  $dompdf->load_html($html);
  $dompdf->render();
  $output = $dompdf->output();
  wp_mkdir_p( YOURPLUGIN_UPLOAD_DIR );
  $file_name="order-".$order_id.'.pdf';
  $file_path = YOURPLUGIN_UPLOAD_DIR . "https://wordpress.stackexchange.com/". $file_name;
  file_put_contents( $file_path, $output);
  $invoice_url = YOURPLUGIN_UPLOAD_URL . $file_name;
  return $invoice_url;
}

The yourplugin_order_invoice_pdf function above is an example of the components needed. You’ll probably want to split parts out into their own specific functions, and handle your inputs. Of course you’ll need to choose a hook from the Plugin API to attach this all to.