Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Last active April 15, 2025 01:08
Show Gist options
  • Save conholdate-gists/7e52181e5c16bc9ab4944c4993d4a65a to your computer and use it in GitHub Desktop.
Save conholdate-gists/7e52181e5c16bc9ab4944c4993d4a65a to your computer and use it in GitHub Desktop.
Convert PDF to Word using C#
// Initialize an object of the Document class and load the source PDF file
Document pdfDocument = new Document( "sample.pdf");
// Save the file into DOC format by invoking Save method
pdfDocument.Save( "PDFToDOC_out.doc", SaveFormat.Doc);
/ Open the source PDF document by initializing an instance of Document class
Document pdfDocument = new Document( "sample.pdf");
// Create an instance of DocSaveOptions class to access save options for export to Doc format
DocSaveOptions saveOptions = new DocSaveOptions
{
// Set the value of this Format property to save the output file in Doc format.
Format = DocSaveOptions.DocFormat.Doc,
// Set the recognition mode as Flow by setting the Mode property
Mode = DocSaveOptions.RecognitionMode.Flow,
// Assign a value to the RelativeHorizontalProximity property Set the Horizontal proximity as 2.5
RelativeHorizontalProximity = 2.5f,
// Enable the value to recognize bullets during conversion process by setting a value of RecognizeBullets property
RecognizeBullets = true
};
// Invoke the Save method to save the file into MS document format
pdfDocument.Save( "PDFToDOC_out.doc", saveOptions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment