Skip to content

Bid letter — generate this PDF with Java (Template)

JQuick-PdfScenario Demos

Template2 页 A4 · 65 KB

The bid letter page of a tender document.

Download the PDFView raw template fileBack to all demos

Bid letter — Template
Rendered output

Output specs

PDF pages
2
Chart type
Template
Template lines
77
Source lines
123

Java source · JQuickBiz86BidLetter.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.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;

public class JQuickBiz86BidLetter {

    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 + "86_bid_letter.pdf";
    private static final String TEMPLATE = "report/biz/86_bid_letter.txt";

    public static void main(String[] args) throws IOException {
        mkdirs();
        generateSeal(IMG_DIR + "86_seal.png");
        generateSignature(IMG_DIR + "86_sign.png", "陈立");

        Map<String, Object> data = new LinkedHashMap<String, Object>();
        data.put("projectName", "××市智慧交通数据中台建设项目");
        data.put("tenderNo", "ZB-2026-1124");
        data.put("bidder", "××数字科技有限公司");
        data.put("bidAmount", "3,180,000.00");
        data.put("bidAmountWords", "叁佰壹拾捌万元整");
        data.put("duration", "合同签订后 120 个日历日内完成建设并上线");
        data.put("validPeriod", "自投标截止之日起 90 个日历日");
        data.put("legalPerson", "陈立");
        data.put("legalIdNo", "3101**********0017");
        data.put("authorizedAgent", "王芳(项目经理)");
        data.put("tenderer", "××市交通运输局");
        data.put("bidDate", "2026年10月19日");
        // 承诺条款逐条 bind:commitment1~5
        String[] commitments = {
                "我方投标文件所载全部资料真实、准确、完整,如有虚假,愿承担相应法律责任;",
                "我方具有履行合同所必需的技术能力、人员配置与财务能力;",
                "我方承诺不与其他投标人串通报价,不以任何方式干扰招标活动;",
                "中标后按招标文件要求及投标承诺签订合同,不擅自变更报价与工期;",
                "项目交付后提供 12 个月免费质保,质保期内 2 小时响应、24 小时到场。"};
        for (int i = 0; i < commitments.length; i++) {
            data.put("commitment" + (i + 1), commitments[i]);
        }

        JPdfConfig config = new JPdfConfig();
        config.getLayoutConfig().setFlexLayout(true);
        config.getDoc().setMargins(Arrays.asList(56, 60, 55, 60));
        config.getHeaderConfig().setEnabled(true);
        config.getHeaderConfig().setText("招标编号:ZB-2026-1124 | 投标函");
        config.getHeaderConfig().setFontSize(8);
        config.getHeaderConfig().setHeight(34);
        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 mkdirs() {
        new File(PDF_DIR).mkdirs();
        new File(IMG_DIR).mkdirs();
    }

    private static void generateSeal(String path) throws IOException {
        int size = 200;
        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 - 38, 66);
        g.drawString("有限公司", size / 2 - 30, 90);
        g.setFont(new Font("Microsoft YaHei", Font.BOLD, 16));
        g.drawString("公章", size / 2 - 16, size / 2 + 32);
        g.dispose();
        ImageIO.write(image, "png", new File(path));
    }

    private static void generateSignature(String path, String name) throws IOException {
        BufferedImage image = new BufferedImage(220, 100, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = image.createGraphics();
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.rotate(Math.toRadians(-5), 110, 50);
        g.setColor(new Color(0x1B, 0x2A, 0x3A));
        g.setFont(new Font("KaiTi", Font.PLAIN, 46));
        g.drawString(name, 46, 70);
        g.dispose();
        ImageIO.write(image, "png", new File(path));
    }
}

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/86_bid_letter.txt");

Template file · 86_bid_letter.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>

  <!-- 第 1 页:投标函 -->
  <h1 style="fontSize:19pt; bold:true; color:#1A2733; textAlignment:center; characterSpacing:8pt">'投 标 函'</h1>
  <p style="fontSize:9pt; color:#5A6B7C; textAlignment:center; marginBottom:12px">'招标编号:'${tenderNo}</p>

  <p style="fontSize:11pt; bold:true; color:#1A2733; marginBottom:6px">'致:'${tenderer}</p>
  <p style="fontSize:10.5pt; color:#333333; textIndent:21pt; marginBottom:5px">'1. 我方已详细审阅「'${projectName}'」招标文件的全部内容,包括澄清、修改文件,我方完全理解并接受招标文件的各项条款。'</p>
  <p style="fontSize:10.5pt; color:#333333; textIndent:21pt; marginBottom:5px">'2. 我方愿意按照招标文件的要求,承担本项目的全部工作,投标报价如下表。'</p>

  <table style="width:100%; fontSize:10pt; marginTop:4px; marginBottom:6px">
    <tr>
      <td style="width:110px; padding:6px; backgroundColor:#E8EDF2; bold:true; border:1px solid #C3CDD8">'投标报价'</td>
      <td style="padding:6px; border:1px solid #C3CDD8; bold:true; color:#B71C1C">'人民币 ¥'${bidAmount}</td>
    </tr>
    <tr>
      <td style="padding:6px; backgroundColor:#E8EDF2; bold:true; border:1px solid #C3CDD8">'大写金额'</td>
      <td style="padding:6px; border:1px solid #C3CDD8">${bidAmountWords}</td>
    </tr>
    <tr>
      <td style="padding:6px; backgroundColor:#E8EDF2; bold:true; border:1px solid #C3CDD8">'计划工期'</td>
      <td style="padding:6px; border:1px solid #C3CDD8">${duration}</td>
    </tr>
    <tr>
      <td style="padding:6px; backgroundColor:#E8EDF2; bold:true; border:1px solid #C3CDD8">'投标有效期'</td>
      <td style="padding:6px; border:1px solid #C3CDD8">${validPeriod}</td>
    </tr>
  </table>

  <p style="fontSize:10.5pt; color:#333333; textIndent:21pt; marginBottom:5px">'3. 我方承诺:'</p>
  <list style="fontSize:10.5pt; color:#333333; listStyleType:decimal; marginLeft:20px">
    <li>${commitment1}</li>
    <li>${commitment2}</li>
    <li>${commitment3}</li>
    <li>${commitment4}</li>
    <li>${commitment5}</li>
  </list>

  <p style="fontSize:10.5pt; color:#333333; textIndent:21pt; marginTop:6px">'投标人(盖章):'${bidder}</p>
  <p style="fontSize:10.5pt; color:#333333; textIndent:21pt; marginTop:4px">'法定代表人或授权代表(签字):'${legalPerson}</p>
  <p style="fontSize:10.5pt; color:#333333; textIndent:21pt; marginTop:4px">${bidDate}</p>

  <!-- 第 2 页:法人身份与授权 -->
  <areaBreak></areaBreak>
  <h1 style="fontSize:17pt; bold:true; color:#1A2733; textAlignment:center; characterSpacing:6pt">'法定代表人身份证明'</h1>
  <p style="fontSize:10.5pt; color:#333333; textIndent:21pt; marginTop:12px">'投标人名称:'${bidder}</p>
  <p style="fontSize:10.5pt; color:#333333; textIndent:21pt">'法定代表人姓名:'${legalPerson}'  身份证号:'${legalIdNo}</p>
  <p style="fontSize:10.5pt; color:#333333; textIndent:21pt; marginTop:6px">'兹证明上述人员系我单位法定代表人,特此证明。'</p>
  <p style="fontSize:10.5pt; color:#333333; textAlignment:right; marginTop:16px">'投标人(盖章):'${bidder}</p>
  <p style="fontSize:10.5pt; color:#333333; textAlignment:right; marginTop:4px">${bidDate}</p>

  <h1 style="fontSize:17pt; bold:true; color:#1A2733; textAlignment:center; characterSpacing:6pt; marginTop:20px">'授 权 委 托 书'</h1>
  <p style="fontSize:10.5pt; color:#333333; textIndent:21pt; marginTop:12px">'本人 '${legalPerson}' 系 '${bidder}' 的法定代表人,现委托 '${authorizedAgent}' 为我方代理人,代表我方参加「'${projectName}'」的投标活动。'</p>
  <p style="fontSize:10.5pt; color:#333333; textIndent:21pt">'代理人权限:签署投标文件、参加开标、澄清答疑、签订合同及相关事宜,其法律后果由我方承担。'</p>
  <p style="fontSize:10.5pt; color:#333333; textIndent:21pt; marginTop:6px">'委托期限:自本委托书签署之日起至本项目招标活动结束止。'</p>

  <!-- 签章双占位区 -->
  <div style="marginTop:24px">
    <p style="fontSize:9pt; color:#8a939b; textAlignment:center">'— 以下为签章区,请打印后加盖公章并由法定代表人签字 —'</p>
  </div>
  <div style="display:flex; justifyContent:space-between; marginTop:8px">
    <div style="width:210px; border:1px dashed #9FB3C8; padding:8px; textAlignment:center">
      <p style="fontSize:9pt; color:#5A6B7C">'投标人公章(占位)'</p>
      <image src='D:/test/image/86_seal.png' style="width:96px; height:96px"></image>
      <p style="fontSize:8.5pt; color:#8a939b">${bidder}</p>
    </div>
    <div style="width:210px; border:1px dashed #9FB3C8; padding:8px; textAlignment:center">
      <p style="fontSize:9pt; color:#5A6B7C">'法定代表人签字(占位)'</p>
      <image src='D:/test/image/86_sign.png' style="width:110px; height:54px"></image>
      <p style="fontSize:8.5pt; color:#8a939b">${bidDate}</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.