Archive file cover (records management) — generate this PDF with Java (Layout)
Layout1 页 A4 · 15 KB
The file cover printed after completion documents of an infrastructure project are handed over to the archive room: a 3pt outer frame, fonds number and security level at the top corners, a three-level oversized title block in the middle, a two-column record table and a filing/checking footer.

Output specs
- PDF pages
- 1
- Chart type
- Layout
- Template lines
- 71
- Source lines
- 63
Java source · JQuickBiz55ArchiveCoverTest.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.biz;
import com.github.paohaijiao.config.JPdfConfig;
import com.github.paohaijiao.demo.constant.JQuickConstant;
import com.github.paohaijiao.executor.JQuickPdfFactory;
import org.junit.Test;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* 档案封面 Demo 55:档案案卷封面(档案管理场景)
*
* <p>业务场景:基建项目竣工资料移交档案室后,为案卷打印封面,需体现全宗号、密级、
* 案卷题名与档案号等要素,供装盒上架使用。</p>
*
* <p>版式:整页 3pt 粗外框 + 顶部全宗号与密级分列两端 + 中部超大字号题名区
* (单位名 14pt / 案卷类别 22pt / 保管期限 11pt 三级层次)+ 两列「标签 + 下划线值」
* 案卷信息表 + 底部立卷人与检查人双栏 + 居中单位与年月。</p>
*
* <p>本模板为纯版式 Demo,不含图表,因此不需要绑定 {@code svg} 变量;
* 模板:{@code report/biz/55_archive_cover.txt},输出:{@code D:\test\biz\55_archive_cover.pdf}。</p>
*
* @author Martin
* @version 1.0.0
*/
public class JQuickBiz55ArchiveCoverTest {
public static final String path = JQuickConstant.path;
@Test
public void biz55ArchiveCover() throws IOException {
File dir = new File(path + "biz");
if (!dir.exists()) {
dir.mkdirs();
}
FileOutputStream fileOutputStream = new FileOutputStream(path + "biz/55_archive_cover.pdf");
JPdfConfig config = new JPdfConfig();
// 开启 flex 行布局,使模板中的 display:flex 生效(全宗号与密级两端对齐、立卷/检查双栏)
config.getLayoutConfig().setFlexLayout(true);
JQuickPdfFactory factory = new JQuickPdfFactory(config);
byte[] bytes = factory.executeResource("report/biz/55_archive_cover.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(...),见下方完整源码
byte[] pdf = new JQuickPdfFactory(config).executeResource("report/biz/55_archive_cover.txt");Template file · 55_archive_cover.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="border:3px solid #6B4A2F; padding:20px">
// ---------- 顶部:全宗号 与 密级 ----------
<div style="display:flex; justifyContent:space-between">
<div style="width:300px">
<p style="fontSize:9pt; color:#6B4A2F; bold:true">'全宗号:QZ-2024-018'</p>
</div>
<div style="width:200px; textAlignment:right">
<p style="fontSize:10pt; color:#B71C1C; bold:true; characterSpacing:3pt">'密级:内部'</p>
</div>
</div>
// ---------- 中部题名区:三级字号层次 ----------
<h1 style="fontSize:14pt; bold:true; color:#3E2A1A; textAlignment:center; marginTop:70px; marginBottom:8px">'××市交通运输局'</h1>
<h1 style="fontSize:22pt; bold:true; color:#1A2733; textAlignment:center; characterSpacing:10pt; marginBottom:10px">'基本建设项目档案'</h1>
<p style="fontSize:11pt; color:#6B4A2F; textAlignment:center; characterSpacing:4pt; marginBottom:56px">'(永 久 保 管)'</p>
// ---------- 案卷信息:四列「标签 + 下划线值」 ----------
<table style="width:470px; fontSize:10pt">
<tr>
<td style="width:90px; padding:7px; textAlignment:right; color:#5A6B7C">'案卷题名:'</td>
<td style="width:300px; padding:7px; color:#1A2733; borderBottom:1px solid #8C7A6B">'××路地下管网改造工程竣工资料'</td>
</tr>
<tr>
<td style="padding:7px; textAlignment:right; color:#5A6B7C">'编制单位:'</td>
<td style="padding:7px; color:#1A2733; borderBottom:1px solid #8C7A6B">'××市政建设集团有限公司'</td>
</tr>
<tr>
<td style="padding:7px; textAlignment:right; color:#5A6B7C">'编制日期:'</td>
<td style="padding:7px; color:#1A2733; borderBottom:1px solid #8C7A6B">'2024年12月20日'</td>
</tr>
<tr>
<td style="padding:7px; textAlignment:right; color:#5A6B7C">'归档年度:'</td>
<td style="padding:7px; color:#1A2733; borderBottom:1px solid #8C7A6B">'2024年度'</td>
</tr>
<tr>
<td style="padding:7px; textAlignment:right; color:#5A6B7C">'保管期限:'</td>
<td style="padding:7px; color:#1A2733; borderBottom:1px solid #8C7A6B">'永久'</td>
</tr>
<tr>
<td style="padding:7px; textAlignment:right; color:#5A6B7C">'案卷件数:'</td>
<td style="padding:7px; color:#1A2733; borderBottom:1px solid #8C7A6B">'共 6 件'</td>
</tr>
<tr>
<td style="padding:7px; textAlignment:right; color:#5A6B7C">'案卷页数:'</td>
<td style="padding:7px; color:#1A2733; borderBottom:1px solid #8C7A6B">'共 428 页(图纸 26 张)'</td>
</tr>
<tr>
<td style="padding:7px; textAlignment:right; color:#5A6B7C">'档案号:'</td>
<td style="padding:7px; bold:true; color:#6B4A2F; borderBottom:1px solid #8C7A6B">'JZ-2024-JS-0186'</td>
</tr>
</table>
// ---------- 底部:立卷 / 检查 双栏 ----------
<div style="display:flex; justifyContent:space-between; marginTop:64px">
<div style="width:230px; borderTop:1px solid #8C7A6B; paddingTop:5px">
<p style="fontSize:9pt; color:#5A6B7C; textAlignment:center">'立卷人(签字)'</p>
</div>
<div style="width:230px; borderTop:1px solid #8C7A6B; paddingTop:5px">
<p style="fontSize:9pt; color:#5A6B7C; textAlignment:center">'档案检查人(签字)'</p>
</div>
</div>
<p style="fontSize:10pt; color:#3E2A1A; textAlignment:center; marginTop:26px">'××市交通运输局档案室'</p>
<p style="fontSize:10pt; color:#6B4A2F; textAlignment:center; marginTop:3px">'二〇二四年十二月'</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.