3 Replies - 363 Views - Last Post: 25 September 2013 - 08:27 AM

#1 dannybarh  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 62
  • Joined: 19-February 11

how to display pdf and docx for user to view

Posted 24 September 2013 - 10:21 AM

Hi, when i run this code,

    echo '<pre>';
    //echo "starting\n";
    					set_time_limit (30); //to allow time for Word to load.
    					$word = new COM("word.application") or die ("Could not initialise MS Word object.");
    					echo "COM instantiated\n";
    					$word->Application->Visible = False; 
    					echo "set visibility to false\n";
    																						
    					$doc = "src='userimages_doc/1364905979.3535.doc'";
    					$document = reapath($doc);
    					//if (is_readable($document)
    					echo "Document exists and is readable \n";
    					//else:
    					if(!is_file($document)):
    					echo "Document does not exist\n";die();
    					else:
    					echo "Document is not readable\n"; die();
    					endif;
    					//endif;
    					$word->Documents->Open( $document ); 
    					echo "Document opened\n";
    					// Extract content. 
    					$content = $word->ActiveDocument->Content; 
    					echo "test\n----------\n";
    					print_r($content);
    					echo "test\n----------\n";
    					echo "Extracting string value of content\n";
    					$content = (string) $content;
    					echo "test\n----------\n";
    					echo $content;
    					echo "test\n----------\n";
    																						
    					echo $content; 
    																						
    					$word->ActiveDocument->Close(false); 
    					echo "Closed Document\n";
    					$word->Quit(); 
    					//echo "Quit Word \n"
    					$word = null; 
    					unset($word);
    																			
    					//}



i keep getting this error

Fatal error:  Call to undefined function reapath() in D:\xampp\htdocs\auto-habari\admin\userindex\vehicles\veh_over_view.php on line 441


i think it may be this
 $doc = "src='userimages_doc/1364905979.3535.doc'";


Is This A Good Question/Topic? 0
  • +

Replies To: how to display pdf and docx for user to view

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1147
  • View blog
  • Posts: 7,134
  • Joined: 07-September 06

Re: how to display pdf and docx for user to view

Posted 24 September 2013 - 11:48 AM

On line 10 in the provided code you call a function reapath, which I believe you meant to have read realpath, notice the missing L. reapath doesn't exist in PHP, unless you have defined a function with that name and haven't provided it in the above code.

Hopefully that helps.
Was This Post Helpful? 0
  • +
  • -

#3 dannybarh  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 62
  • Joined: 19-February 11

Re: how to display pdf and docx for user to view

Posted 25 September 2013 - 03:23 AM

thanks betawar for the help, this is what i get
COM instantiated
set visibility to false
Document exists and is readable 
Document is not readable


can you pls tell me what it means, cos am not sure if the script is working
Was This Post Helpful? 0
  • +
  • -

#4 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1147
  • View blog
  • Posts: 7,134
  • Joined: 07-September 06

Re: how to display pdf and docx for user to view

Posted 25 September 2013 - 08:27 AM

It looks to me like you are getting back something that is either (a) not a path, or (b) not a file.

is_readable checks to ensure that (a) the path exists and (b) that you (* php) have permission to read it.

is_file checks to ensure that (a) the path exists and (b) it is a normal file (not a directory, link, etc.).

I would suggest printing out what it thinks $document is and see if it has a similar value to what you are expecting it to have. At the moment I wouldn't expect it to... I'd guess it has a value of something along the lines of /var/www/src/, which is a readable directory, while not being a file, and has a strong possibility of existing given standard directory layouts.

If the above is the case, you should be able to rectify the problem by removing the src='...' (and not the ... - ie everything in between) from the $doc variable. Either way, please post back with what the $document value is.

Hope that helps.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1