Letter of credit application — generate this PDF with Java (Template)
Template2 页 A4 · 30 KB
Letter of credit / issuance application for cross-border settlement.

Output specs
- PDF pages
- 2
- Chart type
- Template
- Template lines
- 163
- Source lines
- 126
Java source · JQuickBiz139LetterOfCreditApplication.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.customs;
import com.github.paohaijiao.config.JPdfConfig;
import com.github.paohaijiao.executor.JQuickPdfFactory;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 单据 139:信用证 / 开证申请书 / 报关代理委托书(customs 领域第 15 项)。
*
* <p>本类为独立可运行 Demo:自带 {@code main} 方法、不依赖任何公共工具类或实体类,
* 数据以 key-value 形式通过 {@link JQuickPdfFactory#bindAll(Map)} 注入,
* 版式全部落在模板文件 {@code demo/biz/customs/139_letter_of_credit_application.txt} 中。</p>
*
* <p>视觉主题「群青·厚框·下线」:主色 #2B1F8F、辅色 #916A27、浅底 #F1F0F7;
* 版式为 underline 抬头 + kv 信息区 + solid 明细表 + card 签章区 + plain 落款,
* 与同领域其它单据互不重样。</p>
*
* <p>信用证开证申请书:信用证号与类型、开证申请人与受益人、金额与有效期,</p>
* <p>单据要求清单一览、特别条款与开证行签章栏。</p>
*
* <p>运行后输出:{@code D:/test/pdf/139_letter_of_credit_application.pdf}。</p>
*
* @author Martin
* @version 1.0.0
*/
public class JQuickBiz139LetterOfCreditApplication {
private static final String PDF_DIR = "D:/test/pdf/";
private static final String OUT_FILE = PDF_DIR + "139_letter_of_credit_application.pdf";
private static final String TEMPLATE = "demo/biz/customs/139_letter_of_credit_application.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", "商业发票 / COMMERCIAL INVOICE", "注明信用证号与合同号", "3", "提单日后 15 天", "待提交"},
{"2", "提单 / BILL OF LADING", "全套清洁已装船提单,TO ORDER", "3/3", "提单日后 21 天", "待提交"},
{"3", "装箱单 / PACKING LIST", "注明件数毛重尺码", "3", "同发票", "待提交"},
{"4", "原产地证书 / C/O FORM A", "由商会签发并签章", "1", "同发票", "待提交"},
{"5", "保险单 / INSURANCE POLICY", "按发票金额 110% 投保一切险", "2", "同发票", "待提交"},
{"6", "报关代理委托书", "明确代理权限与责任期限", "1", "开证前", "已签署"}
};
Map<String, Object> data = new LinkedHashMap<String, Object>();
data.put("lcNo", "LC-20261017-SG-08812");
data.put("issueDate", "2026年10月17日");
data.put("issuingBank", "中国银行××分行");
data.put("applicant", "××国际贸易有限公司");
data.put("beneficiary", "×× PRECISION MACHINERY PTE. LTD.");
data.put("lcType", "不可撤销即期信用证(IRREVOCABLE SIGHT L/C)");
data.put("lcAmount", "USD 46,280.40");
data.put("expiryInfo", "2026年12月16日 / SINGAPORE");
data.put("negotiatingBank", "×× BANK, SINGAPORE BRANCH");
data.put("agencyName", "××报关服务有限公司");
data.put("specialClause", "允许分批装运,允许转运;货物须于 2026 年 11 月 30 日前装船,不符点单据每次扣 USD 80.00。");
data.put("remark", "开证申请书须加盖申请人预留印鉴,报关代理委托书须明确代理报关、报检的权限与期限。");
data.put("applicantSign", "××国际贸易有限公司");
data.put("bankSign", "中国银行××分行");
data.put("inputer", "苏见宁");
// 明细逐格展开
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]);
data.put("itemQty" + n, items[i][3]);
data.put("itemPrice" + n, items[i][4]);
data.put("itemAmount" + n, items[i][5]);
}
// ---------- 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("中国银行××分行 信用证开证申请书 LC-20261017-SG-08812");
config.getHeaderConfig().setFontSize(8f);
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 + " 字节)");
}
}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/customs/139_letter_of_credit_application.txt");Template file · 139_letter_of_credit_application.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>
// 139 信用证 / 开证申请书 / 报关代理委托书(customs 领域第 15 项) 视觉主题:群青·厚框·下线
// 版式组合:抬头=underline 信息区=kv 明细表=solid 段落=box 签章=card 落款=plain
// 主色 #2B1F8F 辅色 #916A27 浅底 #F1F0F7
// 国际结算信用证、开证申请书与报关代理委托书:条款、单据要求与特别条款。
// 抬头:underline
<table style="width:100%; marginBottom:1px">
<tr>
<td style="width:62%; padding:2px; bold:true; fontSize:15pt; color:#150C6B; characterSpacing:3pt">'信用证 / 开证申请书 / 报关代理委托书'</td>
<td style="padding:2px; textAlign:right; fontSize:7.5pt; color:#78838C">'信用证号 '${lcNo}' 开证日期 '${issueDate}' 开证行 '${issuingBank}</td>
</tr>
</table>
<lineSeparator style="color:#2B1F8F; thickness:2.5f; marginBottom:8px"></lineSeparator>
// 信息区:kv
<table style="width:100%; fontSize:9pt; marginBottom:8px">
<tr>
<td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C1BED7">'信用证号 / L/C NO.'</td>
<td style="padding:5px; border:1px solid #C1BED7">${lcNo}</td>
</tr>
<tr>
<td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C1BED7">'开证日期 / DATE'</td>
<td style="padding:5px; border:1px solid #C1BED7">${issueDate}</td>
</tr>
<tr>
<td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C1BED7">'开证行 / ISSUING BANK'</td>
<td style="padding:5px; border:1px solid #C1BED7">${issuingBank}</td>
</tr>
<tr>
<td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C1BED7">'开证申请人 / APPLICANT'</td>
<td style="padding:5px; border:1px solid #C1BED7">${applicant}</td>
</tr>
<tr>
<td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C1BED7">'受益人 / BENEFICIARY'</td>
<td style="padding:5px; border:1px solid #C1BED7">${beneficiary}</td>
</tr>
<tr>
<td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C1BED7">'信用证类型'</td>
<td style="padding:5px; border:1px solid #C1BED7">${lcType}</td>
</tr>
<tr>
<td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C1BED7">'信用证金额 / AMOUNT'</td>
<td style="padding:5px; border:1px solid #C1BED7">${lcAmount}</td>
</tr>
<tr>
<td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C1BED7">'有效期与地点'</td>
<td style="padding:5px; border:1px solid #C1BED7">${expiryInfo}</td>
</tr>
<tr>
<td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C1BED7">'议付行 / NEGOTIATING BANK'</td>
<td style="padding:5px; border:1px solid #C1BED7">${negotiatingBank}</td>
</tr>
<tr>
<td style="width:22%; padding:5px; backgroundColor:#F1F0F7; bold:true; border:1px solid #C1BED7">'报关代理机构'</td>
<td style="padding:5px; border:1px solid #C1BED7">${agencyName}</td>
</tr>
</table>
<p style="fontSize:10.5pt; bold:true; color:#150C6B; marginBottom:4px">'信用证条款与单据要求'</p>
<table style="width:100%; fontSize:8pt; marginBottom:8px">
<tr>
<th style="width:7%; padding:4px; backgroundColor:#2B1F8F; color:white; bold:true; textAlign:center; border:1px solid #2B1F8F">'序号'</th>
<th style="width:26%; padding:4px; backgroundColor:#2B1F8F; color:white; bold:true; textAlign:center; border:1px solid #2B1F8F">'条款 / 单据名称'</th>
<th style="width:30%; padding:4px; backgroundColor:#2B1F8F; color:white; bold:true; textAlign:center; border:1px solid #2B1F8F">'要求内容'</th>
<th style="width:10%; padding:4px; backgroundColor:#2B1F8F; color:white; bold:true; textAlign:center; border:1px solid #2B1F8F">'份数'</th>
<th style="width:14%; padding:4px; backgroundColor:#2B1F8F; color:white; bold:true; textAlign:center; border:1px solid #2B1F8F">'提交期限'</th>
<th style="padding:4px; backgroundColor:#2B1F8F; color:white; bold:true; textAlign:center; border:1px solid #2B1F8F">'状态'</th>
</tr>
<tr>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemName1}</td>
<td style="padding:4px; textAlign:left; border:1px solid #C1BED7">${itemSpec1}</td>
<td style="padding:4px; textAlign:left; border:1px solid #C1BED7">${itemUnit1}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemQty1}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemPrice1}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemAmount1}</td>
</tr>
<tr>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemName2}</td>
<td style="padding:4px; textAlign:left; border:1px solid #C1BED7">${itemSpec2}</td>
<td style="padding:4px; textAlign:left; border:1px solid #C1BED7">${itemUnit2}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemQty2}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemPrice2}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemAmount2}</td>
</tr>
<tr>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemName3}</td>
<td style="padding:4px; textAlign:left; border:1px solid #C1BED7">${itemSpec3}</td>
<td style="padding:4px; textAlign:left; border:1px solid #C1BED7">${itemUnit3}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemQty3}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemPrice3}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemAmount3}</td>
</tr>
<tr>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemName4}</td>
<td style="padding:4px; textAlign:left; border:1px solid #C1BED7">${itemSpec4}</td>
<td style="padding:4px; textAlign:left; border:1px solid #C1BED7">${itemUnit4}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemQty4}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemPrice4}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemAmount4}</td>
</tr>
<tr>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemName5}</td>
<td style="padding:4px; textAlign:left; border:1px solid #C1BED7">${itemSpec5}</td>
<td style="padding:4px; textAlign:left; border:1px solid #C1BED7">${itemUnit5}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemQty5}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemPrice5}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemAmount5}</td>
</tr>
<tr>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemName6}</td>
<td style="padding:4px; textAlign:left; border:1px solid #C1BED7">${itemSpec6}</td>
<td style="padding:4px; textAlign:left; border:1px solid #C1BED7">${itemUnit6}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemQty6}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemPrice6}</td>
<td style="padding:4px; textAlign:center; border:1px solid #C1BED7">${itemAmount6}</td>
</tr>
</table>
// 段落:box
<table style="width:100%; marginBottom:6px">
<tr>
<td style="width:150px; padding:5px; backgroundColor:#F1F0F7; bold:true; fontSize:9.5pt; color:#150C6B; border:1px solid #C1BED7">'特别条款 / SPECIAL CLAUSES'</td>
<td style="padding:5px; fontSize:9pt; border:1px solid #C1BED7">${specialClause}</td>
</tr>
</table>
<table style="width:100%; marginBottom:6px">
<tr>
<td style="width:150px; padding:5px; backgroundColor:#F1F0F7; bold:true; fontSize:9.5pt; color:#150C6B; border:1px solid #C1BED7">'备注 / REMARKS'</td>
<td style="padding:5px; fontSize:9pt; border:1px solid #C1BED7">${remark}</td>
</tr>
</table>
// 签章区:card
<!-- 签章占位区:后续加盖电子公章 / 骑缝章 / 打印二维码 -->
<table style="width:100%; fontSize:8pt; marginBottom:8px">
<tr>
<td style="width:50%; padding:4px; backgroundColor:#F1F0F7; textAlign:center; color:#2B1F8F; border:1px solid #C1BED7">'(报关专用章 / 海关验讫章占位)'</td>
<td style="padding:4px; backgroundColor:#F1F0F7; textAlign:center; color:#2B1F8F; border:1px solid #C1BED7">'(骑缝章 / 二维码占位)'</td>
</tr>
<tr>
<td style="width:50%; padding:4px; backgroundColor:#F1F0F7; textAlign:center; color:#78838C; border:1px solid #C1BED7">'申报单位:'${applicant}</td>
<td style="padding:4px; backgroundColor:#F1F0F7; textAlign:center; color:#78838C; border:1px solid #C1BED7">'骑缝章沿右边线骑缝加盖'</td>
</tr>
<tr>
<td style="width:50%; padding:4px; backgroundColor:#F1F0F7; textAlign:center; color:#78838C; border:1px solid #C1BED7">'签章日期:'${issueDate}</td>
<td style="padding:4px; backgroundColor:#F1F0F7; textAlign:center; color:#78838C; border:1px solid #C1BED7">'二维码打印于右上角方框内'</td>
</tr>
</table>
// 落款:plain
<!-- 落款栏 -->
<table style="width:100%; fontSize:9pt; marginTop:6px">
<tr>
<td style="width:33%; padding:4px; color:#150C6B; borderBottom:1px solid #C1BED7">'开证申请人签章:'${applicantSign}</td>
<td style="width:33%; padding:4px; color:#150C6B; borderBottom:1px solid #C1BED7">'开证行签章:'${bankSign}</td>
<td style="padding:4px; color:#150C6B; borderBottom:1px solid #C1BED7">'录入:'${inputer}</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.