I’m a newbie of this forum. I’ve encountered problem to manage the AS/400 device printer with .NET framework
I’ve created an application with composer to have a simple terminal on intranet, after I’ve enabled a printer and, using template for instant screen, I’ve tried to connect printer device to my run_printlet.aspx page.
The device seems to be connected, but no document was print.
Following my page “run_printlet.aspx”

		<a>Nascondi Stampante</a> | 
		     <!-- <gx>    --> 
                Shared p As New GXPrinter
                Protected Sub btnConferma_Click(ByVal sender As Object, ByVal e As System.EventArgs)
                    Dim prnObj As GXPrintObject()
                    p.setApplicationParm(GXPrinterSessionConstants.GX_APPLICATION_PARM_DEVICE_NAME, txtPrinterDevice.Text)
                    'p.setApplicationParm(GXPrinterSessionConstants.GX_APPLICATION_PARM_DEVICE_TYPE, "IBM-3812-1")
                    p.setWaitCondition(GXPrinterSessionConstants.GX_WAIT_COND_PRINTER_READY, "", 0, 0, 0, 1000, 500)
                    If p.connect() <> 0 Then Response.Write("<br><b>ERRORE connect()</b><br>")
                    If p.attach() <> 0 Then Response.Write("<br><b>ERRORE attach()</b><br>")
                    Response.Write("<br>Stringa per cfg :  " + GXPrinterSessionConstants.GX_APPLICATION_PARM_DEVICE_NAME)
                    Response.Write("<br><b>Device :</b>" + p.getApplicationParm(GXPrinterSessionConstants.GX_APPLICATION_PARM_DEVICE_NAME) + "<br>")
                    'Response.Write("<br>Printer Buffer Vuoto ?  <b>" + prnObj.isEmpty().ToString() + "</b><br>")
                    'Response.Write("<br><b>Errore : " + prnObj.getErrorMessage.ToString() + "</b><br>")
                    Response.Write("<br>Device name impostato :  " + p.getApplicationParm(GXPrinterSessionConstants.GX_APPLICATION_PARM_DEVICE_NAME))
                    Response.Write("<br>Device Type impostato :  " + p.getApplicationParm(GXPrinterSessionConstants.GX_APPLICATION_PARM_DEVICE_TYPE))
                    Response.Write("<BR>Status : " + p.getPrinterStatus().ToString() + " - " + p.getErrorMessage().ToString() + "<br>")
                    'System.Threading.Thread.Sleep(5000)  ' dovrei aspettare un poco circa 5 sec
                    'Response.Write("<br><b>HO ASPETTATO 5 SEC.</b><br>")
                    p.setWaitCondition(GXPrinterSessionConstants.GX_WAIT_COND_END_OF_PRINT, "", 0, 0, 0, 10000, 500)
                    'If prnObj Is Nothing Then Response.Write("<b><br>Oggetto GXPrinterObject vuoto !!")
                    'GXPrinterControl1.deviceName = txtPrinterDevice.Text
                End Sub
                Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
                    Dim prnobj As GXPrintObject
                    p.setWaitCondition(GXPrinterSessionConstants.GX_WAIT_COND_PRINTER_READY, "", 0, 0, 0, 1000, 500)
                    prnobj = p.getPrint()
                    If prnobj Is Nothing Then
                        Response.Write("<b><BR>Oggetto prnObj Vuoto ! </b><Br>")
                        Response.Write("<br>SeqNumber:" + prnobj.getSeqPrintNumber().ToString())
                        Response.Write("<br>Prelevato il file ? <br>")
                        Response.Write("<br> " + prnobj.isEmpty().ToString())
                    End If
                End Sub

Probably is not correct but documentation is not so clear about method and class use.

Someone could help me to solve this problem ?

Many thanks.

PS: Applinx version - Windows Server 2003 R2 - IIS 6.0

nobody use the printer device in applinx to print spool file ?

Could you help me ?

I’m in trouble.

Hi Henry,
I’m working on it and I hope I will have an answer for you by the end of the day.

Hi Asaf,
many thanks for your answer.
I’ve noticed another problem : when I set a device name with statement
"p.setApplicationParm(GXPrinterSessionConstants.GX_APPLICATION_PARM_DEVICE_NAME, txtPrinterDevice.Text) "
in applinx administrator the device name is set to the name of the as400 system, but the device is connected. In fact in AS400 with the command WRKDEVD I’ve checked the correct connection value.
I don’t understand this behavior.
Thanks for your help

Hi Henry,
Here is a working code for the printer:

   ''' <summary>
    ''' this method is used to print data from host
    ''' </summary>
    ''' <param></param>
    ''' <param></param>
    ''' <remarks></remarks>
    Protected Sub btnPrintFromHost_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        'printer object
        Dim printer As New
        Dim prnobj As

        'connect object to ApplinX
        printer.setApplicationParm(, txtPrinterDevice.Text) 'device from web-form
        'wait for printer ready
        printer.setWaitCondition(, "", 0, 0, 0, 60000, 0)

        'wait to finish printing *
        printer.setWaitCondition(, "", 0, 0, 0, 60000, 0)
        'TODO: * loop & wait for host to finish
        'get print
        prnobj = printer.getPrint()
        'check if object is empty
        If prnobj Is Nothing Then
            txtData.Text = "object is empty"
        End If
        'write object
        txtData.Text = prnobj.ToString()
        'TODO: parse returned data & write to output
    End Sub

Attached the complete file which consist from your code (we did some changes) and the code we added.
Please take a look at the changes we made and the code we add and consider working as close as you can to what we wrote.
We are also working on adding this code example to the user guide.
I hope this will be a good start for you,
Feel free to keep us update and ask more questions,
run_printlet.aspx (5.85 KB)

Hi Asaf,
thank you very much for your help :smiley: .
I’ll try your code tomorrow morning I send to you the result :mrgreen: .


Hi Asaf,
I’ve tested your code but I’ve made a little modification :

 'get print : need a cycle to get the spool 
    while prnobj Is Nothing  
        prnobj = printer.getPrint() 
    end while

I don’t know the reason to have a cycle like this.
I’ve modified the print of the buffer too :

'write object became 
        ' txtData.Text = prnobj.ToString() 
        txtData.Text = prnobj.getBuffer().ToString()

Without this little modification you will see only the reference to this object.
I’ve a lot of question about printing on As400 because my customer want a emulation template with a complete print system.
I’ve another question but this is more complicated. Can I use this forum to send this question ?

Thanks for your advance.

Hi Enrico,
First of all I’m very sorry about the delay in my answer,
I was consulting your issue with the guys here.
The Forum is a place to share thoughts, ideas, questions and so on, so you are more then welcome to ask anything (we even answered many non Applinx questions - we love to help). Of course that if we would think that there is a better place or way to answer your questions we will direct you there.

Regarding your issue it would be very helpful for us (in order to help you) to know what exactly you trying to accomplish.
Our original run_prinlet.aspx should give the answer for complete print system.
What was missing for you in the implementation there? What do you mean when you wrote: “a emulation template with a complete print system”?
Waiting for your replay,