www.webdeveloper.com
Results 1 to 4 of 4

Thread: Trying to read MS word content

Hybrid View

  1. #1
    Join Date
    Dec 2011
    Posts
    28

    Trying to read MS word content

    Hi all,

    I'm trying to read MS word contents using fread or file_get_contents ...
    It works fine using both.

    But my problem is explained in the attached file.
    basma fahiem.doc


    I want to ignore non English characters because they are always converted into strange chars.




    This is my code :

    PHP Code:
    function parseWord($userDoc
    {
    $fileHandle fopen($userDoc"r");

    $line =mb_convert_encoding( @fread($fileHandlefilesize($userDoc)) , "UTF-8");


    $lines explode(chr(0x0D),$line);
    $outtext "";
    foreach(
    $lines as $thisline)
    {
    $pos strpos($thislinechr(0x00));
    if ((
    $pos !== FALSE)||(strlen($thisline)==0))
    {
    } else {
    $outtext .= $thisline." ";
    }
    }
    $outtext preg_replace("/[^a-zA-Z0-9\s\,\.\-\n\r\t@\/\_\(\)]/","",$outtext);
    return 
    $outtext;

    Can someone help?

  2. #2
    Join Date
    Dec 2011
    Posts
    28
    Any help?

  3. #3
    Join Date
    Apr 2013
    Posts
    31
    PHP code? I have only tried to build Word readers with the help of some manual toolkits in C#.NET platform. You can google some PHP manual SDKs to help you. Remember to check its free trial package first if possible. I hope you success. Good luck.



    Best regards,
    Arron

  4. #4
    Join Date
    Feb 2014
    Location
    Canada
    Posts
    155
    Have you tried anything like PHPDocX or used PHP's built-in COM classes? If you need to read the content directly into a database, such as Windows SQL Server or SQL Express, you could try to create a linked server that reads from that file or simply import it (depending on how you want it to function). All of these options should be able to handle non-English characters.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles