ttsprez Posted October 8, 2018 Share Posted October 8, 2018 So I've done a search for pdf to html converters and there are plenty of free online options. The only problem is that they don't convert the pdf to html in an actual 8.5 x11 size, so that when you go to print or use them to be filled by code and then printed, they are to small. Now, some would say, simply resize the html file, but the issue there is when created it actually consists of two files. One an html file with absolute position values for all your text and the second as a jpeg for any backgrounds, frames or images. You can adjust the size of the background, borders and images, but then that would also mean you'd have to go line for line in the html to adjust the absolute positions of all the text. So my question would be, is there a converter that would create an html file in the actual 8.5 x 11 size that anyone knows of? And don't say, Acrobat, cause their conversion doesn't even come close to looking like the original document. Any insight on this matter would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
requinix Posted October 8, 2018 Share Posted October 8, 2018 If you're fine with images (you don't need searchable text) then consider the PDF-to-image direction. Quote Link to comment Share on other sites More sharing options...
ttsprez Posted October 8, 2018 Author Share Posted October 8, 2018 Hey @requinix Thanks for the suggestion, but don't know if that would work as I need to fill the form with MySQL data after the conversion. I'm using the PHP dompdf library to do this and it needs an html doc to be loaded before it renders. Yet not that I think about it I could create jpegs of each and then absolute position each field name into an html with the jpeg as a background. Does that sound right? Thanks for sparking the epiphany... I'll try it and tell you how it goes for the sake of others having this issue. Quote Link to comment Share on other sites More sharing options...
requinix Posted October 8, 2018 Share Posted October 8, 2018 Converting a PDF to HTML will likely get you some basic HTML markup and an image. Unless you have something that can OCR it (they exist) and end up with markup you can use (unlikely) then you're basically stuck with image + positioning. Convert the (uploaded?) PDF into an image, then display it to the user with a way to have them mark what fields exist where on the document. Like by dragging boxes around the fields. You can create textboxes to fit that. Quote Link to comment Share on other sites More sharing options...
ttsprez Posted October 8, 2018 Author Share Posted October 8, 2018 So I can give you a full understanding of what I'm doing... My customers submit info via a form page. On submit the info is passed to the database. When payment is processed the info is then filled into the html temp and then presented back to them as a flattened pdf for download or printing. So taking the original pdf and converting it to a jpeg, then open a new word doc that I can then use the jpeg as a background with text boxes holding the form_field names to be replaced with the customer data, that I can then save as an html. I think that will work for what I need. Compared to what I have now, this would make things much easier and far less html code for the dompdf to process when figuring out which items need to be changed. What I have now has absolute positions for every piece of text on the page. Thanks again for sparking the noggin. Quote Link to comment Share on other sites More sharing options...
requinix Posted October 8, 2018 Share Posted October 8, 2018 Woah woah woah. You say your process will be form -> HTML -> PDF -> JPEG -> HTML? You generated the HTML previously, right? And you want to have HTML, right? Quote Link to comment Share on other sites More sharing options...
ttsprez Posted October 8, 2018 Author Share Posted October 8, 2018 no, sorry if I confused you... I have pdf's that need to go to html, then be filled by dompdf, and then shown to the customer as downloadable/printable pdf. My problem now is that the pdf's I've converted are not printing in an actual 8.5 x 11 size for some reason. It seems like the way they were converted has something to do with it. Danm Free Online Converters! LOL Quote Link to comment Share on other sites More sharing options...
requinix Posted October 8, 2018 Share Posted October 8, 2018 Yeah, but the step before that was 1 hour ago, ttsprez said: My customers submit info via a form page. On submit the info is passed to the database. When payment is processed the info is then filled into the html temp So is that happening on your site or not? Quote Link to comment Share on other sites More sharing options...
ttsprez Posted October 9, 2018 Author Share Posted October 9, 2018 still working on debugging the MySQL query statement to ensure it's returning the info the way I need it, but getting there. This issue was just something that came up as another issue that needed to be corrected. Quote Link to comment Share on other sites More sharing options...
gizmola Posted October 10, 2018 Share Posted October 10, 2018 This is an intrinsic problem with dompdf: you are at the mercy of the styling/fonts and css. You need to insure that your html page fits your desired output, but there are other libraries out there that might be a better fit for this use case: namely tcpdf or mpdf, or even the father of php pdf libraries (fpdf). Quote Link to comment Share on other sites More sharing options...
ttsprez Posted October 10, 2018 Author Share Posted October 10, 2018 unfortunately, I'm too far into my process using the dompdf library that I just can't see starting all over again with something else.... Unless I could find something that would place data straight into a pdf as opposed to creating an html or another kind of template and then rendering a pdf. Taking data straight to a pdf field would be great, but I understand to do that you have to know what the pdf field names are and how to do that is something I'm not familiar with. Quote Link to comment Share on other sites More sharing options...
kicken Posted October 10, 2018 Share Posted October 10, 2018 PDF Toolkit can supposedly fill in PDF forms. I've used it for splitting/merging before but not form filling. If you have proper PDF forms you could give that a try. As for an HTML to PDF conversion, I've been partial to using html-pdf (or similar). It uses PhantomJS, which is like a webkit based browser, to render a page out as a PDF. As with most things it's not always perfect, but for my uses so far (mostly report generation) it's worked pretty well. Both of those solutions would require loading the software onto your server then calling it with PHP using exec. Some shared hosting providers may not allow this, so if you're on a shared environment you'll need to check. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.