-2

I'm using OfficeToPDF to convert the MS-Office files to pdf. However, I only can run the command:

OfficeToPDF test.doc test.pdf

in cmd (windows)

I want to embed this code into my cgi file (Perl). Can anyone show me how to do this, thank you!

(I used:

system("OfficeToPDF test.doc test.pdf");

but seems it's not work)

Shaman
  • 3
  • 4
  • 2
    "seems it's not work" is a terrible way to report a problem. What unexpected behaviour did you see? What error messages did you get? – Dave Cross Aug 03 '12 at 15:06

2 Answers2

0

That should work but your envormental parameters might not be setup right, you should include full paths(or proper relative ones) and see if that fixes the problem up. If not you might want to post your debug log, or enable verbose output. Your perl also might not be setup to execute shell commands for security reasons when in cgi mode and the logs would help clarify that.

gmlime
  • 1,017
  • 8
  • 17
  • I tried but got new error: Object reference not set to an instance of an object. Did not convert – Shaman Aug 03 '12 at 13:35
  • Why don't you paste your new command, and are you sure it is finding the file? – gmlime Aug 03 '12 at 13:57
  • Yes, I tried to change test.doc to test1.doc and the system display: Can not find input file :) I used my CGI file to call some program like that but OfficeToPDF not work – Shaman Aug 03 '12 at 14:13
0

Try to:

  • use the full paths to OfficeToPDF and target PDF location because usually, the CGI scripts are run in another user context,
  • check, the CGI user has reading and writing rights for both files (and, off sure, right to execute the OfficeToPDF)

But it depends what means "it's not work", of sure.

Martin Poljak
  • 1,181
  • 1
  • 8
  • 4
  • I tried but got new error: Object reference not set to an instance of an object. Did not convert – Shaman Aug 03 '12 at 13:35