亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Java實(shí)現(xiàn)PDF轉(zhuǎn)Word的示例代碼(無水印無頁數(shù)限制)

 更新時(shí)間:2022年06月08日 16:31:55   作者:洛陽泰山  
這篇文章主要為大家詳細(xì)介紹了如何利用Java語言實(shí)現(xiàn)PDF轉(zhuǎn)Word文件的效果,并可以無水印、無頁數(shù)限制。文中的示例代碼講解詳細(xì),需要的可以參考一下

一、前言

學(xué)習(xí)概述:簡單的介紹一下本篇文章要講解的Java知識點(diǎn)

學(xué)習(xí)目標(biāo):讀者讀完這篇文章之后,你希望他掌握你講解的哪些重要的知識點(diǎn)

二、jar破解

1.項(xiàng)目遠(yuǎn)程倉庫配置

aspose-pdf 這個(gè)需要配置單獨(dú)的倉庫地址才能下載,不會配置的可以去官網(wǎng)直接下載jar引入項(xiàng)目代碼中。

<repositories>
        <repository>
            <id>AsposeJavaAPI</id>
            <name>Aspose Java API</name>
            <url>https://repository.aspose.com/repo/</url>
        </repository>
    </repositories>

2.pom文件引入相關(guān)依賴

    <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.20.0-GA</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.aspose/aspose-pdf -->
        <dependency>
            <groupId>com.aspose</groupId>
            <artifactId>aspose-pdf</artifactId>
            <version>21.8</version>
        </dependency>

Javassist是一個(gè)開源的分析、編輯和創(chuàng)建Java字節(jié)碼的類庫。

aspose-pdf是一個(gè)處理pdf的java類庫。

3.破解代碼

 
 
import javassist.*;
 
import java.io.*;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
 
/**
 * @date 2022-05-16
 * @user tarzan
 */
public class PDFJarCrack {
 
 
    public static void main(String[] args) throws Exception {
        String jarPath = "E:\\maven_repository\\com\\aspose\\aspose-pdf\\21.8\\aspose-pdf-21.8.jar";
        crack(jarPath);
    }
 
 
    private static void crack(String jarName) {
        try {
            ClassPool.getDefault().insertClassPath(jarName);
            CtClass ctClass = ClassPool.getDefault().getCtClass("com.aspose.pdf.ADocument");
            CtMethod[] declaredMethods = ctClass.getDeclaredMethods();
            int num = 0;
            for (int i = 0; i < declaredMethods.length; i++) {
                if (num == 2) {
                    break;
                }
                CtMethod method = declaredMethods[i];
                CtClass[] ps = method.getParameterTypes();
                if (ps.length == 2
                        && method.getName().equals("lI")
                        && ps[0].getName().equals("com.aspose.pdf.ADocument")
                        && ps[1].getName().equals("int")) {
                    // 最多只能轉(zhuǎn)換4頁 處理
                    System.out.println(method.getReturnType());
                    System.out.println(ps[1].getName());
                    method.setBody("{return false;}");
                    num = 1;
                }
                if (ps.length == 0 && method.getName().equals("lt")) {
                    // 水印處理
                    method.setBody("{return true;}");
                    num = 2;
                }
            }
            File file=new File(jarName);
            ctClass.writeFile(file.getParent());
            disposeJar(jarName, file.getParent()+"/com/aspose/pdf/ADocument.class");
            } catch(NotFoundException e){
                e.printStackTrace();
            } catch(CannotCompileException e){
                e.printStackTrace();
            } catch (IOException e) {
            e.printStackTrace();
            }
 
    }
 
    private static void disposeJar(String jarName, String replaceFile) {
        List<String> deletes = new ArrayList<>();
        deletes.add("META-INF/37E3C32D.SF");
        deletes.add("META-INF/37E3C32D.RSA");
        File oriFile = new File(jarName);
       if (!oriFile.exists()) {
            System.out.println("######Not Find File:" + jarName);
            return;
        }
        //將文件名命名成備份文件
        String bakJarName = jarName.substring(0, jarName.length() - 3) + "cracked.jar";
     //   File bakFile=new File(bakJarName);
        try {
        //創(chuàng)建文件(根據(jù)備份文件并刪除部分)
        JarFile jarFile = new JarFile(jarName);
        JarOutputStream jos = new JarOutputStream(new FileOutputStream(bakJarName));
        Enumeration entries = jarFile.entries();
        while (entries.hasMoreElements()) {
            JarEntry entry = (JarEntry) entries.nextElement();
            if (!deletes.contains(entry.getName())) {
                if(entry.getName().equals("com/aspose/pdf/ADocument.class")){
                    System.out.println("Replace:-------" +entry.getName());
                    JarEntry jarEntry = new JarEntry(entry.getName());
                    jos.putNextEntry(jarEntry);
                    FileInputStream  fin = new FileInputStream(replaceFile);
                    byte[] bytes = readStream(fin);
                    jos.write(bytes, 0, bytes.length);
                }else {
                    jos.putNextEntry(entry);
                    byte[] bytes = readStream(jarFile.getInputStream(entry));
                    jos.write(bytes, 0, bytes.length);
                }
            } else {
                System.out.println("Delete:-------" + entry.getName());
            }
         }
            jos.flush();
            jos.close();
            jarFile.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    private static byte[] readStream(InputStream inStream) throws Exception {
        ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int len = -1;
        while ((len = inStream.read(buffer)) != -1) {
            outSteam.write(buffer, 0, len);
        }
        outSteam.close();
        inStream.close();
        return outSteam.toByteArray();
    }

修改你本機(jī)的aspose-pdf-21.8.jar路徑,然后運(yùn)行主方法,破解成功后,會再同級文件夾下生成一個(gè)aspose-pdf-21.8.cracked.jar包,用這個(gè)包替換原來的aspose-pdf-21.8.jar包即可。

控制臺輸出

三、pdf轉(zhuǎn)word

代碼實(shí)現(xiàn)

 
import com.aspose.pdf.Document;
import com.aspose.pdf.SaveFormat;
 
import java.io.*;
 
public class PDFHelper3 {
 
    public static void main(String[] args) throws IOException {
        pdf2doc("C:\\Users\\liuya\\Desktop\\pdf\\中信重工鑄鍛公司數(shù)字化工廠技術(shù)要求.pdf");
    }
 
 
    //pdf轉(zhuǎn)doc
    public static void pdf2doc(String pdfPath) {
        long old = System.currentTimeMillis();
        try {
            //新建一個(gè)word文檔
            String wordPath=pdfPath.substring(0,pdfPath.lastIndexOf("."))+".docx";
            FileOutputStream os = new FileOutputStream(wordPath);
            //doc是將要被轉(zhuǎn)化的word文檔
            Document doc = new Document(pdfPath);
            //全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF 相互轉(zhuǎn)換
            doc.save(os, SaveFormat.DocX);
            os.close();
            //轉(zhuǎn)化用時(shí)
            long now = System.currentTimeMillis();
            System.out.println("Pdf 轉(zhuǎn) Word 共耗時(shí):" + ((now - old) / 1000.0) + "秒");
        } catch (Exception e) {
            System.out.println("Pdf 轉(zhuǎn) Word 失敗...");
            e.printStackTrace();
        }
    }
 
 
}

修改自己的pdf文件路徑,運(yùn)行主方法即可,完成無水印,無頁數(shù)限制轉(zhuǎn)換word文件

控制臺輸出

到此這篇關(guān)于Java實(shí)現(xiàn)PDF轉(zhuǎn)Word的示例代碼(無水印無頁數(shù)限制)的文章就介紹到這了,更多相關(guān)Java PDF轉(zhuǎn)Word內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • hashset去除重復(fù)值原理實(shí)例解析

    hashset去除重復(fù)值原理實(shí)例解析

    這篇文章主要介紹了hashset去除重復(fù)值原理實(shí)例解析,具有一定借鑒價(jià)值,需要的朋友可以參考下。
    2017-12-12
  • Thread線程的基礎(chǔ)知識及常見疑惑點(diǎn)總結(jié)

    Thread線程的基礎(chǔ)知識及常見疑惑點(diǎn)總結(jié)

    在本篇內(nèi)容里小編給大家分享的是關(guān)于Thread線程的基礎(chǔ)知識及常見疑惑點(diǎn),對此有學(xué)習(xí)需求的朋友們可以學(xué)習(xí)參考下。
    2019-05-05
  • Java基于Spire Cloud Excel把Excel轉(zhuǎn)換成PDF

    Java基于Spire Cloud Excel把Excel轉(zhuǎn)換成PDF

    這篇文章主要介紹了Java基于Spire Cloud Excel把Excel轉(zhuǎn)換成PDF,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-05-05
  • Java獲取漢字拼音的全拼和首拼實(shí)現(xiàn)代碼分享

    Java獲取漢字拼音的全拼和首拼實(shí)現(xiàn)代碼分享

    這篇文章主要介紹了Java獲取漢字拼音的全拼和首拼實(shí)現(xiàn)代碼分享,本文直接給出實(shí)現(xiàn)代碼,需要的朋友可以參考下
    2015-06-06
  • OpenFeign實(shí)現(xiàn)攜帶請求頭方案詳細(xì)介紹

    OpenFeign實(shí)現(xiàn)攜帶請求頭方案詳細(xì)介紹

    這篇文章主要介紹了OpenFeign實(shí)現(xiàn)攜帶請求頭方案,在通過???OpenFeign???進(jìn)行服務(wù)調(diào)用的過程中,我們需要將用戶的??user-token???、??lang??等信息放入請求header中。在分布式系統(tǒng)中,往往一個(gè)業(yè)務(wù)接口內(nèi)部會發(fā)生多次RPC調(diào)用
    2022-11-11
  • JAVA中簡單的for循環(huán)異常踩坑

    JAVA中簡單的for循環(huán)異常踩坑

    這篇文章主要為大家介紹了JAVA中簡單的for循環(huán)異常踩坑避雷詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • Windows下將JAVA?jar注冊成windows服務(wù)的方法

    Windows下將JAVA?jar注冊成windows服務(wù)的方法

    這篇文章主要介紹了Windows下將JAVA?jar注冊成windows服務(wù)的方法,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-07-07
  • Java Map.Entry的使用方法解析

    Java Map.Entry的使用方法解析

    這篇文章主要介紹了Java Map.Entry的使用方法解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-03-03
  • JDK9對String字符串的新一輪優(yōu)化

    JDK9對String字符串的新一輪優(yōu)化

    這篇文章主要介紹了JDK9對String字符串的新一輪優(yōu)化,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-03-03
  • Java泛型和Class類用法示例

    Java泛型和Class類用法示例

    這篇文章主要介紹了Java泛型和Class類用法,結(jié)合實(shí)例形式分析了java使用泛型限制class類避免強(qiáng)制類型轉(zhuǎn)換相關(guān)操作技巧,需要的朋友可以參考下
    2019-07-07

最新評論