Label printing development using b-pac SDK in a C# application

19,080

Solution 1

I had the exact same error message when the exception occurred. The solution for me was to set the "Platform target" to "X86" CPU. This can be done via: (menu) Project -> Properties -> (tab) Build -> Platform target "x86" Instead of "Any CPU"

I have developed the software on Windows 7 64 bit.

You can find more info about this in the b-PAC SDK documentation. C:\Program Files (x86)\Brother bPAC3 SDK\Doc\bPAC30_eng.chm In the section "Troubleshooting" you will find: "The program does not operate on a 64-bit operating system. Change the platform to "x86", and then recompile it."

This solution is tested with the QL560 hardware connected to my PC and it worked.

Solution 2

Here is some code I have used to print using this object.

            string strPrinterAddress = "domain\machinename";
            objDoc = new BrssCom.Document();
            string strPath = "192.168.1.45" + " /D" + strPrinterAddress;
            if (objDoc.Open(strPath))
            {
                objDoc.SetText(0, "Recycle: " + recycleReason);

                objDoc.SetText(1, "Other Text");
                objDoc.SetBarcodeData(0, "1234");
                objDoc.DoPrint(BrssCom.PrintOptionConstants.bpoAutoCut, "0");
            }

However, @JamieMeyer is right. You cannot, absolutely can NOT be sure this will work without having a printer to test with. In my example, I'm using a very simple label with 3 fields, one of them being a barcode. It's not a simple matter of using named variables, it really depends on the order the fields were added, etc.

I didn't have a printer myself, and it took about 2 weeks of me sending code updates at night, and then the customer testing the next day, round and round, to get the look and feel just right. If I had it to do all over again, I would have purchased a printer myself.

Good luck, but you are shooting in the dark without a printer.

Solution 3

How do you intend to verify the results of your coding without the physical unit?? Brother does not offer any sort of visual emulator, so your best bet is to get the unit. These can be had for $75 street price, and likely on the shelf at your local office supply store. http://www.officedepot.com/a/products/506232/Brother-P-Touch-QL-500-PC/

Share:
19,080
Khizer Ali
Author by

Khizer Ali

Software [fullstack] Engineer who works in design, code and things between. Implements (Typescript, Python and Swift), runs and analyze experiments using (ssr, graphql, serverless, rxjs, amazon services and ci) on various web/mobile apps.

Updated on June 05, 2022

Comments

  • Khizer Ali
    Khizer Ali almost 2 years

    I am developing a C# application of POS system in Visual Studio 2012 RC. I have to print the sales on label printer using

    Brothers P-Touch QL-500 Label printer.

    WHAT I HAVE DONE ALREADY.

    • I have installed latest b-pac SDK 3.0
    • Successfully add reference to my C# application.
    • For creating label templates i have installed latest version of p-touch Editor 5.0.
    • Made one template (Mylabel.lbl).

      But before that.

    I run some of the built in Examples but those examples Throws an Exception. After doing alot of search on Google I found that this is the printer's driver Problem.

    i can't install the driver because Driver's installation requires a printer to be connected. I DON'T HAVE THE PRINTER.

    WHAT I NEED TO DO

    • Do you have any idea that how can i do this task.
    • what is the right way of printing a label using Brothers P-Touch QL-500 Label printer.

      Please Help me I have done alot of time on searching. stackoverflow is my last hope. I am new to such label printing. Please help i will be greatly thankful.

    The ruff example Code i am using.

    bpac.DocumentClass doc = new DocumentClass();
    if (doc.Open("templateFile.lbx"))
    {
        doc.GetObject("field1").Text = "...";
        doc.GetObject("field2").Text = "...";
    
        doc.StartPrint("", PrintOptionConstants.bpoDefault);
        doc.PrintOut(1, PrintOptionConstants.bpoDefault);
        doc.EndPrint();
        doc.Close();
    }
    

    This is the example code which i am trying. the very first line throws an exception

    bpac.DocumentClass doc = new DocumentClass();
    

    I am Also attaching a Exception Screen Preview.

    Thrown Exception Screen Preview