java PDF导出

本文档介绍了如何使用Java的iTextPDF库来创建PDF文件。通过示例代码展示了如何设置页面大小、背景色、字体、创建表格以及填充数据。代码中包含了一个用于导出搜索结果到PDF的功能,涉及年份、节电量和节电力等关键数据。
摘要由CSDN通过智能技术生成
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;








  <!-- 指标查询的tab页内容 start-->
  <div class="tab_contents">
  <!-- 搜索条件面板 -->
  <div class="search_box_panel">
  <table class="search-box-table">
  <tr>
  <th width='40px'></th>
  <th>年份:</th>
  <th>
  <select id="beginYear" name="" class="ui-text">
  </select>
  </th>
  <th>至</th>
  <th>
  <select id="endYear" name="" class="ui-text">
  </select>
  </th>
  <th width='55%'></th>
  <th><button id="search_for_index_btn" class="ui-btn ui-btn-primary">查询</button></th>
  <th><button class="ui-btn ui-btn-primary" οnclick="expPdf();">导出PDF</button></th>
  <th><button class="ui-btn ui-btn-primary" οnclick="expExl();">导出Excel</button></th>
  </tr>
  </table>
  </div>
  <!-- 搜索结果面板 -->
  <div id="search_result_panel" class="search_result_panel">
 
  <table id="index_query_table">
  <thead>
  <tr>
  <th rowspan="2">序号</th> 
  <th rowspan="2">年份</th>
  <th colspan="4">节电量(万kWh)</th>
  <th colspan="4">节电力(万kW)</th>
  <th rowspan="2">状态</th>
  </tr>
  <tr>
  <th>预指标值</th>
  <th>确认值</th>
  <th>承担值</th>
  <th>指标值</th>
  <th>预指标值</th>
  <th>确认值</th>
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值