Selecting a printer by IP Address

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

KarlR69
User
Posts: 14
Joined: Tue Sep 24, 2013 2:27 pm

Selecting a printer by IP Address

Post by KarlR69 »

I am trying to select a printer before printing a PDF file using PDF-XChange Viewer. I have modified the sample app and this works when I use the locally-named printer on my computer. However, if I try use the IP address of the printer, I get an "Invaid pages range" error. This is my current code:

Code: Select all

        'Set printer name
        Try
            Dim bsVerb As String = "Print.PrinterName"
            Dim vDataIn As String = ""
            'vDataIn = "OFFICEPRINTER1" 'This works
            vDataIn = "http://172.100.2.67" 'This causes an "Invalid pages range" error.

            AxCoPDFXCview1.SetProperty(bsVerb, vDataIn, 0)
        Catch ex As Exception
            MsgBox("Error setting PrinterName: [" & ex.Message.ToString & "]")
        End Try
I had to add the "http://" to the address, or it came back with an "invalid printer name" error. I am attempting to develop this so that any user of my app can print to any network printer (even if that printer is not installed locally on their computer). Printer names can vary on each computer, so I thought using the IP address might be a better method. Other than this problem, the XChange Viewer is handling all of my issues and I am looking forward to implementing this ASAP.

Please let me know if you need further details. I would appreciate any suggestions anyonce could give me!

Thanks,
Karl
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: Selecting a printer by IP Address

Post by Vasyl - PDF-XChange »

Hi, Karl.

I understand you but looks like that system's OpenPrinter() fails when you pass something like "http://172.100.2.67" or "172.100.2.67" as printer name. It always returns ERROR_INVALID_PRINTER_NAME for such names. The correct name must be a name of installed printer - local printer or remote print-server, doesn't matter. Some printers may have different drivers (ex: Regular, PCL etc) and OpenPrinter() must known exactly what driver should be used for print-session. It can be specified only by printer name..

As idea for you - before printing pdf you may use system's EnumPrinters(), get info about all existing printers (get name, serverName(IP?), port, driverName, etc) and translate using this info the your input printer-IP to 'normal' printer name and pass this name to our pdf-control...

Best
Regards.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
KarlR69
User
Posts: 14
Joined: Tue Sep 24, 2013 2:27 pm

Re: Selecting a printer by IP Address

Post by KarlR69 »

Hi Vasyl,

Thanks for your prompt reply and information. I understand now that this must be an installed printer, but how can you use a remote print-server? Sorry to demonstrate my ignorance, but that is something I am not familiar with. I tried installing a printer on a test server and calling it from my computer. However, since all printer names with a url are invalid, I got the same error when I tried "\\servername\serverprintername".

Thanks again for your support,
Karl
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: Selecting a printer by IP Address

Post by Ivan - Tracker Software »

If your printer is connected to one machine (say, SERVER) and you want to print on this printer from another machine (CLIENT), you have to share this printer on the SERVER and add this printer on your CLIENT machine.
Then you have to pass name of newly created printer to the function.
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
KarlR69
User
Posts: 14
Joined: Tue Sep 24, 2013 2:27 pm

Re: Selecting a printer by IP Address

Post by KarlR69 »

Ivan - Thanks for that clarification. I think I understand now, and I will post back if I have further issues.

Thanks for getting back to me,
Karl
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: Selecting a printer by IP Address

Post by Stefan - PDF-XChange »

:)