Is it possible to perform Word document to Pdf conversion using DocIO in Windows Service?
What is the usage of Windows Service?
Windows services are normally used when an application needs to continuously run. A Windows Service will run even if no-one is logged on. Windows service can start running as soon as the machine is powered up, which makes ideal for running as a server, http server for example. No one is required to login.
Windows services has the following features.
- Don’t need to have a session running. This is good for security, and also reduces overhead on the server.
- We shall make use of some management commands like Start, Stop, Pause and Continue.
- We shall also handle server events such as shutdown.
Please refer the below MSDN link to know about how to create a Windows service application.
MSDN link:
https://msdn.microsoft.com/en-us/library/zt39148a%28v=vs.110%29.aspx
Is it possible to perform Word document to Pdf conversion using DocIO in Windows Service?
Yes, it is possible to convert a Word document as Pdf using Windows service.
We have prepared a sample to illustrate how to perform Word document to Pdf conversion using Windows Service. In this we have created a static method with the below code for Pdf conversion and called this in OnStart event.
C#:
private static void PDFConvertor() { try { //Opens the input document WordDocument document = new WordDocument("inputFilePath"); DocToPDFConverter conv = new DocToPDFConverter(); //Converts the document as Pdf PdfDocument pdf = conv.ConvertToPDF(document); //Saves the Pdf document pdf.Save("outputFilePath"); } catch (Exception exception) { //Exception message } }
VB:
Private Shared Sub PDFConvertor() Try 'Opens the input document Dim document As New WordDocument("inputFilePath") Dim conv As New DocToPDFConverter() 'Converts the document as Pdf Dim pdf As PdfDocument = conv.ConvertToPDF(document) 'Saves the Pdf document pdf.Save("outputFilePath") 'Exception message Catch exception As Exception End Try End Sub
Please refer the below sample which demonstrates Word to Pdf conversion using Windows service.
Sample