学习bfo的Big Faceless Report Generator科学使用

BFO
placeholder image
admin 发布于:2025-09-17 16:38:11
阅读:loading

BFO是开发用于处理 PDF 文档和图表的 Java API。它们体积小巧、速度快、文档丰富,并且持续改进。我们提供快速响应、友好的支持以及免费升级,有以下4款产品组件可以免费试用:

(1)Big Faceless PDF Library 用于创建、编辑、显示和打印 PDF 的 Java 类库;

(2)BFO Publisher 现代 HTML 到 PDF 转换器;

(3)Big Faceless Report Generator 一个将 XML 转换为 PDF 的 Java 工具;

(4)Big Faceless Graph Library 用于生成 2D 和 3D 图形和图表的 Java 类库;

特别说明:只为单纯的学习摸索与自我突破,商业软件请勿直接使用于生产环境(购买商业授权)

1.基本介绍

领先的 Java 报表工具,可将 XML 转换为 PDF 文档。使用 JSP、ASP 或类似技术,您可以像 HTML 一样快速轻松地创建动态 PDF 报表。它支持多种输出格式,包括PDF、HTML、Excel(XLS)、RTF、XML等,能够帮助开发者快速、灵活地创建复杂的、专业的报表。

Big Faceless Report Generator 报表工具提供市面上最全面、最先进的 XML 转 PDF 功能。由于我们的 XML 基于 XHTML 并使用 CSS,因此学习难度大大降低——报表设计人员无需学习全新的语法,因此可以更快地上手使用。

“两阶段”系统首先生成 XML,然后将其转换为 PDF,这意味着您可以使用任何工具生成 XML,尽管 JSP 是自然而然的选择。这意味着您可以访问专为 JSP 设计的所有标记库。在 XML 转换开始之前,数据库连接已全部完成,因此您可以使用任何您喜欢的方法将信息从后端转换为 XML。整个过程非常简单。

2.示例输出

一些从官网示例中整理的xml与pdf作为源文件,在此基础上运行输出报表PDF文件,以下是参考代码与示例输出:

public class HelloWorldTest extends BaseTest {

    @Test
    public void test() throws Exception {

        ReportParser parser = ReportParser.getInstance();
        parser.setFlag(ReportParser.WARNING_UNKNOWN_ATTRIBUTE, false);
        File[] inFiles = new File("resources/input/bforeport/").listFiles();
        assert inFiles != null;
        for (File inFile : inFiles) {
            doParse(parser , inFile);
        }
    }

    public static void doParse(ReportParser parser, File infile) {
        File outfile = new File("resources/output/bforeport/", infile.getName() + ".pdf");
        FileOutputStream out = null;

        try {
            System.out.print("Parsing \"" + infile + "\"... ");
            long now = System.currentTimeMillis();
            PDF pdf = parser.parse(infile);
            out = new FileOutputStream(outfile);
            pdf.render(out);
            System.out.println("created \"" + outfile + "\" in " + (System.currentTimeMillis() - now) + "ms");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (Exception ignore) {
                }
            }
        }
    }

}

(Java代码示例)

<?xml version="1.0" encoding="gb2312"?>
<!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">

<!--

Another "Hello, World" example, this time in simplified Chinese. It's very
similar to the HelloWorld-Japanese.xml example - again we set the font by
setting the language to "zh_CN".

The big difference between the Japanese example and this one is this file is
in the gb2312 encoding, rather then UTF-8. Notice the "encoding" property in
the first line of the XML.

See the "Internationalization" section of the userguide for more information.

-->

<pdf>
 <body font-size="24">
  世界,你好!
 </body>
</pdf>

(XML报表模板)

image.png

(多页面示例)

image.png

(各种列表)

image.png

(一个单据)

image.png

(PDF单据填充)

image.png

(统计图表)

3.其它说明

(1)Report是bfo公司出的众多产品中的其中一款Java语言的产品;

(2)关于Jar文件的下载可以直接从官网提供的下载渠道获取,下载到的Jar文件内有许多class属于加密混淆的;

(3)试用版功能齐全(它会在创建的每个页面中添加“DEMO”标记),本系列文章中的实现属于的科学使用,不需额外关注License,又不改动Jar的任何地方,同时又恰好没有各种限制。特别说明:只为单纯的学习摸索与自我突破,商业软件请勿直接使用于生产环境(购买商业授权)

(5)科学实践版本为2025年的bforeport-1.2.11.jar、bfopdf-jj2000.jar;

(6)相关示例输出文件下载:《示例输出.zip》;


 点赞


 发表评论

当前回复:作者

 评论列表


留言区