Problem With Checking Print Result フォローする

0
Avatar
Legacy Poster

Hello.

 

I have problem with checking print result.

 

Code:

 

if (labelFormat.Print("Label for " + txtPN.Text, out mess) == Seagull.BarTender.Print.Result.Success)
{
   // Save last serial number to DB
}
else
{
    MessageBox.Show("Not printed");
}

 

 
(labelFormat is defined as: Seagull.BarTender.Print.LabelFormatDocument labelFormat = btEngine.Documents.Open(file); )
 
Problem: The label is printed sucessfully but MessageBox is showed.
 
How to properly check whether the label is successfully printed?
 
 
I'm sorry for my bad english...

2 コメント

0
Avatar
Ian Cummings
モデレータ
コメントアクション Permalink

Maybe you'd want to specify a time out.  Also try fault finding things by seeing what messages are returned by the print request.  See the below example from the BarTender Help system:

 

public void Demo()
{
   // Initialize a new BarTender print engine.
   using (Engine btEngine = new Engine())
   {
      // Start the BarTender print engine.
      btEngine.Start();

      // Open a format document.
      LabelFormatDocument btFormat = btEngine.Documents.Open(@"C:\Format1.btw");

      // Print the format document specifying the job name,
      // and get any messages returned.
      Messages btMessages = null;
      Result nResult = btFormat.Print("Test Print", out btMessages);

      // Display the print result.
      Console.WriteLine("Print status = " + nResult);

      // Print all returned messages.
      foreach (Message m in btMessages)
      {
         Console.WriteLine("Category = " + m.Category);
         Console.WriteLine("ID = " + m.ID);
         Console.WriteLine("Severity = " + m.Severity);
         Console.WriteLine("Text = " + m.Text);
         Console.WriteLine(" ");
      }

      // Close the current format without saving.
      btFormat.Close(SaveOptions.DoNotSaveChanges);

      // Stop the BarTender print engine.
      btEngine.Stop();
   }
}
0
Avatar
Legacy Poster
コメントアクション Permalink

Thank you for your answer.

 

When I use this: 

ress = labelFormat.Print("Label for " + txtPN.Text, out mess)

if(ress != Result.Success)
{
    // error
}
else
{
    // Save data to DB
}

All is OK and data are saved in DB.

 

What is the difference between this?

if(labelFormat.Print("Label for " + txtPN.Text, out mess) != Result.Success)
{
    // error
}
else
{
    // Save data to DB
}

This throws error (but label is printed), why? It's the same.

 

 

I'm sorry for my bad english...

ログインしてコメントを残してください。