Page 1 of 1

How to adress the page header in a word document

Posted: Tue Jun 14, 2016 7:54 am
by hybris
Hi,

I want to create a word document for download with some information and Im trying to figure out how to create a page header (everything else works just fine).

I also do not want to install some docx libraries.

Code: Select all

header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=$filename.doc");
//charset=Windows-1252
echo "<html>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";
echo "<thead>";
echo "WHY CANT I GET THIS #"ยค% LINE INTO THE PAGEHEADER?????";
echo "</thead>";
echo "<body>";
echo "<div style ='font:9px/19px Arial,tahoma,sans-serif;color:#000000;text-align:right;'> <b> ".$string."</b></div>";
echo "<div class=Section1>";
echo "<img src=\"".$target_dir." \">";
echo "</div>";
echo "<div style ='font:11px/21px Arial,tahoma,sans-serif;text-align:right;color:#cccccc'> blablabla</div>";
echo "<b>Subject</b> <br>";
echo "<br>";
echo "<div style ='font:13px/23px Arial,tahoma,sans-serif;color:#000000;border-bottom: 1px dotted #003366;'><b> blablabla</b></div>";
if(isset($DBP)){echo "<div style ='font:11px/21px Arial,tahoma,sans-serif;color:#000000'> <b> ".$DBP.$Pinfo."</div>";}

echo "</body>";
echo "</html>";
I tried <head> <phead> <thead>.... but I cant figure out how to acess the pageheader... any suggestions?

Thanks :)

Re: How to adress the page header in a word document

Posted: Tue Jun 14, 2016 7:16 pm
by Christopher
You should look into Word Doc generator libraries if you want to add a page header. I think the HTML method is only for simple documents.