title: How to convert a PDF from Word with PHPOffice
body: <p>I don't have any plan how can I convert an Word document, which I have as a string (blob) from my database, to a PDF via the <a href="https://github.com/PHPOffice/PHPWord" rel="nofollow noreferrer">PHPOffice</a> library. </p>
  
  <p><strong>Concept:</strong></p>
  
  <ol>
  <li>I fetch an existing word document as an string from the database</li>
  <li>Pass the string through an constructor or an function of PHPOffice library.</li>
  <li>Then get via another function the PDF as an string</li>
  <li>And last output the string with <code>Content-Type: application/pdf</code> to the user.</li>
  </ol>
  
  <p>Nr. 1 and 4 I already implemented. But I don't know how to accomplish nr. 2 and 3. Can someone help me?</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>//DB-Connection, Composer autoload, ...
  
  $id = htmlspecialchars(trim($_REQUEST["id"]));
  
  $get_data = $con-&gt;query("SELECT * FROM word_documents WHERE id='$id'"); //Get the blob 
  $data = $get_data-&gt;fetch();
  if ($get_data-&gt;rowCount() == 1) {
      header("Content-Type: application/pdf");
      header("Content-Disposition: inline; filename=" . $data["name"]);
  
      //TODO: Print the PDF as an string
  
  } else {
      echo "File not found";
  }
  </code></pre>