This project has moved. For the latest updates, please go here.

Object reference not set to an instance of an object. Did not convert

Jul 23, 2014 at 10:06 AM
I have a perl program hosted on a windows 7, which is being called by a publishing framework hosted on a linux environment.

This publishing framework has a Java based interface which calls the configured script (perl program calling external officetoPDF) on windows to perform the command-line conversion.

Input files (MS Office files) are copied into windows via an FTP (IIS) for OfficeToPDF.exe to convert to PDF.

When executed locally on windows command line works fine with file converted to PDF.

When invoked through publishing framework,officetopdf returns below message

Object reference not set to an instance of an object. Did not convert

I have another external program call for non-office ASCII file to binary file conversion inside my perl program which works perfectly fine with publishing framework call.

I have checked the user permission,execute permission on the ms-office file before conversion and path,still not able to get around this issue.

I also tried issues with permission as stated below with no luck

http://www.figured-it-out.com/figured-out.php?sid=24

Any pointers much appreciated
Coordinator
Jul 23, 2014 at 11:07 AM
Hi Ranjan

When you say "being called by a publishing framework" - is the linux server sending a HTTP request to IIS to start the officetopdf?

What I'd suggest is rather than calling officetopdf from the web server, try the following:
  1. Create a wrapper batch file that calls officetopdf to create a PDF and then pokes the linux side to say "a PDF is available for pickup" - or uploads the PDF
  2. Set up a file monitoring application (e.g. http://filenotify2.m4f.eu/index.html) to monitor your FTP inbox and have it call the wrapper script on file creation
You may need to have this running as an interactive desktop session on the windows side, but you can have Win 7 automatically log into a user and start the file monitor. This will ensure processing of files happens even after a power cycle.

This should completely remove any of the problems associated with DCOM permissions or Office not starting without a desktop session.

Regards
Vittal
Oct 8, 2014 at 8:46 AM
Hey guys,

i'm getting the same error as Ranjansh, while converting a docx to a pdf out of a Java Application:

cmd.exe /c C:\office2pdf\OfficeToPDF.exe /verbose C:\GDCT\RU_PT\shared\output\OutForm_UC_101_SalaryChange.docx C:\GDCT\RU_PT\shared\output\OutForm_UC_101_SalaryChange.pdf

Converting C:\GDCT\RU_PT\shared\output\OutForm_UC_101_SalaryChange.docx to C:\GDCT\RU_PT\shared\output\OutForm_UC_101_SalaryChange.pdf
Converting with Word converter
The object reference is not set to an instance of an object.
Did not convert

When i run the same command through the command-line, it works like a charm. I've gone through the "figured-out"-guide (http://www.figured-it-out.com/figured-out.php?sid=24) without any change.

Does somebody have any suggestions how to fix this problem? The java code looks like this:

Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("cmd.exe /c C:\office2pdf\OfficeToPDF.exe /verbose " + inputFilePath + " " + outputFilePath);

Regards
Dennis
Oct 9, 2014 at 2:13 PM
Edited Oct 9, 2014 at 2:14 PM
I have a similar setup like yours but i run the OfficeToPDF without cmd and works perfectly.
rt.exec("C:\office2pdf\OfficeToPDF /verbose " + inputFilePath + " " + outputFilePath);
Oct 9, 2014 at 2:16 PM
Wow, thanks for the fast reply! I'll try that tomorrow and report if it worked or not :)
Oct 10, 2014 at 2:09 PM
Doesn't work either :/ Same problem...
Oct 14, 2014 at 11:09 AM
I found the problem:

The webserver (Tomcat 8) was running as a service, causing permission problems on external programs, because every service in Windows is running as a special service user. When i run my application on a webserver not started as a service, everything works like a charm.

So i'm running tomcat through command line for now...

I tried to start the tomcat service as another user, but then, the service isn't starting at all. But i think this is a different topic which does not belong here :)

Thanks for your help!
Dec 11, 2014 at 5:02 AM
Any resolution?

I am calling OfficeToPDF in the java program and deployed in Tomcat.

ProcessBuilder pb = new ProcessBuilder(this.exePath+"/OfficeToPDF.exe", "/verbose" , "/hidden" , "/readonly" , iFile, oFile,"-headless");
Process process = pb.start();

If I start tomcat in command prompt.. everything works great, but when I try running under tomcat as service, I am getting "Object reference not set to an instance of an object."

Any suggestions on resolving this ?
Jan 20, 2015 at 8:39 AM
I was having the same issue.

I was calling the officetopdf using java and web service.

If you wish to run this tool as service need to this modification.

“C:\Windows\SysWOW64\config\systemprofile\Desktop” for 64 bit system , for 32 bit system we need to create “C:\Windows\System32\config\systemprofile\Desktop” folder.

Please try and let me know if that works.
Coordinator
Feb 4, 2015 at 10:51 AM
Edited May 5, 2015 at 8:11 AM