91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 8.17MB
    文件類(lèi)型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2023-10-10
  • 語(yǔ)言: Java
  • 標(biāo)簽: word??pdf??java??linux??jacob??

資源簡(jiǎn)介

因使用java語(yǔ)言實(shí)現(xiàn)將word轉(zhuǎn)pdf功能,在windows和linux上的實(shí)現(xiàn)是不一樣的。本代碼案例分別介紹了在linux和windows上如何使用java語(yǔ)言實(shí)現(xiàn)word轉(zhuǎn)pdf,特別實(shí)用,解決了在轉(zhuǎn)換過(guò)程中元素缺少(下劃線轉(zhuǎn)化成pdf后消失)的問(wèn)題。

資源截圖

代碼片段和文件信息

package?TestProject.com.edu.ouc;

import?java.io.File;

import?com.jacob.activeX.ActiveXComponent;
import?com.jacob.com.Dispatch;

public?class?Word2Pdf?{
public?static?void?main(String?args[])?{
????????ActiveXComponent?app?=?null;
????????String?wordFile?=?“e:/檢驗(yàn)報(bào)告.docx“;
???????String?pdfFile?=?“e:/個(gè)人成長(zhǎng)規(guī)劃報(bào)告.pdf“;
???????System.out.println(“開(kāi)始轉(zhuǎn)換...“);
???????//System.out.println(System.getProperty(“java.library.path“));
???????//?開(kāi)始時(shí)間
???????long?start?=?System.currentTimeMillis();??
???????try?{
????????//?打開(kāi)word
????????app?=?new?ActiveXComponent(“Word.Application“);
????????//?設(shè)置word不可見(jiàn)很多博客下面這里都寫(xiě)了這一句話(huà),其實(shí)是沒(méi)有必要的,因?yàn)槟J(rèn)就是不可見(jiàn)的,如果設(shè)置可見(jiàn)就是會(huì)打開(kāi)一個(gè)word文檔,對(duì)于轉(zhuǎn)化為pdf明顯是沒(méi)有必要的
????????//app.setProperty(“Visible“?false);
????????//?獲得word中所有打開(kāi)的文檔
????????Dispatch?documents?=?app.getProperty(“Documents“).toDispatch();
????????System.out.println(“打開(kāi)文件:?“?+?wordFile);
????????//?打開(kāi)文檔
????????Dispatch?document?=?Dispatch.call(documents?“Open“?wordFile?false?true).toDispatch();
????????//?如果文件存在的話(huà),不會(huì)覆蓋,會(huì)直接報(bào)錯(cuò),所以我們需要判斷文件是否存在
????????File?target?=?new?File(pdfFile);??
?????????if?(target.exists())?{??
????????????target.delete();
?????????}
????????System.out.println(“另存為:?“?+?pdfFile);
????????//?另存為,將文檔報(bào)錯(cuò)為pdf,其中word保存為pdf的格式宏的值是17
????????Dispatch.call(document?“SaveAs“?pdfFile?17);
????????//?關(guān)閉文檔
????????Dispatch.call(document?“Close“?false);
????????//?結(jié)束時(shí)間
????????long?end?=?System.currentTimeMillis();
????????System.out.println(“轉(zhuǎn)換成功,用時(shí):“?+?(end?-?start)?+?“ms“);
???????}catch(Exception?e)?{
????????System.out.println(“轉(zhuǎn)換失敗“+e.getMessage());
???????}finally?{
????????????//?關(guān)閉office
????????//app.invoke(“Quit“?0);
???????}
????}
}

?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----

?????文件?????378865??2018-06-09?11:07??27、Word轉(zhuǎn)PDF\jacob-1.14.3.zip

?????文件????8544036??2018-08-03?16:55??27、Word轉(zhuǎn)PDF\Linux平臺(tái)\aspose-words-14.9.0-jdk16.jar

?????文件????????586??2018-08-03?16:49??27、Word轉(zhuǎn)PDF\Linux平臺(tái)\license.xml

?????文件??????17275??2018-08-03?20:48??27、Word轉(zhuǎn)PDF\Linux平臺(tái)\WriteToWord.java

?????文件????????110??2018-08-03?20:46??27、Word轉(zhuǎn)PDF\Linux平臺(tái)\說(shuō)明.txt

?????文件??????38647??2018-08-01?19:02??27、Word轉(zhuǎn)PDF\ReportDemo.docx

?????文件?????378865??2018-06-09?11:07??27、Word轉(zhuǎn)PDF\Window平臺(tái)\jacob-1.14.3.zip

?????文件???????2089??2018-08-03?16:03??27、Word轉(zhuǎn)PDF\Window平臺(tái)\Word2Pdf.java

?????文件?????????62??2018-08-03?20:41??27、Word轉(zhuǎn)PDF\Window平臺(tái)\轉(zhuǎn)pdf說(shuō)明.txt

?????文件???????2086??2018-06-09?11:05??27、Word轉(zhuǎn)PDF\Word2Pdf.java

?????文件????????364??2018-06-09?11:12??27、Word轉(zhuǎn)PDF\備注.txt

?????目錄??????????0??2018-08-27?08:58??27、Word轉(zhuǎn)PDF\Linux平臺(tái)

?????目錄??????????0??2018-08-27?08:58??27、Word轉(zhuǎn)PDF\Window平臺(tái)

?????目錄??????????0??2018-10-09?10:08??27、Word轉(zhuǎn)PDF

-----------?---------??----------?-----??----

??????????????9362985????????????????????14


評(píng)論

共有 條評(píng)論

相關(guān)資源