tcpdf error

I am trying out on the tcpdf extension -

It works fine when i view it from linux, but always gives me error from windows, it says:“file does not begin with ‘%PDF-’”.

Anyone got any ideas for this problem ?

thank you

Found the answer here ->


The error is because of html layout (headers and footers) of page. We need to disable layout of page before creating pdf file.

So, add the following:

“$this->layout = ‘pdf’;”

before constructor:

$pdf = Yii::createComponent(‘application.extensions.tcpdf.ETcPdf’, ‘P’, ‘cm’, ‘A4’, true, ‘UTF-8’);



I have error message ‘not a PDF file or corrupted’ when I open pdf file…

how to solve it ?