Printing Mulitple Label S’abonner

0
Avatar
Legacy Poster

I'm using the following code to print a Bartender Label, when I do the first call

 

PrintLabels("Master.btw", "Nitro PDF Creator (Pro 8)")

 

the label prints normally, when I do the second call the label doesn't print at all.  Stepping through the code I don't see a reason why the second label doesn't print.

 

Private Sub PrintLabels(ByVal fmtLabel As String, ByVal PrinterName As String)
        Try
            Using btEngine As New Engine()
                ' Start the BarTender print engine.
                btEngine.Start()

                ' Open a label.
                Dim btFormat As LabelFormatDocument = btEngine.Documents.Open(fmtLabel, PrinterName)

                ' Print the format.
                btFormat.Print()

                ' Close label when done
                btFormat.Close(SaveOptions.DoNotSaveChanges)

                ' Stop the BarTender print engine.
                btEngine.Stop()

            End Using
        Catch ex As PrintEngineException
            MessageBox.Show("Error Printing Label: " + vbCrLf + vbCrLf + ex.Message, "Print Label", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

    End Sub

 

 

 

 

 

 

dsfsdfs

6 commentaires

0
Avatar
Domingo Rodriguez
Modérateur
Actions pour les commentaires Permalien

Ddavis,

 

What  exact Edition, version and build of BarTender do you own?

 

If you try printing to a physical printer rather than PDF creator, does the same issue still exist?

 

Once you finish calling the PrintLabels() function, if you open the Windows task manager and show processes from all users, do you still see a "bartend.exe" process running somewhere, or has it been stopped correctly? What happens when you try the second print, is a new "bartend.exe" process started?

 

In any case, you shouldn't be starting and stopping the BT engine for each print job that you wish to perform. You would start the BT engines when your application (or the print module) starts, and only stop it when exiting the application (or the print module). Further optimizations you could implement is to also load the BarTender documents in memory and making the BT documents active at print time rather than having to open them again (this is called document caching).

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

Domingo,

 

We are using BT Automation v10.4 SR4.

 

Printing to a physical printer does the same thing.  The bartend.exe process stays open until the btengine.Stop() function is called.  When I try a second print the bartend.exe process is not started.

 

I can move the start and stop functions with no problem, as far as caching the documents, is that as simple a multiple "open" calls.  How do you make a document active (I can't find the SDK documentation)

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

Domingo,

 

I ran the 2nd print with the messages option and this is what I got

 

Category = Database

ID 3239

Severity = Error

Text = OleDB has encountered error 0x80040E14: Unknown error.

OleDB error message: IDispatch error #3092

Source = Bartender

0
Avatar
Domingo Rodriguez
Modérateur
Actions pour les commentaires Permalien

1. Do you've the same problems when running any of our .NET Print SDK examples, which you can find via "All Programs > BarTender v10.1 > BarTender .NET SDKs"?

 

2. It seems strange to me that an OLE DB message is logged for the 2nd print when the BT process didn't even manage to start... Do you get this message as well if you just start BarTender the first time and then print?

 

3.  In order to make a BarTender document active, you would use the LabelFormatDocument.Activate Method from the Seagull.BarTender.Print namespace.

 

4. BTW, what do you need to do in order to allow a BarTender process to be started again? Do you just close and reopen your .NET SDK application?

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

Domingo,

 

It turns out the OLEDB error was due to underlying query missing some fields, once I added the fields back into the query the second label printed normally.

 

No I don't need to close and reopen my program to restart the Bartender process, the btengine.close() function stops the BarTender process.

0
Avatar
Domingo Rodriguez
Modérateur
Actions pour les commentaires Permalien

Good to know that the problem is solved

Vous devez vous connecter pour laisser un commentaire.