将变量替换为TCPDF的WriteHtml()函数中的值

I have two form fields and I want to generate a pdf with the values entered by the user in that form.I am using tcpdf to accomplish the task.I cant get the function to print the values Of the variables, instead its printing whatever is typed inside the WriteHtml() function. How to make the code work?

HTML :

<html lang="en">
    <head>
        <title>Some Random PDF</title>
    <body>
           <h1>Enter relevant details</h1>
           <form action="form.php" method="post">


        <div class="form-group">
            <label for="inputName">Name of the partner</label>
            <input type="text" class="form-control" id="inputName" placeholder="" name="inputName">
             <span id="inputNameSpan"></span>
        </div> 



        <div class="form-group">   
          <label for="inputAddress">Address of the partner</label>
          <textarea type ="text" class = "form-control" id = "inputAddress" rows = "8" placeholder = "" name="inputAddress"></textarea>
          <span id="inputAddressSpan"></span>
        </div>




        <div class = "form-group">
        <center><button type="submit">SEND</button></center>
      </div>

    </form></center>

    </body>
</head>

PHP:

<?php
require_once('TCPDF/tcpdf.php');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$myName = $_POST['inputName'];
$myAddress = $_POST['inputAddress'];
$pdf->AddPage();
$html= '.htmlspecialchars($myName) lives in .htmlspecialchars($myAddress)';

$pdf->WriteHTML($html);
$pdf->Output();
?>

P.S.

Required/expected output in a PDF File assuming ( $myName= John, $myAddress= New York City).

John lives in New York City

Any help is much appreciated. Thanks in advance!

$html= '.htmlspecialchars($myName) lives in .htmlspecialchars($myAddress)';

htmlspecialchars is PHP function, make sure it's recognize as php script and not as string

make sure you write like this

$html= htmlspecialchars($myName).' lives in '.htmlspecialchars($myAddress);

you need to set your output type I/F/FI. more more example and explain please read the documentation as http://www.tcpdf.org/

you can set for your example as $pdf->Output('yourfilename','I');