Category / Section
Is it possible to perform Word to PDF conversion in Azure Environment in ASP.NET MVC application?
2 mins read
Yes, it is possible to perform Word document to PDF conversion in Azure websites using Essential® DocIO and PDF libraries.
Step 1:
Create an Azure website project and refer to the below Word document to PDF dependent assemblies in it.
- Syncfusion.Compression.Base.dll
- Syncfusion.OfficeChart.Base.dll
- Syncfusion.DocIO.Base.dll
- Syncfusion.DocToPDFConverter.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.OfficeChartToImageConverter.Wpf.dll
- Syncfusion.SfChart.WPF.dll
The following code example illustrates how to convert a Word document into a PDF document.
C#:
// Loading Word document
WordDocument document = new WordDocument(fileName, FormatType.Docx);
document.ChartToImageConverter = new ChartToImageConverter();
DocToPDFConverter converter = new DocToPDFConverter();
// Converts the Word document to PDF
PdfDocument pdf = converter.ConvertToPDF(document);
// Saves the PDF document
pdf.Save("WordtoPDF.pdf", Response, HttpReadType.Save);
document.Close();
VB:
' Loading Word document
Dim document As New WordDocument(stream, FormatType.Docx)
document.ChartToImageConverter = New ChartToImageConverter()
Dim converter As New DocToPDFConverter()
' Converts the Word document to PDF
Dim pdf As PdfDocument = converter.ConvertToPDF(document)
' Saves the PDF document
pdf.Save("WordtoPDF.pdf", Response, HttpReadType.Save)
document.Close()
Please make use of the below sample for converting a Word document into PDF in the Azure environment. This sample is created targeting Azure SDK 2.6.210 and Visual Studio 2015.
Sample link:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/SampleAspWebApp-108874911.zip