Print Page | Close Window

getprintername() question

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=1623
Printed Date: 28 Jan 26 at 10:35AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: getprintername() question
Posted By: quickpdf_learner
Subject: getprintername() question
Date Posted: 02 Nov 10 at 7:28PM
I am trying to get the printer name out of the web application and got different results.
My method is:

PDFLibrary qp = new PDFLibrary(Server.MapPath("~\\QuickPDFDLL0721.dll"));

if (qp.LibraryLoaded())

{

// Check the license key

if (qp.UnlockKey("XXXXXXXX") == 1)

{

string pn = qp.GetDefaultPrinterName();
 
}
 
 
1) publish to local, everything is fine.
2) publish to web server (windows server 2003, iis6), only get "Microsoft XPS Document Writer" as the result.
3) publish to web server (windows server 2008, iis7), receive error message: "NullReferenceException: Object reference not set to an instance of an object.]
   _Default.Page_Load(Object sender, EventArgs e) +229
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627"
 
Actually all the machines have the same default printer (which is not Microsoft XPS Document Writer).
 
Forgive me if I am dumb, I already searched the forum and didn't find any same questions.
 

 
 



Replies:
Posted By: Wheeley
Date Posted: 02 Nov 10 at 10:46PM
First, not knowing about how IIS is works, what I say next might be off base.  So in case you don't know, printers are user specific. So 2 different users on the same computer can have different printers and defaults installed. The reason I mention this is because it sounds like the service is using a different user than whoever is logged onto the computer. So, if a service uses "local system account" as its log on option, their is now way to set the printers for this user. Setting the log on option for the service to a user will allow access to that user's printers. But to get the printers for the currently logged on user will require working on the privilidges I believe.

I hope this helps somehow. At least you will better understand how printers work with services.
Wheeley
Ouch


Posted By: Dimitry
Date Posted: 03 Nov 10 at 1:43AM
GetDefaultPrinterName() should return default printer name and GetPrinterNames() - all installed printers.
Can you please check the following positions:
1. What version of Windows 2008 do you use: x86 or x64?
2. What is you system language?
3. Please make sure that library is loaded and can be properly accessed.
For example try to simply check qp.LibraryVersion(). If this causes an error, make sure that you use proper library path.
 
Hope to hear news from you soon.


-------------
Regards,
Dmitry


Posted By: quickpdf_learner
Date Posted: 03 Nov 10 at 12:42PM
1) local: windows 7 x86, web server: windows 2008 x86 (error seen), windows 2003 x86 (return "Microsoft XPS Document Writer" as default printer which is not).
2) System language: English.
3) Library is loaded well cause other methods work fine.
 
Thanks, I wll check as what Wheeley said.
 


Posted By: quickpdf_learner
Date Posted: 04 Nov 10 at 4:20PM
I have to bring up another question. How to use NewCustomPrinter(string printername)?
 
For example, the printer name I want to use is file://%5C%5Cabc%5CIT%20HP%20M100 - \\abc\IT HP M100  (I get it by using GetPrinterNames method), I get a long string like "F5C4BC4E2DA9D72F39144815BA862ABC" after I pass it to the method.
 
Any help is appreciated.


Posted By: quickpdf_learner
Date Posted: 04 Nov 10 at 8:56PM
Some progress:
This works for server 2003 with iis6, while still doesn't work for server 2008 with iis7.
 
 
Originally posted by quickpdf_learner quickpdf_learner wrote:

I have to bring up another question. How to use NewCustomPrinter(string printername)?
 
For example, the printer name I want to use is file://%5C%5Cabc%5CIT%20HP%20M100 - \\abc\IT HP M100  (I get it by using GetPrinterNames method), I get a long string like "F5C4BC4E2DA9D72F39144815BA862ABC" after I pass it to the method.
 
Any help is appreciated.


Posted By: Dimitry
Date Posted: 08 Nov 10 at 2:18PM
Originally posted by quickpdf_learner quickpdf_learner wrote:

I have to bring up another question. How to use NewCustomPrinter(string printername)?
 
For example, the printer name I want to use is file://%5C%5Cabc%5CIT%20HP%20M100 - \\abc\IT HP M100  (I get it by using GetPrinterNames method), I get a long string like "F5C4BC4E2DA9D72F39144815BA862ABC" after I pass it to the method.
 
Any help is appreciated.
 
NewCustomPrinter() returns a formal printer name that can be used with such functions as SetupCustomPrinter() and PrintDocument().
"F5C4BC4E2DA9D72F39144815BA862ABC" - looks like a valid custom printer name.


-------------
Regards,
Dmitry


Posted By: quickpdf_learner
Date Posted: 08 Nov 10 at 2:46PM
Thank you, Dimitry.
 
I think I found a workaround. Since I am testing the same network printer on different servers, I use the long string  "F5C4BC4E2DA9D72F39144815BA862ABC" generated from server 2003 iis 6 and passed it to printdocument() method on server 2008 iis7, it did work fine!
 
 
Originally posted by Dimitry Dimitry wrote:

Originally posted by quickpdf_learner quickpdf_learner wrote:

I have to bring up another question. How to use NewCustomPrinter(string printername)?
 
For example, the printer name I want to use is file://%5C%5Cabc%5CIT%20HP%20M100 - \\abc\IT HP M100  (I get it by using GetPrinterNames method), I get a long string like "F5C4BC4E2DA9D72F39144815BA862ABC" after I pass it to the method.
 
Any help is appreciated.
 
NewCustomPrinter() returns a formal printer name that can be used with such functions as SetupCustomPrinter() and PrintDocument().
"F5C4BC4E2DA9D72F39144815BA862ABC" - looks like a valid custom printer name.


Posted By: Dimitry
Date Posted: 08 Nov 10 at 2:52PM

Glad to hear that you found the solution.

So using NewCustomPrinter() helped you with PrintDocument() on server 2008 IIS7?

-------------
Regards,
Dmitry


Posted By: quickpdf_learner
Date Posted: 12 Nov 10 at 2:35PM
Yes, and it works fine if you define the printer as //printerservername/printername.
 
Originally posted by Dimitry Dimitry wrote:

Glad to hear that you found the solution.

So using NewCustomPrinter() helped you with PrintDocument() on server 2008 IIS7?



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