Help with PDFtk function


So i just need to provide my customer with a filled out copy of the original gov issued pdf form. doesn’t matter what ouput its in just so long as when they print it out it looks like the gov issue form of acceptable quality. If we can get it to look and print just like the original, the gov office will have no reason to deny acceptance. So whatever format its in, present to browser or saved as makes no difference as long as it does that.


Well, you are going to love this! I found a simple way to save an image of a webpage running live.
Really cool small, very small code… It basically would let you to use the version with support files and
fill them in and display them and then, it can make a PDF of the “image” of the currently live page.

Should work as you want it. It would be basically the same as the governments version but with data in it.
And, it would be a PDF file so the client can keep a copy for their records.

My friend who has the full Acrobat software could not get it to create an accurate HTML version. It just doesn’t do that I guess. No wonder I found so many sites online that do the conversion for you…


1 - Are you going to need other forms used, too? Or just this one and only form?
2 - Is your version with all of the support files looking 100% match of the gov version?

#2 answer, if yes, zip it up and send it to me. If it won’t let you post the file on this post, you can in a private post to me. I will alter it to work with the new ideas and get it to create a PDF version of it with the correct full page display.

I have plans tonight, so running low on time, but, I think we can finish this up soon…


there are other forms, most are interchangeable between services. But would like to learn the entire process incase I need to add forms for other gov serivice in other states later.

As to my versions, tried the publisher to html but got shot down cause dompdf doesn’t recognize the form field names inside the text boxes. Photoshop will allow me to create a layer of text field names where i need them but won’t save the file in an html format. Working with an html editor and the preview shows me an html file like i want it in it’s preview but when I save and use it for the code from the server all I get is the field data with no background image. So I don’t know what’s going on, think it my be the fact that it is a trial version and not publishing correctly until you purchase.

What you have found sound like a good thing…


Well, I have two versions that should work. Just running out of time today. Plans later and a paying job coming up shortly…

So, this new idea should work. We will still use HTML, but, a version with the backup files or support files.
then, the same replace code and query and the new code will take an image of it. That image will become
the input to the PDF code instead of the HTML. Should work. Just a lot of logic to sort out first. I just got the code that let’s me create the image from a live page. Once I pick the best HTML data to start with, I will fill in some of the fields and test it offline. And, then send it to you so you can test on your live data.

But, not sure if I can get it finished testing before I leave later today. I am in VT and it is nearly 3 PM already and have to leave about 6 PM. We will see! If not, I can finish up the testing late night when I get back or in the morning. I want to finish this process up as much as you do! Ha!


Sound like a plan, I’ve been working on this with you this long and just glad I’m getting the help. So do you how you need to and we can hook back up tomorrow morning… i the mean time I will continue with things on my end and see if I can make things work with what we have too.

click the link and enter the refcode “QKEX49MKDE” to see what I’ve got so far


Well, that is “okay”, but, it looks a bit faked. I feel we can solve this with the new idea. Just need some time to test it all… More after I test it…

By the way, the image code appears to be able to render a

tag, too. So, it can create an image of “part” of a page. this is really cool if I can get it working as we can put the form in the page along with controls and a simple button to show the completed form and a button to save as a PDF. I think it should work nicely for you.
Should be able to test it in the morning… I will test the parts of it before I leave!


Sounds good, go make your money and enjoy your evening…


Well, got busy today. Will try to get back to this tonight for you.

I found a fairly simple way to render a DIV into an image. Very interesting tech! Never knew it was possible.
So, I placed one of our tested into a DIV, so it shows the results on the page. Now I will use this image trick
to create an image from it and then a PDF form the image. Not very hard from what I am reading about it.

Will send you a test script for it later tonight…


Cool…I’ve basically tried everything to the image in the background in a full page but it always comes back to small or off center with borders…


I might have a solution. Testing it now as I did not get to it until just now…


Sounds good, got a light day today, so I’ll have time to test what you got and get back quickly. Is this still using the dompdf library or another method? Also want to make sure we are dealing with the most recent form so we are not having to correct something later. I will send you that file in a private message


I have a question for you. How are you indicating check boxes in your database.
SO, as an example, the first thing asked for is type of registration needed.
There are four entries there. Let’s say the user needs the second one checked. (Title-Only)
How are you saving that inside your database? I am trying to sort out how to mark them where needed.
Four this area, there are four possible options. Do you have one field for this with 1-2-3-4 in it or do you have four separate fields, one for each check-box? I need to know this to be able to program that part…


Well, I did some tests and got it working. i had to manually alter the form’s HTML to fit the original one.
It was tedious and took all afternoon… Then, I just created a few of the data fields, six of them, for now.
I used the list you posted awhile ago. I was able to create a form filled in with the data. I added just a small
bit of CSS to put the data in place where it should be. Here is the code I used:
// Set up the PDF library
//require_once ("/home1/thetitl1/public_html/pdforms/dompdf/");
require_once ("…/lib/dompdf/");
use Dompdf\Dompdf;
$dompdf = new Dompdf;
use Dompdf\Options;

//  Load base form template
$new_form = file_get_contents("TX_Title_App/Form130U.html");

//  Temporary manual override replacing some random data into the form...
$new_form = str_replace("___VehVin6___", "123456", $new_form);
$new_form = str_replace("___VehPlt___", "xxx-xxxx", $new_form);
$new_form = str_replace("___VehYr___", "2018", $new_form);
$new_form = str_replace("___VehMk___", "DODGE", $new_form);
$new_form = str_replace("___VehMod___", "DURANGO", $new_form);
$new_form = str_replace("___VehBdy___", "LL", $new_form);
$new_form = str_replace("___VehClr___", "RED", $new_form);
//  Form is ready to convert into PDFnamespace
$options = new Options($options);
$dompdf = new Dompdf($options); $dompdf->loadHtml($new_form);

// (Optional) Setup the paper size and orientation

// Render the HTML as PDF

// Output the generated PDF to Browser 

// Save to file
$output= $dompdf->output();
file_put_contents('TXTitleApp.pdf', $output);
<!DOCTYPE html>
<meta charset="utf-8">
<script type="text/javascript" src="//"></script>
<script type="text/javascript" src="js/html2canvas.js"></script>
<script type="text/javascript" src="js/jquery.plugin.html2canvas.js"></script>
<link rel="stylesheet" type="text/css" href="style.css"/>

<form action="#" method="post">
    <fieldset><legend>Final Details Reference Code</legend> <label for="reference_code">Enter Reference Code Here:</label> <input id="reference_code" name="reference_code" type="text" /></fieldset><br>
    <input name="submit" type="submit" value="Submit">
<?PHP echo $new_form; ?>
I left in the part where we entered the ref-code, but, it does nothing at the moment. (I did not have access to your database, so I removed that part code and just used the hard-coded six fields instead. But, it works! I am sending the form file which is a bit big for a post in a private message. It should let admin's attach files here, but, for some reason it does not. Depending on where you put this code and the form, you might have to alter the get-file-contents to point at it. All it does is use the new form I created and put in the six fields. You would need to alter the form (making a backup of course) and enter all of your other fields you have in the database. They are placed inside
clauses an use the ___fieldname___ format... So, it is working finally!


Also, the results is just HTML. The next step is to convert the output to an image using that new library and then save it to a PDF. More on that tomorrow…


I did get a copy of the form from your link and I will start putting the code together on my end in the morning. Then I’ll await your next message to complete it and begin testing… thanks and it looks I’ll owe you a few bottles…LOL