printing multi records on a page via SDK

Label printing integration (NiceWatch middleware and ActiveX programming interface)

Moderators: Georges, milos, NiceLabel Support Team

Post Reply
Kalthoff_Support
Valued Contributor
Posts: 26
Joined: Tue Sep 27, 2016 1:54 pm

printing multi records on a page via SDK

Post by Kalthoff_Support » Fri Jun 14, 2019 10:50 am

Hi,
we have a .NET-Application which prints labels with data from our MS-SQL-Server.
Now we have a request to print multiple record on one label (10x15 cm). So we defined the label as 10x3 with 5 labels per printer-page.
Printing via Excel works well, but the APP works like this: calling the passed SQL-Statement and print the label for each record (fields are filled by the APP)=> but instead of getting one page with 5 labels we get 5 pages with one label. How can we tell NL to collect the labels until page is filled ?

Code: Select all

                            sQRY = rsLoop.Fields("USER_SQL").Value
                            rs.Open(sQRY, cnnADO, CursorTypeEnum.adOpenKeyset, LockTypeEnum.adLockOptimistic)
                            While Not rs.EOF And Not bFehler
                                NL_Label = NL_PrintEngine.OpenLabel(LabelFileName)
                                For i = 0 To NL_Label.Variables.Count - 1 'alle Variablen auf Etikett
...
                                    NL_Label.Variables.Item(i).SetValue(Trim(rs.Fields.Item(j).Value))
                                Next 'i = alle Variablen auf Etikett (LabelGetVarCount)
                                NL_Label.PrintSettings.JobName = Path.GetFileNameWithoutExtension(LabelName)
                                NL_Label.Print(rsLoop.Fields("USER_EtikettAnzahl").Value)
                                rs.MoveNext()
                            End While
                            rs.Close()

Kalthoff_Support
Valued Contributor
Posts: 26
Joined: Tue Sep 27, 2016 1:54 pm

Re: printing multi records on a page via SDK

Post by Kalthoff_Support » Tue Jun 18, 2019 10:07 am

found a solution:
because there is no "label.close" to tell the engine that data has been finished, we had to look for a similar function ...
that could be done by using the SessionPrint which starts printing with ending the session:

Code: Select all

NL_SessionPrintRequest = NL_Label.StartSessionPrint() 
rs.Open(sQRY, cnnADO, CursorTypeEnum.adOpenKeyset, LockTypeEnum.adLockOptimistic)
While Not rs.EOF And Not bFehler
...
	NL_Label.SessionPrint(rsLoop.Fields("USER_EtikettAnzahl").Value, NL_SessionPrintRequest)
	rs.MoveNext()
End While
rs.Close()
NL_Label.EndSessionPrint(NL_SessionPrintRequest)

Post Reply