Print Page | Close Window

Not able to print PDF from a windows service

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1345
Printed Date: 08 May 24 at 6:05AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Not able to print PDF from a windows service
Posted By: Garima.Arya
Subject: Not able to print PDF from a windows service
Date Posted: 15 Feb 10 at 6:43AM


Hi,

I am using trial version of Quick PDF Library to print PDF files from a .net 3.5 windows service running on 64 bit window server 2008 machine.

I have written following code to do so:

// Create an instance of the class and give it the path to the DLL
PDFLibrary qp
    = new PDFLibrary(ConfigurationManager.AppSettings["QuickPDFLibraryPath"]);
// Check if the DLL was loaded successfully
if (qp.LibraryLoaded())
{
    // Include and check the validity of the license key
    if (qp.UnlockKey(ConfigurationManager.AppSettings["QuickPDFLibraryKey"]) == 1)
    {
        qp.LoadFromFile(fileName);
        int printOptions = qp.PrintOptions(1, 0, "");
        string printerName = ConfigurationManager.AppSettings["PrinterName"];
        int pageCount = qp.PageCount();
        qp.PrintDocument(printerName, 1, pageCount, printOptions);
    }
}

This code works fine on our dev and QA environment. But when I tried to run it on one of our client machines (I just wanted to ensure that it works there before asking my client to buy this tool), it was not working. It was neither giving any error nor firing the print command on the printer.

Please help.

Thanks,
Garima




Replies:
Posted By: Ingo
Date Posted: 16 Feb 10 at 6:27AM
Hi Garima!

Perhaps there are few specialities with the printer name on the client machine?
Are you sure using the correct name?
Quotations, spaces, ... there can be many problems.
Check which are the accessable printers in the environment with QP.GetPrinterNames().
Check what's the name of the standard printer with QP.GetDefaultPrinterName().

Cheers, Ingo



Posted By: Garima.Arya
Date Posted: 16 Feb 10 at 8:25AM

Thanks Ingo...

I checked the printer name and it is same as the one returned by GetPrinterNames() method.

I forgot to mention few points that might give you more insight into the problem.
1) I am using a network printer
2) This method works fine from Windows application.
3) On running this method from Windows service, it gets struck indefinitely (I even waited for more than an hour) while executing the following statement:
qp.PrintDocument(printerName, 1, pageCount, printOptions);
I have to restart the service after this call.

Thanks,
Garima



Posted By: Ingo
Date Posted: 16 Feb 10 at 2:39PM
Hi Garima!

Read this:
http://www.quickpdf.org/forum/printocument-fails_topic1068_post5003.html?KW=printer+server#5003
Perhaps it helps.
Try the advanced searchfunctionality above. You'll find a lot regarding your case.

Cheers, Ingo


Posted By: Garima.Arya
Date Posted: 17 Feb 10 at 9:55AM

Thanks Ingo....I went through the link provided by you. It talks about following problems:

1) Problem while printing large document file. Note that I am trying to print pdf document containing 1 page only.

2) Problem in printing while printer is in spooling mode. This could be the reason but when we tried to test it, printer was not doing any other processing.
 
However, I would definitly like to implement and test this approach. If possible, please send me the code snippet to do so using c#.
 
I have also gone through all the thread that have been created so far for "PrintDocument" and "print pdf" related issues. But I couldnot find any solution/pointer. Please direct me if you are talking about any specific thread.
 
Thanks,
Garima



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk