uB-04 Form SDK

Print Data onto UB-04 Forms

I don’t have to deal with PDF documents anymore.  That’s save us a heap of time.

Quickly create and send UB-04 form data to your printers.  Purchase a license here.

 

 

Main Features

Print Form Data

To print data on a UB-04 form first initialize the form fields using the UB04FormData class then print them using theUB04Form class

Initialize Form Fields

UB04FormData ubData = new UB04FormData();
ubData.Box1A = “Jane Smith”;
ubData.Box1B = “123 Maple Drive”;
ubData.Box1C = “Decalb IL 12345”;
ubData.Box1D = “800 1234244”;
ubData.Box2A = “Jane Smith”;
ubData.Box2B = “123 Maple Drive”;
ubData.Box2C = “Decalb IL 12345”;
ubData.Box2D = “800 1234244”;
ubData.Box3A = “112121”;
ubData.Box3B = “3B12324355”;
ubData.Box4 = “831”;
ubData.Box5 = “343434334”;
ubData.Box6A = DateTime.Today;
ubData.Box6B = DateTime.Today;
ubData.Box7 = “Box7”;
ubData.Box8A = “Jane Smith”;
ubData.Box8B = “Last Name”;
ubData.Box9A = “12345 EVERYDAY STREET”;
ubData.Box9B = “MOFFITT AVENUE”;
ubData.Box9C = “NY”;
ubData.Box9D = “11223”;
ubData.Box9E = “123”;

Next print it using the UB04Form class.

Printing Fields

UB04Form ubForm = new UB04Form();
ubForm .Data = ubData ;
ubForm .Print();

UB-04 forms must also be placed in printer

Sample Output

 

 

Note that the printing offsets may need to be slightly adjusted in the sample below.  See the Setting Printing Offsets topic in the help files to adjust your printer offsets correctly.

Creating a Custom Form Field

By default, the following fields are available; TextField, PriceField, PhoneField and UB04Date.  Custom fields can be created easily.  Just derive from the FormField class and override the GetText() method.

The Code

public class MyCustomField : FormField {
   public MyCustomField(string name): base(name){}

   public MyCustomField(string name, decimal? data, double x, double y, double width, double height): base(name, x, y, width, height){
      Data = data;
   }

   public decimal? Data {
      get;
      set;
   }

   public override string GetText(){
     if (Data != null && Data.HasValue){
       return Data.Value.ToString("F2");
     }
     return null;
    }
}

 

Dynamically modify data before Printing

Form fields can be modified before being sent to the printer.  Field coordinates, width, heights and alignment ( vertical and horizontal ) are modifiable.

The Code

ubForm.BeforePrint += ubForm_BeforePrint;
 
private void ubForm_BeforePrint(object sender, FormEventArgs e){
    //e.Cells has all fields that will be send to printer.
    //The field properties can be modified
e.Cells[0].X = 12;
e.Cells[0].Y = 13;
e.Cells[1].Width = 3;
e.Cells[1].Height = 0.5;
}

 UB04Form comes FREE with a license of RDPCrystal EDI Library.   However it can be purchased separately in our online store