title: Making DomPDF as my pdf writer for phpWord
body: <p>I used laravel for my app and the dompdf is found in: </p>
  
  <blockquote>
    <p>../vendor/dompdf/dompdf</p>
  </blockquote>
  
  <p>What I wanted to achieve is to convert my .docx file (Microsoft Word) to .pdf file. The docx file was generated by phpWord by loading the template file and replacing the values. </p>
  
  <p>Here's the snippet:</p>
  
  <pre><code> // Get the absolute path of the template file
   $wordTemplatePath = $this-&gt;getDocumentTemplatePath('resignation.docx');
  
   // Load the template file
    $document = $this-&gt;phpWord-&gt;loadTemplate($wordTemplatePath);
  
  // This will be filled with data
   $wordData = []
  
  .... Process to fill the data .....
  
  // Replace value to actual word document
    $this-&gt;setTemplateValues($wordData, $document);
  
  
  // Generate its filename
    $file = $this-&gt;generateFileName('Retirement-Certificate.docx', $id);
  
          // Fetch the absolute path to save the document
          $filepath = $this-&gt;getSavePath($file);
  
          // Save the word document
          $document-&gt;saveAs( $filepath );
  </code></pre>
  
  <p>After that, a .docx file will be generated. I wanted to make a PDF version of that as well. so I search and found this code snippet and added in my code:</p>
  
  <pre><code>             \PhpOffice\PhpWord\Settings::setPdfRendererPath('../vendor/dompdf/dompdf');
  \PhpOffice\PhpWord\Settings::setPdfRendererName('DOMPDF');
  
  //Load temp file
  $phpWord = \PhpOffice\PhpWord\IOFactory::load($filepath); 
  
  //Save it
  $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
  $xmlWriter-&gt;save('result.pdf');  
  </code></pre>
  
  <p>But I got this error:</p>
  
  <pre><code>    {"error":
  {"type":"PhpOffice\\PhpWord\\Exception\\Exception","message":"PDF rendering library or library path has not been defined.",
  "file":"C:\\xampp\\htdocs\\vagrant\\vendor\\phpoffice\\phpword\\src\\PhpWord\\Writer\\PDF.php",
  "line":49}}
  </code></pre>
  
  <p>How would I make DomPDF as my pdf writer for PHPWord? I can't find any other options so I ask here. I hope you can help me. Thanks!</p>