I am using following code and all contents of the specific pdf page are converting in a correct manner. But if there is any image in the middle of pdf page, that image in the HTML shows at the top.
PHP CODE:
umask(0);
$output = shell_exec('pdftohtml create.pdf create.html');
Edit:
Please check the pdf what I used for this: https://www.dropbox.com/s/6uy9wq27ff00n0x/create.pdf?dl=0
In this PDF, image is after 2 lines.
// Load the converted html page. shell_exec adds 's' to html file, creates.html
$html = file_get_contents('creates.html');
print_r($html);
// output
<!DOCTYPE html><html>
<head>
</head>
<body>
<img src="/var/www/html/pdf-sign/public/converted_path/create-1_1.png"/><br/>
Test document PDF <br/> <br/>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla est purus, ultrices in porttitor <br/>in, accumsan non quam. Nam consectetur porttitor rhoncus. Curabitur eu est et leo feugiat <br/>auctor vel quis lorem. Ut et ligula dolor, sit amet consequat lorem. Aliquam porta eros sed <br/>velit imperdiet egestas. Maecenas tempus eros ut diam ullamcorper id dictum libero <br/>tempor. Donec quis augue quis magna condimentum lobortis. Quisque imperdiet ipsum vel <br/>magna viverra rutrum. Cras viverra molestie urna, vitae vestibulum turpis varius id. <br/>   PLACEHOLDER      <br/>nulla ac dolor. Maecenas urna elit, tincidunt in dapibus nec, vehicula eu dui. Duis lacinia <br/>fringilla massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur <br/>
suscipit felis eget condimentum. Cum sociis natoque penatibus et magnis dis parturient <br/>montes, nascetur ridiculus mus. Integer bibendum sagittis ligula, non faucibus nulla volutpat <br/>vitae. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.  <br/>In aliquet quam et velit bibendum accumsan. Cum sociis natoque penatibus et magnis dis <br/>parturient montes, nascetur ridiculus mus. Vestibulum vitae ipsum nec arcu semper <br/>adipiscing at ac lacus. Praesent id pellentesque orci. Morbi congue viverra nisl nec rhoncus. <br/>Integer mattis, ipsum a tincidunt commodo, lacus arcu elementum elit, at mollis eros ante ac <br/>risus. In volutpat, ante at pretium ultricies, velit magna suscipit enim, aliquet blandit massa <br/>orci nec lorem. Nulla facilisi. Duis eu vehicula arcu. Nulla facilisi. Maecenas pellentesque <br/>volutpat felis, quis tristique ligula luctus vel. Sed nec mi eros. Integer augue enim, sollicitudin <br/>ullamcorper mattis eget, aliquam in est. Morbi sollicitudin libero nec augue dignissim ut <br/>consectetur dui volutpat. Nulla facilisi. Mauris egestas vestibulum neque cursus tincidunt. <br/>Donec sit amet pulvinar orci.  <br/>Quisque volutpat pharetra tincidunt. Fusce sapien arcu, molestie eget varius egestas, <br/>faucibus ac urna. Sed at nisi in velit egestas aliquam ut a felis. Aenean malesuada iaculis nisl, <br/>ut tempor lacus egestas consequat. Nam nibh lectus, gravida sed egestas ut, feugiat quis <br/>dolor. Donec eu leo enim, non laoreet ante. Morbi dictum tempor vulputate. Phasellus <br/>ultricies risus vel augue sagittis euismod. Vivamus tincidunt placerat nisi in aliquam. Cras <br/>quis mi ac nunc pretium aliquam. Aenean elementum erat ac metus commodo rhoncus. <br/>
<hr/>
</body>
</html>
Now see
<img src="/var/www/html/pdf-sign/public/converted_path/create-1_1.png"/>
is just after at BODY tag. That means that image is gone to the top in replace of the third line.
I also faced this kind of problem. I got a solution. At first you need to convert pdf document to XML
The XML output is like below
Then you conver this string of XML into an object
After that you need to measure the exact image place with the xml attributes top value like below
After finding out all attributes top value sort the values based on array[key]
When all the attributes are sorted based on xml top value, simply process the html like below
I think it help you
You can Also manage your text font
xml stored all font in fontspec attribute and give an id
and this id is call in text attribute font value
now with the help of those values you need to process the font like below
After that you need to process this font into html