Convert DOCX to PDF in C# using PDF Metamorphosis .Net

PDF Metamorphosis .Net

.Net assembly which gives API to convert RTF, Text, HTML, DOCX to PDF in .Net and C#.
Convert DOCX to PDF in C# using PDF Metamorphosis .Net

PDF Metamorphosis .Net

Convert DOCX to PDF in C# using PDF Metamorphosis .Net
Convert DOCX to PDF in C# using PDF Metamorphosis .Net

Introduction

Let's see how to add "DOCX to PDF feature" into any .NET application. First of all, to give your .NET application ability to convert DOCX documents to PDF, add a reference to the "PdfMetamorphosis.dll" assembly.


            SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();

            string docxPath = @"c:\The Master and Margarita.docx";
            string pdfPath = @"c:\The Master and Margarita.pdf";

            p.DocxToPdfConvertFile(docxPath, pdfPath);
          

The docx to pdf conversion method is available starting from .NET Framework 4.0 and higher. We recommend you to use the PdfMetamorphosis.dll compiled for the latest .NET. During conversion to PDF you may adjust following:

  • Set page size, orientation and margins.
  • Set a single font face, size and color for your PDF document.
  • Add custom headers and footers.
  • Add page numbering.
  • Add custom watermarks to your PDF.
  • Specify the version of produced PDF.
  • Embed all fonts inside PDF.

Download

To see this functionality firsthand, download the freshest «PDF Metamorphosis .Net» with code examples, 28.8 Mb.

Limitations

PDF Metamorphosis .Net The limitations of the free version are: The trial notice "Created by unlicensed version of PDF Metamorphosis .Net" and the random addition of the word "TRIAL".


Input DOCX documents

The component has own DOCX parser. If you are looking only for C# DOCX class which can parse and render DOCX documents, see Document .Net.


Some examples to convert DOCX to PDF in C# and VB.NET

SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();
            if (p != null)
            {
                string docxPath = @"d:\Notes from Underground.docx";
                string pdfPath = Path.ChangeExtension(docxPath, ".pdf");

                int result = p.DocxToPdfConvertFile(docxPath, pdfPath);

                if (result==0)
                    System.Diagnostics.Process.Start(pdfPath);
            }

      
2. Convert DOCX to PDF in memory using VB.NET:
Dim p As New SautinSoft.PdfMetamorphosis()
            If p IsNot Nothing Then
                Dim docxPath As String = "d:\Lolita.docx"
                Dim pdfPath As String = Path.ChangeExtension(docxPath, ".pdf")
                Dim docxBytes() As Byte = File.ReadAllBytes(docxPath)

                Dim pdfBytes() As Byte = p.DocxToPdfConvertByte(docxBytes)

                If pdfBytes IsNot Nothing Then
                    File.WriteAllBytes(pdfPath, pdfBytes)
                    System.Diagnostics.Process.Start(pdfPath)
                Else
                    System.Console.WriteLine("An error occurred during converting DOCX to PDF!")
                End If
            End If
      

Requirements and Technical Information

Requires .NET Framework 4.0 or higher. Our product is compatible with all .NET languages and supports all Operating Systems where .NET Framework and .NET Core can be used. Note that PDF Metamorphosis .Net is entirely written in managed C#, which makes it absolutely standalone and an independent library.

.Net Framework 4.0 and higher and .Net Core 2.0 and higher

.NET Framework 4.5, 4.6.1 and higher.

.NET Standard 2.0

.NET Core, .NET 5.0 and higher.


Multi-platform component, runs on:


Our component has proven itself on cloud platforms and services:

  • Microsoft Azure
  • Amazon Web Services (AWS)
  • Google Cloud Platform
  • SharePoint
  • Docker
  • Xamarin Forms
  • etc.