admin管理员组

文章数量:1638919

pom文件代码

        <dependency>
            <groupId>com.aspose</groupId>
            <artifactId>aspose-pdf</artifactId>
            <version>21.11.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/resources/lib/aspose.pdf.jar</systemPath>
        </dependency>

java相关代码

	public static void pdfToWord(String pdfFilePath, String wordFilePath) {
		try {
			long old = System.currentTimeMillis();
			getLicensePPT();
			com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(pdfFilePath);
			pdfDocument.save(wordFilePath, com.aspose.pdf.SaveFormat.Doc);
			long now = System.currentTimeMillis();
			System.out.println("Pdf 转 Word 共耗时:" + ((now - old) / 1000.0) + "秒");
			System.out.println("PDF转换为Word成功!");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		String pdfFilePath = "F:\\资料\\1.pdf";
		String wordFilePath = "F:\\资料\\Desktop\\22.docx";
		pdfToWord(pdfFilePath, wordFilePath);
	}

	//去水印
	public static boolean getLicensePPT() {
		boolean result = false;
		InputStream is = null;
		try {
			ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
			org.springframework.core.io.Resource[] resources = resolver.getResources("classpath:license2.xml");
			is = resources[0].getInputStream();
			com.aspose.pdf.License aposeLic = new com.aspose.pdf.License();
			aposeLic.setLicense(is);
			result = true;
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (is != null) {
				try {
					is.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return result;
	}

如果需要相关jar包文件,可以评论后发,比较着急或不了解的可以加vx好友探讨

本文标签: 水印页数AsposePDFword