Search code examples
c#pdfserverprinters

How to configure Text to PDF programe as Printer in Server 2012 to be used on server for creating PDF's


My goal is to have a C# web forms app on Server 2012 R2 that converts text (and a picture) to PDF and sends it to a client. I have all of the code, just need to set up the printer correctly. The printer (PDF programe) has to be accesible via client-side browser (it sends the request, server creates the PDF with printer and sends it to client).

Whatever I try, the result is:

Unable to determine the application folder of the printer '\server-name\Win2PDF'. Reinstalling the printer using the setup program may fix the problem.

First step is to chose a free Text to PDF programe that works on Server 2012 R2 (because Microsoft Print to PDF doesn't for some reason). The only place my programe mentions the PDF programe is choosing printer name in code:

"PdfSettings.PrinterName = Win2PDF;".

Options so far:

  • Win2PDF - Best so far. Only adds an extra blank page to the document (acceptable).

  • CutePDF - Doesn't support .NET

  • bioPDF - Red watermark on the bottom

  • PDFsharp - I'd have to implement document-creating logic all over again (a lot of work)

  • Spire.PDF - Free trial

  • Win10PDF - Free trial, watermark

Second, I go to Print Managment, Print Servers, Printers, then choose the installed programe (Win2PDF), Properties:

  • Sharing: check "Share this printer"
  • Ports: not sure what to select so I enabled printer spooling and also checked an Standard TCP/IP Port (that i created earlier)
  • Security: I made sure every user there has permission to Print.

When I right click Win2PDF and go to List in directory I get:

The selected printer cannot be published. The directory service is unavalible.

I'm not sure what to do with Deploy with Group Policy.

I also enabled Branch Office Direct Printing for the hell of it.

Third, I made sure Printer Spooler is running. When I go to /System32/spool/PRINTERS I see an empty folder, is that a problem? Some people suggest trying to delete the contents of the PRINTERS folder, but I can't delete nothing. Also, after I installed the Spooling feature the article said to go to Server Manager, Print Services and see if Spooling is on the list (like this) and it's not on my list! Is that a problem?

I have no idea what's wrong or what to try next. Please help!


Solution

  • The answer is trying a different approach. I shouldn't have tried working with the virtual printer (i haven't found a way to make it work).

    To create a PDF from code, the best way is using iTextSharp.dll. With that you need a handful of code (not much, but you got to know what you're doing).