How to Convert MS Word to PDF in ASP.NET

Corey Fleig 120 Reputation points
2025-10-23T00:40:18.42+00:00

I use NuGet's PDFSharp for merging PDFs, and it's great. But now I'm trying to see if I can read an MS WORD document and convert it into a PDF.

I'm not sure PDFSharp or MigraDoc can do it. I know Spire.DOC will work, but it's not free. I can get it done if my app was Windows Forms, but the app is strictly ASP.NET.

Any recommendations?

Developer technologies | ASP.NET | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Omkara Varshitha Kunapalli (INFOSYS LIMITED) 1,350 Reputation points Microsoft External Staff
    2025-10-23T06:12:54.0733333+00:00

    Hello hope your doing well. Thanks for reaching out!

    Step 1: Install Syncfusion DocIO

    • Open NuGet Package Manager
    • Run this command: Install-Package Syncfusion.DocIO.Net.Core
    • Step 2: Add Required Namespaces

    At the top of your .cs file, add:

    using Syncfusion.DocIO; using Syncfusion.DocIO.DLS; using Syncfusion.DocIORenderer; using Syncfusion.Pdf;

    Step 3: Load and Convert the Word Document

    // Load the Word document WordDocument wordDocument = new WordDocument(Server.MapPath("~/Files/input.docx"));

     

    // Convert to PDF DocIORenderer renderer = new DocIORenderer(); PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument);

    Step 4: Save the PDF File

    // Save the PDF to disk pdfDocument.Save(Server.MapPath("~/Files/output.pdf"));

     

    // Close documents pdfDocument.Close(); wordDocument.Close();

    Step 5: Display or Download the PDF

    Response.ContentType = "application/pdf"; Response.TransmitFile(Server.MapPath("~/Files/output.pdf")); Response.End();

     


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.