java - 如何在 Vaadin 中打印

标签 java web layout web-applications vaadin

我有一个 VerticalLayout,其中填充了 Vaadin 中的组件。请我按照 A4 纸的方式打印此布局。任何想法如何做到这一点,代码示例都会很棒。

最佳答案

直接出自Vaadin doc ...

Printing the Browser Window

Vaadin does not have special support for launching the printing in browser, but you can easily use the JavaScript print() method that opens the print window of the browser.

Button print = new Button("Print This Page");
print.addClickListener(new Button.ClickListener() {
    public void buttonClick(ClickEvent event) {
        // Print the current page
        JavaScript.getCurrent().execute("print();");
    }
});

The button in the above example would print the current page, including the button itself. You can hide such elements in CSS, as well as otherwise style the page for printing. Style definitions for printing are defined inside a @media print {} block in CSS.

关于java - 如何在 Vaadin 中打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42963270/

相关文章:

http - 网络服务器在过载时应该如何表现?

python - Scrapy 登录表单

Android EditText 文本的偏移量?

JavaFX 将布局作为参数传递

java - 正则表达式获取比率 x/y 的分子和分母

java - Java 中 Jalali Calendar 的一个好的日期转换器?

java - JButtons 仅在 BorderLayout.CENTER 中出现在 JFrame 上,而不是在 SOUTH 或 NORTH 中

java - 棉花糖权限模型

jakarta-ee - 针对不同请求的 Web 应用程序的不同实例

css - 如何使用CSS将文本放在 "box"的右上角或右下角