Amir Shrestha
Amir Shrestha

Reputation: 451

Printer driver is not been specified with TSCLib.dll

I am getting Printer driver is not been specified error while printing with TSCLIB.dll openport method. My Code looks like this

public partial class TSCPrint : Form
{
    [DllImport("TSCLIB.dll", EntryPoint = "about", SetLastError = true, CharSet = CharSet.Auto)]
    public static extern bool about();

    [DllImport("TSCLIB.dll", EntryPoint = "openport", SetLastError = true, CharSet = CharSet.Auto)]
    public static extern bool openport(string printer);

    [DllImport("TSCLIB.dll", EntryPoint = "barcode")]
    public static extern int barcode(string x, string y, string type,
    string height, string readable, string rotation,
    string narrow, string wide, string code);

    [DllImport("TSCLIB.dll", EntryPoint = "clearbuffer")]
    public static extern int clearbuffer();

    [DllImport("TSCLIB.dll", EntryPoint = "closeport")]
    public static extern int closeport();

    [DllImport("TSCLIB.dll", EntryPoint = "downloadpcx")]
    public static extern int downloadpcx(string filename, string image_name);

    [DllImport("TSCLIB.dll", EntryPoint = "formfeed")]
    public static extern int formfeed();

    [DllImport("TSCLIB.dll", EntryPoint = "nobackfeed")]
    public static extern int nobackfeed();

    [DllImport("TSCLIB.dll", EntryPoint = "printerfont")]
    public static extern int printerfont(string x, string y, string fonttype,
    string rotation, string xmul, string ymul,
    string text);

    [DllImport("TSCLIB.dll", EntryPoint = "printlabel")]
    public static extern int printlabel(string set, string copy);

    [DllImport("TSCLIB.dll", EntryPoint = "sendcommand")]
    public static extern int sendcommand(string printercommand);

    [DllImport("TSCLIB.dll", EntryPoint = "setup")]
    public static extern int setup(string width, string height,
    string speed, string density,
    string sensor, string vertical,
    String offset);

    [DllImport("TSCLIB.dll", EntryPoint = "windowsfont")]
    public static extern int windowsfont(int x, int y, int fontheight,
    int rotation, int fontstyle, int fontunderline,
    string szFaceName, string content);
    public TSCPrint()
    {
        InitializeComponent();
        about();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        openport("USB003");
        setup("100", "63.5", "4", "8", "0", "0", "0"); // Setup the media size and sensor type info
        clearbuffer(); // Clear image buffer
        barcode("100", "100", "128", "100", "1", "0", "2", "2", "Barcode Test"); // Drawing barcode
        printerfont("100", "250", "3", "0", "1", "1", "Print Font Test"); // Drawing printer font
        windowsfont(100, 300, 24, 0, 0, 0, "ARIAL", "Windows Arial Font Test"); // Draw windows font
        //downloadpcx ("UL.PCX", "UL.PCX"); // Download PCX file into printer
        //sendcommand ("PUTPCX 100,400, /" UL.PCX / ""); // Drawing PCX graphic
        printlabel("1", "1"); // Print labels
        closeport(); // Close specified printer driver

    }
}
}

Upvotes: 2

Views: 8341

Answers (1)

roemel
roemel

Reputation: 3297

Your class looks fine. I am using the same class but without SetLastError and without CharSet on about and openport method. I don't know what this is doing.

The error you described above is called when the specified printer doesn't exist.

Make sure your printer called "USB003" exists.

openport("RS11");

In my example the printer "RS11" must exist. Otherwise it will throw this error.

printer

So go to your Control Panel > All Control Panel Items > Devices and Printers and make sure your printer does exist in Printers and Faxes.

Upvotes: 5

Related Questions