使用tcpdf库覆盖pdf文件

I am trying to write pdf file using TCPDF open source liberay.

i use following code..

$html = <<<EOD
$prod
EOD;

$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);

$pdf->Output('pricepdf.pdf', 'FD');

I have dumped $html, and its okay.

now, the problem is with writing pdf file, I can't write the file .either no error is displayed. Onething, i should clear that, a file with same name is already exists in the given folder.

What i want is, to ovewrite 'pricepdf.pdf' file everytime, i run the script

Please guide me regarding this, Is this overwrite problem? or something else is creating problem? I am stuck at the point...

If the script is not able to overwrite the file then you could check whether file exists and remove it.

if (file_exists('pricepdf.pdf')) unlink('pricepdf.pdf');
$pdf->Output('pricepdf.pdf', 'FD');

Turn on errors display to see if there is a problem with access to the file.