We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to convert a Word document to PDF in ASP.NET Core

Platform: ASP.NET Core |
Control: DocIO |
Published Date: February 22, 2018 |
Last Revised Date: April 25, 2019

Syncfusion Essential DocIO Renderer is a .NET Core Word to PDF conversion library (Essential DocIO and Essential PDF) used to convert Word documents to PDF in ASP.NET Core application [C#].

Steps to convert Word document to PDF programmatically in ASP.NET Core:

  1. Create new C# .NET Core console application.

Create .NET Core Web application in Visual Studio

  1. Install the Syncfusion.DocIORenderer.NET.Core NuGet package as a reference to your .NET Core application from NuGet.org.

Add DocIO Renderer NuGet package reference to the project

  1. Include the following namespace in the Program.cs file.

C#

using Syncfusion.DocIO.DLS;
using Syncfusion.DocIORenderer;
using Syncfusion.Pdf;
using System.IO;
  1. Use the following code snippet to create Word document with “Hello World” text and convert Word document to PDF.

C#

//Creates a new Word document.
WordDocument wordDocument = new WordDocument();
//Add a section & a paragraph in the empty document.
wordDocument.EnsureMinimal();
//Append text to the last paragraph of the document.
wordDocument.LastParagraph.AppendText("Hello World...!");
//Create instance for DocIORenderer for Word to PDF conversion
DocIORenderer render = new DocIORenderer();
//Converts Word document to PDF.
PdfDocument pdfDocument = render.ConvertToPDF(wordDocument);
//Release the resources used by the Word document and DocIO Renderer objects.
render.Dispose();
wordDocument.Dispose();
//Saves the PDF file.
FileStream outputStream = new FileStream(@"Ouput.pdf", FileMode.CreateNew, FileAccess.Write);
pdfDocument.Save(outputStream);
//Closes the instance of PDF document object.
pdfDocument.Close();
//Dispose the instance of FileStream.
outputStream.Dispose();

A complete working example of how to convert Word document to PDF using .NET Core Word library can be downloaded from WordToPDF_Example.Zip.

By executing the example program, you will get the PDF document as like below.

Converted PDF document

Take a moment to peruse the documentation, where you can find other file format conversions with code examples and the procedure to deploy the application in Linux OS.

Explore more about the rich set of Syncfusion Word Framework features.

An online example to convert Word document to PDF in ASP.NET Core web application.

Note:

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.

 

2X faster development

The ultimate ASP.NET Core UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
Pieter van Kampen
Feb 22, 2018

Hurray!

Reply
Pieter van Kampen
Feb 28, 2018

No chart support yet. I suggest mentioning that in the KB. If you need chart support, it takes a lot of effort before you discover that it is not there.

Dilli Babu Nandha Gopal [Syncfusion]
Mar 01, 2018

Hi Pieter,


Currently, chart is not supported in Word to PDF conversion in ASP.NET Core application. We will update the limitations of Word to PDF conversion in our UG documentation page.


Regards,

Dilli babu.

Reply
gra-moore
Mar 10, 2018

This is great, just wondering how to control the way the the pdf is saved. Specifically, how to save it in pdf-1a format?

Thanks,

Graham

Reply
Dilli Babu Nandha Gopal [Syncfusion]
Mar 13, 2018

Hi Graham,

Thank you for using Syncfusion products.

Currently DocIORenderer doesn’t have support to generate a PDF document with pdf-1a conformance. We have logged this as a feature request in our database. We will implement this feature in any of our upcoming releases. At present, we cannot provide any concrete timeline for this feature implementation. We will let you know once this feature is implemented.

Regards,
Dilli babu.

Reply
bastien neyer
Sep 03, 2018

All the nuget package names are outdated!

Reply
Dilli Babu Nandha Gopal [Syncfusion]
Sep 04, 2018

Hi Bastien,

 

We regret for the inconvenience.

 

All NuGet package names are updated now. Kindly try our updated sample and let us know if you have any questions.

 

Regards,

Dilli babu.

Reply
Matt Psaltis
Oct 22, 2018

Packages are out of date again :) There seems to be a lot of churn with the nuget packages. Is there a page we can subscribe to?


Also, it seems that chart support still isn't available during document conversion. Is this being actively worked on or still on a backlog?


Cheers!

Reply
Dilli Babu Nandha Gopal [Syncfusion]
Oct 22, 2018

Hi Matt,

We regret for the inconvenience.

All NuGet packages name are updated now. Kindly try our updated sample and let us know if you have any questions.

We have started to work on chart support in Word to PDF conversion. This feature is estimated to be available in 2019 Volume 1 release tentatively

Regards,

Dilli babu.

Aurimas F.
Nov 21, 2018

Hello,

is there a way to embed fonts in ASP .NET Core DOC to PDF conversion (like there was in .NET Framework's DocToPDFConverter, e.g. converter.Settings.EmbedFonts = true;)?

Reply
Dilli Babu Nandha Gopal [Syncfusion]
Mar 14, 2019

Hi Aurimas,

 

Yes, we do support EmbedFonts in Word to PDF conversion in ASP.NET CORE which is explained here.

 

Regards,

Dilli babu.

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon