use of com.axelor.meta.MetaFiles in project axelor-open-suite by axelor.
the class InvoicePrintServiceImpl method printAndSave.
public File printAndSave(Invoice invoice, Integer reportType, String format, String locale) throws AxelorException {
ReportSettings reportSettings = prepareReportSettings(invoice, reportType, format, locale);
MetaFile metaFile;
reportSettings.toAttach(invoice);
File file = reportSettings.generate().getFile();
try {
MetaFiles metaFiles = Beans.get(MetaFiles.class);
metaFile = metaFiles.upload(file);
metaFile.setFileName(String.format("%s.%s", reportSettings.getOutputName(), format));
invoice.setPrintedPDF(metaFile);
return MetaFiles.getPath(metaFile).toFile();
} catch (IOException e) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.INVOICE_PRINTING_IO_ERROR) + " " + e.getLocalizedMessage());
}
}
Aggregations