Jump to content

wite vertical text in document file


sheinak

Recommended Posts

I generate an word document from a SQL database. There are fields (table cells) which are not wide enough to contain the text. I use

writing-mode:tb-rl option to write it vertically. The table is rendered correctly in browser, but still put the text horizontal when it goes to a file.

 

put $path = "" and you have on browser 2 rows of a table, nice

 

put $path = "c:\" or any legal file path you will receive a file named test.doc  into the set location. The table is not so nice.

 

 

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <!--meta http-equiv="Content-type" content="text/html;charset=Windows-1252" /-->
    <meta http-equiv="Content-type" content="text/html;charset=utf-8" />
</head>
<body>
<?php
$path = "c:\\";
$file = openDocument("test",$path);       
writeDocument($file, "<table border=3 cellpadding=0 cellspacing=0 >");
writeDocument($file, "<tr>");
writeDocument($file, "<td style = 'font-size :10pt;height :20pt;font-weight:bold;background-color :DarkGray' colspan=2>Bit</td>");
for ($i=31; $i>=0; $i--)
{
     if ( $i <=9 ) $ii = '0'.$i;
     else $ii = $i;
     writeDocument($file, "<td width=3% style = 'font-size :10pt;height :20pt'> ".$ii." </td>");
}
writeDocument($file, "</tr>");

writeDocument($file, "<tr>");
writeDocument($file, "<td style='font-size :10pt;height :20pt; font-weight:bold;background-color :DarkGray' colspan = 2>Field</td>");
writeDocument($file, "<td style='font-size :10pt;height :20pt' align= middle valign=middle colspan = 13>R3</td>");
//
writeDocument($file, "<td style='font-size :10pt;height :20pt; writing-mode:tb-rl' align= middle valign=middle>DISCARD</td>");
writeDocument($file, "<td style='font-size :10pt;height :20pt; writing-mode:tb-rl' align= middle valign=middle>FLOW31MASK</td>");
writeDocument($file, "<td style='font-size :10pt;height :20pt; writing-mode:tb-rl' align= middle valign=middle>BUFSIZE</td>");
writeDocument($file, "<td style='font-size :10pt;height :20pt' align= middle valign=middle colspan = 3>R2</td>");
writeDocument($file, "<td style='font-size :10pt;height :20pt' align= middle valign=middle colspan = 5>THREAD</td>");
writeDocument($file, "<td style='font-size :10pt;height :20pt' align= middle valign=middle >R1</td>");
writeDocument($file, "<td style='font-size :10pt;height :20pt' align= middle valign=middle colspan = 7>ROUTE</td>");
//
writeDocument($file, "</tr>");
writeDocument($file, "</table>");
closeDocument($file);

function openDocument($gchip,$path)
{
    if ( $path != "" ) 
    {
       $f = $path.$gchip.'.doc';
       $file = fopen($f, 'w+');
       return $file;
    }
    return false;
}
function closeDocument($file)
{
    if ($file) fclose($file);
}
function writeDocument($file, $data)
{
    if ($file) fwrite($file, $data);
    else echo $data;
}

?>

Link to comment
https://forums.phpfreaks.com/topic/138297-wite-vertical-text-in-document-file/
Share on other sites

  • 2 weeks later...

I do write to the file as in browser:

 

function writeDocument($file, $data)

{

    if ($file) fwrite($file, $data);

    else echo $data;

}

 

if $file is a file descriptor it will write to file otherwise it will echo to the browser

 

I need to be a MS word document

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.