473,466 Members | 1,613 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Use Dymo Labelwriter Turbo in .net

1 New Member
Hi,

I'm trying to use a Dymo LabelWriter Turbo (Software version 4.1.0.0) on Windows XP, in my C# code. I'm able to detect the printer through my code. However it doesnt print anything. It tries to print, but the label doesnt have any text on it. Can anyone help me?

Please find my code below.

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Text;

namespace WindowsApplication1
{
static class Program
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct tagLABELINFO
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public String LabelName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public String PaperName;
public object PaperSize;
public object BitmapSize;
public int LabelCount;
public object LabelSize;
} // tagLABELINFO

[StructLayout(LayoutKind.Sequential)]
public struct TObjectID
{
public int oID;
} // TObjectID

[StructLayout(LayoutKind.Sequential)]
public struct posCoordinates
{
public int xPos;
public int yPos;
public int Width;
public int Height;
}//posCoordinates

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct tagObjectInfo
{
public TObjectID ObjID;
public int ObjType;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public String ObjName;
public posCoordinates posCoordinates;
public int Rotate;
} // tagObjectInfo

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct TTextBlockAttributes
{
[MarshalAs(UnmanagedType.LPStr)]
public String Text;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public String Font1;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public String Font2;
public int Justify;
public int VertJustify;
public bool bMirrored;
public bool bVerticalText;
public bool IsRichText;
public int Effects;
} // TTextBlockAttributes

[StructLayout(LayoutKind.Sequential)]
public struct TAddressAttributes
{
public TTextBlockAttributes TextInfo;
public int BarCodePos;
public bool b9DigitOnly;
} // TAddressAttributes

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct TLineAttributes
{
public int Length;
public int Orient;
public int Thickness;
} // TLineAttributes

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct TCounterAttributes
{
public TTextBlockAttributes TextInfo;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public String PreText;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public String PostText;
public int Start;
public int Current;
public int Width;
public int Increment;
bool bLeadingZeros;
} // TCounterAttributes

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct TDateTimeAttributes
{
public TTextBlockAttributes TextInfo;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public String PreText;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public String PostText;
public int DateFormat;
public bool bIncludeTime;
public bool b24Hour;
} // TDateTimeAttributes

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct tagTBarcodeAttributes
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public String Text;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public String Font;
public int HRTextPos;
public int BCType;
public int BCRatio;
public int Justify;
public TObjectID Link;
} // TBarcodeAttributes

[DllImport("labels.dll")]
static extern bool PrintLabel(String DeviceName, String Port, int
Quantity, bool bShowDialog);

[DllImport("labels.dll")]
static extern bool DeleteLabelObject(TObjectID ID);

[DllImport("labels.dll")]
static extern IntPtr AddObject(String ObjType, String ObjName, posCoordinates
posCoordinates, int Rotation, IntPtr Attrib);

[DllImport("labels.dll")]
static extern void NewLabel(String Name);

[DllImport("labels.dll")]
static extern bool SetAttributes(ref TObjectID ID, IntPtr Attrib);

[STAThread]
static void Main(string[] args)
{
// create a new label
NewLabel("sunday");

TTextBlockAttributes txtAttribute = new TTextBlockAttributes();

txtAttribute.Text = "Hello World \r\n Good Morning \r\n";
txtAttribute.Font1 = "Times New Roman, 10, Bold" + '\0';
txtAttribute.Font2 = "Times New Roman, 10, Bold" + '\0';
txtAttribute.Justify = 0;
txtAttribute.VertJustify = 0;
txtAttribute.bMirrored = false;
txtAttribute.bVerticalText = false;
txtAttribute.IsRichText = false;
txtAttribute.Effects = 0;

posCoordinates posCoordinates = new posCoordinates();
posCoordinates.xPos = 0;
posCoordinates.yPos = 0;
posCoordinates.Width = 60;
posCoordinates.Height = 60;

TObjectID to = new TObjectID();

IntPtr mypointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(TTextBl ockAttributes)));

Marshal.StructureToPtr(txtAttribute, mypointer, true);

txtAttribute = (TTextBlockAttributes)Marshal.PtrToStructure(mypoi nter, typeof(TTextBlockAttributes));

to.oID = (int)AddObject("Text", "sunday", posCoordinates, 0, mypointer);

Console.WriteLine("the new object ID is {0}", to.oID);

bool printed = PrintLabel("Dymo LabelWriter Turbo-USB",
null, 1, true);

Marshal.FreeHGlobal(mypointer);

Console.WriteLine("deleted is {0}", printed);

}
}
}
Apr 30 '08 #1
0 1595

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Developwebsites | last post by:
I am taking advanced C++ at college and we use Borland Turbo C++ 4.5 compiler. How different is Turbo C++ from the standard C++? I know Borland used to call their versions of C++ and Pascal Turbo,...
7
by: Ira S | last post by:
I use a DYMO labelwriter with my Access 97 database. I just purchased a new computer and in the report section under page setup/paper size, the new computer keeps changing the size automatically. I...
3
by: Michael | last post by:
Hi, I'm trying to print barcodes to the Dymo LabelWriter printer. Put everytime I send a job to the label printer it just outputs an empty label. If I change the default printer back to the...
1
by: anonymous | last post by:
i wrote a graphical program in turbo c 3.0 ,it runs safe on turbo 3.0,(however i'm using xp) so when i wanted to run it for my teacher,both turbo c & program crashed; so i decided to compile it in...
16
by: scott | last post by:
I am looking for a copy of Turbo C 1.5 from 1987 for some historical research I'm doing into computing from that time period.
0
by: anonymous | last post by:
i wrote a graphical program in turbo c 3.0 ,it runs safe on turbo 3.0,(however i'm using xp) so when i wanted to run it for my teacher,both turbo c & program crashed; so i decided to compile it in...
3
by: postrishi | last post by:
Hello Everybody , I am a new user. I am currently using Turbo C++ 3.0 editor in my engg.Can you tell me or post me a ebook on turbo c++ and NOT on c or C++.MInd it I want a book on TURBO C++ editor...
4
by: BugMan | last post by:
I just bought a Dymo to print name badges from Access with barcodes. When in page view there are blank pages between records, does any have any idea how to fix this? I am using Access 2002 ...
1
by: ARC | last post by:
Hello, Does anyone have an access report that will do dymo labels? It seems the paper size would be similar to an envelope, since dymo's print landscape. Looking for an access report that will...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.