473,224 Members | 1,596 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

Use Dymo Labelwriter Turbo in .net

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 1585

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
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.