Skip to content

Timeline (sepia) — generate this PDF with Java (TimeLine)

JQuick-PdfCreditReport Demo

TimeLine2 页 A4 · 111 KB

Shows the key milestones of the credit business in chronological order on a sepia timeline.

Download the PDFView raw template fileBack to all demos

Timeline (sepia) — TimeLine
Rendered output

Output specs

PDF pages
2
Chart type
TimeLine
Template lines
191
Source lines
85

Java source · JQuickCreditReport15TimelineTest.java

This is the complete test class that produced the PDF above — copy it and run as-is; see the quick-start section for the Maven dependency.

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Copyright (c) [2025-2099] Martin ([email protected])
 */
package com.github.paohaijiao.demo.creditreport;

import com.github.paohaijiao.JOption;
import com.github.paohaijiao.combol.JTimeLineData;
import com.github.paohaijiao.config.JPdfConfig;
import com.github.paohaijiao.demo.constant.JQuickConstant;
import com.github.paohaijiao.enums.JChartType;
import com.github.paohaijiao.executor.JQuickPdfFactory;
import com.github.paohaijiao.factory.JChartRendererFactory;
import org.junit.Test;

import java.awt.Color;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * 统一信用报告 —— 风格 15:时间线(棕褐)
 *
 * <p>以 {@code report/credit_report_15_timeline.txt} 为模板,把时间线渲染成 SVG 后
 * 绑定到模板中的 {@code ${svg}} 占位符,输出到 {@code D:\test\creditreport\15_timeline.pdf}。</p>
 *
 * @author Martin
 * @version 1.0.0
 */
public class JQuickCreditReport15TimelineTest {

    public static final String path = JQuickConstant.path;

    @Test
    public void report15Timeline() throws IOException {
        JTimeLineData data = new JTimeLineData();
        List<JTimeLineData.FlowNode> nodes = new ArrayList<>();
        nodes.add(new JTimeLineData.FlowNode("2018年", "企业成立|注册资本1000万元", new Color(78, 52, 46), new Color(78, 52, 46)));
        nodes.add(new JTimeLineData.FlowNode("2020年", "首轮融资|营收突破8000万元", new Color(109, 76, 65), new Color(109, 76, 65)));
        nodes.add(new JTimeLineData.FlowNode("2021年", "高新技术企业认定|研发投入占比12%", new Color(141, 110, 99), new Color(141, 110, 99)));
        nodes.add(new JTimeLineData.FlowNode("2022年", "专精特新小巨人|客户续约率92%", new Color(161, 136, 127), new Color(161, 136, 127)));
        nodes.add(new JTimeLineData.FlowNode("2023年", "信用评级AAA|营收25680万元", new Color(188, 170, 164), new Color(188, 170, 164)));
        data.setNodes(nodes);
        data.setMainTitle("CREDIT MILESTONE TIMELINE");
        data.setSubtitle("2018-2023 信用建设关键里程碑");
        data.setFooterText("数据来源:企业信用评估中心 | 更新日期:2024年1月");
        data.setHeight(1300);
        data.setBoxWidth(200);
        data.setBoxHeight(90);
        data.setStartX(100);
        data.setEndX(100);
        JOption option = new JOption();
        option.setData(data);

        String svg = JChartRendererFactory.renderChart(JChartType.TimeLine, option);

        File dir = new File(path + "creditreport");
        if (!dir.exists()) {
            dir.mkdirs();
        }
        FileOutputStream fileOutputStream = new FileOutputStream(path + "creditreport/15_timeline.pdf");
        JPdfConfig config = new JPdfConfig();
        // 开启 flex 行布局:图表与其右侧的指标说明面板在宽度允许时并排,而不是换行堆叠。
        config.getLayoutConfig().setFlexLayout(true);
        JQuickPdfFactory factory = new JQuickPdfFactory(config);
        factory.bind("svg", svg);
        byte[] bytes = factory.executeResource("report/credit_report_15_timeline.txt");
        fileOutputStream.write(bytes);
        fileOutputStream.close();
    }
}

Minimal invocation (3 lines)

Skip the full test class — the core is these three lines: bind the chart SVG, execute the template, get the PDF bytes. Copy them straight into your project.

// config 可省略;svg 来自 JChartRendererFactory.renderChart(...),见下方完整源码
factory.bind("svg", svg);
byte[] pdf = new JQuickPdfFactory(config).executeResource("report/credit_report_15_timeline.txt");

Template file · 15_timeline.txt

An HTML-like template with inline CSS that renders to PDF once bound to data. The full template is below — copy it or download the raw file.

<pdf>
<body>
  <div style="backgroundColor:#4E342E; borderRadius:4px; padding:16px; marginBottom:12px">
    <h1 style="textAlignment:center; color:white; fontSize:21; bold:true; marginBottom:8px">'企业信用评级报告'</h1>
    <p style="textAlignment:center; color:#efebe9; fontSize:10; margin:2px">'报告编号: CR-2023-08975 | 评估日期: 2023年11月15日'</p>
    <p style="textAlignment:center; color:#efebe9; fontSize:10; margin:2px">'评估机构: 四川省企业信用评估中心'</p>
  </div>

  <div style="marginBottom:14px">
    <h2 style="color:#4E342E; fontSize:14; bold:true; marginBottom:8px">'四川省泡海椒科技有限公司'</h2>
    <div style="display:flex; justifyContent:space-between; marginBottom:8px">
      <div style="width:190px; padding:8px; borderLeft:3px solid #8D6E63; backgroundColor:#efebe9">
        <p style="fontSize:9; color:#6D4C41; marginBottom:2px">'统一信用代码'</p>
        <p style="fontSize:11; bold:true; color:#4E342E">'91110108MA01XX1234'</p>
      </div>
      <div style="width:190px; padding:8px; borderLeft:3px solid #8D6E63; backgroundColor:#efebe9">
        <p style="fontSize:9; color:#6D4C41; marginBottom:2px">'成立日期'</p>
        <p style="fontSize:11; bold:true; color:#4E342E">'2018年5月20日'</p>
      </div>
      <div style="width:190px; padding:8px; borderLeft:3px solid #8D6E63; backgroundColor:#efebe9">
        <p style="fontSize:9; color:#6D4C41; marginBottom:2px">'注册资本'</p>
        <p style="fontSize:11; bold:true; color:#4E342E">'1000万元人民币'</p>
      </div>
    </div>
    <div style="display:flex; justifyContent:space-between">
      <div style="width:190px; padding:8px; borderLeft:3px solid #8D6E63; backgroundColor:#efebe9">
        <p style="fontSize:9; color:#6D4C41; marginBottom:2px">'法定代表人'</p>
        <p style="fontSize:11; bold:true; color:#4E342E">'泡海椒'</p>
      </div>
      <div style="width:190px; padding:8px; borderLeft:3px solid #8D6E63; backgroundColor:#efebe9">
        <p style="fontSize:9; color:#6D4C41; marginBottom:2px">'所属行业'</p>
        <p style="fontSize:11; bold:true; color:#4E342E">'软件和信息技术服务业'</p>
      </div>
      <div style="width:190px; padding:8px; borderLeft:3px solid #8D6E63; backgroundColor:#efebe9">
        <p style="fontSize:9; color:#6D4C41; marginBottom:2px">'企业规模'</p>
        <p style="fontSize:11; bold:true; color:#4E342E">'中型(150-200人)'</p>
      </div>
    </div>
  </div>

  <div style="marginBottom:14px">
    <h2 style="color:#6D4C41; fontSize:13; bold:true; marginBottom:10px">'历年财务数据(单位:万元)'</h2>
    <table style="width:600px; fontSize:10">
      <tr>
        <th style="backgroundColor:#6D4C41; color:white; padding:6px; textAlignment:center">'财务指标'</th>
        <th style="backgroundColor:#6D4C41; color:white; padding:6px; textAlignment:center">'2020年'</th>
        <th style="backgroundColor:#6D4C41; color:white; padding:6px; textAlignment:center">'2021年'</th>
        <th style="backgroundColor:#6D4C41; color:white; padding:6px; textAlignment:center">'2022年'</th>
        <th style="backgroundColor:#6D4C41; color:white; padding:6px; textAlignment:center">'2023年'</th>
        <th style="backgroundColor:#6D4C41; color:white; padding:6px; textAlignment:center">'增长率'</th>
      </tr>
      <tr>
        <td style="padding:5px; bold:true; borderBottom:1px solid #d7ccc8">'营业收入'</td>
        <td style="padding:5px; textAlignment:right; borderBottom:1px solid #d7ccc8">'8,560'</td>
        <td style="padding:5px; textAlignment:right; borderBottom:1px solid #d7ccc8">'12,340'</td>
        <td style="padding:5px; textAlignment:right; borderBottom:1px solid #d7ccc8">'18,920'</td>
        <td style="padding:5px; textAlignment:right; borderBottom:1px solid #d7ccc8">'25,680'</td>
        <td style="padding:5px; textAlignment:right; borderBottom:1px solid #d7ccc8; color:#2e7d32; bold:true">'+44.2%'</td>
      </tr>
      <tr>
        <td style="padding:5px; bold:true; backgroundColor:#f7f4f3; borderBottom:1px solid #d7ccc8">'净利润'</td>
        <td style="padding:5px; textAlignment:right; backgroundColor:#f7f4f3; borderBottom:1px solid #d7ccc8">'1,240'</td>
        <td style="padding:5px; textAlignment:right; backgroundColor:#f7f4f3; borderBottom:1px solid #d7ccc8">'2,150'</td>
        <td style="padding:5px; textAlignment:right; backgroundColor:#f7f4f3; borderBottom:1px solid #d7ccc8">'3,890'</td>
        <td style="padding:5px; textAlignment:right; backgroundColor:#f7f4f3; borderBottom:1px solid #d7ccc8">'5,420'</td>
        <td style="padding:5px; textAlignment:right; backgroundColor:#f7f4f3; borderBottom:1px solid #d7ccc8; color:#2e7d32; bold:true">'+63.8%'</td>
      </tr>
      <tr>
        <td style="padding:5px; bold:true; borderBottom:1px solid #d7ccc8">'总资产'</td>
        <td style="padding:5px; textAlignment:right; borderBottom:1px solid #d7ccc8">'15,800'</td>
        <td style="padding:5px; textAlignment:right; borderBottom:1px solid #d7ccc8">'22,450'</td>
        <td style="padding:5px; textAlignment:right; borderBottom:1px solid #d7ccc8">'31,200'</td>
        <td style="padding:5px; textAlignment:right; borderBottom:1px solid #d7ccc8">'42,800'</td>
        <td style="padding:5px; textAlignment:right; borderBottom:1px solid #d7ccc8; color:#2e7d32; bold:true">'+39.5%'</td>
      </tr>
      <tr>
        <td style="padding:5px; bold:true; backgroundColor:#f7f4f3; borderBottom:1px solid #d7ccc8">'净资产'</td>
        <td style="padding:5px; textAlignment:right; backgroundColor:#f7f4f3; borderBottom:1px solid #d7ccc8">'9,200'</td>
        <td style="padding:5px; textAlignment:right; backgroundColor:#f7f4f3; borderBottom:1px solid #d7ccc8">'13,800'</td>
        <td style="padding:5px; textAlignment:right; backgroundColor:#f7f4f3; borderBottom:1px solid #d7ccc8">'19,500'</td>
        <td style="padding:5px; textAlignment:right; backgroundColor:#f7f4f3; borderBottom:1px solid #d7ccc8">'26,400'</td>
        <td style="padding:5px; textAlignment:right; backgroundColor:#f7f4f3; borderBottom:1px solid #d7ccc8; color:#2e7d32; bold:true">'+42.1%'</td>
      </tr>
      <tr>
        <td style="padding:5px; bold:true; borderBottom:1px solid #d7ccc8">'毛利率'</td>
        <td style="padding:5px; textAlignment:right; borderBottom:1px solid #d7ccc8">'42.5%'</td>
        <td style="padding:5px; textAlignment:right; borderBottom:1px solid #d7ccc8">'45.8%'</td>
        <td style="padding:5px; textAlignment:right; borderBottom:1px solid #d7ccc8">'48.2%'</td>
        <td style="padding:5px; textAlignment:right; borderBottom:1px solid #d7ccc8">'51.6%'</td>
        <td style="padding:5px; textAlignment:right; borderBottom:1px solid #d7ccc8; color:#2e7d32; bold:true">'+9.1%'</td>
      </tr>
    </table>
  </div>

  <div style="marginBottom:14px">
    <h2 style="color:#6D4C41; fontSize:13; bold:true; marginBottom:10px">'关键经营指标'</h2>
    <div style="display:flex; marginBottom:10px">
      <div style="width:24px; paddingTop:4px">
        <div style="width:12px; height:12px; borderRadius:6px; backgroundColor:#8D6E63"></div>
      </div>
      <div style="width:560px; fontSize:11">
        <span style="bold:true; color:#4E342E">'营收增长率: '</span>
        '连续三年保持40%以上增长,2023年达到25,680万元'
      </div>
    </div>
    <div style="display:flex; marginBottom:10px">
      <div style="width:24px; paddingTop:4px">
        <div style="width:12px; height:12px; borderRadius:6px; backgroundColor:#8D6E63"></div>
      </div>
      <div style="width:560px; fontSize:11">
        <span style="bold:true; color:#4E342E">'利润率提升: '</span>
        '净利率从14.5%提升至21.1%,盈利能力显著增强'
      </div>
    </div>
    <div style="display:flex; marginBottom:10px">
      <div style="width:24px; paddingTop:4px">
        <div style="width:12px; height:12px; borderRadius:6px; backgroundColor:#8D6E63"></div>
      </div>
      <div style="width:560px; fontSize:11">
        <span style="bold:true; color:#4E342E">'研发投入: '</span>
        '研发费用年均增长38.9%,占营收比例达13.3%'
      </div>
    </div>
    <div style="display:flex; marginBottom:10px">
      <div style="width:24px; paddingTop:4px">
        <div style="width:12px; height:12px; borderRadius:6px; backgroundColor:#8D6E63"></div>
      </div>
      <div style="width:560px; fontSize:11">
        <span style="bold:true; color:#4E342E">'人才结构: '</span>
        '技术研发人员占比42%,硕士以上学历占35%'
      </div>
    </div>
    <div style="display:flex; marginBottom:10px">
      <div style="width:24px; paddingTop:4px">
        <div style="width:12px; height:12px; borderRadius:6px; backgroundColor:#8D6E63"></div>
      </div>
      <div style="width:560px; fontSize:11">
        <span style="bold:true; color:#4E342E">'客户质量: '</span>
        '服务15家上市公司,客户续约率92%,大客户满意度4.8/5.0'
      </div>
    </div>
    <div style="display:flex; marginBottom:10px">
      <div style="width:24px; paddingTop:4px">
        <div style="width:12px; height:12px; borderRadius:6px; backgroundColor:#8D6E63"></div>
      </div>
      <div style="width:560px; fontSize:11">
        <span style="bold:true; color:#4E342E">'资产质量: '</span>
        '资产负债率维持在38%左右,流动比率2.8,偿债能力良好'
      </div>
    </div>
  </div>

  <div style="marginBottom:14px">
    <h2 style="color:#6D4C41; fontSize:13; bold:true; marginBottom:10px">'信用里程碑时间线'</h2>
    <div style="textAlignment:center">
      <svg style="width:440px;height:400px">${svg}</svg>
    </div>
    <div style="display:flex; flexWrap:wrap; justifyContent:center; marginTop:10px">
      <div style="width:200px; textAlignment:center; fontSize:10">
        <span style="bold:true; color:#4E342E">'财务状况(90分): '</span>
        '营收稳定增长'
      </div>
      <div style="width:200px; textAlignment:center; fontSize:10">
        <span style="bold:true; color:#4E342E">'经营能力(95分): '</span>
        '客户留存率高'
      </div>
      <div style="width:200px; textAlignment:center; fontSize:10">
        <span style="bold:true; color:#4E342E">'偿债能力(85分): '</span>
        '负债率合理'
      </div>
      <div style="width:200px; textAlignment:center; fontSize:10">
        <span style="bold:true; color:#4E342E">'发展潜力(92分): '</span>
        '研发投入增加'
      </div>
    </div>
  </div>

  <div style="marginBottom:14px; background:linear-gradient(135deg, #efebe9 0%, #d7ccc8 100%); borderRadius:4px; padding:16px; borderLeft:4px solid #8D6E63">
    <h2 style="color:#4E342E; fontSize:13; bold:true; marginBottom:8px">'综合评价'</h2>
    <p style="textAlignment:justify; fontSize:11">
      '四川省泡海椒科技有限公司作为国家级高新技术企业和专精特新"小巨人"企业,在云计算和大数据领域表现出色。公司财务状况健康,经营能力突出,技术创新能力强,具备良好的发展潜力。信用评级为AAA级,展望稳定。'
    </p>
  </div>

  <div style="textAlignment:center; marginTop:12px">
    <p style="fontSize:9; color:#a1887f">'本报告依据公开信息和专业评估模型生成,仅供参考 | 报告生成时间: 2025年09月06日'</p>
    <p style="fontSize:9; color:#a1887f">'© 2023 企业信用评估中心 版权所有 | 认证编号: CE-2023-001'</p>
  </div>
</body>
</pdf>

More demos in this group

The PDF, preview image, template and source code on this page were all produced by a real JQuick-Pdf run and are free to copy into your own project.