翻譯|使用教程|編輯:李顯亮|2020-01-08 09:39:57.890|閱讀 743 次
概述:本系列教程中,將為開發者帶來Aspose.PDF for .NET的一系列使用教程,例如進行文檔間的轉換,如何標記PDF文件,如何使用表單和圖表等等。本文將介紹如何將PDF轉換為DOC和DOCX。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Aspose.PDF for .NET是一種高PDF處理和解析API,用于在跨平臺應用程序中執行文檔管理和操作任務。API可以輕松用于生成、修改、轉換、渲染、保護和打印PDF文檔,而無需使用Adobe Acrobat。此外,API還提供PDF壓縮選項,表格創建和操作,圖形和圖像功能,廣泛的超鏈接功能,印章和水印任務,擴展的安全控制和自定義字體處理。
在接下來的系列教程中,將為開發者帶來Aspose.PDF for .NET的一系列使用教程,例如進行文檔間的轉換,如何標記PDF文件,如何使用表單和圖表等等。本文將介紹如何將PDF轉換為DOC和DOCX。
>>Aspose.PDF for .NET更新至最新版v20.1,歡迎下載體驗。
許多用戶都要求將PDF轉換為DOC:將PDF文件轉換為Microsoft Word文檔。之所以需要這樣做,是因為PDF文件不容易編輯,而Word文檔卻可以。一些公司希望其用戶能夠處理以PDF開頭的文件中的文本,表格和圖像。
Aspose.PDF for .NET允許使用兩行代碼將源PDF文件轉換為DOC文件。為了實現此功能,引入了一個名為的枚舉SaveFormat ,從而可以將源文件保存為Microsoft Word格式。以下代碼段顯示了將PDF文件轉換為DOC的過程。
// For complete examples and data files, please go to //github.com/aspose-pdf/Aspose.PDF-for-.NET // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion(); // Open the source PDF document Document pdfDocument = new Document(dataDir + "PDFToDOC.pdf"); // Save the file into MS document format pdfDocument.Save(dataDir + "PDFToDOC_out.doc", SaveFormat.Doc);
DocSaveOptions類提供了完善的PDF文件轉換成DOC格式的過程中眾多特性。在這些屬性中,Mode可以指定PDF內容的識別模式。從而可以從RecognitionMode枚舉中為此屬性指定任何值。這些值均具有特定的優點和局限性:
// For complete examples and data files, please go to //github.com/aspose-pdf/Aspose.PDF-for-.NET // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion(); // Open the source PDF document Document pdfDocument = new Document(dataDir + "PDFToDOC.pdf"); // Save using save options // Create DocSaveOptions object DocSaveOptions saveOptions = new DocSaveOptions(); // Set the recognition mode as Flow saveOptions.Mode = DocSaveOptions.RecognitionMode.Flow; // Set the Horizontal proximity as 2.5 saveOptions.RelativeHorizontalProximity = 2.5f; // Enable the value to recognize bullets during conversion process saveOptions.RecognizeBullets = true; // Save the resultant DOC file pdfDocument.Save(dataDir + "saveOptionsOutput_out.doc", saveOptions);
Docx是Microsoft Word文檔的一種眾所周知的格式,其結構從純二進制更改為XML和二進制文件的組合。 可以使用Word 2007和橫向版本打開Docx文件,但不能使用支持DOC文件擴展名的早期版本的MS Word打開。
DocSaveOptions類具有一個名為Format的屬性,該屬性提供了指定結果文檔格式(即DOC或DOCX)的功能。 為了將PDF文件轉換為DOCX格式,請傳遞DocSaveOptions.DocFormat枚舉中的Docx值。以下代碼片段提供了將PDF文件轉換為DOCX格式的功能。
// For complete examples and data files, please go to //github.com/aspose-pdf/Aspose.PDF-for-.NET // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion(); // Open the source PDF document Document pdfDocument = new Document(dataDir + "PDFToDOC.pdf"); // Instantiate DocSaveOptions object DocSaveOptions saveOptions = new DocSaveOptions(); // Specify the output format as DOCX saveOptions.Format = DocSaveOptions.DocFormat.DocX; // Save document in docx format pdfDocument.Save("ConvertToDOCX_out.docx", saveOptions);
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn