Last post May 14, 2008 08:09 AM by jdaelhousen
Apr 10, 2008 08:49 AM|jdaelhousen|LINK
I have a windows service running on a Windows 2000 server that opens up an instance of Microsoft Access 2000, saves an access report as a pdf file on the server, and then emails the pdf file to a group of users. Just recently, the section of the code that
creates the physical pdf file stopped working. The service code was written in vb.net and opens up an instance of MS Access using impersonation of a user that has appropriate rights on the server.
I have recreated this service code as a vb.net console app, and when executing the console .exe, the pdf file is created and everything works fine. However, when the service runs the same code, the following error is logged:
<< There was a problem retrieving printer information for the Win2PDF on PDFFILE:. The object may have been sent to a printer that is unavailable. >>
In this case, Win2PDF is the name of the pdf printer driver and PDFFILE: is the name of the port. I have narrowed down that the pdf driver seems to be working fine, as I can create a pdf file when running the console application. Also, the user that I
am using for impersonation purposes has not expired or anything like that, as the same service is sending out excel reports as this user. Just the ability to create pdf files seems to have gone away when the service executes the code.
Does anyone out there have any ideas as to what might have happened all of the sudden where the pdf file cannot be created?
Thanks in advance.
May 13, 2008 08:47 PM|akhangura|LINK
I want to do a similar kind of thing ie saving a sql server report as a pdf on the server using windows service and email to a group of users. Can you please send me the code for what you have done so that I get an idea about how to do this in .net ?
May 14, 2008 08:09 AM|jdaelhousen|LINK
I am not able to send you any code as I am contractually obligated to keep the code for my client projects confidential.
However, the route you want to go is using a pdf driver to stream text to a file using the system.IO namespace (you are creating the physical file on the server somewhere. You can delete the file afterwards). You'll know the location of this file and can
then use the .net system.web.mail namespace for emailing purposes. Windows services is a pretty broad topic for a message thread. I would suggest digging up knowledge base articles or buying a book on how to put one of these together.