Articles in this section
Category / Section

Is it possible to perform Word document to Pdf conversion using DocIO in Windows Service?

1 min read

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 services can start running as soon as the machine is powered up, which makes them ideal for running as a server—for example, an HTTP server. No one is required to log in.

Windows services have 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 to the below MSDN link to learn 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 to PDF using a Windows service.

We have prepared a sample to illustrate how to perform Word document to PDF conversion using a Windows Service. In this, we have created a static method with the below code for PDF conversion and called this in the OnStart event.

C#:

private static void PDFConvertor()
{
    try
    {
        // Opens the input document
        WordDocument document = new WordDocument("inputFilePath");               
        DocToPDFConverter conv = new DocToPDFConverter();
        // Converts the document to 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 to PDF
        Dim pdf As PdfDocument = conv.ConvertToPDF(document)
        ' Saves the PDF document
        pdf.Save("outputFilePath")
                 
    Catch exception As Exception
        ' Exception message
    End Try
End Sub

Please refer to the below sample which demonstrates Word to PDF conversion using a Windows service.
Sample

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied