word文件doc、docx转pdf

2023-11-09

综合类管理系统不管是自研还是外包项目都会被客户或者产品经理要求,实现word导出,excel导出,pdf导出等功能,其实pdf导出呢,有很多种方式,我实现过的就有两种,接下来呢,就说说其中的一种,就是当你已经实现了word导出,或有明确的要求说要用word文件转化为pdf文件的时候,可以看看下来,实现的这种 word文件doc、docx转pdf。

项目中jar包引用情况

 <properties>
        <java.version>1.8</java.version>
        <poi.version>3.17</poi.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>${poi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>${poi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
            <version>${poi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-scratchpad</artifactId>
            <version>${poi.version}</version>
        </dependency>
        <dependency>
            <groupId>fr.opensagres.xdocreport</groupId>
            <artifactId>fr.opensagres.poi.xwpf.converter.pdf-gae</artifactId>
            <version>2.0.1</version>
            <exclusions>
            <exclusion>
                <artifactId>poi-ooxml</artifactId>
                <groupId>org.apache.poi</groupId>
            </exclusion>
        </exclusions>
        </dependency>
        <dependency>
            <groupId>fr.opensagres.xdocreport</groupId>
            <artifactId>org.apache.poi.xwpf.converter.xhtml</artifactId>
            <version>1.0.6</version>
        </dependency>

        <dependency>
            <groupId>fr.opensagres.xdocreport</groupId>
            <artifactId>org.apache.poi.xwpf.converter.core</artifactId>
            <version>1.0.6</version>
            <exclusions>
                <exclusion>
                    <artifactId>poi-ooxml</artifactId>
                    <groupId>org.apache.poi</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.itextpdf</groupId>
            <artifactId>itextpdf</artifactId>
            <version>5.5.13</version>
        </dependency>
        <dependency>
            <groupId>com.itextpdf.tool</groupId>
            <artifactId>xmlworker</artifactId>
            <version>5.5.11</version>
        </dependency>
        <dependency>
            <groupId>com.itextpdf</groupId>
            <artifactId>itext-asian</artifactId>
            <version>5.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.9</version>
        </dependency>
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.13.1</version>
        </dependency>
    </dependencies>

以上就是doc、docx转pdf涉及到的包。

转换工具代码

package com.ttos.utils;

import com.itextpdf.text.BaseColor;
import com.itextpdf.text.FontProvider;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.tool.xml.XMLWorkerHelper;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Font;
import com.lowagie.text.pdf.BaseFont;
import fr.opensagres.poi.xwpf.converter.pdf.PdfConverter;
import fr.opensagres.poi.xwpf.converter.pdf.PdfOptions;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.converter.WordToHtmlConverter;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Entities;
import org.jsoup.select.Elements;
import org.w3c.dom.Document;

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 java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Objects;


public class Word2PdfUtils {

    /**
     * docx2pdf
     *
     * @param wordFilePath wordFilePath
     * @param pdfFilePath  pdfFilePath
     * @throws Exception Exception
     */
    public static void docx2pdf(String wordFilePath, String pdfFilePath) throws Exception {
        if (Objects.isNull(wordFilePath)) {
            log.error("docx的word文件路径不能为空");
            return;
        }
        docx2Pdf(new File(wordFilePath), pdfFilePath);
    }

    /**
     * docx2Pdf
     *
     * @param wordFile    wordFile
     * @param pdfFilePath pdfFilePath
     * @throws Exception Exception
     */
    public static void docx2Pdf(File wordFile, String pdfFilePath) throws Exception {
        if (Objects.isNull(pdfFilePath)) {
            log.error("pdf转化后的pdf目标文件路径不能为空");
            return;
        }
        docx2Pdf(wordFile, new File(pdfFilePath));
    }

    /**
     * doc2Pdf
     *
     * @param docFilePath docFilePath
     * @param pdfFIlePath pdfFIlePath
     * @param imgTmpPath  imgTmpPath
     */
    public static void doc2Pdf(String docFilePath, String pdfFIlePath,String imgTmpPath) throws Exception {
        final String html = word2Html(docFilePath, imgTmpPath);
        final String formatHtml = formatHtml(html);
        html2Pdf(formatHtml, pdfFIlePath);
    }

    /**
     * doc2Pdf
     *
     * @param docFIle    docFIle
     * @param pdfFIlePath    pdfFIlePath
     * @param imgTmpPath imgTmpPath
     * @throws Exception Exception
     */
    public static void doc2Pdf(File docFIle,String pdfFIlePath, String imgTmpPath) throws Exception {
        final String html = word2Html(docFIle, imgTmpPath);
        final String formatHtml = formatHtml(html);
        html2Pdf(formatHtml, pdfFIlePath);
    }

    /**
     * docx2Pdf
     *
     * @param wordFile wordFile
     * @param pdfFile  pdfFile
     * @throws Exception Exception
     */
    public static void docx2Pdf(File wordFile, File pdfFile) throws Exception {
        if (Objects.isNull(wordFile) || !wordFile.exists()) {
            log.error("docx的word文件不存在,请核实");
            return;
        }

        if (Objects.isNull(pdfFile)) {
            log.error("转化后的pdf目标文件不能为空");
            return;
        }
        if (!pdfFile.exists()) {
            log.info("转化后的pdf目标文件不存在,创建pdf目标文件");
            if (!pdfFile.createNewFile()) {
                log.error("转化后的pdf目标文件创建失败");
                return;
            }
        }

        try (final FileInputStream inputStream = new FileInputStream(wordFile);
             final FileOutputStream outputStream = new FileOutputStream(pdfFile)) {
            XWPFDocument xwpfDocument = new XWPFDocument(inputStream);
            PdfOptions pdfOptions = PdfOptions.create();
            pdfOptions.fontProvider((familyName, encoding, size, style, color) -> {
                try {
                    final String path = Objects.requireNonNull(ClassLoader.getSystemClassLoader().getResource("0.ttf")).getFile();
                    final BaseFont bfChn = BaseFont.createFont(path, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
                    final Font fontChn = new Font(bfChn, size, style, color);
                    if (!Objects.isNull(familyName)) {
                        fontChn.setFamily(familyName);
                    }
                    return fontChn;
                } catch (DocumentException | IOException e) {
                    log.error("pdf文件内容样式设置失败");
                    return null;
                }
            });
            PdfConverter.getInstance().convert(xwpfDocument, outputStream, pdfOptions);
        }
    }

    /**
     * word2Html
     *
     * @param wordPath      wordPath
     * @param imageTempPath imageTempPath
     * @return html
     * @throws Exception Exception
     */
    public static String word2Html(String wordPath, String imageTempPath) throws Exception {
        if (Objects.isNull(wordPath)) {
            log.error("doc文件路径: {} ,不能为空", wordPath);
            return null;
        }
        return word2Html(new File(wordPath), imageTempPath);
    }

    /**
     * word2Html
     *
     * @param wordFile   wordFile
     * @param imgTmpPath imgTmpPath
     * @return html
     * @throws Exception Exception
     */
    public static String word2Html(File wordFile, String imgTmpPath) throws Exception {
        if (Objects.isNull(imgTmpPath)) {
            log.error("doc文件内容图片缓存文件路径: {} ,不能为空", imgTmpPath);
            return null;
        }
        return word2Html(wordFile, new File(imgTmpPath));
    }

    /**
     * word2Html
     *
     * @param wordFile   wordFile
     * @param imgTmpPath imgTmpPath
     * @return html
     * @throws Exception Exception
     */
    public static String word2Html(File wordFile, File imgTmpPath) throws Exception {
        if (Objects.isNull(wordFile) || !wordFile.exists()) {
            log.error("doc的word文件不存在,请核实");
            return null;
        }

        if (Objects.isNull(imgTmpPath)) {
            log.error("doc文件内容图片缓存文件路径不能为空");
            return null;
        }
        if (!imgTmpPath.exists()) {
            log.info("doc文件内容图片缓存文件路径不存在,创建目标文件路径");
            if (!imgTmpPath.createNewFile()) {
                log.error("doc文件内容图片缓存文件路径创建失败");
                return null;
            }
        }
        try (final FileInputStream docInputStream = new FileInputStream(wordFile);
             final ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream()) {
            final HWPFDocument hwpfDocument = new HWPFDocument(docInputStream);
            final Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
            final WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(document);
            wordToHtmlConverter.setPicturesManager((bts, pictureType, picName, width, height) -> {
                String tmpPicFilePath = imgTmpPath.getAbsolutePath() + File.separator + picName;
                final File tmpPicFile = new File(tmpPicFilePath);
                try (final FileOutputStream picOutputStream = new FileOutputStream(tmpPicFile)) {
                    picOutputStream.write(bts);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return tmpPicFilePath;
            });
            wordToHtmlConverter.processDocument(hwpfDocument);
            final Document htmlDocument = wordToHtmlConverter.getDocument();
            final DOMSource domSource = new DOMSource(htmlDocument);
            final StreamResult streamResult = new StreamResult(byteArrayStream);
            final Transformer transformer = TransformerFactory.newInstance().newTransformer();
            transformer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.setOutputProperty(OutputKeys.METHOD, "html");
            transformer.transform(domSource, streamResult);
            return byteArrayStream.toString(StandardCharsets.UTF_8.name());
        }
    }

    /**
     * formatHtml 格式化html,补全内容html标签
     *
     * @param html html
     * @return formatHtml
     */
    private static String formatHtml(String html) {
        final org.jsoup.nodes.Document document = Jsoup.parse(html);
        final String style = document.attr("style");
        if (StringUtils.isNotEmpty(style) && style.indexOf("width") > 0) {
            document.attr("style", "");
        }
        final Elements divs = document.select("div");
        for (Element div : divs) {
            final String divStyle = div.attr("style");
            if (StringUtils.isNotEmpty(divStyle) && divStyle.indexOf("width") > 0) {
                div.attr("style", "");
            }
        }

        document.outputSettings().syntax(org.jsoup.nodes.Document.OutputSettings.Syntax.xml);
        document.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
        return document.html();
    }

    /**
     * html2Pdf
     *
     * @param html        html
     * @param pdfFilePath pdfFilePath
     */
    public static void html2Pdf(String html, String pdfFilePath) throws Exception {
        if (Objects.isNull(pdfFilePath)) {
            log.error("转化后的pdf文件路径不能为空");
            return;
        }

        html2Pdf(html, new File(pdfFilePath));
    }

    public static void html2Pdf(String html, File pdfFile) throws Exception {
        if (Objects.isNull(html)) {
            log.error("需转化的html内容不能为空");
            return;
        }
        if (Objects.isNull(pdfFile)) {
            log.error("需转化的pdf文件不能为空");
            return;
        }
        if (!pdfFile.exists()) {
            log.error("需转化的pdf文件 不存在,创建文件");
            if (!pdfFile.createNewFile()) {
                log.error("需转化的pdf文件创建失败");
                return;
            }
        }

        try (final FileOutputStream fileOutputStream = new FileOutputStream(pdfFile);
             final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(html.getBytes())) {
            final com.itextpdf.text.Document document = new com.itextpdf.text.Document(PageSize.A4);
            final PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOutputStream);
            document.open();
            XMLWorkerHelper.getInstance().parseXHtml(pdfWriter, document, byteArrayInputStream, StandardCharsets.UTF_8,
                    new FontProvider() {
                        @Override
                        public boolean isRegistered(String s) {
                            return false;
                        }

                        @Override
                        public com.itextpdf.text.Font getFont(String s, String s1, boolean b, float v, int i, BaseColor baseColor) {
                            try {
                                final com.itextpdf.text.pdf.BaseFont baseFont = com.itextpdf.text.pdf.BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", com.itextpdf.text.pdf.BaseFont.EMBEDDED);
                                final com.itextpdf.text.Font font = new com.itextpdf.text.Font(baseFont, v, i, baseColor);
                                font.setColor(baseColor);
                                return font;
                            } catch (IOException | com.itextpdf.text.DocumentException e) {
                                log.error("pdf内容设置格式出现错误");
                            }
                            return null;
                        }
                    });
            document.close();
        }
    }

    public static void main(String[] args) throws Exception {
        docx2pdf("G:\\00_com\\123.docx", "G:\\00_com\\1234.pdf");
        doc2Pdf("G:\\123.doc", "G:\\1234.pdf","G:\\pic\\");
    }
}

以上功能代码亲测有效,可以拷进项目直接用。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

word文件doc、docx转pdf 的相关文章

  • 如何默认将 Maven 插件附加到阶段?

    我有一个 Maven 插件应该在编译阶段运行 所以在项目中consumes我的插件 我必须做这样的事情
  • 如何在 Play java 中创建数据库线程池并使用该池进行数据库查询

    我目前正在使用 play java 并使用默认线程池进行数据库查询 但了解使用数据库线程池进行数据库查询可以使我的系统更加高效 目前我的代码是 import play libs Akka import scala concurrent Ex
  • Java JDBC:更改表

    我希望对此表进行以下修改 添加 状态列 varchar 20 日期列 时间戳 我不确定该怎么做 String createTable Create table aircraft aircraftNumber int airLineCompa
  • 制作一个交互式Windows服务

    我希望我的 Java 应用程序成为交互式 Windows 服务 用户登录时具有 GUI 的 Windows 服务 我搜索了这个 我发现这样做的方法是有两个程序 第一个是服务 第二个是 GUI 程序并使它们进行通信 服务将从 GUI 程序获取
  • JAXb、Hibernate 和 beans

    目前我正在开发一个使用 Spring Web 服务 hibernate 和 JAXb 的项目 1 我已经使用IDE hibernate代码生成 生成了hibernate bean 2 另外 我已经使用maven编译器生成了jaxb bean
  • 反射找不到对象子类型

    我试图通过使用反射来获取包中的所有类 当我使用具体类的代码 本例中为 A 时 它可以工作并打印子类信息 B 扩展 A 因此它打印 B 信息 但是当我将它与对象类一起使用时 它不起作用 我该如何修复它 这段代码的工作原理 Reflection
  • 路径中 File.separator 和斜杠之间的区别

    使用有什么区别File separator和一个正常的 在 Java 路径字符串中 与双反斜杠相反 平台独立性似乎不是原因 因为两个版本都可以在 Windows 和 Unix 下运行 public class SlashTest Test
  • Mockito when().thenReturn 不必要地调用该方法

    我正在研究继承的代码 我编写了一个应该捕获 NullPointerException 的测试 因为它试图从 null 对象调用方法 Test expected NullPointerException class public void c
  • 无法解析插件 Java Spring

    我正在使用 IntelliJ IDEA 并且我尝试通过 maven 安装依赖项 但它给了我这些错误 Cannot resolve plugin org apache maven plugins maven clean plugin 3 0
  • 斯坦福 NLP - 处理文件列表时 OpenIE 内存不足

    我正在尝试使用斯坦福 CoreNLP 中的 OpenIE 工具从多个文件中提取信息 当多个文件 而不是一个 传递到输入时 它会给出内存不足错误 All files have been queued awaiting termination
  • 十进制到八进制的转换[重复]

    这个问题在这里已经有答案了 可能的重复 十进制转换错误 https stackoverflow com questions 13142977 decimal conversion error 我正在为一个类编写一个程序 并且在计算如何将八进
  • JRE 系统库 [WebSphere v6.1 JRE](未绑定)

    将项目导入 Eclipse 后 我的构建路径中出现以下错误 JRE System Library WebSphere v6 1 JRE unbound 谁知道怎么修它 右键单击项目 特性 gt Java 构建路径 gt 图书馆 gt JRE
  • 如何在 javadoc 中使用“<”和“>”而不进行格式化?

    如果我写
  • 如何在控制器、服务和存储库模式中使用 DTO

    我正在遵循控制器 服务和存储库模式 我只是想知道 DTO 在哪里出现 控制器应该只接收 DTO 吗 我的理解是您不希望外界了解底层域模型 从领域模型到 DTO 的转换应该发生在控制器层还是服务层 在今天使用 Spring MVC 和交互式
  • Eclipse Java 远程调试器通过 VPN 速度极慢

    我有时被迫离开办公室工作 这意味着我需要通过 VPN 进入我的实验室 我注意到在这种情况下使用 Eclipse 进行远程调试速度非常慢 速度慢到调试器需要 5 7 分钟才能连接到远程 jvm 连接后 每次单步执行断点 行可能需要 20 30
  • 在mockito中使用when进行模拟ContextLoader.getCurrentWebApplicationContext()调用。我该怎么做?

    我试图在使用 mockito 时模拟 ContextLoader getCurrentWebApplicationContext 调用 但它无法模拟 here is my source code Mock org springframewo
  • Firebase 添加新节点

    如何将这些节点放入用户节点中 并创建另一个节点来存储帖子 我的数据库参考 databaseReference child user getUid setValue userInformations 您需要使用以下代码 databaseRef
  • 捕获的图像分辨率太大

    我在做什么 我允许用户捕获图像 将其存储到 SD 卡中并上传到服务器 但捕获图像的分辨率为宽度 4608 像素和高度 2592 像素 现在我想要什么 如何在不影响质量的情况下获得小分辨率图像 例如我可以获取或设置捕获的图像分辨率为原始图像分
  • 将 List 转换为 JSON

    Hi guys 有人可以帮助我 如何将我的 HQL 查询结果转换为带有对象列表的 JSON 并通过休息服务获取它 这是我的服务方法 它返回查询结果列表 Override public List
  • 节拍匹配算法

    我最近开始尝试创建一个移动应用程序 iOS Android 它将自动击败比赛 http en wikipedia org wiki Beatmatching http en wikipedia org wiki Beatmatching 两

随机推荐

  • [Leetcode] 76. 最小覆盖子串

    给你一个字符串 s 一个字符串 t 返回 s 中涵盖 t 所有字符的最小子串 如果 s 中不存在涵盖 t 所有字符的子串 则返回空字符串 注意 对于 t 中重复字符 我们寻找的子字符串中该字符数量必须不少于 t 中该字符数量 如果 s 中存
  • 算法(公式法):判断是否完全平方数

    给定一个正整数 num 编写一个函数 如果 num 是一个完全平方数 则返回 True 否则返回 False 说明 不要使用任何内置的库函数 如 sqrt 示例 1 输入 16 输出 True 示例 2 输入 14 输出 False 利用公
  • Qt常用的快捷键

    alt enter 自动创建类定义的实现 F1 查看帮助 文档 F2 快速到变量声明 Shift F2 函数的声明和定义之间快速切换 F4 在 cpp 和 h 文件切换 Ctrl M 创建书签 Ctrl 切换书签 Alt M打开书签栏 Ct
  • SVN学习2020.8.9

    SVN账号密码一般是有一个配置管理员给配置的 文件夹绿色标志 代表和服务器文档是一致的 同步更新的 同步更新服务器信息 update 执行操作都先update 再做其他 先保证本地和服务器一致 先更新 上锁 再修改 再提交 解锁 如何把本地
  • 供应链金融与区块链01——论文阅读

    本文章仅用于记录本人学习过程 当作笔记来用 如有侵权请及时告知 谢谢 1 基于区块链技术的供应链金融体系优化研究 龙云安 但是由于 互联网 供应链 无法 及时跟进资金流和信息流 导致核心企业 供应链金 融平台和提供融资的商业银行无法及时掌控
  • 解决前端跨域的问题.Access to XMLHttpRequest at http://xxx.xxx from origin 'http://localhost:8000' has been bl

    1 前端浏览器报错如下 Access to XMLHttpRequest at http xxx xxx from origin http localhost 8000 has been blocked by CORS policy Res
  • Scratch 3.0源码 之 多语言实现

    文章目录 实现方式 初始版本 多语言版本 1 页面文件 2 配置文件 3 建立关联 语法说明 案例1 带HTML标签写法 建议写法 案例2 带超链接写法 建议写法 Scratch 3 0中各类显示文本默认是英文 如果不支持自己的语言 或者自
  • 红队隧道应用篇之Neo-reGeorg实现内网穿透(四)

    简介 reGeorg是一个能够实现内网穿透的工具 基于socks5协议 且能支持众多脚本 由于此工具使用率过高 导致容易被杀毒软件拦截 现有一个项目是由reGeorg修改而来 而且做了加密和免杀处理 这款工具的名字就叫Neo reGeorg
  • sqlServer 自定义函数-传入参数并返回动态表

    自定义函数 传入参数并返回动态表 create FUNCTION dbo v usrlist usr varchar 20 传入当前用户代码 返回动态表 表里面包含编码及名称两个字段 RETURNS tolist TABLE usrcode
  • 一般面试时会遇到的九大难题的对策解析

    终于接到面试通知书了 欣喜之余开始考虑即将面对的种种问题 所谓有备无患 您是否尝试过面试彩排 建议您现在就不妨试上一试 我想这会帮助你对其他问题的回答做准备 好啦面试开始 想象着考官已经坐在您的面前 问题1 为什么不谈谈你自己 分析 这是个
  • 渲染函数render

    文章目录 节点 树以及虚拟 DOM 树 节点 虚拟 DOM vue中render函数的作用 render函数去创建子组件内容 createElement官方文档 参考 节点 树以及虚拟 DOM 在深入渲染函数之前 了解一些浏览器的工作原理是
  • 2016去哪儿编程题:5-血型遗传检测

    题目描述 血型遗传对照表如下 父母血型 子女会出现的血型 子女不会出现的血型 O与O O A B AB A与O A O B AB A与A A O B AB A与B A B AB O A与AB A B AB O B与O B O A AB B与
  • shell 数组(字符串下标)

    现在游戏开的服务器越来越多了 每次用ssh操作都要写ip地址 很烦 也容易出错 所以要自己搞个服务器名到ip的映射 map anahost count 0 temp cat home linwencai sh HOST while read
  • ubuntu18.04合并pdf文件

    以前使用pdftk比较常见 但是pdftk的更新似乎没有跟上 改用pdfunite轻松解决 pdftk原来使用apt安装 现在改成用snap安装pdftk sudo snap install pdftk pdftk合并命令为 pdftk p
  • 洛谷 P1200 [USACO1.1]你的飞碟在这儿Your Ride Is Here

    题目链接 https www luogu com cn problem P1200 include
  • C++函数基础

    一 函数的定义和使用 1 函数的定义 类型说明符 函数名 含类型说明的形参表 语句序列 如 int GetSum int a int b return a b 2 形式参数 形式参数的作用是实现主函数与被调函数之间的联系 3 函数的返回值和
  • 【ubuntu】ubuntu实体机与windows互传文件(两台电脑)

    先记录一些命令 dpkg list 查看软件列表 sudo apt get purge remove 包名 purge是可选项 写上这个属性是将软件及其配置文件一并删除 如不需要删除配置文件 可执行sudo apt get remove 包
  • Python列表操作中extend和append的区别

    1 用法 append 用于在列表末尾添加新的对象 输入参数为对象 extend 用于在列表末尾追加另一个序列中的多个值 输入对象为元素队列 2 相同点 两个都是对列表即list进行的操作 具体句法可以写为 list1 append obj
  • 解决EXPLORER应用程序错误,桌面出不来

    打开运行 输入CMD 输入for 1 in windir system32 dll do regsvr32 exe s 1 意思是注册所有DLL组件 一般都能解决问题 转载于 https blog 51cto com feifei888 4
  • word文件doc、docx转pdf

    综合类管理系统不管是自研还是外包项目都会被客户或者产品经理要求 实现word导出 excel导出 pdf导出等功能 其实pdf导出呢 有很多种方式 我实现过的就有两种 接下来呢 就说说其中的一种 就是当你已经实现了word导出 或有明确的要