WordToPDF2.java

用Java将Word转PDF

本例子测试了spire.doc.free-3.9.0.jar的包

		
			 e-iceblue 
			spire.doc.free
			3.9.0
		

package word;

import com.spire.doc.Document;
import com.spire.doc.FileFormat;

/**
 * spire.doc-3.4.3.jar
 * Java-itext-5.0.4.jar




    e-iceblue
    spire.doc
    5.4.10





    com.lowagie
    itext
    4.2.0



 * 
 *
 * @author ZengWenFeng
 * @date 2023.08.15
 */
public class WordToPDF2
{
	public static void test3()
	{
		//实例化Document类的对象
		Document doc = new Document();

		//加载Word
		doc.loadFromFile("d:\\ChatGPT.docx");

		//保存为PDF格式
		doc.saveToFile("d:\\ChatGPT_temp.pdf", FileFormat.PDF);

		
		//Evaluation Warning: The document was created with Spire.Doc for JAVA.
		
		/*
		
			 e-iceblue 
			spire.doc.free
			2.6.3
		
		
		
			 e-iceblue 
			spire.doc.free
			3.9.0
		
		
		
			 e-iceblue 
			spire.doc.free
			4.3.0
		
		
		
			 e-iceblue 
			spire.doc.free
			4.4.1
		

		
			 e-iceblue 
			spire.doc.free
			5.1.0
		
		 */
	}
	
	public static void main(String[] args)
	{
		long time1 = System.currentTimeMillis();
		
		test3();
		
		//
		long time2 = System.currentTimeMillis();
		
		//
		System.out.println("Word to PDF completed!time : " + (time2 - time1));
	}
}

遇到问题,1)正式包下载不下载,2)正式包有水印,3)文档格式错误

分别处理:

spire.doc.jar_spencer_tseng的博客-CSDN博客

Evaluation Warning: The document was created with Spire.Doc for JAVA._spencer_tseng的博客-CSDN博客

org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type pa_spencer_tseng的博客-CSDN博客

linux 

yum install libgcc -y
yum install libgcc_s.so.1

你可能感兴趣的:(java,java)