Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save groupdocs-com-kb/3b3a86b66ec103d4d686a3d4c6ce8aaa to your computer and use it in GitHub Desktop.
Save groupdocs-com-kb/3b3a86b66ec103d4d686a3d4c6ce8aaa to your computer and use it in GitHub Desktop.
How to Convert Word to PDF using C#. For more information, please follow link: https://kb.groupdocs.com/conversion/net/how-to-convert-word-to-pdf-using-csharp/
using System;
using GroupDocs.Conversion.Options.Convert;
namespace ConvertWordToPdfUsingCSharp
{
class Program
{
public static void Main(string[] args) // Main function to convert Word to PDF using C#
{
// Remove the watermark in output PDF by adding license
string licensePath = "GroupDocs.Conversion.lic";
GroupDocs.Conversion.License lic = new GroupDocs.Conversion.License();
lic.SetLicense(licensePath);
// Load the source Word file for conversion to PDF
var converter = new GroupDocs.Conversion.Converter("sample.docx");
// Set the convert options for the output PDF
var convertOptions = new PdfConvertOptions();
// Convert and save the DOCX in PDF format
converter.Convert("converted.pdf", convertOptions);
Console.WriteLine("Done");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment