Преобразование файла в PDF

Добрый день.
Необходимо преобразовывать файл в PDF в системе.
В версии платформы 6.4 делал преобразование в сервисе следующим кодом:


String officePath = reportingConfig.getOpenOfficePath(); 
if (officePath != null) {
   byte[] bytes = null;
   try {
      bytes = fileStorageService.loadFile(fileDescriptor);
   } catch (FileStorageException e) {
      e.printStackTrace();
   }
   if (bytes != null) {
      PdfConverter.FileType type;
      if (fileDescriptor.getExtension().toLowerCase().equals("xls") ||
            fileDescriptor.getExtension().toLowerCase().equals("xlsx")) {
         type = PdfConverter.FileType.SPREADSHEET;
      } else type = PdfConverter.FileType.DOCUMENT;

      OfficeIntegrationAPI officeIntegration = new OfficeIntegration(officePath, 8100,8101,8102,8103);
      PdfConverter pdfConverter = new PdfConverterImpl(officeIntegration);
      ByteArrayOutputStream outputResult = new ByteArrayOutputStream();
      pdfConverter.convertToPdf(type, bytes, outputResult);

      return new ByteArrayInputStream(outputResult.toByteArray());
   }
}
return null;

После обновления на 6.5.3 при вызове сервиса возникает ошибка NotSerializableException: java.io.ByteArrayInputStream.
Как ее исправить? Как корректно выполнять преобразование файла?

Добрый день,

Аргументами и возвращаемыми типами сервисов могут быть только сериализуемые типы. В вашем случае из сервиса необходимо возвращать byte[].

Спасибо.

1 симпатия

Спасибо, работает.