們經常會在網上查找資料,而大多文檔下載都需要付費,有哪些方法能免費將網頁轉換成Word文檔呢?下面一起來看一看吧。
1、直接復制
最簡單的方法就是直接將網頁中所需段落或文字選中后,然后右擊并選擇“復制”,再新建一個Word文檔粘貼進去就可以了。
2、另存為
有一些資料網站做了限制,文字無法選擇,或者選擇之后也復制不了,那么我們可以先將其以網頁進行保存。在網頁任意處右擊并選擇“網頁另存為”;
接著將網頁以HTML文件形式保存到電腦桌面后,雙擊打開這個網頁,就可以隨意進行復制并且粘貼到Word中了,只是這個網頁加載會比較慢,不太建議使用。
3、截圖轉文字
如果有些網頁資料限制多,以上兩種方式都無法操作,那我們可以將需要的頁面內容進行截圖保存,使用一些聊天工具的截圖工具或電腦自帶的屏幕截取都可以。
然后再使用轉換工具將圖片識別成文字就可以啦。我們可以使用speedpdf在線轉換工具的圖片轉Word功能,不僅能識別文字,如果有圖片,也能以原有格式轉換成Word。
首先搜索Speedpdf進入在線轉換后,選擇列表中轉換格式中的“JPG to Word ”;然后將所有保存的圖片批量全部上傳進行轉換,這樣就能將內容轉到同一個Word文檔中。
轉換完成之后直接下載就可以打開Word文檔了,是不是很方便,而且轉換也是免費的哦,強烈推薦這種處理方式呢。
在項目開發時,平時喜歡用markdown寫文檔.
但項目交付給客戶的時候,需要將markdown轉換為更加正式的word文檔進行交付.
于是用pandoc將.md文件轉換為word文檔.
Pandoc 可以用于各種文檔格式之間的轉換。如: Markdown、Microsoft Word、HTML、EPUB、roff man、LaTeX、PDF。
// 1 .md 文件轉換為word文檔
pandoc test.md -o newtest.docx
// 2 多個md轉換為一個word文檔,
pandoc xx1.md xx2.md -o 合并后的.docx
/**3 自定義文檔格模板格式**/
//3.1 首先獲取pandoc 自帶的doc模板文檔muban.docx
pandoc.exe -o muban.docx --print-default-data-file=reference.docx
//3.2 打開muban.docx,修改模板文件中樣式(如下圖,需要通過右鍵修改樣式方式,模板才能生效)
//3.3 使用模板文檔,進行轉換
pandoc.exe xx1.md xx2.md -o 合并后的.docx --reference-doc=C:\\reference.docx
https://javabus.oss-cn-beijing.aliyuncs.com/reference.docx
需要通過右鍵修改樣式方式,模板才能生效
通過名稱可以控制樣式排序
段落背景色設置
前后縮進控制
待轉換文檔目錄結構如下:
dev-docs
|__docs
|____docsify
|____imgs 文檔圖片存放
|____core
|____other
_sidebar.md md文檔目錄
markdown文檔
轉換后word效果圖
/**
* 通過pandoc輸出默認模板到custom.docx: pandoc.exe -o custom.docx --print-default-data-file=reference.docx
* <p>
* 使用指定的文件作為輸出文件的格式參考。參考文件的內容被忽略,只使用其中的樣式和文檔屬性(包括邊界、頁面尺寸、頁眉頁腳等) (--reference-doc=File(custom.docx)) 指定要生成的word模板
*/
public class Markdown2Docx_backup {
//pandoc.exe 文件絕對路徑
private static final String PANDOC_PATH = "C:\\doc\\pandoc.exe ";
//markdown文檔(.md后綴格式) 所在路徑
private static final String DOCS_DIR = "C:\\doc\\docs\\docs";
//文檔依賴圖片路徑
private static final String IMG_DIR = "C:\\doc\\docs\\docs\\imgs";
//側邊欄_sidebar.md,根據側邊欄順序轉換文檔
private static final String _sidebar = "C:\\doc\\docs\\docs\\_sidebar.md";
//docx模板 使用 pandoc 進行文檔轉換(markdown轉word) http://t.zoukankan.com/kofyou-p-14932700.html
private static final String reference_docx = "C:\\doc\\docs\\docs\\reference.docx";
public static void main(String[] args) {
copyImageDir();
String mdFilePath = buildAllMdFilePath();
convertmd2Docx(mdFilePath);
}
/**
* 解析側邊欄 _sidebar.md 生成所有markdown文件路徑,如: xx1.md xx2.md
* <p>
* 側邊欄內容示例: -[文檔說明](/job-debug.md)
*/
private static final String buildAllMdFilePath() {
StringBuilder mds = new StringBuilder();
File sidebarFile = new File(_sidebar);
if (!sidebarFile.exists()) {
System.err.println("_sidebar.md 側邊欄文件不存在");
return null;
}
//獲取文件首行作為文件名
List<String> contents = FileUtil.readTxtFile(_sidebar, "utf-8");
for (String content : contents) {
//content示例必須有()將md路徑包含: -[文檔說明](/job-debug.md)
try {
if (StringUtil.isNullOrEmpty(content.trim())) {
continue;
}
if (content.indexOf("](") < 0) {
System.out.println(content + ", 不是markdown 路徑不進行轉換");
continue;
}
//解析出 /job-debug.md
String mdPath = content.split("]\\(")[1].replace(")", "").replace("/", "\\").trim();
if (mdPath.endsWith(".md")) {
mds.append(DOCS_DIR).append("\\").append(mdPath).append(" ");
} else {
mds.append(DOCS_DIR).append("\\").append(mdPath).append(".md").append(" ");
}
} catch (Exception e) {
System.err.println("從文檔中解析md文件路徑失敗");
}
}
return mds.toString();
}
private static void convertmd2Docx(String mdFilePath) {
String docxPath = DOCS_DIR + "\\開發手冊.docx";
Runtime rn = Runtime.getRuntime();
try {
//pandoc xx1.md xx2.md -o test.docx
String command;
File mubanDoc = new File(reference_docx);
if (mubanDoc.exists()) {
System.out.println("使用docx模板進行文檔轉換: " + reference_docx);
command = PANDOC_PATH + " " + mdFilePath + " -o " + docxPath + " --toc-depth=3 --reference-doc=" + reference_docx;
} else {
//pandoc xx1.md xx2.md -o test.docx
command = PANDOC_PATH + " " + mdFilePath + " -o " + docxPath + " ";
}
System.out.println(command);
Process exec = rn.exec(command);
} catch (Exception e) {
System.out.println("調用服務生成word文檔錯誤 " + e.getMessage());
}
}
/**
* 1 (pandoc test.md -o test.docx 無法識別../imgs ),將../imgs替換為/imgs絕對路徑
* <p>
* 2 修改 markdown文檔中的圖片引入方式,手動將文檔中所有../imgs 替換為/imgs 
* <p>
* 3 通過copyImageDir()方法,將/docs/imgs目錄下的圖片,復制到當前程序運行的根目錄/的imgs下(/imgs)
*/
private static void copyImageDir() {
//文檔中依賴圖片文件路徑
File docImgsDir = new File(IMG_DIR);
//解決pandoc 轉換文件時,找不到圖片路徑../imgs問題
File dir = new File("/imgs");
if (!dir.exists()) {
dir.mkdir();
File[] files = docImgsDir.listFiles();
for (File file : files) {
String s = FileUtil.readToString(file);
try {
FileUtil.writeToFile(dir + "\\" + file.getName(), s, "utf-8", false);
} catch (IOException e) {
e.printStackTrace();
}
}
System.out.println("復制文檔圖片到路徑:" + dir.getAbsolutePath());
} else {
System.out.println("文檔圖片已存在路徑:" + dir.getAbsolutePath());
}
}
}
參考文檔
自動生成文檔目錄
數據表和字段描述示例
<!--文檔地址 -->
<!--數據庫文檔生成工具 screw-->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.30</version>
</dependency>
<dependency>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-core</artifactId>
<version>1.0.3</version>
</dependency>
ava實現在線預覽功能是一個大家在工作中也許會遇到的需求,如果公司有錢,直接使用付費的第三方軟件或者云在線預覽服務就可以了,例如永中office、office web 365(http://www.officeweb365.com/)他們都有云在線預覽服務,就是要錢0.0
如果想要免費的,可以用openoffice,還需要借助其他的工具(例如swfTools、FlexPaper等)才行,可參考這篇文章http://blog.csdn.net/z69183787/article/details/17468039,寫的挺細的,實現原理就是:
1.通過第三方工具openoffice,將word、excel、ppt、txt等文件轉換為pdf文件;
2.通過swfTools將pdf文件轉換成swf格式的文件;
3.通過FlexPaper文檔組件在頁面上進行展示。
當然如果裝了Adobe Reader XI,那把pdf直接拖到瀏覽器頁面就可以直接打開預覽,這樣就不需要步驟2、3了,前提就是客戶裝了Adobe Reader XI這個pdf閱讀器。
我這里介紹通過poi實現word、excel、ppt轉html,這樣就可以放在頁面上了。
###word轉html
###excel轉html
###ppt轉html
其實只是ppt轉圖片,有了圖片后放到頁面上去,點擊下一頁就一張張顯示就可以了。這里只介紹ppt轉圖片的過程。
*請認真填寫需求信息,我們會在24小時內與您取得聯系。