I have the following powershell script to open excel file and use excel save as PDF feature to generate a PDF file, and it works like a charm.
D:\test.ps1
$xlFixedFormat = "Microsoft.Office.Interop.Excel.xlFixedFormatType" -as [type] 
$xlRAMF = "Microsoft.Office.Interop.Excel.XlRunAutoMacro" -as [type] 
$xl = New-Object -comobject Excel.Application
# Show Excel
$xl.visible = $true
$xl.DisplayAlerts = $False
# Create a workbook
$wb = $xl.Workbooks.open("C:\Users\Administrator\Desktop\CAP\Book1.xlsx") 
$wb.RunAutoMacros($xlRAMF::xlAutoActivate)
$wb.Saved = $true
$wb.ExportAsFixedFormat($xlFixedFormat::xlTypePDF, "C:\Users\Administrator\Desktop\CAP\Book1.pdf")
$xl.Workbooks.close() 
$xl.Quit()
And then we wrote this test JSP script to call that powershell script.
<%@page import="org.apache.cactus.server.*" session="true" %>
<%
    Runtime runtime = Runtime.getRuntime();
        Process proc = runtime.exec("powershell D:\\test.ps1");
        java.io.InputStream is = proc.getInputStream();
        java.io.InputStreamReader isr = new java.io.InputStreamReader(is);
        java.io.BufferedReader reader = new java.io.BufferedReader(isr);
        String line;
        while ((line = reader.readLine()) != null)
        {
            out.println(line);
        }
        reader.close();
        proc.getOutputStream().close();
%>
When running this JSP script the Excel application is started under local administrator, which is right because I already configured tomcat to run as a service using local administrator, but it never generates the PDF file nor the excel application is closed, could it be a security issue ?, for example do I need to change catalena security policy file ?, etc. I already did the steps found here