Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
getprintername() question |
Post Reply
|
| Author | ||
quickpdf_learner
Beginner
Joined: 15 Oct 10 Status: Offline Points: 13 |
Post Options
Thanks(0)
Quote Reply
Topic: getprintername() questionPosted: 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.
|
||
![]() |
||
Wheeley
Senior Member
Joined: 30 Oct 05 Location: United States Status: Offline Points: 146 |
Post Options
Thanks(0)
Quote Reply
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 ![]() |
||
![]() |
||
Dimitry
Team Player
Joined: 18 Feb 10 Status: Offline Points: 37 |
Post Options
Thanks(0)
Quote Reply
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 |
||
![]() |
||
quickpdf_learner
Beginner
Joined: 15 Oct 10 Status: Offline Points: 13 |
Post Options
Thanks(0)
Quote Reply
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.
|
||
![]() |
||
quickpdf_learner
Beginner
Joined: 15 Oct 10 Status: Offline Points: 13 |
Post Options
Thanks(0)
Quote Reply
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 \\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.
|
||
![]() |
||
quickpdf_learner
Beginner
Joined: 15 Oct 10 Status: Offline Points: 13 |
Post Options
Thanks(0)
Quote Reply
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.
|
||
![]() |
||
Dimitry
Team Player
Joined: 18 Feb 10 Status: Offline Points: 37 |
Post Options
Thanks(0)
Quote Reply
Posted: 08 Nov 10 at 2:18PM |
|
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. Edited by Dimitry - 08 Nov 10 at 2:18PM |
||
|
Regards,
Dmitry |
||
![]() |
||
quickpdf_learner
Beginner
Joined: 15 Oct 10 Status: Offline Points: 13 |
Post Options
Thanks(0)
Quote Reply
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!
|
||
![]() |
||
Dimitry
Team Player
Joined: 18 Feb 10 Status: Offline Points: 37 |
Post Options
Thanks(0)
Quote Reply
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 |
||
![]() |
||
quickpdf_learner
Beginner
Joined: 15 Oct 10 Status: Offline Points: 13 |
Post Options
Thanks(0)
Quote Reply
Posted: 12 Nov 10 at 2:35PM |
|
|
Yes, and it works fine if you define the printer as //printerservername/printername.
|
||
![]() |
||
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store