当前位置: 首页 > news >正文

西安建设局网站首页百度网盘人工客服电话多少

西安建设局网站首页,百度网盘人工客服电话多少,网站建设pc指什么,提升wordpress性能的插件java itext5 生成PDF并填充数据导出 依赖**文本勾选框****页眉**&#xff0c;**页脚****图片**实际图 主要功能有文本勾选框&#xff0c;页眉&#xff0c;页脚&#xff0c;图片等功能。肯定没有专业软件画的好看&#xff0c;只是一点儿方法。仅供参考。 依赖 <!--pdf-->&…

java itext5 生成PDF并填充数据导出

  • 依赖
  • **文本勾选框**
  • **页眉**,**页脚**
  • **图片**
  • 实际图

主要功能有文本勾选框页眉页脚图片等功能。肯定没有专业软件画的好看,只是一点儿方法。仅供参考。

依赖

        <!--pdf--><dependency><groupId>com.itextpdf</groupId><artifactId>itextpdf</artifactId><version>5.5.13</version></dependency><dependency><groupId>com.itextpdf</groupId><artifactId>itext-asian</artifactId><version>5.2.0</version></dependency>

文本勾选框

生成勾选框的图片,将图片插入到文本前面

private static Image checkBoxPng;static {ClassPathResource classPathResource = new ClassPathResource(CHECK_BOX_PATH);try {byte[] byteArray = FileCopyUtils.copyToByteArray(classPathResource.getInputStream());checkBoxPng = Image.getInstance(byteArray);} catch (IOException | BadElementException e1) {e1.printStackTrace();}}-------------------------------------------------------------------------final Paragraph paragraph = new Paragraph();if (checkBox != null && checkBox) {try {
//				final Image png = Image.getInstance(CHECK_BOX_PATH);// y轴 向下偏移5 保证大致上都是水平的final Chunk chunk = new Chunk(checkBoxPng, 0, -5);paragraph.add(chunk);} catch (Exception e) {throw new BusinessException(e.getMessage());}}paragraph.add(new Phrase(value, font));

页眉页脚

itext5没有页眉页脚设置的api,所以用的是定位的方式;
new Document();时预留出页眉和页脚数据所需要的空间大小
pdfPTable.writeSelectedRows(); 定位的方式把表格定位到对应的位置上即可

@Slf4j
@Component
public abstract class HeaderFooterEventHelper extends PdfPageEventHelper {/*** 页眉*/protected final List<CustomExportTemplateModuleDTO> headerList;/*** 页脚*/protected final List<CustomExportTemplateModuleDTO> footerList;public HeaderFooterEventHelper(List<CustomExportTemplateModuleDTO> headerList,List<CustomExportTemplateModuleDTO> footerList) {this.headerList = headerList;this.footerList = footerList;}/*** 一页加载完成触发,写入页眉和页脚*/@Overridepublic abstract void onEndPage(PdfWriter writer, Document document);
}
		//移除边距 方便设置页眉和页脚  定制页眉页脚Document document = new Document(PageSize.A4,-30 + ObjectUtils.defaultIfNull(module.getLeftMargin(), 0),-30 + ObjectUtils.defaultIfNull(module.getRightMargin(), 0),// 页眉高度 + 间隙高度  /页脚高度 - 间隙高度 (页面底部有一部分真空区域)headerSize + GAP_SIZE + ObjectUtils.defaultIfNull(module.getUpMargin(), 0),footerSize + GAP_SIZE + ObjectUtils.defaultIfNull(module.getDownMargin(), 0));ByteArrayOutputStream baos = new ByteArrayOutputStream();final PdfWriter writer = PdfWriter.getInstance(document, baos);// 初始化 页眉、页脚数据体writer.setPageEvent(new HeaderFooterEventHelper(headerDTOS, footerDTOS) {@Overridepublic void onEndPage(PdfWriter writer, Document document) {final ICustomExportTemplateService customExportTemplateService = SpringContextUtil.getBean(ICustomExportTemplateService.class);if (customExportTemplateService != null) {customExportTemplateService.setPdfData(this.headerList, writer, ZERO);customExportTemplateService.setPdfData(this.footerList, writer, ONE);}}});-------------------------------------------------------------------
@Overridepublic void setPdfData(List<CustomExportTemplateModuleDTO> moduleDTOS, PdfWriter writer, Integer type) {float size = 0;final float sumSize = getSumSize(moduleDTOS);for (CustomExportTemplateModuleDTO item : moduleDTOS) {PdfPTable pdfPTable; // 创建的表格pdfPTable.setTotalWidth(PageSize.A4.getWidth());pdfPTable.setWidthPercentage(WIDTH_PERCENT);if (Objects.equals(type, ZERO)) {// 页眉 基点为 左下角0点 高度为 A4全高 - 使用高度pdfPTable.writeSelectedRows(0, -1, ZERO,PageSize.A4.getHeight() - size, writer.getDirectContent());} else if (Objects.equals(type, ONE)) {// 页脚 基点为 左下角0点 高度为 列表使用总高度 - 使用高度pdfPTable.writeSelectedRows(0, -1, ZERO,sumSize - size, writer.getDirectContent());}if (item.getLabel().equals(2)) {size += BigDecimal.valueOf(item.getData().size()).multiply(BigDecimal.valueOf(CELL_SIZE)).intValue();} else {// 默认每行高度为 25size += CELL_SIZE;}}}

图片

PdfPCell cell = new PdfPCell();
// 我这里是根据文件服务器上的图片链接进行获取的。
cell.setImage(Image.getInstance(MinioUtil.getUrlName(imageUrl)));

实际图

http://www.hengruixuexiao.com/news/6996.html

相关文章:

  • 网络推广合同范本宁波怎么优化seo关键词
  • 测试工程师就是个坑福州seo推广优化
  • 大航母网站建设服务市场营销公司有哪些
  • 素材图汕头seo全网营销
  • 做网站设计师好吗临沂百度推广的电话
  • app网站怎么下载企业网络营销策略
  • 成都网站建设收费邵阳疫情最新消息
  • 香港 网站建设 可视化网站程序如何被百度收录
  • 网站建设代码合同免费引流推广方法
  • dede做招聘网站文案代写
  • 做美术鉴赏网站的心得谷歌广告联盟
  • 桐乡网站设计公司新闻稿发布平台
  • 公众平台网站建设哪家专业公司网站建设费用多少
  • udacity 移动网站开发谷歌浏览器网页版入口手机版
  • 做网站1500全包今日国际新闻事件
  • 百度投放广告联系谁seo基础入门视频教程
  • 郑州信息网官网seo排名优化软件有用吗
  • 用什么软件写网站网络营销方式都有哪些
  • 国际网站怎么样做企业网站管理系统怎么操作
  • 网页的版面设计是指郭生b如何优化网站
  • 做招标应该关注什么网站无锡整站百度快照优化
  • 莆田企业自助建站系统电子商务说白了就是干什么的
  • 网站开发工程师是什么内容seo推广有哪些方式
  • 网站建设的好处论文济南网络推广公司
  • 网站建设项目运营岗江西百度推广公司
  • 怎么做网站注册的网页站长友情链接平台
  • 中文旅游网站模板下载如何建立网上销售平台
  • 镇江网站设计哪家好软文推广渠道主要有
  • 简单页面设计海淀区seo搜索引擎优化企业
  • 公司网站作用百度客服电话人工服务热线