Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
この記事では、C#を使用してPDFをMicrosoft Word文書に変換する方法について説明します。以下のトピックをカバーしています。
形式: DOC
形式: DOCX
形式: Word
次のコードスニペットは、Aspose.PDF.Drawingライブラリでも動作します。
最も人気のある機能の1つは、PDFからMicrosoft Word DOCへの変換であり、コンテンツ管理をより簡単にします。Aspose.PDF for .NETを使用すると、PDFファイルをDOCおよびDOCX形式に迅速かつ効率的に変換できます。
PDFファイルをDOC形式に簡単に変換し、完全な制御を行います。Aspose.PDF for .NETは柔軟で、さまざまな変換をサポートしています。たとえば、PDF文書のページを画像に変換することは非常に人気のある機能です。
多くの顧客がPDFからDOCへの変換をリクエストしています。PDFファイルをMicrosoft Word文書に変換することです。顧客は、PDFファイルは簡単に編集できないのに対し、Word文書は編集可能であるため、これを望んでいます。一部の企業は、ユーザーがPDFとして始まったファイル内のテキスト、表、画像を操作できるようにしたいと考えています。
物事をシンプルで理解しやすくする伝統を守り、Aspose.PDF for .NETを使用すると、ソースPDFファイルを2行のコードでDOCファイルに変換できます。この機能を実現するために、SaveFormatという列挙型を導入し、その値.Docを使用してソースファイルをMicrosoft Word形式に保存できます。
以下のC#コードスニペットは、PDFファイルをDOC形式に変換する方法を示しています。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ConvertPDFtoWord()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Open PDF document
usnig (var document = new Aspose.Pdf.Document(dataDir + "PDFToDOC.pdf"))
{
// Save the file into MS document format
document.Save(dataDir + "PDFToDOC_out.doc", SaveFormat.Doc);
}
}
DocSaveOptions
クラスは、PDFファイルをDOC形式に変換するための多数のプロパティを提供します。これらのプロパティの中で、ModeはPDFコンテンツの認識モードを指定するために使用できます。このプロパティには、RecognitionMode列挙型から任意の値を選択できます。これらの値にはそれぞれ特定の利点と制限があります。
Textbox
モードは高速で、PDFファイルの元の外観を保持するのに適していますが、結果の文書の編集可能性は制限される可能性があります。元のPDF内の視覚的にグループ化されたテキストブロックは、出力文書内のテキストボックスに変換されます。これにより、元の文書に最大限似た出力文書が得られますが、出力文書は完全にテキストボックスで構成されており、Microsoft Wordで編集するのは非常に難しいです。Flow
は完全認識モードであり、エンジンがグループ化と多層分析を実行して、著者の意図に従って元の文書を復元し、簡単に編集可能な文書を生成します。制限は、出力文書が元の文書とは異なる外観になる可能性があることです。RelativeHorizontalProximity
プロパティは、テキスト要素間の相対的な近接性を制御するために使用できます。これは、距離がフォントサイズによって規定されることを意味します。大きなフォントは音節間に大きなスペースを持つことができ、依然として1つの全体と見なされます。これはフォントサイズのパーセンテージとして指定されます。たとえば、1 = 100%です。これは、12ptの2文字が12pt離れて配置されている場合、近接していることを意味します。
RecognitionBullets
は、変換中に箇条書きの認識をオンにするために使用されます。// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ConvertPDFtoWordDocAdvanced()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "PDF-to-DOC.pdf"))
{
var saveOptions = new Aspose.Pdf.DocSaveOptions
{
// Set format to save MS document
Format = Aspose.Pdf.DocSaveOptions.DocFormat.Doc,
// Set the recognition mode as Flow
Mode = Aspose.Pdf.DocSaveOptions.RecognitionMode.Flow,
// Set the Horizontal proximity as 2.5
RelativeHorizontalProximity = 2.5f,
// Enable the value to recognize bullets during the conversion process
RecognizeBullets = true
};
// Save the file into MS document with save options
document.Save(dataDir + "PDFtoDOC_out.doc", saveOptions);
}
}
Aspose.PDF for .NET APIを使用すると、C#および任意の.NET言語を使用してPDF文書をDOCXに読み取り、変換できます。DOCXは、Microsoft Word文書のためのよく知られた形式で、その構造はプレーンバイナリからXMLとバイナリファイルの組み合わせに変更されました。DocxファイルはWord 2007以降のバージョンで開くことができますが、以前のバージョンのMS WordではDOCファイル拡張子をサポートしていません。
以下のC#コードスニペットは、PDFファイルをDOCX形式に変換する方法を示しています。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ConvertPDFtoWord_DOCX_Format()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "PDFToDOC.pdf"))
{
// Save the file into MS document format
document.Save(dataDir + "PDFtoDOC_out.docx", SaveFormat.DocX);
}
}
PDFからDOCXへの変換の結果を向上させるために、EnhancedFlow
モードを使用できます。
FlowとEnhanced Flowの主な違いは、テーブル(境界線の有無にかかわらず)が実際のテーブルとして認識され、背景に画像があるテキストとしてではないことです。
番号付きリストやその他の多くの小さな要素も認識されます。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ConvertPDFtoWord_Advanced_DOCX_Format()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "PDFToDOC.pdf"))
{
// Instantiate DocSaveOptions object
DocSaveOptions saveOptions = new Aspose.Pdf.DocSaveOptions
{
// Set format to save MS document
Format = Aspose.Pdf.DocSaveOptions.DocFormat.DocX,
// Set the recognition mode as EnhancedFlow
Mode = Aspose.Pdf.DocSaveOptions.RecognitionMode.EnhancedFlow
};
// Save the file into MS document format
document.Save(dataDir + "PDFToDOC_out.docx", saveOptions);
}
}
この記事では、以下のトピックもカバーしています。コードは上記と同じです。
形式: Word
形式: DOC
形式: DOCX
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.