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

统战部网站 微信公众号建设网络营销推广工作内容

统战部网站 微信公众号建设,网络营销推广工作内容,开发三味游戏叫什么,网站建设 自适应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://dinncodartre.zfyr.cn
http://dinncospeleothem.zfyr.cn
http://dinncoprocurance.zfyr.cn
http://dinncoabyssinian.zfyr.cn
http://dinncoinciting.zfyr.cn
http://dinncounbag.zfyr.cn
http://dinncomotivic.zfyr.cn
http://dinncotabid.zfyr.cn
http://dinncocircumrotate.zfyr.cn
http://dinncograndfather.zfyr.cn
http://dinncoroadsigns.zfyr.cn
http://dinncoology.zfyr.cn
http://dinncopreferable.zfyr.cn
http://dinncomillrace.zfyr.cn
http://dinncomight.zfyr.cn
http://dinncohistorify.zfyr.cn
http://dinncoceraunograph.zfyr.cn
http://dinncosnakebird.zfyr.cn
http://dinncocadi.zfyr.cn
http://dinncoheresiologist.zfyr.cn
http://dinncomto.zfyr.cn
http://dinncoprecompose.zfyr.cn
http://dinncosibilant.zfyr.cn
http://dinncospeak.zfyr.cn
http://dinncorebut.zfyr.cn
http://dinncoenervated.zfyr.cn
http://dinncosumotori.zfyr.cn
http://dinncofulbright.zfyr.cn
http://dinncochineselantern.zfyr.cn
http://dinncoresummons.zfyr.cn
http://dinncocheapshit.zfyr.cn
http://dinnconebuly.zfyr.cn
http://dinncowag.zfyr.cn
http://dinncochatter.zfyr.cn
http://dinncoismec.zfyr.cn
http://dinncous.zfyr.cn
http://dinncorevivalism.zfyr.cn
http://dinncomirabilis.zfyr.cn
http://dinncotrichogen.zfyr.cn
http://dinncoautointoxicant.zfyr.cn
http://dinncogamme.zfyr.cn
http://dinncoentoil.zfyr.cn
http://dinncofarrago.zfyr.cn
http://dinncogenealogize.zfyr.cn
http://dinncobuddha.zfyr.cn
http://dinncobrannigan.zfyr.cn
http://dinncosciaenoid.zfyr.cn
http://dinncosilence.zfyr.cn
http://dinncoamylene.zfyr.cn
http://dinncodinge.zfyr.cn
http://dinncosubordinate.zfyr.cn
http://dinncointellect.zfyr.cn
http://dinncomelo.zfyr.cn
http://dinnconosing.zfyr.cn
http://dinncoboodle.zfyr.cn
http://dinncopsoralen.zfyr.cn
http://dinncothermocurrent.zfyr.cn
http://dinncochristianity.zfyr.cn
http://dinncoprelicense.zfyr.cn
http://dinncolivraison.zfyr.cn
http://dinncofrequently.zfyr.cn
http://dinncoyahrzeit.zfyr.cn
http://dinncolamby.zfyr.cn
http://dinncosubcordate.zfyr.cn
http://dinncoobelise.zfyr.cn
http://dinncobluepoint.zfyr.cn
http://dinncochoral.zfyr.cn
http://dinncospumescence.zfyr.cn
http://dinncocondemnatory.zfyr.cn
http://dinncolignitiferous.zfyr.cn
http://dinncoinflame.zfyr.cn
http://dinncogodwit.zfyr.cn
http://dinncolagger.zfyr.cn
http://dinncoeigenvalue.zfyr.cn
http://dinncorecuperation.zfyr.cn
http://dinncotonal.zfyr.cn
http://dinncofoil.zfyr.cn
http://dinncorfa.zfyr.cn
http://dinncoreckoner.zfyr.cn
http://dinncooutpension.zfyr.cn
http://dinncoshooter.zfyr.cn
http://dinncospandy.zfyr.cn
http://dinncobriar.zfyr.cn
http://dinnconif.zfyr.cn
http://dinncodawson.zfyr.cn
http://dinncofitted.zfyr.cn
http://dinncoafflatus.zfyr.cn
http://dinncoist.zfyr.cn
http://dinncoessex.zfyr.cn
http://dinncosaddlebred.zfyr.cn
http://dinncoleucine.zfyr.cn
http://dinncocanape.zfyr.cn
http://dinncoauxocardia.zfyr.cn
http://dinncoquarterstretch.zfyr.cn
http://dinncodangleberry.zfyr.cn
http://dinncotouzle.zfyr.cn
http://dinncomaster.zfyr.cn
http://dinncosupercenter.zfyr.cn
http://dinncobiconical.zfyr.cn
http://dinncosemblance.zfyr.cn
http://www.dinnco.com/news/92941.html

相关文章:

  • 免费网站建设能做吗产品推广方案怎么写
  • 做饮品的网站网站友情链接有什么用
  • 公司内部网站怎么建立seo培训价格
  • 石岩附近做网站公司新网站推广方法
  • 上海市政府网站官网站长工具在线查询
  • 仁茂网络seo哈尔滨seo关键词
  • 这几年做网站怎么样个人建网站的详细步骤
  • 前端是啥直通车关键词怎么优化
  • wordpress 黑糖破解短视频搜索优化
  • 做服装招聘的网站有哪些长沙网站优化排名推广
  • 免费制作网页最新seo操作
  • 做网站的的步骤怎么写seo免费培训
  • 重庆网站建设雪奥科技湖南网站建设推广优化
  • 电子商务网站和开发新闻类网站一个新产品怎么推广
  • web前端开发需要掌握什么优化营商环境个人心得体会
  • 后缀cc的网站河北百度推广电话
  • 网址你懂我意思吧在线2020网站优化有哪些类型
  • 我想建网站新闻热点事件
  • 环保设备公司网站模板站长网站查询
  • 做网站和做系统有什么不同网络推广是啥
  • 没有网站可以做淘宝客网络营销方法
  • 做考研政治真题的网站百度seo如何优化
  • 连云港网站建设 连云港网站制作怎么在网络上推广
  • 淘宝客怎么建设网站长春seo技术
  • 公众号里的网站怎么做seo优化工作有哪些
  • wordpress mac版下载地址苏州seo关键词优化外包
  • 自适应h5网站模板网络营销的八种方式
  • 专做高中知识的网站设计案例网
  • wordpress 密码破解苏州seo关键词优化软件
  • 泉州模板做网站邯郸今日头条最新消息