Bank credit letter — generate this PDF with Java (Template)
Template1 页 A4 · 31 KB
Bank creditworthiness certificate with the bank seal at the bottom right.

Output specs
- PDF pages
- 1
- Chart type
- Template
- Template lines
- 60
- Source lines
- 96
Java source · JQuickBiz82CreditCertificate.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.scenario;
import com.github.paohaijiao.config.JPdfConfig;
import com.github.paohaijiao.executor.JQuickPdfFactory;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
public class JQuickBiz82CreditCertificate {
private static final String PDF_DIR = "D:/test/pdf/";
private static final String IMG_DIR = "D:/test/image/";
private static final String OUT_FILE = PDF_DIR + "82_credit_certificate.pdf";
private static final String TEMPLATE = "report/biz/82_credit_certificate.txt";
public static void main(String[] args) throws IOException {
new File(PDF_DIR).mkdirs();
new File(IMG_DIR).mkdirs();
// ---------- 1. 生成业务专用章图片(模板按字面量路径引用)----------
generateSeal(IMG_DIR + "82_seal.png");
// ---------- 2. 组织数据(普通 Map,无实体类)----------
Map<String, Object> data = new LinkedHashMap<String, Object>();
data.put("certNo", "资信证明〔2026〕第 20261019-086 号");
data.put("customerName", "××数字科技有限公司");
data.put("idNo", "91310115MA1K9XXXX");
data.put("accountNo", "3100 1234 5678 9012 345");
data.put("accountType", "基本存款账户");
data.put("balance", "人民币 ¥ 8,642,300.00");
data.put("openDate", "2018年05月16日");
data.put("validUntil", "90 日");
data.put("bankName", "××银行××支行");
data.put("issueDate", "2026年10月19日");
// ---------- 3. 渲染 ----------
JPdfConfig config = new JPdfConfig();
config.getLayoutConfig().setFlexLayout(true);
config.getDoc().setMargins(Arrays.asList(58, 66, 58, 66));
config.getFooterConfig().setEnabled(false);
JQuickPdfFactory factory = new JQuickPdfFactory(config);
factory.bindAll(data);
byte[] pdf = factory.executeResource(TEMPLATE);
java.nio.file.Files.write(new File(OUT_FILE).toPath(), pdf);
System.out.println("已生成:" + OUT_FILE);
}
/** 生成银行业务专用章(圆环 + 行名 + 「业务专用章」字样)。 */
private static void generateSeal(String path) throws IOException {
int size = 210;
BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = image.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Color red = new Color(0xC6, 0x28, 0x28);
g.setColor(red);
g.setStroke(new BasicStroke(6f));
g.drawOval(8, 8, size - 16, size - 16);
g.setFont(new Font("Microsoft YaHei", Font.BOLD, 15));
g.drawString("××银行", size / 2 - 30, 62);
g.drawString("××支行", size / 2 - 30, 84);
g.setFont(new Font("Microsoft YaHei", Font.BOLD, 17));
g.drawString("业务专用章", size / 2 - 45, size / 2 + 32);
g.dispose();
ImageIO.write(image, "png", new File(path));
}
/** 预留:余额格式化,业务中建议用 BigDecimal 处理后再传入字符串。 */
@SuppressWarnings("unused")
private static String format(BigDecimal amount) {
return String.format("%,.2f", amount);
}
}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("report/biz/82_credit_certificate.txt");Template file · 82_credit_certificate.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>
<h1 style="fontSize:17pt; bold:true; color:#B71C1C; textAlignment:center; characterSpacing:4pt">${bankName}</h1>
<div style="borderBottom:2px solid #B71C1C; marginTop:5px"></div>
<div style="borderBottom:1px solid #B71C1C; marginTop:2px; marginBottom:14px"></div>
<h2 style="fontSize:20pt; bold:true; color:#1A2733; textAlignment:center; characterSpacing:8pt; marginBottom:4px">'资 信 证 明'</h2>
<p style="fontSize:9pt; color:#5A6B7C; textAlignment:right; marginBottom:10px">'编号:'${certNo}</p>
<p style="fontSize:11pt; bold:true; color:#1A2733; marginBottom:6px">${customerName}':'</p>
<p style="fontSize:10.5pt; color:#333333; textIndent:21pt; marginBottom:4px">'应贵单位申请,现就贵单位在我行开立账户及资信情况证明如下:'</p>
<table style="width:100%; fontSize:10pt; marginTop:8px; marginBottom:8px">
<tr>
<td style="width:110px; padding:6px; backgroundColor:#FDF2F2; bold:true; border:1px solid #D9B3B3">'客户名称'</td>
<td style="padding:6px; border:1px solid #D9B3B3">${customerName}</td>
</tr>
<tr>
<td style="padding:6px; backgroundColor:#FDF2F2; bold:true; border:1px solid #D9B3B3">'证件号码'</td>
<td style="padding:6px; border:1px solid #D9B3B3">${idNo}</td>
</tr>
<tr>
<td style="padding:6px; backgroundColor:#FDF2F2; bold:true; border:1px solid #D9B3B3">'账户账号'</td>
<td style="padding:6px; border:1px solid #D9B3B3">${accountNo}</td>
</tr>
<tr>
<td style="padding:6px; backgroundColor:#FDF2F2; bold:true; border:1px solid #D9B3B3">'账户类型'</td>
<td style="padding:6px; border:1px solid #D9B3B3">${accountType}</td>
</tr>
<tr>
<td style="padding:6px; backgroundColor:#FDF2F2; bold:true; border:1px solid #D9B3B3">'存款余额'</td>
<td style="padding:6px; border:1px solid #D9B3B3">${balance}</td>
</tr>
<tr>
<td style="padding:6px; backgroundColor:#FDF2F2; bold:true; border:1px solid #D9B3B3">'开户日期'</td>
<td style="padding:6px; border:1px solid #D9B3B3">${openDate}</td>
</tr>
</table>
<p style="fontSize:10.5pt; color:#333333; textIndent:21pt; marginBottom:4px">'截至 '${issueDate}' 止,贵单位上述账户资金往来正常,信用状况良好,在我行无不良记录、无未结清的逾期贷款及欠息。'</p>
<p style="fontSize:10.5pt; color:#333333; textIndent:21pt; marginBottom:4px">'本证明自开具之日起 '${validUntil}' 内有效,仅用于证明贵单位资信状况,不作其他用途。'</p>
<p style="fontSize:10.5pt; color:#333333; textIndent:21pt; marginTop:8px">'特此证明。'</p>
<div style="display:flex; justifyContent:space-between; marginTop:24px">
<div style="width:44%">
<p style="fontSize:8.5pt; color:#8a939b">'说明:本证明仅对所列账户在证明时点的状态负责,'</p>
<p style="fontSize:8.5pt; color:#8a939b">'不构成我行对客户未来偿付能力的担保。'</p>
</div>
<div style="width:48%; paddingLeft:110px">
<image src='D:/test/image/82_seal.png' style="width:100px; height:100px"></image>
<p style="fontSize:10.5pt; bold:true; color:#1A2733; textAlignment:center">${bankName}</p>
<p style="fontSize:9pt; color:#5A6B7C; textAlignment:center">'业务专用章'</p>
<p style="fontSize:10.5pt; color:#333333; textAlignment:center; marginTop:2px">${issueDate}</p>
</div>
</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.