Skip to content

Service acceptance receipt (government service window) — generate this PDF with Java (Layout)

JQuick-PdfBiz Demo

Layout1 页 A4 · 28 KB

Issued by a government service window after accepting an enterprise data-asset registration: a four-column acceptance table, grey section headings, two-column checkbox confirmations, numbered instructions, plus a tear-off customer copy and dual signature area.

Download the PDFView raw template fileBack to all demos

Service acceptance receipt (government service window) — Layout
Rendered output

Output specs

PDF pages
1
Chart type
Layout
Template lines
98
Source lines
63

Java source · JQuickBiz54AcknowledgementReceiptTest.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 54:业务受理回执单(政务窗口场景)
 *
 * <p>业务场景:政务综合窗口受理企业数据资产登记申请后,向申请人出具回执,
 * 载明受理信息、窗口已办事项确认、办理须知,并保留可裁剪的客户留存联与签收位。</p>
 *
 * <p>版式:细边框标题区(编号左、日期右)+ 四列受理信息表(仅下边框)+
 * 灰底通栏小节标题 + 两列 checkbox 确认事项 + 有序办理须知 + 裁剪线分隔客户留存联 +
 * 双栏签字区 + 联次注记。</p>
 *
 * <p>本模板为纯版式 Demo,不含图表,因此不需要绑定 {@code svg} 变量;
 * 模板:{@code report/biz/54_acknowledgement_receipt.txt},输出:{@code D:\test\biz\54_acknowledgement_receipt.pdf}。</p>
 *
 * @author Martin
 * @version 1.0.0
 */
public class JQuickBiz54AcknowledgementReceiptTest {

    public static final String path = JQuickConstant.path;

    @Test
    public void biz54AcknowledgementReceipt() throws IOException {
        File dir = new File(path + "biz");
        if (!dir.exists()) {
            dir.mkdirs();
        }
        FileOutputStream fileOutputStream = new FileOutputStream(path + "biz/54_acknowledgement_receipt.pdf");
        JPdfConfig config = new JPdfConfig();
        // 开启 flex 行布局,使模板中的 display:flex 生效(标题区两端对齐、两列确认事项、双栏签字区)
        config.getLayoutConfig().setFlexLayout(true);
        JQuickPdfFactory factory = new JQuickPdfFactory(config);
        byte[] bytes = factory.executeResource("report/biz/54_acknowledgement_receipt.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/54_acknowledgement_receipt.txt");

Template file · 54_acknowledgement_receipt.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:1px solid #1F4E79; padding:10px">
    <h1 style="fontSize:16pt; bold:true; color:#1F4E79; textAlignment:center; characterSpacing:4pt; marginBottom:6px">'业务受理回执单'</h1>
    <div style="display:flex; justifyContent:space-between">
      <div style="width:250px">
        <p style="fontSize:9pt; color:#5A6B7C">'回执编号:HZ-2024-1206-0186'</p>
      </div>
      <div style="width:250px; textAlignment:right">
        // 右对齐长行必须拆开写:250px 容不下「受理日期 + 受理窗口」整句,自动折行会把
        // 「综合服务 3 号窗口」拆成两行,视觉上像两条不同信息。
        <p style="fontSize:9pt; color:#5A6B7C">'受理日期:2024年12月6日'</p>
        <p style="fontSize:9pt; color:#5A6B7C">'受理窗口:综合服务 3 号窗口'</p>
      </div>
    </div>
  </div>

  // ---------- 小节标题:灰底通栏条(与其它模板的左侧竖条不同)----------
  <div style="background:#E8EDF2; borderLeft:4px solid #1F4E79; padding:4px 8px; marginTop:10px; marginBottom:6px">
    <p style="fontSize:10pt; bold:true; color:#1F4E79">'一、受理信息'</p>
  </div>
  <table style="width:560px; fontSize:9pt">
    <tr>
      <td style="width:80px; padding:5px; bold:true; color:#5A6B7C; borderBottom:1px solid #D3DCE5">'申请人'</td>
      <td style="width:180px; padding:5px; borderBottom:1px solid #D3DCE5">'陈嘉禾'</td>
      <td style="width:80px; padding:5px; bold:true; color:#5A6B7C; borderBottom:1px solid #D3DCE5">'联系电话'</td>
      <td style="width:220px; padding:5px; borderBottom:1px solid #D3DCE5">'138-0000-0000'</td>
    </tr>
    <tr>
      <td style="padding:5px; bold:true; color:#5A6B7C; borderBottom:1px solid #D3DCE5">'申请事项'</td>
      <td style="padding:5px; borderBottom:1px solid #D3DCE5">'企业数据资产登记'</td>
      <td style="padding:5px; bold:true; color:#5A6B7C; borderBottom:1px solid #D3DCE5">'业务类型'</td>
      <td style="padding:5px; borderBottom:1px solid #D3DCE5">'首次登记'</td>
    </tr>
    <tr>
      <td style="padding:5px; bold:true; color:#5A6B7C; borderBottom:1px solid #D3DCE5">'提交材料'</td>
      <td style="padding:5px; borderBottom:1px solid #D3DCE5">'共 5 份(清单见附件)'</td>
      <td style="width:100px; padding:5px; bold:true; color:#5A6B7C; borderBottom:1px solid #D3DCE5">'办结时限'</td>
      <td style="padding:5px; borderBottom:1px solid #D3DCE5">'3 个工作日'</td>
    </tr>
    <tr>
      <td style="padding:5px; bold:true; color:#5A6B7C; borderBottom:1px solid #D3DCE5">'当前状态'</td>
      <td style="padding:5px; bold:true; color:#1E7A46; borderBottom:1px solid #D3DCE5">'已受理 · 待审核'</td>
      <td style="padding:5px; bold:true; color:#5A6B7C; borderBottom:1px solid #D3DCE5">'查询方式'</td>
      <td style="padding:5px; borderBottom:1px solid #D3DCE5">'凭回执编号在线查询办理进度'</td>
    </tr>
  </table>

  // ---------- 确认事项:两列 checkbox,勾选项用 checked ----------
  <div style="background:#E8EDF2; borderLeft:4px solid #1F4E79; padding:4px 8px; marginTop:10px; marginBottom:6px">
    <p style="fontSize:10pt; bold:true; color:#1F4E79">'二、窗口已办事项确认'</p>
  </div>
  <div style="display:flex; justifyContent:space-between">
    <div style="width:270px">
      <p style="fontSize:9pt"><checkbox style="width:9px; marginRight:6px; fontSize:9pt" checked>'申请材料当场核对齐全'</checkbox></p>
      <p style="fontSize:9pt"><checkbox style="width:9px; marginRight:6px; fontSize:9pt" checked>'受理通知书已交付申请人'</checkbox></p>
      <p style="fontSize:9pt"><checkbox style="width:9px; marginRight:6px; fontSize:9pt" checked>'办结时限与查询方式已告知'</checkbox></p>
    </div>
    <div style="width:270px">
      <p style="fontSize:9pt"><checkbox style="width:9px; marginRight:6px; fontSize:9pt">'已出具材料补正清单'</checkbox></p>
      <p style="fontSize:9pt"><checkbox style="width:9px; marginRight:6px; fontSize:9pt">'需现场核查后另行通知'</checkbox></p>
      <p style="fontSize:9pt"><checkbox style="width:9px; marginRight:6px; fontSize:9pt">'已收取费用并开具票据'</checkbox></p>
    </div>
  </div>

  // ---------- 办理须知:有序列表 ----------
  <div style="background:#E8EDF2; borderLeft:4px solid #1F4E79; padding:4px 8px; marginTop:10px; marginBottom:6px">
    <p style="fontSize:10pt; bold:true; color:#1F4E79">'三、办理须知'</p>
  </div>
  <list style="paddingLeft:16px; fontSize:9pt" listType="ordered">
    <li style="marginBottom:3px">'请妥善保管本回执,办理进度查询与结果领取均需提供回执编号。'</li>
    <li style="marginBottom:3px">'审核过程中如需补充材料,将通过预留电话或短信通知,请保持畅通。'</li>
    <li style="marginBottom:3px">'对办理结果有异议的,可在收到结果之日起 15 日内申请复核。'</li>
  </list>

  // ---------- 裁剪线 + 客户留存联 ----------
  <div style="marginTop:14px">
    <p style="fontSize:8pt; color:#B0BEC5; textAlignment:center; marginBottom:2px">'— — — — — — — — — — — — — — 沿 此 线 裁 剪 , 以 下 为 客 户 留 存 联 — — — — — — — — — — — — — —'</p>
    <lineSeparator style="strokeColor:#B0BEC5"></lineSeparator>
    <p style="fontSize:8pt; color:#8a939b; textAlignment:center; marginTop:4px">'客户留存联 回执编号:HZ-2024-1206-0186  申请人:陈嘉禾  受理日期:2024年12月6日  承诺办结:3 个工作日'</p>
  </div>

  // ---------- 签字区:双栏 ----------
  <div style="display:flex; justifyContent:space-between; marginTop:16px">
    <div style="width:250px; borderTop:1px solid #5A6B7C; paddingTop:4px">
      <p style="fontSize:9pt; color:#5A6B7C; textAlignment:center">'申请人(签收)     年  月  日'</p>
    </div>
    <div style="width:250px; borderTop:1px solid #5A6B7C; paddingTop:4px">
      <p style="fontSize:9pt; color:#5A6B7C; textAlignment:center">'受理人(签章)     年  月  日'</p>
    </div>
  </div>

  <p style="fontSize:8pt; color:#8a939b; textAlignment:center; marginTop:12px">'本回执一式两联:第一联 受理窗口留存  第二联 申请人留存(裁剪线以下部分)'</p>
</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.