Label printing


I need to print shipping labels from CUBA. My idea is to use an existing CSS format inside a Freemarker template, and merge the CUBA data with the template.

Is there any way to output the generated html in a new, independent window (i.e. without CUBA formatting). Or should I generate the labels to an html file and then download that file ?

Do you suggest any other method ? Perhaps use the reporting module ? What do you recommend ?


You can easily open new browser popup window using ExportDisplay bean:

public class DemoScreen extends AbstractWindow {
    private ExportDisplay exportDisplay;

    public void init(Map<String, Object> params) {

        String htmlPage =
                "<html>\n" +
                "  <body>\n" +
                "    <h1> Html page </h1>\n" +
                "  </body>\n" +
                "</html>"; ByteArrayDataProvider(htmlPage.getBytes(StandardCharsets.UTF_8)),
                "my-html.html", ExportFormat.HTML);

Also, Iā€™d recommend that you use our reports add-on because it supports printing of HTML files to PDF, that might be useful if you want to give PDF files to users. Check this manual page:

1 Like

Thanks !