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

成都建设网站那家好wordpress的视频教程

成都建设网站那家好,wordpress的视频教程,wordpress 前端表单,青海西宁网页网站制作springboot 动态导出pdf 原理是通过freemarker插入数据到html模版里面#xff0c;html你就叫前端帮你写好#xff0c;他不写你就告诉你主管让他叫他写#xff0c;你只管往预留的位置插入数据就行#xff0c;然后通过itextpdf会将准备好html文件转成PDF。 ### 1、准备依赖 html你就叫前端帮你写好他不写你就告诉你主管让他叫他写你只管往预留的位置插入数据就行然后通过itextpdf会将准备好html文件转成PDF。 ### 1、准备依赖 !--下载pdf begin--dependencygroupIdcom.itextpdf/groupIdartifactIdhtml2pdf/artifactIdversion4.0.3/version/dependency!-- freemarker模版 --dependencygroupIdorg.freemarker/groupIdartifactIdfreemarker/artifactIdversion2.3.30/version/dependency!--下载pdf end--### 2、准备html模版 html headmeta charsetUTF-8style.main-container {font-family: SF-UI-Text-Regular;width: 21cm;margin: 0 auto;padding: 20px;}.float-left {float: left;}.float-right {float: right;}.padding-left-right {padding-left: 20px;padding-right: 20px;}.margin-left-right {margin-left: 20px;margin-right: 20px;}.section {/*border: 3px dashed #CCC;*//*padding: 20px;*/border-Top: 2px dashed #D3D3D3;padding-Top: 13px;margin-bottom: 16px;margin-Top: 20px;}.section-details p {color: #126089;/*font-size: 16px;*/}.grouper {overflow: hidden;}.grid-50 {width: 50%;}font-face {font-family: SF-UI-Text-Regular;src: url(https://s3-ap-southeast-1.amazonaws.com/content.staging.whitecoat.global/PDF/Templates/fonts/SF-UI-Text-Regular.otf);font-style: normal;}h1 {font-size: 22px;font-family: SF-UI-Text-Regular;}.h1-main {margin-top: 90px;}p {margin: 0 0 10px 0;font-family: SF-UI-Text-Regular;font-size: 12px;}.p-spec {color: #149a9a;font-weight: bold;}table, th, td {padding: 5px;border-collapse: collapse;}th, td {border: 1px solid #D3D3D3;}.margin-b-30 {margin-bottom: 30px;}.row:after {content: ;display: table;clear: both;}.column-4 {float: left;width: 33.33%;padding: 10px;}.column-8 {float: left;width: 66.66%;padding: 10px;}* {box-sizing: border-box;font-size: 12px;}/style /head bodydiv classmain-containerdiv stylebackground-color: #fffdiv classgrouper main-header grouper padding-left-right stylepadding-top: 20pxdiv classmargin-b-30 rowdiv classcolumn-4img stylemax-width:90%srchttps://s3-ap-southeast-1.amazonaws.com/content.staging.whitecoat.global/PDF/Templates/Images/WhiteCoat_Tax_Invoice.png/divdiv classcolumn-4WhiteCoat Holdings Pte Ltd. br/Clinic Licence No.: 18M0119/01/182 br/201 Henderson Road #05-11/12 br/Apex Henderson br/Singapore 159545 br//divdiv classcolumn-4GST Reg. No: 201610235E br/T: 65 6909 6909 br/F: 65 6909 6909 br/E: contactuswhitecoat.com.sg br/a styletext-decoration: none; hrefhttps://whitecoat.com.sg/whitecoat.com.sg/a/div/div/divdiv classmain-bodydiv classgrouperdiv classgrouper margin-left-right row styleborder-Top: 1px solid #D3D3D3;padding-top:20px;div classcolumn-4Name: br/${data.name!} br/br/NRIC/FIN/Passport No: br/${data.idNo!}/divdiv classcolumn-8Invoice No.: br/${data.invoiceNo!} br/br/Invoice Date: br/${data.invoiceDateStr!} br/br/iThis is a computer generated invoice. No signature is required./i/div/divdiv classgrouper margin-left-right styleborder-Top: 1px solid #D3D3D3;padding-top:20px;tabletrthS/N/thth colspan2Description/thth styleborder:1px solid #D3D3D3;Amount/th/trtrtd stylewidth:30px;text-align:center;1/tdtd stylewidth:550px; border-right: noneMedication br/#list data.medicationList as item${item.productName!} br//#listibr/Subtotal/i/tdtd styletext-align:right; border-left: noneQuantity br/#list data.medicationList as item${item.quantity!} br//#listi stylecolor:#fffbr/Subtotal/i/tdtd stylewidth:200px;text-align:rightbr/#list data.medicationList as item$${item.amount!} br//#listbr/i${data.subtotal!}/i/td/trtrtd styletext-align:center;2/tdtd colspan2Administrative charges/tdtd styletext-align:right$${data.adminCharge!}/td/trtrtd colspan3 styletext-align:right; border-bottom: none; border-left: noneSubtotal(Excluding GST)/tdtd styletext-align:right$${data.subtotalExcludingGST!}/td/trtrtd colspan3styletext-align:right; ; border-bottom: none; border-top: none; border-left: noneGST(${data.tax!}%)/tdtd styletext-align:right$${data.GST!}/td/trtrtd colspan3styletext-align:right; border-top: none; border-left: none; border-bottom: noneTotal(Including GST)/tdtd styletext-align:right$${data.totalIncludingGST!}/td/tr/table/divdiv classgrouper margin-left-right float-left stylepadding-bottom :20px;padding-top :20pxspanBank remittance details for payment by Bank Telegraphic br/Transfer in Singapore Dollars to:br/Name of Bank: United Overseas Bank Ltd. Holland Branchbr/Account Name: Whitecoat Holdings Pte Ltd.br/Account No: 341-308-316-6br/Bank Code: 7375br/Branch Code: 020br/Bank Swift Code: UOVBSGSG/span/div/div/div/div/body /html### 3、下载代码 ApiOperation(value 下载pdf)GetMapping(downloadPDF/staffPurchase)public ResponseResult download(String id, HttpServletResponse response) throws Exception {StaffPurchasePDFVo data staffPurchaseMapper.getStaffPurchasePDFData(id);HashMapString, Object mapData Maps.newHashMap();mapData.put(data, data);long timeMillis System.currentTimeMillis();String templateContent HtmlUtils.getTemplateContent(Staff_Purchase_Receipt.ftl, mapData);HtmlUtils.html2Pdf(response, templateContent, timeMillis );return ResponseResult.success();}### 4、htmlutils代码 import com.itextpdf.html2pdf.ConverterProperties; import com.itextpdf.html2pdf.HtmlConverter; import com.itextpdf.layout.font.FontProvider; import freemarker.template.Configuration; import freemarker.template.Template; import lombok.extern.slf4j.Slf4j; import org.springframework.ui.freemarker.FreeMarkerTemplateUtils; import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.FileOutputStream; import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; import java.util.Map; import java.util.Objects;Slf4j public class HtmlUtils {/*** return* throws Exception*/public static String getTemplateDirectory() {ClassLoader classLoader HtmlUtils.class.getClassLoader();URL resource classLoader.getResource(templates);try {return Objects.requireNonNull(resource).toURI().getPath();} catch (URISyntaxException e) {log.error(获取模板文件夹失败,{}, e);}return null;}/*** 获取模板内容** param templateName 模板文件名* param paramMap 模板参数* return* throws Exception*/public static String getTemplateContent(String templateName, MapString, Object paramMap) throws Exception {Configuration config ApplicationContextUtil.getBean(FreeMarkerConfigurer.class).getConfiguration();config.setDefaultEncoding(UTF-8);Template template config.getTemplate(templateName, UTF-8);return FreeMarkerTemplateUtils.processTemplateIntoString(template, paramMap);}/*** HTML 转 PDF** param content html内容* param outPath 输出pdf路径* return 是否创建成功*/public static boolean html2Pdf(String content, String outPath) {try {ConverterProperties converterProperties new ConverterProperties();converterProperties.setCharset(UTF-8);FontProvider fontProvider new FontProvider();fontProvider.addSystemFonts();converterProperties.setFontProvider(fontProvider);HtmlConverter.convertToPdf(content, new FileOutputStream(outPath), converterProperties);} catch (Exception e) {log.error(生成模板内容失败,{}, e);return false;}return true;}/*** HTML 转 PDF** param content html内容* return PDF字节数组*/public static void html2Pdf(HttpServletResponse response, String content,String filename) throws IOException {response.setHeader(Content-Type, application/octet-stream);response.setCharacterEncoding(utf-8);response.setHeader(Content-Disposition, attachment;filenamefilename.pdf);try (ServletOutputStream outputStream response.getOutputStream()) {ConverterProperties converterProperties new ConverterProperties();converterProperties.setCharset(UTF-8);FontProvider fontProvider new FontProvider();fontProvider.addSystemFonts();converterProperties.setFontProvider(fontProvider);HtmlConverter.convertToPdf(content, outputStream, converterProperties);} catch (Exception e) {log.error(生成 PDF 失败,{}, e);}} } ApplicationContextUtil代码、 import org.springframework.beans.BeansException; import org.springframework.boot.autoconfigure.AutoConfigureOrder; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.annotation.Configuration;Configuration AutoConfigureOrder(-1) public class ApplicationContextUtil implements ApplicationContextAware {private static ApplicationContext applicationContext null;public static Object getBeanByName(String beanName) {if (applicationContext null) {return null;}return applicationContext.getBean(beanName);}public static T T getBean(ClassT type) {return applicationContext.getBean(type);}Overridepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException {ApplicationContextUtil.applicationContext applicationContext;}}5、freemarker的基本语法 https://developer.aliyun.com/article/942606
http://www.zqtcl.cn/news/380574/

相关文章:

  • 福州网站建设公司哪个网站可以做前端项目
  • 十二冶金建设集团有限公司网站wordpress安装在哪里
  • 怎么做网站源码wordpress的rss
  • wordpress能不能做企业网站软件技术和计算机网络技术哪个好
  • 甘肃省住房和城乡建设部网站首页ip怎么做网站
  • 怎么开一家网站开发公司百度推广一年大概需要多少钱
  • 小破站下载h5企业模板网站
  • 服务器怎么设置ip做网站凌云seo博客
  • 莱芜四大金刚是谁啊镇江网站优化推广
  • 上海门户网站开发企业号码查询系统
  • 西安做网站设计的公司golang 网站开发 教程
  • 做网站哪些公司专业做app软件开发公司
  • 蒙特网站建设湖北省建设厅网站上岗证查询
  • 宁波网站建设 联系哪家电子商务网站建设过程范文
  • 南宁商城网站建设网站建设的需求文档
  • dedeampz 部署wordpress 网站访问慢如何评价网站是否做的好处
  • 怎样建设个人影视网站设计学专业
  • 没有公司 接单做网站网站建设加盟合作
  • 如何将域名和网站绑定做网站找投资人
  • 网站开发 平台WordPress首页可见
  • 沧州做网站费用打开上海发布
  • 重庆潼南网站建设公司电话网站能调用一些字体
  • 摄影网站设计素材做彩票网站电话多少
  • 开网站公司企业管理网课
  • 相城高端网站建设施工建设集团网站
  • .电子商务网站的开发原则包括网络服务示范区创建情况
  • 网站如何做权重php做网站登陆验证
  • 昆山制造网站的地方网站建设 有聊天工具的吗
  • 自己做网站制作需要多少钱如何免费注册网站域名
  • 如何做网站美化怎样写网站文案