将带有CSS的Jsp转换为pdf [英] Convert a Jsp with css to pdf

查看:101
本文介绍了将带有CSS的Jsp转换为pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将jsp和他的css转换为pdf(外观应该相同).

I'm trying to convert a jsp with his css on a pdf (who should look the same).

首先,我创建了一个过滤器来获取我的html代码.

First, I created a filter to take my html code.

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException,
            IOException {
        ServletResponse newResponse = response;

        if (request instanceof HttpServletRequest) {
            newResponse = new CharResponseWrapper((HttpServletResponse) response);
        }
        chain.doFilter(request, newResponse);

        if (newResponse instanceof CharResponseWrapper) {
            String text = newResponse.toString();
            if (text != null) {
                response.getWriter().write(text);
                System.out.println(text);
            }
        }
    }
}

我确实有我的jsp的代码,但没有我的CSS的代码.我将页眉和页脚分开,这就是为什么我没有CSS的原因. 如何从中获得完整的设计pdf? 我是完全错误的,还是一个好的开始? 非常感谢您的帮助.

I do have a code of my jsp but not my css. I split my header and footer, that why I do not have my css. How from that can I get a full design pdf? Am I totally wrong, or it's a good start ? Thx a lot for your help.

推荐答案

然后,您可以将在过滤器中捕获的拦截响应反馈给飞行的守护者".这是一个从xhtml + css生成pdf的框架.

You could then feed the intercepted response you have captured inside the filter to 'flying sacuer'. It's a framework for generating pdf from xhtml + css.

https://code.google.com/p/flying-saucer/

这篇关于将带有CSS的Jsp转换为pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆