EvoPdf Classic · Word to PDF

EVO Classic Word to PDF for .NET

EVO Classic Word to PDF Converter for .NET can be used in any type of .NET application to convert Word (.doc, .docx) and RTF documents to PDF documents. The Word to PDF Converter does not use Microsoft Office or other third party tools. The Word document to convert can be in a memory buffer or in a file and the resulted PDF can be produced in a memory buffer, in a file on disk or in a stream.

Classic v14.0 · Windows, .NET Framework 4.0+ and .NET 6–10 · Evaluate without registration — demo mode by default (watermarked) · Licensed with the EVO PDF Toolkit

$dotnet add package EvoPdf.WordToPdf

Windows · .NET Framework 4.0+ and .NET 6–10 (.NET Standard 2.0)

Program.csC#
using EvoWordToPdf;

var converter = new WordToPdfConverter();
byte[] pdf = converter.ConvertWordFile("report.docx");
File.WriteAllBytes("report.pdf", pdf);
Classic API: EvoWordToPdf namespace, one converter class, synchronous calls. API reference →
  • Windows 10 / 11 / Server 2016–2025
  • .NET Framework 4.0 – 4.8.1
  • .NET 6 → 10, .NET Standard 2.0
  • Azure Cloud Services & Virtual Machines
  • Web, console and desktop applications
Features

What the Word to PDF component does

  • Convert Word DOC and DOCX documents to PDF
  • Convert RTF documents to PDF
  • Does not require Microsoft Word or other third party tools
  • Convert to memory buffer, file, stream or to a PDF object for further processing
  • Convert all the pages or select the pages in document to convert
  • Add headers and footers with page numbering to PDF pages
  • Append or prepend external PDF files to conversion result
  • Password protect and set permissions of the PDF document
  • Add a digital signature to generated PDF document
  • Add graphic elements to generated PDF document
  • Generate PDF/A and PDF/X compliant documents
  • Generate CMYK and Gray Scale PDF documents
  • Edit existing PDF documents
  • Merge multiple PDF documents in a single PDF document
  • Split a PDF document in multiple PDF documents
  • Support for .NET 4.0 framework and later
  • Documentation and C# samples for all the features
In detail

EVO Classic Word to PDF for .NET — how it works

EVO Classic Word to PDF Converter for .NET

EVO Classic Word to PDF Converter for .NET can be used in any type of .NET application to convert Word (.doc, .docx) and RTF documents to PDF. The Word to PDF Converter does not use Microsoft Office or any other third-party tools. The Word document to be converted can be stored in a memory buffer or in a file, and the resulting PDF can be generated in a memory buffer, saved to a file on disk, or output to a stream.

Integration with existing .NET applications is extremely easy, and no installation is required. The downloaded evaluation package contains assemblies for .NET Framework and .NET Standard 2.0, as well as demo applications with full C# source code in the Samples folder.

It can also be used to create, edit, and merge PDF documents. The Classic library is compatible with .NET Framework, .NET Core, and .NET Standard 2.0 on Windows platforms. For applications that need to run on both Windows and Linux platforms, you can use the EvoPdf Next Word to PDF Converter for .NET to convert Word (.docx) to PDF, and the EvoPdf Next RTF to PDF Converter for .NET to convert RTF to PDF.

The full EvoPdf Next Library for .NET can be used on Windows, Linux, Azure, and Docker platforms to create, edit, and merge PDF documents, convert HTML to PDF or images, convert Word, Excel, RTF, and Markdown to PDF, extract text and images from PDFs, search text in PDFs, and convert PDF pages to images.

The code below was taken from the Word to PDF Converter demo application available for download in the Word to PDF Converter product package. In this sample an instance of the WordToPdfConverter class is constructed and used to convert an Word file to a PDF document in a memory buffer.

The resulted buffer is saved in a PDF file on disk. The demo also contains code for adding a header and a footer with page numbering to the resulted PDF document.

At a glance

Component
EvoPdf Classic · Word to PDF
NuGet package
EvoPdf.WordToPdf
Namespace
EvoWordToPdf
Main class
WordToPdfConverter
Runs on
Windows · .NET Framework 4.0+ · .NET 6–10 (.NET Standard 2.0)
Version
Classic v14.0
License
EVO PDF Toolkit; evaluation without registration
Documentation →
Sample.csC#
private void btnWordToPdf_Click(object sender, EventArgs e)
{
    // Create a Word to PDF converter object with default settings
    WordToPdfConverter wordToPdfConverter = new WordToPdfConverter();

    // Set license key received after purchase to use the converter in licensed mode
    // Leave it not set to use the converter in demo mode

    // Word Content Destination and Spacing Options

    // Set Word content destination in PDF page
    if (xLocationTextBox.Text.Length > 0)
        wordToPdfConverter.PdfDocumentOptions.X = float.Parse(xLocationTextBox.Text);
    if (yLocationTextBox.Text.Length > 0)
        wordToPdfConverter.PdfDocumentOptions.Y = float.Parse(yLocationTextBox.Text);
    if (contentWidthTextBox.Text.Length > 0)
        wordToPdfConverter.PdfDocumentOptions.Width = float.Parse(contentWidthTextBox.Text);
    if (contentHeightTextBox.Text.Length > 0)
        wordToPdfConverter.PdfDocumentOptions.Height = float.Parse(contentHeightTextBox.Text);

    // Set Word content top and bottom spacing or leave them not set to have no spacing for the Word content
    wordToPdfConverter.PdfDocumentOptions.TopSpacing = float.Parse(topSpacingTextBox.Text);
    wordToPdfConverter.PdfDocumentOptions.BottomSpacing = float.Parse(bottomSpacingTextBox.Text);
            
    // Add Header

    // Enable header in the generated PDF document
    wordToPdfConverter.PdfDocumentOptions.ShowHeader = addHeaderCheckBox.Checked;

    // Draw header elements
    if (wordToPdfConverter.PdfDocumentOptions.ShowHeader)
        DrawHeader(wordToPdfConverter, true);

    // Add Footer

    // Enable footer in the generated PDF document
    wordToPdfConverter.PdfDocumentOptions.ShowFooter = addFooterCheckBox.Checked;

    // Draw footer elements
    if (wordToPdfConverter.PdfDocumentOptions.ShowFooter)
        DrawFooter(wordToPdfConverter, true, true);

    Cursor = Cursors.WaitCursor;

    string outPdfFile = @"DemoAppFiles\Output\WordToPdf.pdf";
    try
    {
        string wordFile = wordFilePathTextBox.Text;

        // Convert the Word document to a PDF document
        byte[] outPdfBuffer = wordToPdfConverter.ConvertWordFile(wordFile);

        // Write the memory buffer in a PDF file
        System.IO.File.WriteAllBytes(outPdfFile, outPdfBuffer);
    }
    catch (Exception ex)
    {
        // The Word to PDF conversion failed
        MessageBox.Show(String.Format("Word to PDF Error. {0}", ex.Message));
        return;
    }
    finally
    {
        Cursor = Cursors.Arrow;
    }

    // Open the created PDF document in default PDF viewer
    try
    {
        System.Diagnostics.Process.Start(outPdfFile);
    }
    catch (Exception ex)
    {
        MessageBox.Show(String.Format("Cannot open created PDF file '{0}'. {1}", outPdfFile, ex.Message));
    }
}

/// <summary>
/// Draw the header elements
/// </summary>
/// <param name="wordToPdfConverter">The Word to PDF Converter object</param>
/// <param name="drawHeaderLine">A flag indicating if a line should be drawn at the bottom of the header</param>
private void DrawHeader(WordToPdfConverter WordToPdfConverter, bool drawHeaderLine)
{
    string headerImagePath = System.IO.Path.Combine(Application.StartupPath,
                @"DemoAppFiles\Input\Images\logo.jpg");

    // Set the header height in points
    WordToPdfConverter.PdfHeaderOptions.HeaderHeight = 60;

    // Set header background color
    WordToPdfConverter.PdfHeaderOptions.HeaderBackColor = Color.WhiteSmoke;

    // Set logo
    ImageElement headerImage = new ImageElement(5, 5, 100, 50, headerImagePath);
    WordToPdfConverter.PdfHeaderOptions.AddElement(headerImage);

    // Set header text
    TextElement headerText = new TextElement(0, 5, "EVO Word to PDF Converter ",
        new System.Drawing.Font(new System.Drawing.FontFamily("Times New Roman"), 10, System.Drawing.GraphicsUnit.Point));
    // Align the text at the right of the footer
    headerText.TextAlign = HorizontalTextAlign.Right;
    // Set text color
    headerText.ForeColor = Color.Navy;
    // Embed the text element font in PDF
    headerText.EmbedSysFont = true;
    // Add the text element to header
    WordToPdfConverter.PdfHeaderOptions.AddElement(headerText);
}

/// <summary>
/// Draw the footer elements
/// </summary>
/// <param name="wordToPdfConverter">The Word to PDF Converter object</param>
/// <param name="addPageNumbers">A flag indicating if the page numbering is present in footer</param>
/// <param name="drawFooterLine">A flag indicating if a line should be drawn at the top of the footer</param>
private void DrawFooter(WordToPdfConverter WordToPdfConverter, bool addPageNumbers, bool drawFooterLine)
{
    string footerImagePath = System.IO.Path.Combine(Application.StartupPath,
                @"DemoAppFiles\Input\Images\logo.jpg");

    // Set the footer height in points
    WordToPdfConverter.PdfFooterOptions.FooterHeight = 60;

    // Set footer background color
    WordToPdfConverter.PdfFooterOptions.FooterBackColor = Color.WhiteSmoke;

    // Set logo
    ImageElement headerImage = new ImageElement(5, 5, 100, 50, footerImagePath);
    WordToPdfConverter.PdfFooterOptions.AddElement(headerImage);

    // Add page numbering
    if (addPageNumbers)
    {
        // Create a text element with page numbering place holders &p; and & P;
        TextElement footerText = new TextElement(0, 30, "Page &p; of &P;  ",
            new System.Drawing.Font(new System.Drawing.FontFamily("Times New Roman"), 10, System.Drawing.GraphicsUnit.Point));

        // Align the text at the right of the footer
        footerText.TextAlign = HorizontalTextAlign.Right;

        // Set page numbering text color
        footerText.ForeColor = Color.Navy;

        // Embed the text element font in PDF
        footerText.EmbedSysFont = true;

        // Add the text element to footer
        WordToPdfConverter.PdfFooterOptions.AddElement(footerText);
    }
}
Licensing

Perpetual licenses, updates and support included for a year

The HTML to PDF Converter license (450 USD Deployment / 1200 USD Company) covers the Classic and the Next converter; the EVO PDF Toolkit (650 / 1400 USD) covers every component on this site, Classic tools included. The Company License includes redistribution.