Hi there
We have a small Brother Barcode printer which we like to control from a WCF Service. Brother has an API called bPAC SDK version 3 which allows to print those labels. But the problem arises, as soon as we want to print from code only without showing a windows with a button on it. As an addition, this happens only if you want to print a QR-code as barcode. Standard EAN-codes seems to work.
Below is a small piece of code which outputs the stuff to a bitmap instead of the printer (debugging reasons).
DocumentClass doc = new DocumentClass();
if (doc.Open(templatePath))
{
doc.GetObject("barcode1").Text = txtCompany.Text;
doc.GetObject("barcode2").Text = txtName.Text;
doc.Export(ExportType.bexBmp, testImagePath, 300);
doc.Close();
}
If this is called by a button click, it perfectly works.
If this is called in Form.Show-event, it perfectly works.
If this is called in Form.Load-event, it does NOT work.
If this is called in a Form constructor, it does NOT work.
If this is called somewhere else (without forms), it does NOT work.
DocumentClass and related classes are COM-objects, so I guess the form setup/show process seems to do something which is not done without opening forms. I tried calling CoInitialize with a p/invoke, but it hadn't changed anything.
Is there anyone out there willing and able to help me?
Are there any alternatives which (also) MUST be able to print directly on our Brother printer?
Thanks lot.