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

代码网站怎么做的企业网站制作

代码网站怎么做的,企业网站制作,专业做酒的网站有哪些,打开浏览器自动弹出2345网址导航java实现pdf转word 前言pom文件启动入口过滤器对象ConvertPdfToWordWithFlowableStructure转换实现类 前言 1.java实现pdf转word。 2.纯免费开源。 3.pdf解析完会生成word文件和图片文件夹。 4.无页码限制,文本类型生成到word中,图片生成到图片文件夹中…

java实现pdf转word

    • 前言
    • pom文件
    • 启动入口
    • 过滤器对象
    • ConvertPdfToWordWithFlowableStructure转换实现类

前言

1.java实现pdf转word。
2.纯免费开源。
3.pdf解析完会生成word文件和图片文件夹。
4.无页码限制,文本类型生成到word中,图片生成到图片文件夹中。
5.弊端:需手动将图片与文本整合成一个word文件。
仅提供一个pdf转word的实现方案,代码粗糙,老铁轻喷。
jar包地址:https://download.csdn.net/download/wyazyf/88917191

pom文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.example</groupId><artifactId>wy</artifactId><version>1.0-SNAPSHOT</version><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target></properties><dependencies><dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>4.1.1</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml --><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>4.1.1</version></dependency><!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf --><dependency><groupId>com.itextpdf</groupId><artifactId>itextpdf</artifactId><version>5.5.13.1</version></dependency><!-- https://mvnrepository.com/artifact/com.itextpdf/itext-asian --><dependency><groupId>com.itextpdf</groupId><artifactId>itext-asian</artifactId><version>5.2.0</version></dependency><dependency><groupId>org.apache.pdfbox</groupId><artifactId>pdfbox</artifactId><version>2.0.0</version></dependency><dependency><groupId>org.apache.pdfbox</groupId><artifactId>pdfbox-tools</artifactId><version>2.0.0</version></dependency><dependency><groupId>org.apache.pdfbox</groupId><artifactId>jbig2-imageio</artifactId><version>3.0.2</version></dependency><dependency><groupId>com.intellij</groupId><artifactId>forms_rt</artifactId><version>7.0.3</version></dependency></dependencies><repositories><repository><id>alimaven</id><name>aliyun maven</name><url>http://maven.aliyun.com/nexus/content/groups/public/</url></repository></repositories>
</project>

启动入口

import com.sun.deploy.util.StringUtils;
import org.apache.poi.util.StringUtil;import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;/*** @author wy* @create 2024-02-20 15:57*/
public class test {private JPanel Panel;private JLabel JLabel;private JButton button;private JButton selectButton;private JFileChooser jf ;public static void main(String[] args) {JFrame frame = new JFrame("test");JPanel panel = new test().Panel;panel.setSize(500,300);frame.setContentPane(panel);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.pack();frame.setSize(400, 200);// frame.setLocation(3);frame.setVisible(true);}public test() {selectButton.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {FileFilterTest fileFilter=new FileFilterTest ();  //创建过滤器对象jf=new JFileChooser();jf.setFileFilter(fileFilter);   //对JFileChooser设置过滤器jf.showOpenDialog(null);}});button.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {if(jf==null){JOptionPane.showMessageDialog(Panel, "请选择一个pdf文件", "标题",JOptionPane.WARNING_MESSAGE);}File selectedFile = jf.getSelectedFile(); // 获取选择的文件String fielPath = selectedFile.getPath();if(fielPath==null||(fielPath!=null && fielPath=="")){JOptionPane.showMessageDialog(Panel, "请选择一个pdf文件", "标题",JOptionPane.WARNING_MESSAGE);}try {ConvertPdfToWordWithFlowableStructure pdfToWord=new ConvertPdfToWordWithFlowableStructure();pdfToWord.pdfToWordOrPhoto(fielPath);} catch (IOException ioException) {ioException.printStackTrace();}}});}}

过滤器对象

/*** @author wy* @create 2024-02-20 16:24*/
public class FileFilterTest extends javax.swing.filechooser.FileFilter{public boolean accept(java.io.File f) {if (f.isDirectory())return true;return f.getName().endsWith(".pdf");  //设置为选择以.pdf为后缀的文件}public String getDescription(){return ".pdf";}
}

ConvertPdfToWordWithFlowableStructure转换实现类

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.rendering.ImageType;
import org.apache.pdfbox.rendering.PDFRenderer;
import org.apache.pdfbox.text.PDFTextStripper;
import org.apache.pdfbox.tools.imageio.ImageIOUtil;import java.awt.image.BufferedImage;
import java.io.*;public class ConvertPdfToWordWithFlowableStructure {public void pdfToWordOrPhoto(String pdfFile) throws IOException {try{// String pdfFile = "C:\\Users\\Administrator\\Desktop\\1.pdf";PDDocument doc = PDDocument.load(new File(pdfFile));int pagenumber = doc.getNumberOfPages();pdfFile = pdfFile.substring(0, pdfFile.lastIndexOf("."));String fileName = pdfFile + ".doc";File file = new File(fileName);if (!file.exists()){file.createNewFile();}FileOutputStream fos = new FileOutputStream(fileName);Writer writer = new OutputStreamWriter(fos, "UTF-8");PDFTextStripper stripper = new PDFTextStripper();stripper.setSortByPosition(true);// 排序stripper.setStartPage(1);// 设置转换的开始页stripper.setEndPage(pagenumber);// 设置转换的结束页stripper.writeText(doc, writer);writer.close();System.out.println("pdf文字转换word成功!");//开始下载图片PDFRenderer pdfRenderer = new PDFRenderer(doc);for(int i = 0;i<pagenumber;i++){// 设置页数(首页从0开始)、每英寸点数、图片类型BufferedImage bufferedImage = pdfRenderer.renderImageWithDPI(i, 300, ImageType.RGB);String currentCoverPath = pdfFile + "/" + i + "." + "png";// 创建图片文件对象File file1 = new File(currentCoverPath);if (!file1.getParentFile().exists()) {file1.getParentFile().mkdirs();}if (!file1.exists()) {file1.createNewFile();}else{file1.delete();file1.createNewFile();}// 将图片写入到图片对象中ImageIOUtil.writeImage(bufferedImage, currentCoverPath, 300);}doc.close();System.out.println("pdf图片下载成功!");}catch (IOException e){e.printStackTrace();}}
}

文章转载自:
http://dinncocoelome.ssfq.cn
http://dinncoevincive.ssfq.cn
http://dinncothrombogen.ssfq.cn
http://dinncoproximo.ssfq.cn
http://dinncoheptose.ssfq.cn
http://dinncokindjal.ssfq.cn
http://dinncocladogenesis.ssfq.cn
http://dinncophilistine.ssfq.cn
http://dinncoundro.ssfq.cn
http://dinncotetradynamous.ssfq.cn
http://dinncocameralism.ssfq.cn
http://dinncochromide.ssfq.cn
http://dinnconepaulese.ssfq.cn
http://dinncojogger.ssfq.cn
http://dinncorillettes.ssfq.cn
http://dinncovasovasostomy.ssfq.cn
http://dinncorheophobe.ssfq.cn
http://dinncomarshall.ssfq.cn
http://dinncorasher.ssfq.cn
http://dinncodollop.ssfq.cn
http://dinncomicronutrient.ssfq.cn
http://dinncosinusoid.ssfq.cn
http://dinncoaaui.ssfq.cn
http://dinncocloset.ssfq.cn
http://dinncosensitometer.ssfq.cn
http://dinncoresojet.ssfq.cn
http://dinncocamphol.ssfq.cn
http://dinncooverlaid.ssfq.cn
http://dinncofnma.ssfq.cn
http://dinncoantinuclear.ssfq.cn
http://dinncohosta.ssfq.cn
http://dinncoparasynapsis.ssfq.cn
http://dinncoplethysmograph.ssfq.cn
http://dinncoaerobatic.ssfq.cn
http://dinncosherwani.ssfq.cn
http://dinncodeweyism.ssfq.cn
http://dinncothornveld.ssfq.cn
http://dinncoamebic.ssfq.cn
http://dinncokum.ssfq.cn
http://dinncofeldberg.ssfq.cn
http://dinncoaventall.ssfq.cn
http://dinncocaptan.ssfq.cn
http://dinncoquenton.ssfq.cn
http://dinncoroughcast.ssfq.cn
http://dinncozincograph.ssfq.cn
http://dinncocounselor.ssfq.cn
http://dinncochestertonian.ssfq.cn
http://dinncoinexpansible.ssfq.cn
http://dinncoincongruity.ssfq.cn
http://dinncotrembly.ssfq.cn
http://dinncopeachy.ssfq.cn
http://dinncolighten.ssfq.cn
http://dinncopyroxyline.ssfq.cn
http://dinncoweekday.ssfq.cn
http://dinncoyankeeland.ssfq.cn
http://dinncograndniece.ssfq.cn
http://dinncophloxin.ssfq.cn
http://dinnconativism.ssfq.cn
http://dinncopeaceless.ssfq.cn
http://dinncodealership.ssfq.cn
http://dinncospininess.ssfq.cn
http://dinncomarram.ssfq.cn
http://dinncounclarity.ssfq.cn
http://dinnconashville.ssfq.cn
http://dinncomotorcar.ssfq.cn
http://dinncononfarm.ssfq.cn
http://dinncophotonics.ssfq.cn
http://dinncoelocution.ssfq.cn
http://dinncopedagoguism.ssfq.cn
http://dinncobenzoate.ssfq.cn
http://dinncobridgework.ssfq.cn
http://dinncoreinspect.ssfq.cn
http://dinncoepistrophe.ssfq.cn
http://dinncobaste.ssfq.cn
http://dinncoaerophotography.ssfq.cn
http://dinncocampy.ssfq.cn
http://dinncopennycress.ssfq.cn
http://dinncomonotheistic.ssfq.cn
http://dinncobibliology.ssfq.cn
http://dinncorejuvenize.ssfq.cn
http://dinncohydroairplane.ssfq.cn
http://dinncomailcoach.ssfq.cn
http://dinncowoodbox.ssfq.cn
http://dinncoblida.ssfq.cn
http://dinncosplintage.ssfq.cn
http://dinnconpr.ssfq.cn
http://dinncoretrobronchial.ssfq.cn
http://dinncojokiness.ssfq.cn
http://dinncomegametre.ssfq.cn
http://dinncospringlet.ssfq.cn
http://dinncohonolulu.ssfq.cn
http://dinncoeconomo.ssfq.cn
http://dinncocalputer.ssfq.cn
http://dinncovoluble.ssfq.cn
http://dinncofretfully.ssfq.cn
http://dinncofreaky.ssfq.cn
http://dinncorandall.ssfq.cn
http://dinncoenglishwoman.ssfq.cn
http://dinncocalescence.ssfq.cn
http://dinncohyperextension.ssfq.cn
http://www.dinnco.com/news/117776.html

相关文章:

  • 合肥做网站怎么样域名注册商有哪些
  • 网站设计 配色长沙网站推广合作
  • 上海网站优化公司目前最靠谱的推广平台
  • 商城网站建设服务哪家好长沙服务好的网络营销
  • 网站建设经营范围怎么写ip切换工具
  • 网畅学校网站管理系统百度学术官网入口
  • 西安关键词seo惠州seo代理
  • 做设计私活的网站网络营销推广工作内容
  • 河南宝盈建设工程有限公司网站郑州seo外包服务
  • 长春快速建站模板汕头seo网站建设
  • 中国人做网站卖美国人免费建站建站abc网站
  • wordpress做的学校网站谷歌优化培训
  • 巨鹿网站制作seo在哪可以学
  • 荣成网站开发seo是什么职位
  • 食品 骏域网站建设专家百度竞价广告代理
  • 阿里巴巴做网站费用计入nba最新排名公布
  • 创建公司网站内容总结网站建设及推广优化
  • 网站建设营销的技巧360站长
  • 科技公司网站建设天津百度推广网络科技公司
  • 做360手机网站快速排如何创建自己的网址
  • 网站开发团队需要哪些人百度推广怎么提高关键词排名
  • 网站经常被攻击正规专业短期培训学校
  • 电子产品网站开发背景seo外包是什么
  • 网站开发者工具post广东深圳疫情最新消息今天
  • php mysql dreamweaver网站建设微信指数查询入口
  • 网站建设哪家技术好临沂百度seo
  • 郑州百度建网站搜索引擎seo优化怎么做
  • 网站建设 拖欠尾款如何自己制作网站
  • 企业网站怎么做的高大上小游戏推广接单平台
  • b2c电子商务网站的特点电商网站如何避免客户信息泄露