benphp Posted September 13, 2012 Share Posted September 13, 2012 I'm generating a Microsoft Word doc with header("Content-type: application/vnd.ms-word"); header("Content-Disposition: attachment;Filename=myPrintInLandscape.doc"); but it opens in portrait orientation. Does anyone know of a way to force it into landscape? Link to comment https://forums.phpfreaks.com/topic/268337-how-to-generate-a-ms-word-document-and-open-it-in-landscape-orientation/ Share on other sites More sharing options...
Barand Posted September 13, 2012 Share Posted September 13, 2012 Somewhere in the bowels of the document there will be a page orientation setting. Link to comment https://forums.phpfreaks.com/topic/268337-how-to-generate-a-ms-word-document-and-open-it-in-landscape-orientation/#findComment-1377672 Share on other sites More sharing options...
benphp Posted September 13, 2012 Author Share Posted September 13, 2012 It's opening the HTML in a Word document. I'm guessing it must be a CSS solution. Link to comment https://forums.phpfreaks.com/topic/268337-how-to-generate-a-ms-word-document-and-open-it-in-landscape-orientation/#findComment-1377675 Share on other sites More sharing options...
premiso Posted September 13, 2012 Share Posted September 13, 2012 Somewhere in the bowels You know, I just had a bowel movement and man, that was a relief. I think the orientation was set at Landscape, but not sure. Link to comment https://forums.phpfreaks.com/topic/268337-how-to-generate-a-ms-word-document-and-open-it-in-landscape-orientation/#findComment-1377683 Share on other sites More sharing options...
Jessica Posted September 13, 2012 Share Posted September 13, 2012 I think you'll want to get a library that helps you build a Word document. Link to comment https://forums.phpfreaks.com/topic/268337-how-to-generate-a-ms-word-document-and-open-it-in-landscape-orientation/#findComment-1377684 Share on other sites More sharing options...
benphp Posted September 13, 2012 Author Share Posted September 13, 2012 Found it. Add this to the HTML - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <html> <head> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"> <meta name=ProgId content=Word.Document> <meta name=Generator content="Microsoft Word 9"> <meta name=Originator content="Microsoft Word 9"> <title>My Title Here</title> <LINK href="common/style.css" type=text/css rel=stylesheet> <style> @page Section1 {size:595.45pt 841.7pt; margin:1.0in 1.25in 1.0in 1.25in;mso-header-margin:.5in;mso-footer-margin:.5in;mso-paper-source:0;} div.Section1 {page:Section1;} @page Section2 {size:841.7pt 595.45pt;mso-page-orientation:landscape;margin:1.25in 1.0in 1.25in 1.0in;mso-header-margin:.5in;mso-footer-margin:.5in;mso-paper-source:0;} div.Section2 {page:Section2;} </style> </head> <body> <div class=Section2> stuff here </div> </body> </html> Thanks Barand for sparking my memory! Link to comment https://forums.phpfreaks.com/topic/268337-how-to-generate-a-ms-word-document-and-open-it-in-landscape-orientation/#findComment-1377685 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.