Skip to content

Credit release voucher — generate this PDF with Java (Template)

JQuick-PdfBanking Demos

Template2 页 A4 · 27 KB

Loan release voucher / repayment completion receipt.

Download the PDFView raw template fileBack to all demos

Credit release voucher — Template
Rendered output

Output specs

PDF pages
2
Chart type
Template
Template lines
172
Source lines
206

Java source · JQuickBiz147CreditReleaseVoucher.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.biz.bank;

import com.github.paohaijiao.config.JPdfConfig;
import com.github.paohaijiao.executor.JQuickPdfFactory;

import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 单据 147:信贷放款凭证 / 还款结清回执(bank 领域第 8 项)。
 *
 * <p>本类为独立可运行 Demo:自带 {@code main} 方法、不依赖任何公共工具类或实体类,
 * 数据以 key-value 形式通过 {@link JQuickPdfFactory#bindAll(Map)} 注入,
 * 版式全部落在模板文件 {@code demo/biz/bank/147_credit_release_voucher.txt} 中。</p>
 *
 * <p>视觉主题「群青·疏朗·通栏」:主色 #2A1D98、辅色 #916A27、浅底 #F1F0F7;
 * 版式为 banner 抬头 + kv 信息区 + airy 明细表 + right 签章区 + right 落款,
 * 与同领域其它单据互不重样。</p>
 *
 * <p>信贷放款凭证 / 还款结清回执:授信合同与业务类型、放款与逐期还款明细、</p>
 * <p>累计归还本金与利息、结清说明与银企签章栏。</p>
 *
 * <p>运行后输出:{@code D:/test/pdf/147_credit_release_voucher.pdf}。</p>
 *
 * @author Martin
 * @version 1.0.0
 */
public class JQuickBiz147CreditReleaseVoucher {

    private static final String PDF_DIR = "D:/test/pdf/";
    private static final String OUT_FILE = PDF_DIR + "147_credit_release_voucher.pdf";
    private static final String TEMPLATE = "demo/biz/bank/147_credit_release_voucher.txt";

    /** 模板固定明细行数,不足时补空行,避免占位符原样输出。 */
    private static final int ITEM_ROWS = 6;

    public static void main(String[] args) throws IOException {
        new File(PDF_DIR).mkdirs();

        // ---------- 1. 数据(无实体类,直接 bind)----------
        String[][] items = {
                {"1", "贷款放款", "2026-10-22", "3000000.00", "0.00", "3000000.00"},
                {"2", "按期付息", "2026-11-21", "0.00", "9625.00", "3000000.00"},
                {"3", "按期付息", "2026-12-21", "0.00", "9625.00", "3000000.00"},
                {"4", "部分还本", "2027-06-21", "500000.00", "8020.83", "2500000.00"},
                {"5", "提前还本", "2027-09-21", "1200000.00", "6250.00", "1300000.00"},
                {"6", "到期结清", "2027-10-21", "1300000.00", "80979.17", "0.00"}
        };

        Map<String, Object> data = new LinkedHashMap<String, Object>();
        data.put("voucherNo", "CR-20261023-0022");
        data.put("handleDate", "2026年10月23日");
        data.put("bankName", "中国建设银行××支行");
        data.put("customerName", "××智能装备制造有限公司");
        data.put("creditNo", "CREDIT-2026-0881");
        data.put("bizType", "流动资金贷款放款 / 到期结清");
        data.put("releaseAmount", "¥3,000,000.00");
        data.put("repaidPrincipal", "¥3,000,000.00");
        data.put("repaidInterest", "¥115,500.00");
        data.put("settleStatus", "已结清(本息全部归还)");
        data.put("settleNo", "SETTLE-20261023-0022");
        data.put("settleNote", "截至 2027 年 10 月 21 日,该笔授信项下贷款本息已全部清偿,贷款合同项下权利义务终止,可凭本回执办理抵押注销手续。");
        data.put("customerSign", "××智能装备制造有限公司");
        data.put("operator", "崔行知");
        data.put("bankSign", "中国建设银行××支行");

        // 明细逐格展开,并累计金额
        BigDecimal itemTotal = BigDecimal.ZERO;
        for (int i = 0; i < ITEM_ROWS; i++) {
            int n = i + 1;
            if (i >= items.length) {
                data.put("itemName" + n, "—");
                data.put("itemSpec" + n, "—");
                data.put("itemUnit" + n, "—");
                data.put("itemQty" + n, "—");
                data.put("itemPrice" + n, "—");
                data.put("itemAmount" + n, "—");
                continue;
            }
            data.put("itemName" + n, items[i][0]);
            data.put("itemSpec" + n, items[i][1]);
            data.put("itemUnit" + n, items[i][2]);
            itemTotal = itemTotal.add(new BigDecimal(items[i][3]));
            data.put("itemQty" + n, items[i][3]);
            data.put("itemPrice" + n, items[i][4]);
            data.put("itemAmount" + n, items[i][5]);
        }

        data.put("totalAmount", itemTotal.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
        data.put("totalAmountInWords", toChineseAmount(itemTotal));

        data.put("interestTotal", new BigDecimal("114500.00").setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());

        data.put("totalLine", "累计归还本金合计(大写)" + toChineseAmount(itemTotal) + "  (小写)¥" + itemTotal.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());

        // ---------- 2. 渲染 ----------
        JPdfConfig config = new JPdfConfig();
        config.getLayoutConfig().setFlexLayout(true);
        config.getDoc().setMargins(Arrays.asList(48, 48, 48, 48));
        config.getFontConfig().setDefaultFontName("Noto Sans CJK SC");
        config.getHeaderConfig().setEnabled(true);
        config.getHeaderConfig().setText("中国建设银行××支行 信贷放款 / 结清回执 CR-20261023-0022");
        config.getHeaderConfig().setFontSize(7.5f);
        config.getHeaderConfig().setHeight(30);
        config.getFooterConfig().setEnabled(true);
        config.getFooterConfig().setFontSize(8);
        config.getFooterConfig().setPageNumberFormat("第 %d 页");

        JQuickPdfFactory factory = new JQuickPdfFactory(config);
        factory.bindAll(data);
        byte[] pdf = factory.executeResource(TEMPLATE);
        Files.write(new File(OUT_FILE).toPath(), pdf);
        System.out.println("已生成:" + OUT_FILE + "(" + pdf.length + " 字节)");
    }

    /** 人民币金额转票据大写(元角分,末尾补「整」)。 */
    private static String toChineseAmount(BigDecimal amount) {
        String[] digits = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
        String[] units = {"", "拾", "佰", "仟"};
        String[] sections = {"", "万", "亿", "万亿"};
        long cents = amount.setScale(2, BigDecimal.ROUND_HALF_UP)
                .movePointRight(2).longValue();
        if (cents == 0) {
            return "零元整";
        }
        long yuan = cents / 100;
        int jiao = (int) (cents % 100 / 10);
        int fen = (int) (cents % 10);
        StringBuilder sb = new StringBuilder();
        if (yuan > 0) {
            sb.append(toChineseSection(yuan, digits, units, sections)).append("元");
        }
        if (jiao == 0 && fen == 0) {
            sb.append("整");
        } else {
            if (jiao > 0) {
                sb.append(digits[jiao]).append("角");
            } else if (yuan > 0) {
                sb.append("零");
            }
            if (fen > 0) {
                sb.append(digits[fen]).append("分");
            }
        }
        return sb.toString();
    }

    /** 整数部分按四位分节转大写。 */
    private static String toChineseSection(long value, String[] digits, String[] units, String[] sections) {
        StringBuilder sb = new StringBuilder();
        int sectionIndex = 0;
        boolean needZero = false;
        while (value > 0) {
            int section = (int) (value % 10000);
            StringBuilder part = new StringBuilder();
            int unitIndex = 0;
            boolean zeroInSection = false;
            int temp = section;
            while (temp > 0) {
                int digit = temp % 10;
                if (digit == 0) {
                    zeroInSection = true;
                } else {
                    if (zeroInSection || (needZero && part.length() == 0 && sb.length() > 0)) {
                        part.insert(0, digits[0]);
                    }
                    part.insert(0, units[unitIndex]);
                    part.insert(0, digits[digit]);
                    zeroInSection = false;
                    needZero = false;
                }
                unitIndex++;
                temp /= 10;
            }
            if (part.length() > 0) {
                part.append(sections[sectionIndex]);
            }
            sb.insert(0, part);
            needZero = section < 1000 && section > 0;
            value /= 10000;
            sectionIndex++;
        }
        return sb.toString();
    }
}

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(...),见下方完整源码
byte[] pdf = new JQuickPdfFactory(config).executeResource("demo/biz/bank/147_credit_release_voucher.txt");

Template file · 147_credit_release_voucher.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>
  // 147 信贷放款凭证 / 还款结清回执(bank 领域第 8 项) 视觉主题:群青·疏朗·通栏
  // 版式组合:抬头=banner 信息区=kv 明细表=airy 段落=plain 签章=right 落款=right
  // 主色 #2A1D98 辅色 #916A27 浅底 #F1F0F7
  // 信贷放款凭证与还款结清回执:放款、付息、还本、结清全链路与余额变化。

  // 抬头:banner
  <table style="width:100%; marginBottom:6px">
    <tr>
      <td style="width:58%; padding:8px; backgroundColor:#2A1D98; color:white; bold:true; fontSize:15pt; characterSpacing:4pt">'信贷放款凭证 / 还款结清回执'</td>
      <td style="padding:8px; backgroundColor:#150A73; color:white; textAlign:right; fontSize:7.5pt">'凭证编号 '${voucherNo}'  放款 / 结清日期 '${handleDate}'  经办行 '${bankName}</td>
    </tr>
  </table>

  // 信息区:kv
  <table style="width:100%; fontSize:9pt; marginBottom:8px">
    <tr>
      <td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C0BDD8">'凭证编号 / NO.'</td>
      <td style="padding:5px; border:1px solid #C0BDD8">${voucherNo}</td>
    </tr>
    <tr>
      <td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C0BDD8">'办理日期 / DATE'</td>
      <td style="padding:5px; border:1px solid #C0BDD8">${handleDate}</td>
    </tr>
    <tr>
      <td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C0BDD8">'经办行'</td>
      <td style="padding:5px; border:1px solid #C0BDD8">${bankName}</td>
    </tr>
    <tr>
      <td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C0BDD8">'客户名称'</td>
      <td style="padding:5px; border:1px solid #C0BDD8">${customerName}</td>
    </tr>
    <tr>
      <td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C0BDD8">'授信合同编号'</td>
      <td style="padding:5px; border:1px solid #C0BDD8">${creditNo}</td>
    </tr>
    <tr>
      <td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C0BDD8">'业务类型'</td>
      <td style="padding:5px; border:1px solid #C0BDD8">${bizType}</td>
    </tr>
    <tr>
      <td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C0BDD8">'放款金额'</td>
      <td style="padding:5px; border:1px solid #C0BDD8">${releaseAmount}</td>
    </tr>
    <tr>
      <td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C0BDD8">'累计还款本金'</td>
      <td style="padding:5px; border:1px solid #C0BDD8">${repaidPrincipal}</td>
    </tr>
    <tr>
      <td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C0BDD8">'累计还款利息'</td>
      <td style="padding:5px; border:1px solid #C0BDD8">${repaidInterest}</td>
    </tr>
    <tr>
      <td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C0BDD8">'结清状态'</td>
      <td style="padding:5px; border:1px solid #C0BDD8">${settleStatus}</td>
    </tr>
    <tr>
      <td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C0BDD8">'结清证明编号'</td>
      <td style="padding:5px; border:1px solid #C0BDD8">${settleNo}</td>
    </tr>
  </table>

  <table style="width:100%; marginBottom:3px">
    <tr>
      <td style="width:4px; padding:0px; backgroundColor:#916A27">' '</td>
      <td style="padding:3px; bold:true; fontSize:10.5pt; color:#150A73">'放款与还款明细'</td>
    </tr>
  </table>
  <table style="width:100%; fontSize:8.5pt; marginBottom:8px">
    <tr>
      <th style="width:7%; padding:5px; backgroundColor:#F1F0F7; color:#150A73; bold:true; textAlign:center; border:1px solid #C0BDD8">'序号'</th>
      <th style="width:16%; padding:5px; backgroundColor:#F1F0F7; color:#150A73; bold:true; textAlign:center; border:1px solid #C0BDD8">'业务类型'</th>
      <th style="width:13%; padding:5px; backgroundColor:#F1F0F7; color:#150A73; bold:true; textAlign:center; border:1px solid #C0BDD8">'交易日期'</th>
      <th style="width:16%; padding:5px; backgroundColor:#F1F0F7; color:#150A73; bold:true; textAlign:center; border:1px solid #C0BDD8">'本金金额'</th>
      <th style="width:16%; padding:5px; backgroundColor:#F1F0F7; color:#150A73; bold:true; textAlign:center; border:1px solid #C0BDD8">'利息金额'</th>
      <th style="padding:5px; backgroundColor:#F1F0F7; color:#150A73; bold:true; textAlign:center; border:1px solid #C0BDD8">'余额'</th>
    </tr>
    <tr>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemName1}</td>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemSpec1}</td>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemUnit1}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemQty1}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemPrice1}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemAmount1}</td>
    </tr>
    <tr>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemName2}</td>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemSpec2}</td>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemUnit2}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemQty2}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemPrice2}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemAmount2}</td>
    </tr>
    <tr>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemName3}</td>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemSpec3}</td>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemUnit3}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemQty3}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemPrice3}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemAmount3}</td>
    </tr>
    <tr>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemName4}</td>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemSpec4}</td>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemUnit4}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemQty4}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemPrice4}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemAmount4}</td>
    </tr>
    <tr>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemName5}</td>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemSpec5}</td>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemUnit5}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemQty5}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemPrice5}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemAmount5}</td>
    </tr>
    <tr>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemName6}</td>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemSpec6}</td>
      <td style="padding:5px; textAlign:center; border:1px solid #E8EBEE">${itemUnit6}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemQty6}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemPrice6}</td>
      <td style="padding:5px; textAlign:right; border:1px solid #E8EBEE">${itemAmount6}</td>
    </tr>
    <tr>
      <td style="padding:5px; bold:true; backgroundColor:#F1F0F7; textAlign:center; border:1px solid #2A1D98">'累计还款合计'</td>
      <td style="padding:5px; backgroundColor:#F1F0F7; border:1px solid #2A1D98">'—'</td>
      <td style="padding:5px; backgroundColor:#F1F0F7; border:1px solid #2A1D98">'—'</td>
      <td style="padding:5px; bold:true; backgroundColor:#F1F0F7; textAlign:right; border:1px solid #2A1D98">'¥'${totalAmount}</td>
      <td style="padding:5px; bold:true; backgroundColor:#F1F0F7; textAlign:right; border:1px solid #2A1D98">'¥'${interestTotal}</td>
      <td style="padding:5px; backgroundColor:#F1F0F7; border:1px solid #2A1D98">'—'</td>
    </tr>
  </table>

  // 段落:plain
  <p style="fontSize:10.5pt; bold:true; color:#150A73; marginBottom:3px">'累计归还本金合计'</p>
  <p style="fontSize:9pt; marginBottom:6px">${totalLine}</p>
  <p style="fontSize:10.5pt; bold:true; color:#150A73; marginBottom:3px">'结清说明'</p>
  <p style="fontSize:9pt; marginBottom:6px">${settleNote}</p>

  // 签章区:right
  <!-- 签章占位区:后续加盖电子公章 / 骑缝章 / 打印二维码 -->
  <table style="width:100%; fontSize:8pt; marginBottom:8px">
    <tr>
      <td style="width:32%; padding:5px; backgroundColor:#F1F0F7; fontSize:7.5pt; color:#78838C; border:1px solid #C0BDD8">'本联次加盖印章后有效,扫码可验真'</td>
      <td style="padding:3px; textAlign:center; color:#2A1D98; border:1px dashed #2A1D98">'(银行业务章 / 公章占位)' '(骑缝章 / 二维码占位)'</td>
    </tr>
    <tr>
      <td style="width:32%%; padding:4px">' '</td>
      <td style="padding:3px; textAlign:center; color:#78838C; border:1px dashed #2A1D98">'机构名称:'${bankName} '骑缝章沿右边线骑缝加盖'</td>
    </tr>
    <tr>
      <td style="width:32%%; padding:4px">' '</td>
      <td style="padding:3px; textAlign:center; color:#78838C; border:1px dashed #2A1D98">'业务日期:'${handleDate} '二维码打印于右上角方框内'</td>
    </tr>
  </table>

  // 落款:right
  <!-- 落款栏 -->
  <table style="width:100%; fontSize:9pt; marginTop:6px">
    <tr>
      <td style="width:24%; padding:4px">' '</td>
      <td style="width:38%; padding:4px; textAlign:center; color:#150A73">'客户签章:'${customerSign}</td>
      <td style="width:38%; padding:4px; textAlign:center; color:#150A73">'经办客户经理:'${operator}</td>
      <td style="padding:4px; textAlign:center; color:#150A73">'银行签章:'${bankSign}</td>
    </tr>
  </table>
</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.