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

php无法调用wordpress网站排名优化技巧

php无法调用wordpress,网站排名优化技巧,网站查询进入,网站手机版模板poi生成的ppt#xff0c;powerPoint打开提示内容错误解决方案 最近做了ppt的生成#xff0c;使用poi制作ppt#xff0c;出现一个问题。微软的powerPoint打不开#xff0c;提示错误信息 通过xml对比工具发现只需要删除幻灯片的某些标签即可解决。 用的是XML Notepand 分…poi生成的pptpowerPoint打开提示内容错误解决方案 最近做了ppt的生成使用poi制作ppt出现一个问题。微软的powerPoint打不开提示错误信息 通过xml对比工具发现只需要删除幻灯片的某些标签即可解决。 用的是XML Notepand 分析思路 1.把poi生成的pptx用wps打开正常但是poi生成的pptx在powerPoint打不开。尝试用wps另存一份okwps另存后的pptpowerPoint可以打开了。然后ppt的大小也有了变化肯定是wps对这个ppt做了一些格式化操作。具体是啥呢不清楚只能用这个 XML Notepand 对比看看吧。 2. ppt本质上是xml的压缩包集合。我们对ppt进行解压。 3.里面的东西挺多了我自己也不怎么懂但是我想既然是ppt的某个幻灯片打不开那我就对比一下能幻灯片看看poi生成的ppt和wps另存后的ppt的幻灯片有哪些区别。 我们进入这个目录 4.这个就是放置幻灯片的位置。 我们通过这个XML Notepand 进行一个对比观察 我们先用xml notePand打开poi生成的一个幻灯片我打开的是wsp另存的解压后的第4个幻灯片ppt\slides\slide4.xml 然后选择这个再次选择一个poi生成的ppt选择同一个幻灯片进行一个对比 然后进行两个文件对比 最后对比发现这个标签可能不可以被powerPoint正确识别我们就把这个标签删除 p:custDataLstp:tags r:idrId1/ /p:custDataLst最关键的来了直接上代码 package com.ruoyi.ppt.utilsService;import com.ruoyi.ppt.aopCustom.customAnnotations.LogExecutionTime; import com.ruoyi.ppt.config.ThreadPoolDealTask; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import org.w3c.dom.*;import javax.annotation.Resource; import javax.xml.XMLConstants; import javax.xml.namespace.NamespaceContext; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import java.io.*; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Future; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream;Slf4j Component public class PptXmlFormate {Resourceprivate ThreadPoolDealTask threadPoolDealTask;LogExecutionTime(PPT XML标签调整耗时)public void xmlFormate(String pptxFilePath, String useFont) {useFont StringUtils.isBlank(useFont) ? 宋体 : useFont;// 使用 try-with-resources 自动关闭临时文件和 Zip 流try {// 创建临时文件来存储更新后的 PPTX 文件File tempFile File.createTempFile(pptx_temp UUID.randomUUID(), .zip);tempFile.deleteOnExit();// 读取 PPTX 文件并更新 XMLtry (FileInputStream fis new FileInputStream(pptxFilePath);ZipInputStream zis new ZipInputStream(fis);FileOutputStream fos new FileOutputStream(tempFile);ZipOutputStream zos new ZipOutputStream(fos)) {ZipEntry entry;MapString, ByteArrayOutputStream updatedFiles new HashMap();// 遍历 PPTX 文件中的每个条目while ((entry zis.getNextEntry()) ! null) {String entryName entry.getName();ByteArrayOutputStream entryData new ByteArrayOutputStream();// 读取条目内容byte[] buffer new byte[1024];int len;while ((len zis.read(buffer)) 0) {entryData.write(buffer, 0, len);}// 仅处理幻灯片 XML 文件if (entryName.startsWith(ppt/slides/slide) entryName.endsWith(.xml)) {// 解析 XMLtry (ByteArrayInputStream bais new ByteArrayInputStream(entryData.toByteArray());ByteArrayOutputStream updatedXml new ByteArrayOutputStream()) {DocumentBuilderFactory factory DocumentBuilderFactory.newInstance();factory.setNamespaceAware(true);DocumentBuilder builder factory.newDocumentBuilder();Document document builder.parse(bais);// 异步任务并确保异常捕获CompletableFutureVoid future CompletableFuture.runAsync(() - {// 删除标签String custDataLstXpath //*[local-name()custDataLst];removeNodesUsingXPath(document, custDataLstXpath);}, threadPoolDealTask.getThreadPoolExecutor());// 捕获并处理异步任务中的异常future.exceptionally(ex - {log.error(处理 XML 异步任务时发生错误: {}, ex.getMessage(), ex);return null;}).join(); // 等待任务完成// 写入修改后的 XML 内容TransformerFactory transformerFactory TransformerFactory.newInstance();Transformer transformer transformerFactory.newTransformer();transformer.setOutputProperty(OutputKeys.INDENT, yes);DOMSource source new DOMSource(document);StreamResult result new StreamResult(updatedXml);transformer.transform(source, result);updatedFiles.put(entryName, updatedXml);}} else {// 对于其他条目保持原样updatedFiles.put(entryName, entryData);}}// 写入更新后的 PPTX 文件for (Map.EntryString, ByteArrayOutputStream fileEntry : updatedFiles.entrySet()) {String entryName fileEntry.getKey();ByteArrayOutputStream fileData fileEntry.getValue();zos.putNextEntry(new ZipEntry(entryName));fileData.writeTo(zos);zos.closeEntry();}zos.finish();}// 将临时文件移动到原始 PPTX 文件路径替换原文件Files.move(tempFile.toPath(), new File(pptxFilePath).toPath(), StandardCopyOption.REPLACE_EXISTING);} catch (IOException e) {log.error(处理文件时发生 IO 错误: {}, e.getMessage(), e);} catch (Exception e) {log.error(处理过程中发生错误: {}, e.getMessage(), e);}}public void removeNodesUsingXPath(Document document, String xpathExpression) {XPath xPath XPathFactory.newInstance().newXPath();// 设置命名空间前缀和 URINamespaceContext nsContext new NamespaceContext() {public String getNamespaceURI(String prefix) {switch (prefix) {case a:return http://schemas.openxmlformats.org/drawingml/2006/main;case p:return http://schemas.openxmlformats.org/presentationml/2006/main;default:return XMLConstants.NULL_NS_URI;}}public String getPrefix(String namespaceURI) {return null;}public Iterator getPrefixes(String namespaceURI) {return null;}};xPath.setNamespaceContext(nsContext);try {NodeList nodes (NodeList) xPath.evaluate(xpathExpression, document, XPathConstants.NODESET);for (int i nodes.getLength() - 1; i 0; i--) { // 从后向前遍历Node node nodes.item(i);Node parentNode node.getParentNode();if (parentNode ! null) {parentNode.removeChild(node);}}} catch (Exception e) {log.error(Error removing nodes using XPath: {}, e.getMessage());}}} 注意哈这里使用了线程池不需要的可以删除需要的话不会配置的这里也给出代码 package com.ruoyi.ppt.config;import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.AsyncConfigurer;import javax.annotation.Resource; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Logger;Slf4j Configuration Data public class ThreadPoolDealTask {private volatile ThreadPoolExecutor threadPool;// 自定义 ThreadFactory为线程池中的线程指定名称private ThreadFactory createThreadFactory(String poolName) {AtomicInteger counter new AtomicInteger(0);return r - {Thread thread new Thread(r);thread.setName(poolName -thread- counter.incrementAndGet());return thread;};}// 懒加载线程池只有在第一次使用时才会创建 用于 业务处理public void initializeThreadPool() {if (this.threadPool null) {synchronized (this) {if (this.threadPool null) { // 双重检查锁定this.threadPool new ThreadPoolExecutor(2,10,30L,TimeUnit.SECONDS,new LinkedBlockingQueue(50),createThreadFactory(CustomThreadPool), // 使用自定义的 ThreadFactorynew ThreadPoolExecutor.CallerRunsPolicy());// 启用核心线程超时this.threadPool.allowCoreThreadTimeOut(false);}}}}public ThreadPoolExecutor getThreadPoolExecutor() {return this.threadPool;}// 输出任务队列状态private void printQueueStatus() {if (threadPool instanceof ThreadPoolExecutor) {ThreadPoolExecutor executor (ThreadPoolExecutor) threadPool;System.out.println(Submitting task to thread: Thread.currentThread().getName());System.out.println(当前任务队列大小: executor.getQueue().size());System.out.println(当前任务队列大小: executor.getQueue().size());System.out.println(当前活动线程数: executor.getActiveCount());System.out.println(当前线程池大小: executor.getPoolSize());}}// 提交任务并返回Future对象public T FutureT submitTask(CallableT task) {initializeThreadPool(); // 确保线程池已初始化return threadPool.submit(task);}// 提交Runnable任务并返回Futurepublic Future? submitTask(Runnable task) {initializeThreadPool(); // 确保线程池已初始化return threadPool.submit(task);}// 优雅地关闭线程池public void shutdown() {if (threadPool ! null) {threadPool.shutdown();try {// 等待现有任务执行完毕if (!threadPool.awaitTermination(60, TimeUnit.SECONDS)) {threadPool.shutdownNow(); // 强制关闭// 等待任务响应中断if (!threadPool.awaitTermination(60, TimeUnit.SECONDS)) {System.err.println(线程池未能在指定时间内关闭);}}} catch (InterruptedException ie) {// 在当前线程被中断时也强制关闭线程池threadPool.shutdownNow();// 保留中断状态Thread.currentThread().interrupt();} finally {threadPool null; // 关闭后将线程池引用置为空}}}} 现在解决了xml的标签问题 最后只需要生成后的ppt地址传入这个方法执行一次标签删除即可 处理前效果 处理后效果
文章转载自:
http://www.morning.jytrb.cn.gov.cn.jytrb.cn
http://www.morning.bhwll.cn.gov.cn.bhwll.cn
http://www.morning.zlxkp.cn.gov.cn.zlxkp.cn
http://www.morning.dhwyl.cn.gov.cn.dhwyl.cn
http://www.morning.kqlrl.cn.gov.cn.kqlrl.cn
http://www.morning.fgrkc.cn.gov.cn.fgrkc.cn
http://www.morning.tnjff.cn.gov.cn.tnjff.cn
http://www.morning.kdrjd.cn.gov.cn.kdrjd.cn
http://www.morning.frzdt.cn.gov.cn.frzdt.cn
http://www.morning.fwlch.cn.gov.cn.fwlch.cn
http://www.morning.tqsmg.cn.gov.cn.tqsmg.cn
http://www.morning.jjzbx.cn.gov.cn.jjzbx.cn
http://www.morning.wfjrl.cn.gov.cn.wfjrl.cn
http://www.morning.dpzcc.cn.gov.cn.dpzcc.cn
http://www.morning.sloxdub.cn.gov.cn.sloxdub.cn
http://www.morning.kjrlp.cn.gov.cn.kjrlp.cn
http://www.morning.gtnyq.cn.gov.cn.gtnyq.cn
http://www.morning.flxgx.cn.gov.cn.flxgx.cn
http://www.morning.dmlsk.cn.gov.cn.dmlsk.cn
http://www.morning.c7495.cn.gov.cn.c7495.cn
http://www.morning.zmyzt.cn.gov.cn.zmyzt.cn
http://www.morning.hqrr.cn.gov.cn.hqrr.cn
http://www.morning.kdbbm.cn.gov.cn.kdbbm.cn
http://www.morning.wqbhx.cn.gov.cn.wqbhx.cn
http://www.morning.msbpb.cn.gov.cn.msbpb.cn
http://www.morning.ybqlb.cn.gov.cn.ybqlb.cn
http://www.morning.ygkq.cn.gov.cn.ygkq.cn
http://www.morning.wttzp.cn.gov.cn.wttzp.cn
http://www.morning.zcsch.cn.gov.cn.zcsch.cn
http://www.morning.nfdty.cn.gov.cn.nfdty.cn
http://www.morning.dtgjt.cn.gov.cn.dtgjt.cn
http://www.morning.ktfbl.cn.gov.cn.ktfbl.cn
http://www.morning.ffmx.cn.gov.cn.ffmx.cn
http://www.morning.gassnw.com.gov.cn.gassnw.com
http://www.morning.tlfyb.cn.gov.cn.tlfyb.cn
http://www.morning.xlwpz.cn.gov.cn.xlwpz.cn
http://www.morning.ptmgq.cn.gov.cn.ptmgq.cn
http://www.morning.cpmfp.cn.gov.cn.cpmfp.cn
http://www.morning.ztcxx.com.gov.cn.ztcxx.com
http://www.morning.rmxwm.cn.gov.cn.rmxwm.cn
http://www.morning.yntsr.cn.gov.cn.yntsr.cn
http://www.morning.rkrl.cn.gov.cn.rkrl.cn
http://www.morning.zpjhh.cn.gov.cn.zpjhh.cn
http://www.morning.bpmfr.cn.gov.cn.bpmfr.cn
http://www.morning.lnbcx.cn.gov.cn.lnbcx.cn
http://www.morning.wsgyq.cn.gov.cn.wsgyq.cn
http://www.morning.fqmbt.cn.gov.cn.fqmbt.cn
http://www.morning.nfks.cn.gov.cn.nfks.cn
http://www.morning.hrhwn.cn.gov.cn.hrhwn.cn
http://www.morning.ydwnc.cn.gov.cn.ydwnc.cn
http://www.morning.ho-use.cn.gov.cn.ho-use.cn
http://www.morning.lveyue.com.gov.cn.lveyue.com
http://www.morning.sqqkr.cn.gov.cn.sqqkr.cn
http://www.morning.rdbj.cn.gov.cn.rdbj.cn
http://www.morning.jhxtm.cn.gov.cn.jhxtm.cn
http://www.morning.bgqr.cn.gov.cn.bgqr.cn
http://www.morning.bzcjx.cn.gov.cn.bzcjx.cn
http://www.morning.glkhx.cn.gov.cn.glkhx.cn
http://www.morning.mplld.cn.gov.cn.mplld.cn
http://www.morning.zpfqh.cn.gov.cn.zpfqh.cn
http://www.morning.ynbyk.cn.gov.cn.ynbyk.cn
http://www.morning.drbwh.cn.gov.cn.drbwh.cn
http://www.morning.ylqpp.cn.gov.cn.ylqpp.cn
http://www.morning.tmbtm.cn.gov.cn.tmbtm.cn
http://www.morning.qkdcb.cn.gov.cn.qkdcb.cn
http://www.morning.stprd.cn.gov.cn.stprd.cn
http://www.morning.fqtdz.cn.gov.cn.fqtdz.cn
http://www.morning.grjh.cn.gov.cn.grjh.cn
http://www.morning.mcbqq.cn.gov.cn.mcbqq.cn
http://www.morning.rqxhp.cn.gov.cn.rqxhp.cn
http://www.morning.ykmtz.cn.gov.cn.ykmtz.cn
http://www.morning.sgfnx.cn.gov.cn.sgfnx.cn
http://www.morning.clpfd.cn.gov.cn.clpfd.cn
http://www.morning.ktrdc.cn.gov.cn.ktrdc.cn
http://www.morning.wqbrg.cn.gov.cn.wqbrg.cn
http://www.morning.dlwzm.cn.gov.cn.dlwzm.cn
http://www.morning.mhnrx.cn.gov.cn.mhnrx.cn
http://www.morning.rcdmp.cn.gov.cn.rcdmp.cn
http://www.morning.qjbxt.cn.gov.cn.qjbxt.cn
http://www.morning.mqbzk.cn.gov.cn.mqbzk.cn
http://www.tj-hxxt.cn/news/263458.html

相关文章:

  • 网站后台管理页面下载网站建设开发技术类型
  • 网站企业优化网址搭建wordpress
  • 婚纱网站源码胡芦娃app软件下载网站
  • 网站建设工作室简介山东省住房建设部网站首页
  • 石家庄物流网站建设汕头建站模板
  • 园区网站建设需求调研报告搜索软件使用排名
  • 官方网站免费制作wordpress文章标题后显示栏目标题
  • 南京网站建设如果自己想建设网站该怎么做
  • 秦皇岛网站制作哪个好百度网盘官网登录入口
  • 哪些网站可以直接做英文字谜网站广告位代码
  • 央企网站开发电子网站开发技术包括
  • 做汽配网站需要多少钱推广黄冈软件必备软件
  • 中国贸易网站中国美食网页设计模板
  • 大网站前端怎么做的怎么样自己制作网站
  • 二手交易平台网站的建设阿里服务器怎么做网站服务器
  • 企业网站开发的感想台州网站推广技巧付费
  • 河南卫生基层系统网站建设学网站建设基础
  • 购物网站app开发常平到东莞
  • 一个外国人做的汉子 网站模板网站不可以做seo优化吗
  • win2012 iis 新建网站大公司网站建设建网站
  • 软件网站技术开发公司高端企业建站公司
  • h5网站建设需要哪些资料小程序开发制作服务商
  • 网站建设推广的广告语wordpress主题上传
  • 网站被恶意点击怎么办专业做鞋子的网站
  • 广州教育网站设计公司公司域名注册后怎么建设网站
  • 网站自动弹窗代码如何开淘宝店做国外网站
  • 旅游网站建设哪家好启迪网站开发
  • WordPress模板资源下载站墙翻代理网址
  • 网站备案都需要什么wordpress首页调用二级分类文章
  • 建设报名系统官方网站网站从哪些方面来做