How to create PDF from a Windows service?
To create PDF from a Windows service:
- In the Visual Studio, choose File->New->Project.
- In the list of Visual C# project templates, choose Windows Service and name the Project, for example, MyPdfService, and then click ok.
- In the solution explorer, rename the service1.cs to PdfService.cs.
- PdfService.cs contains two default functions, OnStart() and OnStop(). Write the appropriate codes for these two functions. The following code example shows how to merge a PDF document in the Windows Services.
- In the solution explorer, right click the PdfService.cs and choose View Designer. Now, the designer window is opened.
- Right Click the Designer window and choose AddInstaller. By default, a component class that contains two installers is added to your project. The component’s name is ProjectInstaller.
- In the design view of the ProjectInstaller, choose serviceInstaller1 in the property window, and set the ServiceName as PdfService.
- In the design view of the ProjectInstaller, choose ServiceProcessInstaller1. In the property window, set the Account property as LocalSystem.
Installing the service:
- Run the Visual Studio Developer Command Prompt as the Administrator.
- In the command Prompt window, navigate the folder that contains your project bin file. For example, visual studio 2012\Projects\MyPdfService\bin\Debug.
- Then enter the following command: installutil.exe MyPdfService.exe
Now, the service is installed successfully.
Start the Service:
- Open administrative tools and choose services. You should see PdfService in the services window.
- In the services window, right click the PdfService and select start. Now, the Windows Service is started.
Uninstalling the service:
Enter the following command for the Visual Studio Developer Command Prompt: installutil.exe /u MyPdfService.exe
Now, the service is uninstalled.
Last Revised Date: