Search in sources :

Example 1 with Catalog

use of com.axelor.apps.crm.db.Catalog in project axelor-open-suite by axelor.

the class CatalogController method showPdf.

public void showPdf(ActionRequest request, ActionResponse response) {
    try {
        Catalog catalog = Beans.get(CatalogRepository.class).find(request.getContext().asType(Catalog.class).getId());
        MetaFile pdf = catalog.getPdfFile();
        String title = catalog.getName();
        Path path = MetaFiles.getPath(pdf.getFileName());
        String fileLink = PdfTool.getFileLinkFromPdfFile(PdfTool.printCopiesToFile(path.toFile(), 1), title + ".pdf");
        response.setView(ActionView.define(title).add("html", fileLink).map());
    } catch (Exception e) {
        TraceBackService.trace(e);
    }
}
Also used : Path(java.nio.file.Path) CatalogRepository(com.axelor.apps.crm.db.repo.CatalogRepository) MetaFile(com.axelor.meta.db.MetaFile) Catalog(com.axelor.apps.crm.db.Catalog)

Aggregations

Catalog (com.axelor.apps.crm.db.Catalog)1 CatalogRepository (com.axelor.apps.crm.db.repo.CatalogRepository)1 MetaFile (com.axelor.meta.db.MetaFile)1 Path (java.nio.file.Path)1