Print Content more than one page..?

I want to print a window in multiple pages…below is my code… but it is printing first page

public class WindowComp extends CustomComponent {

/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

@AutoGenerated
private VerticalLayout mainLayout;
@AutoGenerated
private VerticalLayout verticalLayout_7;
@AutoGenerated
private static VerticalLayout vlWindows;
@AutoGenerated
private Panel panel_14;
@AutoGenerated
private VerticalLayout verticalLayout_18;
@AutoGenerated
private Panel panel_13;
@AutoGenerated
private VerticalLayout verticalLayout_17;
@AutoGenerated
private Panel panel_12;
@AutoGenerated
private VerticalLayout verticalLayout_16;
@AutoGenerated
private Panel panel_11;
@AutoGenerated
private VerticalLayout verticalLayout_14;
@AutoGenerated
private Panel panel_10;
@AutoGenerated
private VerticalLayout verticalLayout_13;
@AutoGenerated
private HorizontalLayout horizontalLayout_2;
@AutoGenerated
private Button btnPrint;
private static final long serialVersionUID = 6568071254511464649L;
/**
 * The constructor should first build the main layout, set the
 * composition root and then do any custom initialization.
 *
 * The constructor will not be automatically regenerated by the
 * visual editor.
 */
public WindowComp() {
    buildMainLayout();
    setCompositionRoot(mainLayout);    
    addComponentsEventHandlers();
}

private void addComponentsEventHandlers() {
    // Add print buttton change listener.
            btnPrint.addClickListener(new ClickListener() {
                private static final long serialVersionUID = 3443163114334805003L;
                @Override
                public void buttonClick(ClickEvent event) {
                    printwindow();    

// printBrowser();
}
});
}

protected void printwindow() {
    final Window window = new Window("Window  REPORT");
    window.setModal(true);
    window.setId("window");
    window.setSizeFull();
    window.setContent(vlWindows); 
    getUI().addWindow(window);
    JavaScript.getCurrent().execute("setTimeout(function() {" + " print(); self.close();}, 100);");
}

private void printBrowser() {
    
     BrowserWindowOpener opener = new BrowserWindowOpener(PrintUI.class);
     opener.setFeatures("height=2000,width=1600,resizable,printall");
     opener.extend(btnPrint);    
}        

public static class PrintUI  extends UI{
    private static final long serialVersionUID = 2944723925173168186L;
    protected void init(VaadinRequest request) {
                // Have some content to print
                setContent(vlWindows);         
                // Print automatically when the window opens
                JavaScript.getCurrent().execute(
                    "setTimeout(function() {" +
                    "  print(); self.close();}, 1000);");                                    
    }

}

Has anyone come up with a solution for this?

I found a way to
print multiple pages from Vaadin 7
.

I followed the Vaadin 7 example for printing a simple HTML report

https://vaadin.com/book/-/page/advanced.printing.html#advanced.printing.opening

This works but only prints the first page.

I found the following ‘style’ tag on the header of the Vaadin HTML who is the responsible for this behavior

[font=courier new]

... [color=#FF0000] html, body {height:100%;margin:0;} [/color] ... ... [/font]

So the workaround to avoid this is
override the style
.
You can achieve this including an inline Javascript on the body of the page like this:

[color=#008000]
[font=courier new]

html, body {height:initial;margin:initial;}

[/font]
[/color]

I am afraid that the ‘style scoped’ tag belongs to HTML 5.

Hope this helps.

I have achieved the same result by simply calling setHeight(null) on the UI. The downside of both of these solutions is that you will lose the ability to scroll the page, so it will be usable only for printing purposes.

Try workaround here:

https://vaadin.com/forum/#!/thread/3869543/3869542