News Category

C#, VB.NET Convert Word to PDF in Azure Apps

2021-06-01 09:17:56 Written by  support iceblue
Rate this item
(22 votes)

It is possible to perform Word to PDF conversion in Azure apps such as Azure Web apps and Azure Functions apps using Spire.Doc for .NET. In this article, you can see the code example to achieve this function with Spire.Doc for .NET.

The input Word document:

C#, VB.NET Convert Word to PDF in Azure Apps

Step 1: Install Spire.Doc NuGet Package as a reference to your project from NuGet.org.

C#, VB.NET Convert Word to PDF in Azure Apps

Step 2: Add the following code to convert Word to PDF.

C#
//Create a Document instance
Document document = new Document(false);
//Load the Word document
document.LoadFromFile(@"sample.docx");

//Create a ToPdfParameterList instance
ToPdfParameterList ps = new ToPdfParameterList
{
    UsePSCoversion = true
};
//Save Word document to PDF using PS conversion
document.SaveToFile("ToPdf.pdf", ps);
VB.NET
Private Sub SurroundingSub()
    Dim document As Document = New Document(false)
    document.LoadFromFile("sample.docx")
    Dim ps As ToPdfParameterList = New ToPdfParameterList With {
        .UsePSCoversion = True
    }
    document.SaveToFile("ToPdf.pdf", ps)
End Sub

The Output PDF document:

C#, VB.NET Convert Word to PDF in Azure Apps

Additional Info

  • tutorial_title:
Last modified on Monday, 14 November 2022 06:27