Jump to content

File formatting


lional

Recommended Posts

Are you hoping to read in for the purpose of outputting to a browser?  Unfortunately, Word documents are proprietary.  They do not use HTML to markup the files, so you cannot just read in a word document and output it.  If it is a Word 2007 document (.docx, I think) then you may be able to parse through the file, but it will be a lot of work converting it to HTML.  You might be able to find a prewritten class somewhere, but I don't know if it exists.  Try google.  I wouldn't hold my breath.

Link to comment
https://forums.phpfreaks.com/topic/126855-file-formatting/#findComment-657928
Share on other sites

When you're outputting the HTML, put your read-in text in pre tags, which tells the browser that the surrounded text is preformatted, meaning that the white space new lines, indents, etc, matter.  Keep in mind that by default, the pre tags will output text in a fixed width font, like Courier.  To change it, you need to use CSS to specify the font.  Example:

 


<html>
<body>
<pre style="font-family: Verdana">
Hello. I am preformatted text.

                      This line will be indented.



            This line will be indented less, with three blank lines above
</pre>
</body>
</html>

 

Just echo all of that like you normally would in PHP, but with those extra pre tags.  This method works best with regular text-files.

 

This solution alone does not solve the problem of special formatting, like bold-face or underline.  For that, you might just teach your client to use < b ></ b > and < u ></ u > tags.  It's not that much trouble.

Link to comment
https://forums.phpfreaks.com/topic/126855-file-formatting/#findComment-658015
Share on other sites

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.