How to adress the page header in a word document

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hybris
Forum Contributor
Posts: 172
Joined: Wed Sep 25, 2013 4:09 am

How to adress the page header in a word document

Post 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 :)
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

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

Post 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.
(#10850)
Post Reply