2

I am looking for a library that can convert PDFs and other formats to docx using .NET.

I have found some libraries but they all require an internet connection to send the file, I need this completely offline. I am using Xamarin-forms

I found this post but it is going from PDF to docx and not vice-versa: .NET library to convert Microsoft Office docs to PDF

Can anybody recommend a library?

4
  • What exact platforms are you looking to run on? Android? iOS? UWP? Are you looking for a pure .NET library, or one that might also contain native binaries (e.g. x86)? Are you open to commercial paid libraries? Or FOSS only?
    – Ryan
    Commented Jan 19, 2021 at 23:01
  • I don't mind a pure .net or one that uses native binaries, so long as it's not too complicated to do since the reason I'm using Xamarin is so I don't have to mess too much with the native binaries. I am open to commercial paid libraries, so long as they are easy to use and have good technical support I can use in-case I need help Commented Jan 20, 2021 at 13:49
  • What devices/platforms are you targeting though? iOS?
    – Ryan
    Commented Jan 20, 2021 at 18:59
  • Android and iOS and maybe UWP too Commented Jan 20, 2021 at 20:42

1 Answer 1

1

If you're interested in using a commercial product the LEADTOOLS SDK can perform this conversion for you. They have Xamarin libraries available for DocumentConversion. https://www.leadtools.com/sdk/document/document-converter

The conversion also takes place on the device where the libraries are, so no internet connection is required. The libraries can handle conversion to and from PDF, DOCX, and various other office and SVG formats. Here's a code sample showing how to convert an input DOCX file to an output PDF.

   using (DocumentConverter documentConverter = new DocumentConverter()) 
   { 
      var inFile = Path.Combine(ImagesPath.Path, @"Leadtools.pdf"); 
      var outFile = Path.Combine(ImagesPath.Path, @"output.docx"); 
      var format = DocumentFormat.Docx; 
      var jobData = DocumentConverterJobs.CreateJobData(inFile, outFile, format); 
      jobData.JobName = "conversion job"; 
 
      var job = documentConverter.Jobs.CreateJob(jobData); 
      documentConverter.Jobs.RunJob(job); 
 
      if (job.Status == DocumentConverterJobStatus.Success) 
      { 
         Console.WriteLine("Success"); 
      } 
      else 
      { 
         Console.WriteLine("{0} Errors", job.Status); 
         foreach (var error in job.Errors) 
         { 
            Console.WriteLine("  {0} at {1}: {2}", error.Operation, error.InputDocumentPageNumber, error.Error.Message); 
         } 
      } 
   } 

You can grab all these in a NuGet package if you prefer. https://www.nuget.org/packages/Leadtools.Document.Sdk/

Note I'm an employee of the company which makes this product. They also offer free technical support for the product.

3
  • @ben-thomson The question was specifically "pdf convert to doc", but your code is the other way. What is your code to convert PDF to DOC/DOCX?
    – Ryan
    Commented Jan 20, 2021 at 18:46
  • Thanks for the heads-up. The toolkit actually works both ways--the only thing which needs to be modified is the input file and the output format and filename. I updated the code in the the post. Sorry about that. Commented Jan 20, 2021 at 19:05
  • The Document Converter SDK is available on the following platforms: .NET, .NET Core, UWP, iOS/macOS, Xamarin, Linux, and Android, as stated at the bottom of this link: leadtools.com/sdk/document/document-converter Commented Jan 21, 2021 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.