This technical tip shows how to convert PDF file to DOC or DOCX format in .Net using Aspose.PDF. Aspose.Pdf for .NET is flexible and supports a wide variety of conversions. Converting pages from PDF documents to images, for example, is a very popular feature. A conversion that many of our customers have requested is PDF to DOC: converting a PDF file to a Microsoft Word document. Customers want this because PDF files cannot easily be edited, whereas Word documents can. Some companies want their users to be able to manipulate text, tables and images in files that started as PDFs. Keeping alive the tradition of making things simple and understandable, Aspose.Pdf for .NET provides few lines code to transform source PDF file into a DOC file. The DocSaveOptions class provides numerous properties that improve the process of converting PDF files to DOC format. Among these properties, Mode enables you to specify the recognition mode for PDF content. You can specify any value from the RecognitionMode enumeration for this property.


Converting PDF to DOC



[C#]


Code:
// Path of input PDF document
StringfilePath = @"d:\\Source.pdf";
// Instantiate the Document object
Aspose.Pdf.Document document = newAspose.Pdf.Document(filePath);
// CreateDocSaveOptions object
DocSaveOptionssaveOptions = newDocSaveOptions();
// 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
document.Save(@"d:\\Resultant.doc", saveOptions);

[VB.NET]

Code:
' Path of input PDF document
Dim filePath As String = "d:\\Source.pdf"
' Instantiate the Document object
Dim document As Aspose.Pdf.Document = New Aspose.Pdf.Document(filePath)
' CreateDocSaveOptions object
Dim saveOptions As DocSaveOptions = 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 resultnat DOC file
document.Save("d:\\Resultant.doc", saveOptions);


Converting PDF to Docx format



[C#]


Code:
//open pdf document
Document pdfDocument = newDocument("source.pdf");
// instantiate DocSaveOptions object
DocSaveOptionssaveOptions = newDocSaveOptions();
// specify the output format as DOCX
saveOptions.Format = DocSaveOptions.DocFormat.DocX;
//save document in docx format
pdfDocument.Save("output.docx", saveOptions);


[VB.NET]

Code:
//open pdf document
Document pdfDocument = newDocument("source.pdf");
// instantiate DocSaveOptions object
DocSaveOptionssaveOptions = newDocSaveOptions();
// specify the output format as DOCX
saveOptions.Format = DocSaveOptions.DocFormat.DocX;
//save document in docx format
pdfDocument.Save("output.docx", saveOptions);