How to call doc2any.exe from PHP source code to convert a xlsx file to pdf?

Hello, I'm trying doc2any.exe to convert a xlsx file to pdf, so far is working fine on command line but when I use shell_exec on php i get the following response:

[Message] You have 299 time to evaluate 'VeryDOC DOC to Any Converter Command Line' product, you may purchase a full version from 'https://www.verydoc.com/doc-to-any.html' web page.
[Message] Conversion time = 0ms [Message] "C:\inetpub\wwwroot\generados\SMR47001000000009794437.xlsx" ==> "C:\inetpub\wwwroot\out.pdf", result=ERROR
[Warning] If the conversion is fail, it may caused by permission problem, please run a CMD window by administrator privilege, and run same command line to try again. doc2any.exe is only require administrator privilege at first time when you run it.

Customer
-----------------------------------------
Because MS Office can't be run from Local System user account directly, so you need arrange MS Office or doc2any.exe run inside an interactive user account, we have several solutions for you to solve this problem,

Solution 1: Use VeryPDFComRunCmd COM to call doc2any.exe from PHP code, please look at following web pages for more information,

https://www.verydoc.com/blog/how-to-call-doc2any-exe-from-php-source-code.html
https://www.verydoc.com/blog/how-to-call-doc2any-from-php.html
http://www.verypdf.com/wordpress/201502/how-to-convert-any-file-to-pdf-using-php-script-41447.html
https://www.verydoc.com/blog/verydoc-release-notes-verydoc-releases-an-exe-com-of-verypdfcomruncmd-exe-today-verypdf-exe-com-does-allow-you-to-call-ms-office-and-any-exe-application-from-asp-php-c-net-etc-program-languag.html

Solution 2: Set MS Office DCOM run inside an interactive user account instead of default Local System user account,

https://www.verydoc.com/blog/microsoft-excel-application-entry-missing-in-dcomcnfg.html
https://www.verydoc.com/others/configure-word-and-excel.htm
https://www.verydoc.com/others/configure%20office%20applications%20to%20run%20under%20the%20interactive%20user%20account.htm
https://www.verydoc.com/doc-to-any-faq.html
https://www.verydoc.com/blog/how-to-make-iis7-play-nice-with-office-interop.html
https://www.verydoc.com/blog/aspnet-account-dcom-permisson-for-ms-word.html

Solution 3: Run conversion via "docPrint_Service.exe" application, please look at Example #7 from this web page,

https://www.verydoc.com/doc-to-any-shell.html

Example #7 (Run conversion via "docPrint_Service.exe" application),

docPrint Service can be used to run a Command Line from current active user account or a special user account, this tool is useful to overcome permission restrictions in SYSTEM and Non-Interactive user accounts.

Please by following steps to use docPrint Service,

1. Download docPrint_Service.zip and unzip it to a folder,

2. Run docPrint_Service.exe application, you will see an icon appear in tray area,

3. You can run following command lines to test it first, "docPrint_client.exe" will deliver the Command Line to docPrint_Service.exe application, docPrint_Service.exe application will execute the Command Line from active user account automatically,

docPrint_client.exe nowait "C:\VeryDOC\doc2any.exe" C:\test.doc C:\out.pdf
docPrint_client.exe wait "C:\VeryDOC\doc2any.exe" C:\test.doc C:\out.pdf

4. You can call "docPrint_client.exe" from your code, please refer to a simple C# code at below,

public partial class rundoc2any: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Process proc = new Process();
proc.StartInfo.FileName = "C:\\VeryDOC\\docPrint_client.exe";
string strArguments = "wait C:\\VeryDOC\\doc2any.exe C:\\test.doc C:\\test.pdf";
Console.WriteLine(strArguments);
proc.StartInfo.Arguments = @strArguments;
proc.Start();
proc.WaitForExit();
Response.Write("File has been successfully converted");
}
}

5. Close Remote Desktop and leave this user logged in.

*Please Notice: After you reboot the server, you need login your server via Remote Desktop with this user account ("doc2pdf_service.exe" was installed inside this user account), and close Remote Desktop, leave this user logged in, when you call docPrint_client.exe application, the conversion will be executed from this user account automatically.

VeryPDF

VN:F [1.9.20_1166]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.20_1166]
Rating: -1 (from 1 vote)
How to call doc2any.exe from PHP source code to convert a xlsx file to pdf?, 10.0 out of 10 based on 1 rating

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!