Is it possible to perform Word to PDF conversion in Azure Environment in ASP.NET WebForms?
Yes, it is possible to perform Word document to PDF conversion in Azure Web sites using Essential® DocIO and PDF libraries.
Step 1:
Create an Azure web site project and refer the below Word document to PDF dependent assemblies on 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 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 Word document into PDF in 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
Note:
A new version of Essential® Studio® for ASP.NET is available. Versions prior to the release of Essential® Studio® 2014, Volume 2 will now be referred to as a classic versions.The new ASP.NET suite is powered by Essential® Studio® for JavaScript providing client-side rendering of HTML 5-JavaScript controls, offering better performance, and better support for touch interactivity. The new version includes all the features of the old version, so migration is easy.
The Classic controls can be used in existing projects; however, if you are starting a new project, we recommend using the latest version of Essential® Studio® for ASP.NET. Although Syncfusion® will continue to support all Classic Versions, we are happy to assist you in migrating to the newest edition.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls. If you have any queries or require clarifications, please let us know in the comments section below.
You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
Hi Brad,
We have also ensured the above given KB sample in Microsoft Azure Tools for Microsoft Visual Studio 2015-v2.9.5. So, kindly upgrade to Microsoft Azure Tools for Microsoft Visual Studio 2015-v2.9.5 which will resolve the issue at your end.
Regards,
Dilli babu.
Hi
We are in the process of moving an old ASP.net Web Forms system to Azure. An important part of this system is the need to generate and convert word documents to PDF.
I have been trying to do this in Azure with the new version (15.3.0.26) but still end up getting "A generic error occurred in GDI+" errors when the ConvertToPDF method executes. Below is my code. Am I doing something wrong?
Thank you
Dim wordDocument As Syncfusion.DocIO.DLS.WordDocument = Nothing
Select Case Extension.ToUpper().Trim()
Case "DOCX", "DOTX"
wordDocument = New Syncfusion.DocIO.DLS.WordDocument(ms, Syncfusion.DocIO.FormatType.Docx)
Case "DOC"
wordDocument = New Syncfusion.DocIO.DLS.WordDocument(ms, Syncfusion.DocIO.FormatType.Doc)
Case "DOT"
wordDocument = New Syncfusion.DocIO.DLS.WordDocument(ms, Syncfusion.DocIO.FormatType.Dot)
Case "RTF"
wordDocument = New Syncfusion.DocIO.DLS.WordDocument(ms, Syncfusion.DocIO.FormatType.Rtf)
Case Else
wordDocument = New Syncfusion.DocIO.DLS.WordDocument(ms, Syncfusion.DocIO.FormatType.Automatic)
End Select
wordDocument.ChartToImageConverter = New Syncfusion.OfficeChartToImageConverter.ChartToImageConverter()
Dim converter As New Syncfusion.DocToPDFConverter.DocToPDFConverter()
Dim document As PdfDocument = converter.ConvertToPDF(wordDocument)
Using ms2 As New MemoryStream
document.Save(ms2)
FileData = ms2.ToArray()
End Using
document.Close()