Java 生成「不动产查询告知单」PDF 示例(Template)
Template1 页 A4 · 39 KB
不动产登记信息查询结果告知单,政务查询回执。

输出规格
- PDF 页数
- 1
- 图表类型
- Template
- 模板行数
- 107
- 源码行数
- 93
Java 源码 · JQuickBiz91RealEstateQuery.java
以下代码即生成上方 PDF 的完整测试类,可直接复制运行;Maven 依赖见快速开始章节。
/*
* 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.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
public class JQuickBiz91RealEstateQuery {
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 + "91_real_estate_query.pdf";
private static final String TEMPLATE = "report/biz/91_real_estate_query.txt";
private static final String SEAL = IMG_DIR + "91_seal.png";
public static void main(String[] args) throws IOException {
new File(PDF_DIR).mkdirs();
new File(IMG_DIR).mkdirs();
generateSeal(SEAL);
Map<String, Object> data = new LinkedHashMap<String, Object>();
data.put("queryNo", "BDC-CX-20261019-00486");
data.put("queryPerson", "陈嘉禾");
data.put("idNo", "3101**********1234");
data.put("location", "××市浦东新区××路 88 弄 12 号 1802 室");
data.put("unitNo", "310115 008001 GB00012 F00010186");
// 权证信息拆为 4 个单元格变量(引擎不支持 colspan,模板按 2×2 展示)
data.put("rightsInfo1", "沪(2021)浦字不动产权第 0123456 号");
data.put("rightsInfo2", "2021-08-16");
data.put("rightsInfo3", "单独所有");
data.put("rightsInfo4", "2019-03-01 至 2089-02-28");
data.put("restrictionInfo", "除上述抵押登记外,未查询到查封、异议、预告等其他限制登记信息。");
data.put("queryTime", "2026-10-19 14:20:31");
data.put("issueOrg", "××市不动产登记中心");
data.put("issueDate", "2026-10-19");
JPdfConfig config = new JPdfConfig();
config.getLayoutConfig().setFlexLayout(true);
config.getDoc().setMargins(Arrays.asList(58, 62, 58, 62));
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);
FileOutputStream out = new FileOutputStream(OUT_FILE);
out.write(pdf);
out.close();
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, 14));
g.drawString("××市不动产登记中心", 18, 60);
g.setFont(new Font("Microsoft YaHei", Font.BOLD, 16));
g.drawString("查询专用章", size / 2 - 40, size / 2 + 30);
g.dispose();
ImageIO.write(image, "png", new File(path));
}
}最小调用(3 行)
不想读完整测试类?核心就是这三行:绑定图表 SVG,执行模板,拿到 PDF 字节流。可直接复制到你的项目里。
// config 可省略;svg 来自 JChartRendererFactory.renderChart(...),见下方完整源码
byte[] pdf = new JQuickPdfFactory(config).executeResource("report/biz/91_real_estate_query.txt");模板文件 · 91_real_estate_query.txt
类 HTML + 内联 CSS 的模板语法,绑定数据后渲染为 PDF。下方为完整模板,可直接复制,也可下载原始文件。
<pdf>
<body>
<h1 style="fontSize:16pt; bold:true; color:#1F4E79; textAlignment:center; characterSpacing:3pt">${issueOrg}</h1>
<div style="borderBottom:2px solid #1F4E79; marginTop:5px; marginBottom:12px"></div>
<h1 style="fontSize:17pt; bold:true; color:#1A2733; textAlignment:center; characterSpacing:2pt">'不动产登记信息查询结果告知单'</h1>
<p style="fontSize:9pt; color:#5A6B7C; textAlignment:right; marginTop:4px; marginBottom:8px">'查询单号:'${queryNo}</p>
// 查询人与标的物
<table style="width:100%; fontSize:9pt">
<tr>
<td style="width:78px; padding:5px; backgroundColor:#E8EDF2; bold:true; border:1px solid #C3CDD8">'查询人'</td>
<td style="padding:5px; border:1px solid #C3CDD8">${queryPerson}</td>
<td style="width:78px; padding:5px; backgroundColor:#E8EDF2; bold:true; border:1px solid #C3CDD8">'证件号码'</td>
<td style="padding:5px; border:1px solid #C3CDD8">${idNo}</td>
</tr>
<tr>
<td style="padding:5px; backgroundColor:#E8EDF2; bold:true; border:1px solid #C3CDD8">'查询时间'</td>
<td style="padding:5px; border:1px solid #C3CDD8">${queryTime}</td>
<td style="padding:5px; backgroundColor:#E8EDF2; bold:true; border:1px solid #C3CDD8">'查询类型'</td>
<td style="padding:5px; border:1px solid #C3CDD8">'权属及限制状况查询'</td>
</tr>
<tr>
<td style="padding:5px; backgroundColor:#E8EDF2; bold:true; border:1px solid #C3CDD8">'不动产坐落'</td>
<td style="padding:5px; border:1px solid #C3CDD8">${location}</td>
<td style="padding:5px; backgroundColor:#E8EDF2; bold:true; border:1px solid #C3CDD8">'单元号'</td>
<td style="padding:5px; border:1px solid #C3CDD8">${unitNo}</td>
</tr>
</table>
// 一、权利信息
<h2 style="fontSize:11pt; bold:true; color:#1F4E79; borderLeft:3px solid #1F4E79; paddingLeft:6px; marginTop:10px; marginBottom:5px">'一、权利信息'</h2>
<table style="width:100%; fontSize:9pt">
<tr>
<th style="width:15%; padding:5px; backgroundColor:#1F4E79; color:white; textAlign:center; border:1px solid #1F4E79">'权利人'</th>
<th style="width:28%; padding:5px; backgroundColor:#1F4E79; color:white; textAlign:center; border:1px solid #1F4E79">'权利类型'</th>
<th style="width:23%; padding:5px; backgroundColor:#1F4E79; color:white; textAlign:center; border:1px solid #1F4E79">'权利性质'</th>
<th style="width:14%; padding:5px; backgroundColor:#1F4E79; color:white; textAlign:center; border:1px solid #1F4E79">'用途'</th>
<th style="padding:5px; backgroundColor:#1F4E79; color:white; textAlign:center; border:1px solid #1F4E79">'面积'</th>
</tr>
<tr>
<td style="padding:5px; border:1px solid #C3CDD8">'陈嘉禾'</td>
<td style="padding:5px; border:1px solid #C3CDD8">'国有建设用地使用权/房屋所有权'</td>
<td style="padding:5px; border:1px solid #C3CDD8">'出让/市场化商品房'</td>
<td style="padding:5px; textAlign:center; border:1px solid #C3CDD8">'住宅'</td>
<td style="padding:5px; textAlign:right; border:1px solid #C3CDD8">'128.60㎡'</td>
</tr>
<tr>
<td style="padding:5px; backgroundColor:#E8EDF2; bold:true; border:1px solid #C3CDD8">'权证信息'</td>
<td style="padding:5px; border:1px solid #C3CDD8">${rightsInfo1}</td>
<td style="padding:5px; backgroundColor:#E8EDF2; bold:true; border:1px solid #C3CDD8">'登记时间'</td>
<td style="padding:5px; border:1px solid #C3CDD8">${rightsInfo2}</td>
</tr>
<tr>
<td style="padding:5px; backgroundColor:#E8EDF2; bold:true; border:1px solid #C3CDD8">'共有情况'</td>
<td style="padding:5px; border:1px solid #C3CDD8">${rightsInfo3}</td>
<td style="padding:5px; backgroundColor:#E8EDF2; bold:true; border:1px solid #C3CDD8">'使用期限'</td>
<td style="padding:5px; border:1px solid #C3CDD8">${rightsInfo4}</td>
</tr>
</table>
// 二、限制信息
<h2 style="fontSize:11pt; bold:true; color:#1F4E79; borderLeft:3px solid #1F4E79; paddingLeft:6px; marginTop:10px; marginBottom:5px">'二、限制信息'</h2>
<table style="width:100%; fontSize:9pt">
<tr>
<th style="width:16%; padding:5px; backgroundColor:#1F4E79; color:white; textAlign:center; border:1px solid #1F4E79">'限制类型'</th>
<th style="padding:5px; backgroundColor:#1F4E79; color:white; textAlign:center; border:1px solid #1F4E79">'限制内容'</th>
<th style="width:13%; padding:5px; backgroundColor:#1F4E79; color:white; textAlign:center; border:1px solid #1F4E79">'状态'</th>
<th style="width:17%; padding:5px; backgroundColor:#1F4E79; color:white; textAlign:center; border:1px solid #1F4E79">'登记时间'</th>
</tr>
<tr>
<td style="padding:5px; border:1px solid #C3CDD8">'抵押权'</td>
<td style="padding:5px; border:1px solid #C3CDD8">'××银行××支行,被担保主债权 320 万元'</td>
<td style="padding:5px; textAlign:center; color:#B71C1C; bold:true; border:1px solid #C3CDD8">'有效'</td>
<td style="padding:5px; border:1px solid #C3CDD8">'2023-05-12'</td>
</tr>
<tr>
<td style="padding:5px; backgroundColor:#E8EDF2; bold:true; border:1px solid #C3CDD8">'其他限制'</td>
<td style="padding:5px; border:1px solid #C3CDD8">${restrictionInfo}</td>
<td style="padding:5px; textAlign:center; border:1px solid #C3CDD8">'—'</td>
<td style="padding:5px; border:1px solid #C3CDD8">'—'</td>
</tr>
</table>
// 三、告知事项
<h2 style="fontSize:11pt; bold:true; color:#1F4E79; borderLeft:3px solid #1F4E79; paddingLeft:6px; marginTop:10px; marginBottom:5px">'三、告知事项'</h2>
<p style="fontSize:9.5pt; color:#333333; textIndent:19pt; marginBottom:3px">'1. 本告知单所载信息来源于不动产登记簿,查询时点为 '${queryTime}',仅供查询人参考。'</p>
<p style="fontSize:9.5pt; color:#333333; textIndent:19pt; marginBottom:3px">'2. 本告知单不作为权属证明使用,权利归属以不动产登记簿记载为准。'</p>
<p style="fontSize:9.5pt; color:#333333; textIndent:19pt; marginBottom:3px">'3. 如对本查询结果有异议,可自收到本告知单之日起 30 日内申请复查。'</p>
<p style="fontSize:9.5pt; color:#333333; textIndent:19pt; marginBottom:3px">'4. 未经权利人同意,任何单位和个人不得将本告知单信息用于其他用途。'</p>
// 落款
<div style="display:flex; justifyContent:space-between; marginTop:20px">
<div style="width:46%">
<p style="fontSize:8.5pt; color:#8a939b">'查询窗口:××市不动产登记中心 3 号窗口'</p>
<p style="fontSize:8.5pt; color:#8a939b; marginTop:3px">'经办人:林静 复核人:周敏'</p>
</div>
<div style="width:48%; textAlignment:center">
<image src='D:/test/image/91_seal.png' style="width:100px; height:100px"></image>
<p style="fontSize:10pt; bold:true; color:#1A2733; textAlignment:center">${issueOrg}</p>
<p style="fontSize:10pt; color:#333333; textAlignment:center">${issueDate}</p>
</div>
</div>
</body>
</pdf>同分组示例
本页 PDF、预览图、模板与源码均由 JQuick-Pdf 真实运行产出,可自由复制到你的项目中使用。