Добрый день.
Необходимо преобразовывать файл в PDF.
Версия платформы 6.10.5. Преобразование выполняется в сервисе:
Форматы файлов doc, docx, xls, xlsx работают нормально.
String officePath = "C:\\Program Files (x86)\\OpenOffice 4\\program";
if (officePath != null) {
byte[] bytes = null;
try {
bytes = fileStorageService.loadFile(fileDescriptor);
} catch (FileStorageException e) {
e.printStackTrace();
}
if (bytes != null) {
DocumentConverter.FileType type;
if (fileDescriptor.getExtension().toLowerCase().equals("xls") ||
fileDescriptor.getExtension().toLowerCase().equals("xlsx")) {
type = DocumentConverter.FileType.SPREADSHEET;
} else type = DocumentConverter.FileType.DOCUMENT;
OfficeIntegrationAPI officeIntegration = new OfficeIntegration(officePath, 8100,8101,8102,8103);
DocumentConverter pdfConverter = new DocumentConverterImpl(officeIntegration);
ByteArrayOutputStream outputResult = new ByteArrayOutputStream();
pdfConverter.convertToPdf(type, bytes, outputResult);
return outputResult.toByteArray();
}
}
return null;
Формат txt вылетает с ошибкой:
com.haulmont.cuba.core.global.RemoteException:
---
java.lang.RuntimeException: com.haulmont.yarg.exception.ReportingException: An error occurred while running task in Open Office server
---
com.haulmont.yarg.exception.ReportingException: An error occurred while running task in Open Office server
---
com.sun.star.task.ErrorCodeIOException:
at com.haulmont.cuba.core.sys.ServiceInterceptor.aroundInvoke(ServiceInterceptor.java:129)
at sun.reflect.GeneratedMethodAccessor180.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy292.convertToPdf(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.haulmont.cuba.core.sys.remoting.LocalServiceInvokerImpl.invoke(LocalServiceInvokerImpl.java:94)
at com.haulmont.cuba.web.sys.remoting.LocalServiceProxy$LocalServiceInvocationHandler.invoke(LocalServiceProxy.java:154)
at com.sun.proxy.$Proxy78.convertToPdf(Unknown Source)
at ru.finexcons.reportcard.web.screens.Previewscreen.setSource(Previewscreen.java:62)
at ru.finexcons.reportcard.web.screens.Previewscreen.init(Previewscreen.java:34)
at com.haulmont.cuba.gui.WindowManager.init(WindowManager.java:1247)
at com.haulmont.cuba.gui.WindowManager.initWrapperFrame(WindowManager.java:1236)
at com.haulmont.cuba.gui.WindowManager.createWindow(WindowManager.java:581)
at com.haulmont.cuba.gui.WindowManager.openWindow(WindowManager.java:750)
at com.haulmont.cuba.web.WebWindowManager.openWindow(WebWindowManager.java:158)
at com.haulmont.cuba.web.gui.components.WebFrame.openWindow(WebFrame.java:298)
at com.haulmont.cuba.gui.components.AbstractFrame.openWindow(AbstractFrame.java:484)
at ru.finexcons.reportcard.web.screens.Documentsframe.preViewFile(Documentsframe.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.haulmont.cuba.gui.xml.DeclarativeAction.actionPerform(DeclarativeAction.java:92)
at com.haulmont.cuba.web.gui.components.WebButton.performAction(WebButton.java:46)
at com.haulmont.cuba.web.gui.components.WebButton.lambda$new$61446b05$1(WebButton.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:200)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:163)
at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1037)
at com.vaadin.ui.Button.fireClick(Button.java:377)
at com.haulmont.cuba.web.toolkit.ui.CubaButton.fireClick(CubaButton.java:69)