title: Convert PDF to HTML in PHP?
body: <p>I want to be able to convert a PDF file to an HTML file via PHP, but am running into some trouble.</p>
  
  <p>I found a basic way to do this using <a href="http://web.archive.org/web/20130302034024/http://saaspose.com/" rel="noreferrer">Saaspose</a>, which lets you convert PDF's to HTML files. There are some problems with this, however, such as the use of SVGs, images, positioning, fonts, etc.</p>
  
  <p>All I would need is the ability to grab the text from the PHP file and any images associated with it, and then display it in a linear format as opposed to it being formatted with absolute positioning.</p>
  
  <p>What I mean by this is that if the PDF looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/Sb83em.png" alt="enter image description here"></p>
  
  <p>I'd want to convert it to a single column design HTML file. If there were images, I'd want them returned as well.</p>
  
  <p>Is this possible in PHP? I know I can simply grab the text from the PDF file, but what about grabbing images as well?</p>
  
  <p>Another problem is that I want everything to be inline, as it's being served to the client in a single file. Currently, I can do this with my setup through some code:</p>
  
  <pre><code>for ($i = 0; $i &lt; $object_number; $i++) {
                  $object = $html-&gt;find("object")-&gt;find("embed")-&gt;eq($i);
                  $embed = file_get_contents("Output/OutputHtml/" . $object-&gt;attr("src"));
                  array_push($converted_obj, $embed);
                  array_push($original_obj, $object);
              }
  
              for ($i = 0; $i &lt; $object_number; $i++){
                  pq($original_obj[$i])-&gt;replaceWith($converted_obj[$i]);
              }
  </code></pre>
  
  <p>Which grabs all the <code>SVG</code> files and displays them inline. Images would be easier for this, as I could use <code>base64</code>.</p>