[Print PDF file by Network Printer] Printer name is invalid

Forge Component
(5)
Published on 2019-04-02 by Salman Ansari
5 votes
Published on 2019-04-02 by Salman Ansari

Hi,

I'm trying to use this component, but keep getting the following error:

An exception occurred while creating the PrintServer object. Win32 error: The printer name is invalid.


These are the inputs I'm passing:

PathOnDiskToCreatePDF: a valid path, because I have access to it and managed to write a file to it (so probably not relevant for this error)

PrinterServerName: my local IP address at home (also tried prefixing it with "\\", but to no avail)

PrinterName: the share name of the printer as it appears in my local network at home

PDFFileData: some random PDF file (probably not relevant for this error)


Am I using the wrong inputs for the PrinterServerName or PrinterName? 


Any insight would be much appreciated.

Kind regards,

Artuur

Hi Artuur,

Are you passing below correct values to extension method also please check the read/write permission on path "PathonDiskToCreatePDF" in server

Hi Salman,

Thank you for your speedy reply. An example of what I'm passing to the PathOnDiskToCreatePDF input parameter is "D:\User\binaries\NetworkPrinter.pdf". This is similar to the path used in the HTML to PDF component on the forge where a temporary file also needs to be stored. I believe we have the correct permissions, because before I was using another path and was getting an error saying that access to the path was denied. But while using this path, that error no longer occurs.

I see you have attached a screenshot of example inputs to the forge component, but the images are rather small, so I couldn't zoom in enough to see if I perhaps made a mistake in the structure of the inputs.

Do you perhaps have an example of valid inputs to the 4 inputs or a sample oml I could look at to see if I spot any differences with my code?

Kind regards,

Art

Artuur De Maeyer wrote:

Hi Salman,

Thank you for your speedy reply. An example of what I'm passing to the PathOnDiskToCreatePDF input parameter is "D:\User\binaries\NetworkPrinter.pdf". This is similar to the path used in the HTML to PDF component on the forge where a temporary file also needs to be stored. I believe we have the correct permissions, because before I was using another path and was getting an error saying that access to the path was denied. But while using this path, that error no longer occurs.

I see you have attached a screenshot of example inputs to the forge component, but the images are rather small, so I couldn't zoom in enough to see if I perhaps made a mistake in the structure of the inputs.

Do you perhaps have an example of valid inputs to the 4 inputs or a sample oml I could look at to see if I spot any differences with my code?

Kind regards,

Art

Hi Art,

1.As you said not getting now permission issue so looks good but I prefer other than C drive

2.You can try to Print any "Testpage" using notepad from your LAN printer to check whether you printer working or not (make sure we have paper in printer tray)
3.Please see below screen shot


Hi Salman,

Thank you for your reply. The printer is working, so it must be something in the request.

Can I ask where you get your values for PrinterServerName and PrinterName? 

Is PrinterServerName: "\\" + <the IP address of your network at home>?

Is PrinterName: <(for Windows 10) Settings -> Devices -> Printers &Scanners -> Click Printer -> Manage -> Printer Properties -> Sharing -> Share Name>? 

Artuur De Maeyer wrote:

Hi Salman,

Thank you for your reply. The printer is working, so it must be something in the request.

Can I ask where you get your values for PrinterServerName and PrinterName? 

Is PrinterServerName: "\\" + <the IP address of your network at home>?

Is PrinterName: <(for Windows 10) Settings -> Devices -> Printers &Scanners -> Click Printer -> Manage -> Printer Properties -> Sharing -> Share Name>? 


PrinterName-This is the name of the Printer that will appear in LAN OR when you are trying to print any document then you need to select that printer to print the page.

PrinterServerName-IP of the printer that deployed on LAN using this IP.



Thanks Salman,

This is what I am seeing at the moment:

I would like to print to the first printer. I think only the printer name is shown, since it is not controlled by a printer server, just connected to the wifi network. Does your component also work in this example?

Artuur De Maeyer wrote:

Thanks Salman,

This is what I am seeing at the moment:

I would like to print to the first printer. I think only the printer name is shown, since it is not controlled by a printer server, just connected to the wifi network. Does your component also work in this example?

Printer should deployed on LAN using on server IP/Host Name