-
Notifications
You must be signed in to change notification settings - Fork 21
/
Label.cs
117 lines (100 loc) · 3.07 KB
/
Label.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SharpPDFLabel
{
/// <summary>
/// The base class for a Label, all the actual label definition classes derive from this
/// Dimensions and margins are defined in mm but converted to Points when read back (for use in iTextSharp)
/// </summary>
public abstract class Label
{
/// <summary>
/// The width of 1 label
/// </summary>
protected double _Width;
public float Width
{
get { return mmToPoint(_Width); }
}
/// <summary>
/// The height of 1 label
/// </summary>
protected double _Height;
public float Height
{
get { return mmToPoint(_Height); }
}
/// <summary>
/// The width of the horizontal gap between labels
/// </summary>
protected double _HorizontalGapWidth;
public float HorizontalGapWidth
{
get { return mmToPoint(_HorizontalGapWidth); }
}
/// <summary>
/// The height of the vertical gap between labels
/// </summary>
protected double _VerticalGapHeight;
public float VerticalGapHeight
{
get { return mmToPoint(_VerticalGapHeight); }
}
/// <summary>
/// The left page margin
/// </summary>
protected double _PageMarginLeft;
public float PageMarginLeft
{
get { return mmToPoint(_PageMarginLeft); }
}
/// <summary>
/// The right page margin
/// </summary>
protected double _PageMarginRight;
public float PageMarginRight
{
get { return mmToPoint(_PageMarginRight); }
}
/// <summary>
/// The top page margin
/// </summary>
protected double _PageMarginTop;
public float PageMarginTop
{
get { return mmToPoint(_PageMarginTop); }
}
/// <summary>
/// The bottom page margin
/// </summary>
protected double _PageMarginBottom;
public float PageMarginBottom
{
get { return mmToPoint(_PageMarginBottom); }
}
/* page definitions */
/// <summary>
/// The paper size
/// </summary>
public Enums.PageSize PageSize { get; set; }
/// <summary>
/// The number of labels running across the page
/// </summary>
public int LabelsPerRow { get; set; }
/// <summary>
/// The number of labels running down the page
/// </summary>
public int LabelRowsPerPage { get; set; }
/// <summary>
/// iTextSharp uses points as its units
/// </summary>
/// <param name="mm">Millimetres to convert</param>
/// <returns>millimetres converted to points represented by a float</returns>
private float mmToPoint(double mm)
{
return (float)((mm / 25.4) * 72);
}
}
}