vendor: import KillerPDF 1.7.5 source (GPL-3.0) as the base for MMD PDF
This commit is contained in:
@@ -0,0 +1,170 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Klaus Potzesny
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the base class of all bar codes.
|
||||
/// </summary>
|
||||
public abstract class BarCode : CodeBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BarCode"/> class.
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="direction"></param>
|
||||
public BarCode(string text, XSize size, CodeDirection direction)
|
||||
: base(text, size, direction)
|
||||
{
|
||||
Text = text;
|
||||
Size = size;
|
||||
Direction = direction;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a bar code from the specified code type.
|
||||
/// </summary>
|
||||
public static BarCode FromType(CodeType type, string text, XSize size, CodeDirection direction)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CodeType.Code2of5Interleaved:
|
||||
return new Code2of5Interleaved(text, size, direction);
|
||||
|
||||
case CodeType.Code3of9Standard:
|
||||
return new Code3of9Standard(text, size, direction);
|
||||
|
||||
default:
|
||||
throw new InvalidEnumArgumentException("type", (int)type, typeof(CodeType));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a bar code from the specified code type.
|
||||
/// </summary>
|
||||
public static BarCode FromType(CodeType type, string text, XSize size)
|
||||
{
|
||||
return FromType(type, text, size, CodeDirection.LeftToRight);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a bar code from the specified code type.
|
||||
/// </summary>
|
||||
public static BarCode FromType(CodeType type, string text)
|
||||
{
|
||||
return FromType(type, text, XSize.Empty, CodeDirection.LeftToRight);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a bar code from the specified code type.
|
||||
/// </summary>
|
||||
public static BarCode FromType(CodeType type)
|
||||
{
|
||||
return FromType(type, String.Empty, XSize.Empty, CodeDirection.LeftToRight);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When overridden in a derived class gets or sets the wide narrow ratio.
|
||||
/// </summary>
|
||||
public virtual double WideNarrowRatio
|
||||
{
|
||||
get { return 0; }
|
||||
set { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the location of the text next to the bar code.
|
||||
/// </summary>
|
||||
public TextLocation TextLocation
|
||||
{
|
||||
get { return _textLocation; }
|
||||
set { _textLocation = value; }
|
||||
}
|
||||
TextLocation _textLocation;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the length of the data that defines the bar code.
|
||||
/// </summary>
|
||||
public int DataLength
|
||||
{
|
||||
get { return _dataLength; }
|
||||
set { _dataLength = value; }
|
||||
}
|
||||
int _dataLength;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional start character.
|
||||
/// </summary>
|
||||
public char StartChar
|
||||
{
|
||||
get { return _startChar; }
|
||||
set { _startChar = value; }
|
||||
}
|
||||
char _startChar;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional end character.
|
||||
/// </summary>
|
||||
public char EndChar
|
||||
{
|
||||
get { return _endChar; }
|
||||
set { _endChar = value; }
|
||||
}
|
||||
char _endChar;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the turbo bit is to be drawn.
|
||||
/// (A turbo bit is something special to Kern (computer output processing) company (as far as I know))
|
||||
/// </summary>
|
||||
public virtual bool TurboBit
|
||||
{
|
||||
get { return _turboBit; }
|
||||
set { _turboBit = value; }
|
||||
}
|
||||
bool _turboBit;
|
||||
|
||||
internal virtual void InitRendering(BarCodeRenderInfo info)
|
||||
{
|
||||
if (Text == null)
|
||||
throw new InvalidOperationException(BcgSR.BarCodeNotSet);
|
||||
|
||||
if (Size.IsEmpty)
|
||||
throw new InvalidOperationException(BcgSR.EmptyBarCodeSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When defined in a derived class renders the code.
|
||||
/// </summary>
|
||||
protected internal abstract void Render(XGraphics gfx, XBrush brush, XFont font, XPoint position);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// PDFsharp - A library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Klaus Potzesny
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds all temporary information needed during rendering.
|
||||
/// </summary>
|
||||
class BarCodeRenderInfo
|
||||
{
|
||||
public BarCodeRenderInfo(XGraphics gfx, XBrush brush, XFont font, XPoint position)
|
||||
{
|
||||
Gfx = gfx;
|
||||
Brush = brush;
|
||||
Font = font;
|
||||
Position = position;
|
||||
}
|
||||
|
||||
public XGraphics Gfx;
|
||||
public XBrush Brush;
|
||||
public XFont Font;
|
||||
public XPoint Position;
|
||||
public double BarHeight;
|
||||
public XPoint CurrPos;
|
||||
public int CurrPosInString;
|
||||
public double ThinBarWidth;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Klaus Potzesny
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
// TODO: Mere with PDFsharp strings table
|
||||
/// <summary>
|
||||
/// String resources for the empira barcode renderer.
|
||||
/// </summary>
|
||||
internal class BcgSR
|
||||
{
|
||||
internal static string Invalid2Of5Code(string code)
|
||||
{
|
||||
return string.Format("'{0}' is not a valid code for an interleave 2 of 5 bar code. It can only represent an even number of digits.", code);
|
||||
}
|
||||
|
||||
internal static string Invalid3Of9Code(string code)
|
||||
{
|
||||
return string.Format("'{0}' is not a valid code for a 3 of 9 standard bar code.", code);
|
||||
}
|
||||
|
||||
internal static string BarCodeNotSet
|
||||
{
|
||||
get { return "A text must be set before rendering the bar code."; }
|
||||
}
|
||||
|
||||
internal static string EmptyBarCodeSize
|
||||
{
|
||||
get { return "A non-empty size must be set before rendering the bar code."; }
|
||||
}
|
||||
|
||||
internal static string Invalid2of5Relation
|
||||
{
|
||||
get { return "Value of relation between thick and thin lines on the interleaved 2 of 5 code must be between 2 and 3."; }
|
||||
}
|
||||
|
||||
internal static string InvalidMarkName(string name)
|
||||
{
|
||||
return string.Format("'{0}' is not a valid mark name for this OMR representation.", name);
|
||||
}
|
||||
|
||||
internal static string OmrAlreadyInitialized
|
||||
{
|
||||
get { return "Mark descriptions cannot be set when marks have already been set on OMR."; }
|
||||
}
|
||||
|
||||
internal static string DataMatrixTooBig
|
||||
{
|
||||
get { return "The given data and encoding combination is too big for the matrix size."; }
|
||||
}
|
||||
|
||||
internal static string DataMatrixNotSupported
|
||||
{
|
||||
get { return "Zero sizes, odd sizes and other than ecc200 coded DataMatrix is not supported."; }
|
||||
}
|
||||
|
||||
internal static string DataMatrixNull
|
||||
{
|
||||
get { return "No DataMatrix code is produced."; }
|
||||
}
|
||||
|
||||
internal static string DataMatrixInvalid(int columns, int rows)
|
||||
{
|
||||
return string.Format("'{1}'x'{0}' is an invalid ecc200 DataMatrix size.", columns, rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Klaus Potzesny
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation of the Code 2 of 5 bar code.
|
||||
/// </summary>
|
||||
public class Code2of5Interleaved : ThickThinBarCode
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of Interleaved2of5.
|
||||
/// </summary>
|
||||
public Code2of5Interleaved()
|
||||
: base("", XSize.Empty, CodeDirection.LeftToRight)
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of Interleaved2of5.
|
||||
/// </summary>
|
||||
public Code2of5Interleaved(string code)
|
||||
: base(code, XSize.Empty, CodeDirection.LeftToRight)
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of Interleaved2of5.
|
||||
/// </summary>
|
||||
public Code2of5Interleaved(string code, XSize size)
|
||||
: base(code, size, CodeDirection.LeftToRight)
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of Interleaved2of5.
|
||||
/// </summary>
|
||||
public Code2of5Interleaved(string code, XSize size, CodeDirection direction)
|
||||
: base(code, size, direction)
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an array of size 5 that represents the thick (true) and thin (false) lines or spaces
|
||||
/// representing the specified digit.
|
||||
/// </summary>
|
||||
/// <param name="digit">The digit to represent.</param>
|
||||
static bool[] ThickAndThinLines(int digit)
|
||||
{
|
||||
return Lines[digit];
|
||||
}
|
||||
static bool[][] Lines =
|
||||
{
|
||||
new bool[] {false, false, true, true, false},
|
||||
new bool[] {true, false, false, false, true},
|
||||
new bool[] {false, true, false, false, true},
|
||||
new bool[] {true, true, false, false, false},
|
||||
new bool[] {false, false, true, false, true},
|
||||
new bool[] {true, false, true, false, false},
|
||||
new bool[] {false, true, true, false, false},
|
||||
new bool[] {false, false, false, true, true},
|
||||
new bool[] {true, false, false, true, false},
|
||||
new bool[] {false, true, false, true, false},
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Renders the bar code.
|
||||
/// </summary>
|
||||
protected internal override void Render(XGraphics gfx, XBrush brush, XFont font, XPoint position)
|
||||
{
|
||||
XGraphicsState state = gfx.Save();
|
||||
|
||||
BarCodeRenderInfo info = new BarCodeRenderInfo(gfx, brush, font, position);
|
||||
InitRendering(info);
|
||||
info.CurrPosInString = 0;
|
||||
//info.CurrPos = info.Center - Size / 2;
|
||||
info.CurrPos = position - CodeBase.CalcDistance(AnchorType.TopLeft, Anchor, Size);
|
||||
|
||||
if (TurboBit)
|
||||
RenderTurboBit(info, true);
|
||||
RenderStart(info);
|
||||
while (info.CurrPosInString < Text.Length)
|
||||
RenderNextPair(info);
|
||||
RenderStop(info);
|
||||
if (TurboBit)
|
||||
RenderTurboBit(info, false);
|
||||
if (TextLocation != TextLocation.None)
|
||||
RenderText(info);
|
||||
|
||||
gfx.Restore(state);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the thick and thin line widths,
|
||||
/// taking into account the required rendering size.
|
||||
/// </summary>
|
||||
internal override void CalcThinBarWidth(BarCodeRenderInfo info)
|
||||
{
|
||||
/*
|
||||
* The total width is the sum of the following parts:
|
||||
* Starting lines = 4 * thin
|
||||
* +
|
||||
* Code Representation = (2 * thick + 3 * thin) * code.Length
|
||||
* +
|
||||
* Stopping lines = 1 * thick + 2 * thin
|
||||
*
|
||||
* with r = relation ( = thick / thin), this results in
|
||||
*
|
||||
* Total width = (6 + r + (2 * r + 3) * text.Length) * thin
|
||||
*/
|
||||
double thinLineAmount = 6 + WideNarrowRatio + (2 * WideNarrowRatio + 3) * Text.Length;
|
||||
info.ThinBarWidth = Size.Width / thinLineAmount;
|
||||
}
|
||||
|
||||
private void RenderStart(BarCodeRenderInfo info)
|
||||
{
|
||||
RenderBar(info, false);
|
||||
RenderGap(info, false);
|
||||
RenderBar(info, false);
|
||||
RenderGap(info, false);
|
||||
}
|
||||
|
||||
private void RenderStop(BarCodeRenderInfo info)
|
||||
{
|
||||
RenderBar(info, true);
|
||||
RenderGap(info, false);
|
||||
RenderBar(info, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the next digit pair as bar code element.
|
||||
/// </summary>
|
||||
private void RenderNextPair(BarCodeRenderInfo info)
|
||||
{
|
||||
int digitForLines = int.Parse(Text[info.CurrPosInString].ToString());
|
||||
int digitForGaps = int.Parse(Text[info.CurrPosInString + 1].ToString());
|
||||
bool[] linesArray = Lines[digitForLines];
|
||||
bool[] gapsArray = Lines[digitForGaps];
|
||||
for (int idx = 0; idx < 5; ++idx)
|
||||
{
|
||||
RenderBar(info, linesArray[idx]);
|
||||
RenderGap(info, gapsArray[idx]);
|
||||
}
|
||||
info.CurrPosInString += 2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks the code to be convertible into an interleaved 2 of 5 bar code.
|
||||
/// </summary>
|
||||
/// <param name="text">The code to be checked.</param>
|
||||
protected override void CheckCode(string text)
|
||||
{
|
||||
#if true_
|
||||
if (text == null)
|
||||
throw new ArgumentNullException("text");
|
||||
|
||||
if (text == "")
|
||||
throw new ArgumentException(BcgSR.Invalid2Of5Code(text));
|
||||
|
||||
if (text.Length % 2 != 0)
|
||||
throw new ArgumentException(BcgSR.Invalid2Of5Code(text));
|
||||
|
||||
foreach (char ch in text)
|
||||
{
|
||||
if (!Char.IsDigit(ch))
|
||||
throw new ArgumentException(BcgSR.Invalid2Of5Code(text));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Klaus Potzesny
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
/// <summary>
|
||||
/// Imlpementation of the Code 3 of 9 bar code.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class Code3of9Standard : ThickThinBarCode
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of Standard3of9.
|
||||
/// </summary>
|
||||
public Code3of9Standard()
|
||||
: base("", XSize.Empty, CodeDirection.LeftToRight)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of Standard3of9.
|
||||
/// </summary>
|
||||
public Code3of9Standard(string code)
|
||||
: base(code, XSize.Empty, CodeDirection.LeftToRight)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of Standard3of9.
|
||||
/// </summary>
|
||||
public Code3of9Standard(string code, XSize size)
|
||||
: base(code, size, CodeDirection.LeftToRight)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of Standard3of9.
|
||||
/// </summary>
|
||||
public Code3of9Standard(string code, XSize size, CodeDirection direction)
|
||||
: base(code, size, direction)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Returns an array of size 9 that represents the thick (true) and thin (false) lines and spaces
|
||||
/// representing the specified digit.
|
||||
/// </summary>
|
||||
/// <param name="ch">The character to represent.</param>
|
||||
private static bool[] ThickThinLines(char ch)
|
||||
{
|
||||
return Lines["0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*".IndexOf(ch)];
|
||||
}
|
||||
static readonly bool[][] Lines =
|
||||
{
|
||||
// '0'
|
||||
new bool[] {false, false, false, true, true, false, true, false, false},
|
||||
// '1'
|
||||
new bool[] {true, false, false, true, false, false, false, false, true},
|
||||
// '2'
|
||||
new bool[] {false, false, true, true, false, false, false, false, true},
|
||||
// '3'
|
||||
new bool[] {true, false, true, true, false, false, false, false, false},
|
||||
// '4'
|
||||
new bool[] {false, false, false, true, true, false, false, false, true},
|
||||
// '5'
|
||||
new bool[] {true, false, false, true, true, false, false, false, false},
|
||||
// '6'
|
||||
new bool[] {false, false, true, true, true, false, false, false, false},
|
||||
// '7'
|
||||
new bool[] {false, false, false, true, false, false, true, false, true},
|
||||
// '8'
|
||||
new bool[] {true, false, false, true, false, false, true, false, false},
|
||||
// '9'
|
||||
new bool[] {false, false, true, true, false, false, true, false, false},
|
||||
// 'A'
|
||||
new bool[] {true, false, false, false, false, true, false, false, true},
|
||||
// 'B'
|
||||
new bool[] {false, false, true, false, false, true, false, false, true},
|
||||
// 'C'
|
||||
new bool[] {true, false, true, false, false, true, false, false, false},
|
||||
// 'D'
|
||||
new bool[] {false, false, false, false, true, true, false, false, true},
|
||||
// 'E'
|
||||
new bool[] {true, false, false, false, true, true, false, false, false},
|
||||
// 'F'
|
||||
new bool[] {false, false, true, false, true, true, false, false, false},
|
||||
// 'G'
|
||||
new bool[] {false, false, false, false, false, true, true, false, true},
|
||||
// 'H'
|
||||
new bool[] {true, false, false, false, false, true, true, false, false},
|
||||
// 'I'
|
||||
new bool[] {false, false, true, false, false, true, true, false, false},
|
||||
// 'J'
|
||||
new bool[] {false, false, false, false, true, true, true, false, false},
|
||||
// 'K'
|
||||
new bool[] {true, false, false, false, false, false, false, true, true},
|
||||
// 'L'
|
||||
new bool[] {false, false, true, false, false, false, false, true, true},
|
||||
// 'M'
|
||||
new bool[] {true, false, true, false, false, false, false, true, false},
|
||||
// 'N'
|
||||
new bool[] {false, false, false, false, true, false, false, true, true},
|
||||
// 'O'
|
||||
new bool[] {true, false, false, false, true, false, false, true, false},
|
||||
// 'P':
|
||||
new bool[] {false, false, true, false, true, false, false, true, false},
|
||||
// 'Q'
|
||||
new bool[] {false, false, false, false, false, false, true, true, true},
|
||||
// 'R'
|
||||
new bool[] {true, false, false, false, false, false, true, true, false},
|
||||
// 'S'
|
||||
new bool[] {false, false, true, false, false, false, true, true, false},
|
||||
// 'T'
|
||||
new bool[] {false, false, false, false, true, false, true, true, false},
|
||||
// 'U'
|
||||
new bool[] {true, true, false, false, false, false, false, false, true},
|
||||
// 'V'
|
||||
new bool[] {false, true, true, false, false, false, false, false, true},
|
||||
// 'W'
|
||||
new bool[] {true, true, true, false, false, false, false, false, false},
|
||||
// 'X'
|
||||
new bool[] {false, true, false, false, true, false, false, false, true},
|
||||
// 'Y'
|
||||
new bool[] {true, true, false, false, true, false, false, false, false},
|
||||
// 'Z'
|
||||
new bool[] {false, true, true, false, true, false, false, false, false},
|
||||
// '-'
|
||||
new bool[] {false, true, false, false, false, false, true, false, true},
|
||||
// '.'
|
||||
new bool[] {true, true, false, false, false, false, true, false, false},
|
||||
// ' '
|
||||
new bool[] {false, true, true, false, false, false, true, false, false},
|
||||
// '$'
|
||||
new bool[] {false, true, false, true, false, true, false, false, false},
|
||||
// '/'
|
||||
new bool[] {false, true, false, true, false, false, false, true, false},
|
||||
// '+'
|
||||
new bool[] {false, true, false, false, false, true, false, true, false},
|
||||
// '%'
|
||||
new bool[] {false, false, false, true, false, true, false, true, false},
|
||||
// '*'
|
||||
new bool[] {false, true, false, false, true, false, true, false, false},
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the thick and thin line widths,
|
||||
/// taking into account the required rendering size.
|
||||
/// </summary>
|
||||
internal override void CalcThinBarWidth(BarCodeRenderInfo info)
|
||||
{
|
||||
/*
|
||||
* The total width is the sum of the following parts:
|
||||
* Starting lines = 3 * thick + 7 * thin
|
||||
* +
|
||||
* Code Representation = (3 * thick + 7 * thin) * code.Length
|
||||
* +
|
||||
* Stopping lines = 3 * thick + 6 * thin
|
||||
*
|
||||
* with r = relation ( = thick / thin), this results in
|
||||
*
|
||||
* Total width = (13 + 6 * r + (3 * r + 7) * code.Length) * thin
|
||||
*/
|
||||
double thinLineAmount = 13 + 6 * WideNarrowRatio + (3 * WideNarrowRatio + 7) * Text.Length;
|
||||
info.ThinBarWidth = Size.Width / thinLineAmount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks the code to be convertible into an standard 3 of 9 bar code.
|
||||
/// </summary>
|
||||
/// <param name="text">The code to be checked.</param>
|
||||
protected override void CheckCode(string text)
|
||||
{
|
||||
if (text == null)
|
||||
throw new ArgumentNullException("text");
|
||||
|
||||
if (text.Length == 0)
|
||||
throw new ArgumentException(BcgSR.Invalid3Of9Code(text));
|
||||
|
||||
foreach (char ch in text)
|
||||
{
|
||||
if ("0123456789ABCDEFGHIJKLMNOP'QRSTUVWXYZ-. $/+%*".IndexOf(ch) < 0)
|
||||
throw new ArgumentException(BcgSR.Invalid3Of9Code(text));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the bar code.
|
||||
/// </summary>
|
||||
protected internal override void Render(XGraphics gfx, XBrush brush, XFont font, XPoint position)
|
||||
{
|
||||
XGraphicsState state = gfx.Save();
|
||||
|
||||
BarCodeRenderInfo info = new BarCodeRenderInfo(gfx, brush, font, position);
|
||||
InitRendering(info);
|
||||
info.CurrPosInString = 0;
|
||||
//info.CurrPos = Center - Size / 2;
|
||||
info.CurrPos = position - CalcDistance(AnchorType.TopLeft, Anchor, Size);
|
||||
|
||||
if (TurboBit)
|
||||
RenderTurboBit(info, true);
|
||||
RenderStart(info);
|
||||
while (info.CurrPosInString < Text.Length)
|
||||
{
|
||||
RenderNextChar(info);
|
||||
RenderGap(info, false);
|
||||
}
|
||||
RenderStop(info);
|
||||
if (TurboBit)
|
||||
RenderTurboBit(info, false);
|
||||
if (TextLocation != TextLocation.None)
|
||||
RenderText(info);
|
||||
|
||||
gfx.Restore(state);
|
||||
}
|
||||
|
||||
private void RenderNextChar(BarCodeRenderInfo info)
|
||||
{
|
||||
RenderChar(info, Text[info.CurrPosInString]);
|
||||
++info.CurrPosInString;
|
||||
}
|
||||
|
||||
private void RenderChar(BarCodeRenderInfo info, char ch)
|
||||
{
|
||||
bool[] thickThinLines = ThickThinLines(ch);
|
||||
int idx = 0;
|
||||
while (idx < 9)
|
||||
{
|
||||
RenderBar(info, thickThinLines[idx]);
|
||||
if (idx < 8)
|
||||
RenderGap(info, thickThinLines[idx + 1]);
|
||||
idx += 2;
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderStart(BarCodeRenderInfo info)
|
||||
{
|
||||
RenderChar(info, '*');
|
||||
RenderGap(info, false);
|
||||
}
|
||||
|
||||
private void RenderStop(BarCodeRenderInfo info)
|
||||
{
|
||||
RenderChar(info, '*');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Klaus Potzesny
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the base class of all codes.
|
||||
/// </summary>
|
||||
public abstract class CodeBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CodeBase"/> class.
|
||||
/// </summary>
|
||||
public CodeBase(string text, XSize size, CodeDirection direction)
|
||||
{
|
||||
_text = text;
|
||||
_size = size;
|
||||
_direction = direction;
|
||||
}
|
||||
|
||||
//public static CodeBase FromType(CodeType type, string text, XSize size, CodeDirection direction)
|
||||
//{
|
||||
// switch (type)
|
||||
// {
|
||||
// case CodeType.Code2of5Interleaved:
|
||||
// return new Code2of5Interleaved(text, size, direction);
|
||||
|
||||
// case CodeType.Code3of9Standard:
|
||||
// return new Code3of9Standard(text, size, direction);
|
||||
|
||||
// default:
|
||||
// throw new InvalidEnumArgumentException("type", (int)type, typeof(CodeType));
|
||||
// }
|
||||
//}
|
||||
|
||||
//public static CodeBase FromType(CodeType type, string text, XSize size)
|
||||
//{
|
||||
// return FromType(type, text, size, CodeDirection.LeftToRight);
|
||||
//}
|
||||
|
||||
//public static CodeBase FromType(CodeType type, string text)
|
||||
//{
|
||||
// return FromType(type, text, XSize.Empty, CodeDirection.LeftToRight);
|
||||
//}
|
||||
|
||||
//public static CodeBase FromType(CodeType type)
|
||||
//{
|
||||
// return FromType(type, String.Empty, XSize.Empty, CodeDirection.LeftToRight);
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the size.
|
||||
/// </summary>
|
||||
public XSize Size
|
||||
{
|
||||
get { return _size; }
|
||||
set { _size = value; }
|
||||
}
|
||||
XSize _size;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text the bar code shall represent.
|
||||
/// </summary>
|
||||
public string Text
|
||||
{
|
||||
get { return _text; }
|
||||
set
|
||||
{
|
||||
CheckCode(value);
|
||||
_text = value;
|
||||
}
|
||||
}
|
||||
string _text;
|
||||
|
||||
/// <summary>
|
||||
/// Always MiddleCenter.
|
||||
/// </summary>
|
||||
public AnchorType Anchor
|
||||
{
|
||||
get { return _anchor; }
|
||||
set { _anchor = value; }
|
||||
}
|
||||
AnchorType _anchor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the drawing direction.
|
||||
/// </summary>
|
||||
public CodeDirection Direction
|
||||
{
|
||||
get { return _direction; }
|
||||
set { _direction = value; }
|
||||
}
|
||||
CodeDirection _direction;
|
||||
|
||||
/// <summary>
|
||||
/// When implemented in a derived class, determines whether the specified string can be used as Text
|
||||
/// for this bar code type.
|
||||
/// </summary>
|
||||
/// <param name="text">The code string to check.</param>
|
||||
/// <returns>True if the text can be used for the actual barcode.</returns>
|
||||
protected abstract void CheckCode(string text);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the distance between an old anchor point and a new anchor point.
|
||||
/// </summary>
|
||||
/// <param name="oldType"></param>
|
||||
/// <param name="newType"></param>
|
||||
/// <param name="size"></param>
|
||||
public static XVector CalcDistance(AnchorType oldType, AnchorType newType, XSize size)
|
||||
{
|
||||
if (oldType == newType)
|
||||
return new XVector();
|
||||
|
||||
XVector result;
|
||||
Delta delta = Deltas[(int)oldType, (int)newType];
|
||||
result = new XVector(size.Width / 2 * delta.X, size.Height / 2 * delta.Y);
|
||||
return result;
|
||||
}
|
||||
|
||||
struct Delta
|
||||
{
|
||||
public Delta(int x, int y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
public readonly int X;
|
||||
public readonly int Y;
|
||||
}
|
||||
static readonly Delta[,] Deltas = new Delta[9, 9]
|
||||
{
|
||||
{ new Delta(0, 0), new Delta(1, 0), new Delta(2, 0), new Delta(0, 1), new Delta(1, 1), new Delta(2, 1), new Delta(0, 2), new Delta(1, 2), new Delta(2, 2) },
|
||||
{ new Delta(-1, 0), new Delta(0, 0), new Delta(1, 0), new Delta(-1, 1), new Delta(0, 1), new Delta(1, 1), new Delta(-1, 2), new Delta(0, 2), new Delta(1, 2) },
|
||||
{ new Delta(-2, 0), new Delta(-1, 0), new Delta(0, 0), new Delta(-2, 1), new Delta(-1, 1), new Delta(0, 1), new Delta(-2, 2), new Delta(-1, 2), new Delta(0, 2) },
|
||||
{ new Delta(0, -1), new Delta(1, -1), new Delta(2, -1), new Delta(0, 0), new Delta(1, 0), new Delta(2, 0), new Delta(0, 1), new Delta(1, 1), new Delta(2, 1) },
|
||||
{ new Delta(-1, -1), new Delta(0, -1), new Delta(1, -1), new Delta(-1, 0), new Delta(0, 0), new Delta(1, 0), new Delta(-1, 1), new Delta(0, 1), new Delta(1, 1) },
|
||||
{ new Delta(-2, -1), new Delta(-1, -1), new Delta(0, -1), new Delta(-2, 0), new Delta(-1, 0), new Delta(0, 0), new Delta(-2, 1), new Delta(-1, 1), new Delta(0, 1) },
|
||||
{ new Delta(0, -2), new Delta(1, -2), new Delta(2, -2), new Delta(0, -1), new Delta(1, -1), new Delta(2, -1), new Delta(0, 0), new Delta(1, 0), new Delta(2, 0) },
|
||||
{ new Delta(-1, -2), new Delta(0, -2), new Delta(1, -2), new Delta(-1, -1), new Delta(0, -1), new Delta(1, -1), new Delta(-1, 0), new Delta(0, 0), new Delta(1, 0) },
|
||||
{ new Delta(-2, -2), new Delta(-1, -2), new Delta(0, -2), new Delta(-2, -1), new Delta(-1, -1), new Delta(0, -1), new Delta(-2, 0), new Delta(-1, 0), new Delta(0, 0) },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// David Stephensen
|
||||
// Stefan Lange
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the DataMatrix 2D barcode. THIS IS AN EMPIRA INTERNAL IMPLEMENTATION. THE CODE IN
|
||||
/// THE OPEN SOURCE VERSION IS A FAKE.
|
||||
/// </summary>
|
||||
public class CodeDataMatrix : MatrixCode
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of CodeDataMatrix.
|
||||
/// </summary>
|
||||
public CodeDataMatrix()
|
||||
: this("", "", 26, 26, 0, XSize.Empty)
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of CodeDataMatrix.
|
||||
/// </summary>
|
||||
public CodeDataMatrix(string code, int length)
|
||||
: this(code, "", length, length, 0, XSize.Empty)
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of CodeDataMatrix.
|
||||
/// </summary>
|
||||
public CodeDataMatrix(string code, int length, XSize size)
|
||||
: this(code, "", length, length, 0, size)
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of CodeDataMatrix.
|
||||
/// </summary>
|
||||
public CodeDataMatrix(string code, DataMatrixEncoding dmEncoding, int length, XSize size)
|
||||
: this(code, CreateEncoding(dmEncoding, code.Length), length, length, 0, size)
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of CodeDataMatrix.
|
||||
/// </summary>
|
||||
public CodeDataMatrix(string code, int rows, int columns)
|
||||
: this(code, "", rows, columns, 0, XSize.Empty)
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of CodeDataMatrix.
|
||||
/// </summary>
|
||||
public CodeDataMatrix(string code, int rows, int columns, XSize size)
|
||||
: this(code, "", rows, columns, 0, size)
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of CodeDataMatrix.
|
||||
/// </summary>
|
||||
public CodeDataMatrix(string code, DataMatrixEncoding dmEncoding, int rows, int columns, XSize size)
|
||||
: this(code, CreateEncoding(dmEncoding, code.Length), rows, columns, 0, size)
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of CodeDataMatrix.
|
||||
/// </summary>
|
||||
public CodeDataMatrix(string code, int rows, int columns, int quietZone)
|
||||
: this(code, "", rows, columns, quietZone, XSize.Empty)
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of CodeDataMatrix.
|
||||
/// </summary>
|
||||
public CodeDataMatrix(string code, string encoding, int rows, int columns, int quietZone, XSize size)
|
||||
: base(code, encoding, rows, columns, size)
|
||||
{
|
||||
QuietZone = quietZone;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the encoding of the DataMatrix.
|
||||
/// </summary>
|
||||
public void SetEncoding(DataMatrixEncoding dmEncoding)
|
||||
{
|
||||
Encoding = CreateEncoding(dmEncoding, Text.Length);
|
||||
}
|
||||
|
||||
static string CreateEncoding(DataMatrixEncoding dmEncoding, int length)
|
||||
{
|
||||
string tempencoding = "";
|
||||
switch (dmEncoding)
|
||||
{
|
||||
case DataMatrixEncoding.Ascii:
|
||||
tempencoding = new string('a', length);
|
||||
break;
|
||||
case DataMatrixEncoding.C40:
|
||||
tempencoding = new string('c', length);
|
||||
break;
|
||||
case DataMatrixEncoding.Text:
|
||||
tempencoding = new string('t', length);
|
||||
break;
|
||||
case DataMatrixEncoding.X12:
|
||||
tempencoding = new string('x', length);
|
||||
break;
|
||||
case DataMatrixEncoding.EDIFACT:
|
||||
tempencoding = new string('e', length);
|
||||
break;
|
||||
case DataMatrixEncoding.Base256:
|
||||
tempencoding = new string('b', length);
|
||||
break;
|
||||
}
|
||||
return tempencoding;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the size of the Matrix' Quiet Zone.
|
||||
/// </summary>
|
||||
public int QuietZone
|
||||
{
|
||||
get { return _quietZone; }
|
||||
set { _quietZone = value; }
|
||||
}
|
||||
int _quietZone;
|
||||
|
||||
/// <summary>
|
||||
/// Renders the matrix code.
|
||||
/// </summary>
|
||||
protected internal override void Render(XGraphics gfx, XBrush brush, XPoint position)
|
||||
{
|
||||
XGraphicsState state = gfx.Save();
|
||||
|
||||
switch (Direction)
|
||||
{
|
||||
case CodeDirection.RightToLeft:
|
||||
gfx.RotateAtTransform(180, position);
|
||||
break;
|
||||
|
||||
case CodeDirection.TopToBottom:
|
||||
gfx.RotateAtTransform(90, position);
|
||||
break;
|
||||
|
||||
case CodeDirection.BottomToTop:
|
||||
gfx.RotateAtTransform(-90, position);
|
||||
break;
|
||||
}
|
||||
|
||||
XPoint pos = position + CalcDistance(Anchor, AnchorType.TopLeft, Size);
|
||||
|
||||
if (MatrixImage == null)
|
||||
MatrixImage = DataMatrixImage.GenerateMatrixImage(Text, Encoding, Rows, Columns);
|
||||
|
||||
if (QuietZone > 0)
|
||||
{
|
||||
XSize sizeWithZone = new XSize(Size.Width, Size.Height);
|
||||
sizeWithZone.Width = sizeWithZone.Width / (Columns + 2 * QuietZone) * Columns;
|
||||
sizeWithZone.Height = sizeWithZone.Height / (Rows + 2 * QuietZone) * Rows;
|
||||
|
||||
XPoint posWithZone = new XPoint(pos.X, pos.Y);
|
||||
posWithZone.X += Size.Width / (Columns + 2 * QuietZone) * QuietZone;
|
||||
posWithZone.Y += Size.Height / (Rows + 2 * QuietZone) * QuietZone;
|
||||
|
||||
gfx.DrawRectangle(XBrushes.White, pos.X, pos.Y, Size.Width, Size.Height);
|
||||
gfx.DrawImage(MatrixImage, posWithZone.X, posWithZone.Y, sizeWithZone.Width, sizeWithZone.Height);
|
||||
}
|
||||
else
|
||||
gfx.DrawImage(MatrixImage, pos.X, pos.Y, Size.Width, Size.Height);
|
||||
|
||||
gfx.Restore(state);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified string can be used as data in the DataMatrix.
|
||||
/// </summary>
|
||||
/// <param name="text">The code to be checked.</param>
|
||||
protected override void CheckCode(string text)
|
||||
{
|
||||
if (text == null)
|
||||
throw new ArgumentNullException("text");
|
||||
|
||||
DataMatrixImage mImage = new DataMatrixImage(Text, Encoding, Rows, Columns);
|
||||
mImage.Iec16022Ecc200(Columns, Rows, Encoding, Text.Length, Text, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Klaus Potzesny
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an OMR code.
|
||||
/// </summary>
|
||||
public class CodeOmr : BarCode
|
||||
{
|
||||
/// <summary>
|
||||
/// initializes a new OmrCode with the given data.
|
||||
/// </summary>
|
||||
public CodeOmr(string text, XSize size, CodeDirection direction)
|
||||
: base(text, size, direction)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Renders the OMR code.
|
||||
/// </summary>
|
||||
protected internal override void Render(XGraphics gfx, XBrush brush, XFont font, XPoint position)
|
||||
{
|
||||
XGraphicsState state = gfx.Save();
|
||||
|
||||
switch (Direction)
|
||||
{
|
||||
case CodeDirection.RightToLeft:
|
||||
gfx.RotateAtTransform(180, position);
|
||||
break;
|
||||
|
||||
case CodeDirection.TopToBottom:
|
||||
gfx.RotateAtTransform(90, position);
|
||||
break;
|
||||
|
||||
case CodeDirection.BottomToTop:
|
||||
gfx.RotateAtTransform(-90, position);
|
||||
break;
|
||||
}
|
||||
|
||||
//XPoint pt = center - size / 2;
|
||||
XPoint pt = position - CodeBase.CalcDistance(AnchorType.TopLeft, Anchor, Size);
|
||||
uint value;
|
||||
uint.TryParse(Text, out value);
|
||||
// HACK: Project Wallenwein: set LK
|
||||
value |= 1;
|
||||
_synchronizeCode = true;
|
||||
|
||||
if (_synchronizeCode)
|
||||
{
|
||||
XRect rect = new XRect(pt.X, pt.Y, _makerThickness, Size.Height);
|
||||
gfx.DrawRectangle(brush, rect);
|
||||
pt.X += 2 * _makerDistance;
|
||||
}
|
||||
for (int idx = 0; idx < 32; idx++)
|
||||
{
|
||||
if ((value & 1) == 1)
|
||||
{
|
||||
XRect rect = new XRect(pt.X + idx * _makerDistance, pt.Y, _makerThickness, Size.Height);
|
||||
gfx.DrawRectangle(brush, rect);
|
||||
}
|
||||
value = value >> 1;
|
||||
}
|
||||
gfx.Restore(state);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether a synchronize mark is rendered.
|
||||
/// </summary>
|
||||
public bool SynchronizeCode
|
||||
{
|
||||
get { return _synchronizeCode; }
|
||||
set { _synchronizeCode = value; }
|
||||
}
|
||||
bool _synchronizeCode;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the distance of the markers.
|
||||
/// </summary>
|
||||
public double MakerDistance
|
||||
{
|
||||
get { return _makerDistance; }
|
||||
set { _makerDistance = value; }
|
||||
}
|
||||
double _makerDistance = 12; // 1/6"
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the thickness of the makers.
|
||||
/// </summary>
|
||||
public double MakerThickness
|
||||
{
|
||||
get { return _makerThickness; }
|
||||
set { _makerThickness = value; }
|
||||
}
|
||||
double _makerThickness = 1;
|
||||
|
||||
///// <summary>
|
||||
///// Renders the mark at the given position.
|
||||
///// </summary>
|
||||
///// <param name="position">The mark position to render.</param>
|
||||
//private void RenderMark(int position)
|
||||
//{
|
||||
// double yPos = TopLeft.Y + UpperDistance + position * ToUnit(markDistance).Centimeter;
|
||||
// //Center mark
|
||||
// double xPos = TopLeft.X + Width / 2 - this.MarkWidth / 2;
|
||||
|
||||
// Gfx.DrawLine(pen, xPos, yPos, xPos + MarkWidth, yPos);
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Distance of the marks. Default is 2/6 inch.
|
||||
///// </summary>
|
||||
//public MarkDistance MarkDistance
|
||||
//{
|
||||
// get { return markDistance; }
|
||||
// set { markDistance = value; }
|
||||
//}
|
||||
//private MarkDistance markDistance = MarkDistance.Inch2_6;
|
||||
|
||||
///// <summary>
|
||||
///// Converts a mark distance to an XUnit object.
|
||||
///// </summary>
|
||||
///// <param name="markDistance">The mark distance to convert.</param>
|
||||
///// <returns>The converted mark distance.</returns>
|
||||
//public static XUnit ToUnit(MarkDistance markDistance)
|
||||
//{
|
||||
// switch (markDistance)
|
||||
// {
|
||||
// case MarkDistance.Inch1_6:
|
||||
// return XUnit.FromInch(1.0 / 6.0);
|
||||
// case MarkDistance.Inch2_6:
|
||||
// return XUnit.FromInch(2.0 / 6.0);
|
||||
// case MarkDistance.Inch2_8:
|
||||
// return XUnit.FromInch(2.0 / 8.0);
|
||||
// default:
|
||||
// throw new ArgumentOutOfRangeException("markDistance");
|
||||
// }
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// The upper left point of the reading zone.
|
||||
///// </summary>
|
||||
//public XPoint TopLeft
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// XPoint topLeft = center;
|
||||
// topLeft.X -= Width;
|
||||
// double height = upperDistance + lowerDistance;
|
||||
// height += (data.Marks.Length - 1) * ToUnit(MarkDistance).Centimeter;
|
||||
// topLeft.Y -= height / 2;
|
||||
// return topLeft;
|
||||
// }
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// the upper distance from position to the first mark.
|
||||
///// The default value is 8 / 6 inch.
|
||||
///// </summary>
|
||||
//double UpperDistance
|
||||
//{
|
||||
// get { return upperDistance; }
|
||||
// set { upperDistance = value; }
|
||||
//}
|
||||
//private double upperDistance = XUnit.FromInch(8.0 / 6.0).Centimeter;
|
||||
|
||||
///// <summary>
|
||||
///// The lower distance from the last possible mark to the end of the reading zone.
|
||||
///// The default value is
|
||||
///// </summary>
|
||||
//double LowerDistance
|
||||
//{
|
||||
// get { return lowerDistance; }
|
||||
// set { lowerDistance = value; }
|
||||
//}
|
||||
//private double lowerDistance = XUnit.FromInch(2.0 / 6.0).Centimeter;
|
||||
|
||||
///// <summary>
|
||||
///// Gets or sets the width of the reading zone.
|
||||
///// Default and minimum is 3/12 inch.
|
||||
///// </summary>
|
||||
//public double Width
|
||||
//{
|
||||
// get { return width; }
|
||||
// set { width = value; }
|
||||
//}
|
||||
//double width = XUnit.FromInch(3.0 / 12.0).Centimeter;
|
||||
|
||||
///// <summary>
|
||||
///// Gets or sets the mark width. Default is 1/2 * width.
|
||||
///// </summary>
|
||||
//public XUnit MarkWidth
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (markWidth > 0)
|
||||
// return markWidth;
|
||||
// else
|
||||
// return width / 2;
|
||||
// }
|
||||
// set { markWidth = value; }
|
||||
//}
|
||||
//XUnit markWidth;
|
||||
|
||||
///// <summary>
|
||||
///// Gets or sets the width of the mark line. Default is 1pt.
|
||||
///// </summary>
|
||||
//public XUnit MarkLineWidth
|
||||
//{
|
||||
// get { return markLineWidth; }
|
||||
// set { markLineWidth = value; }
|
||||
//}
|
||||
//XUnit markLineWidth = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified string can be used as Text for the OMR code.
|
||||
/// </summary>
|
||||
protected override void CheckCode(string text)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// David Stephensen
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
// ========================================================================================
|
||||
// ========================================================================================
|
||||
// ===== THIS CLASS IS A FAKE. THE OPEN SOURCE VERSION OF PDFSHARP DOES NOT IMPLEMENT =====
|
||||
// ===== A DATAMATRIX CODE. THIS IS BECAUSE OF THE ISO COPYRIGHT. =====
|
||||
// ========================================================================================
|
||||
// ========================================================================================
|
||||
|
||||
// Even if it looks like a datamatrix code it is just random
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates the XImage object for a DataMatrix.
|
||||
/// Important note for OpenSource version of PDFsharp:
|
||||
/// The generated image object only contains random data.
|
||||
/// If you need the correct implementation as defined in the ISO/IEC 16022:2000 specification,
|
||||
/// please contact empira Software GmbH via www.PdfSharp.com.
|
||||
/// </summary>
|
||||
internal class DataMatrixImage
|
||||
{
|
||||
public static XImage GenerateMatrixImage(string text, string encoding, int rows, int columns)
|
||||
{
|
||||
DataMatrixImage dataMatrixImage = new DataMatrixImage(text, encoding, rows, columns);
|
||||
return dataMatrixImage.DrawMatrix();
|
||||
}
|
||||
|
||||
public DataMatrixImage(string text, string encoding, int rows, int columns)
|
||||
{
|
||||
this.text = text;
|
||||
this.encoding = encoding;
|
||||
this.rows = rows;
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
string text;
|
||||
string encoding;
|
||||
int rows;
|
||||
int columns;
|
||||
|
||||
/// <summary>
|
||||
/// Possible ECC200 Matrixes
|
||||
/// </summary>
|
||||
static Ecc200Block[] ecc200Sizes =
|
||||
{
|
||||
new Ecc200Block( 10, 10, 10, 10, 3, 3, 5), //
|
||||
new Ecc200Block( 12, 12, 12, 12, 5, 5, 7), //
|
||||
new Ecc200Block( 8, 18, 8, 18, 5, 5, 7), //
|
||||
new Ecc200Block( 14, 14, 14, 14, 8, 8, 10), //
|
||||
new Ecc200Block( 8, 32, 8, 16, 10, 10, 11), //
|
||||
new Ecc200Block( 16, 16, 16, 16, 12, 12, 12), //
|
||||
new Ecc200Block( 12, 26, 12, 26, 16, 16, 14), //
|
||||
new Ecc200Block( 18, 18, 18, 18, 18, 18, 14), //
|
||||
new Ecc200Block( 20, 20, 20, 20, 22, 22, 18), //
|
||||
new Ecc200Block( 12, 36, 12, 18, 22, 22, 18), //
|
||||
new Ecc200Block( 22, 22, 22, 22, 30, 30, 20), //
|
||||
new Ecc200Block( 16, 36, 16, 18, 32, 32, 24), //
|
||||
new Ecc200Block( 24, 24, 24, 24, 36, 36, 24), //
|
||||
new Ecc200Block( 26, 26, 26, 26, 44, 44, 28), //
|
||||
new Ecc200Block( 16, 48, 16, 24, 49, 49, 28), //
|
||||
new Ecc200Block( 32, 32, 16, 16, 62, 62, 36), //
|
||||
new Ecc200Block( 36, 36, 18, 18, 86, 86, 42), //
|
||||
new Ecc200Block( 40, 40, 20, 20, 114, 114, 48), //
|
||||
new Ecc200Block( 44, 44, 22, 22, 144, 144, 56), //
|
||||
new Ecc200Block( 48, 48, 24, 24, 174, 174, 68), //
|
||||
new Ecc200Block( 52, 52, 26, 26, 204, 102, 42), //
|
||||
new Ecc200Block( 64, 64, 16, 16, 280, 140, 56), //
|
||||
new Ecc200Block( 72, 72, 18, 18, 368, 92, 36), //
|
||||
new Ecc200Block( 80, 80, 20, 20, 456, 114, 48), //
|
||||
new Ecc200Block( 88, 88, 22, 22, 576, 144, 56), //
|
||||
new Ecc200Block( 96, 96, 24, 24, 696, 174, 68), //
|
||||
new Ecc200Block(104, 104, 26, 26, 816, 136, 56), //
|
||||
new Ecc200Block(120, 120, 20, 20, 1050, 175, 68), //
|
||||
new Ecc200Block(132, 132, 22, 22, 1304, 163, 62), //
|
||||
new Ecc200Block(144, 144, 24, 24, 1558, 156, 62), // 156*4+155*2
|
||||
new Ecc200Block( 0, 0, 0, 0, 0, 0, 0) // terminate
|
||||
};
|
||||
|
||||
public XImage DrawMatrix()
|
||||
{
|
||||
return CreateImage(DataMatrix(), this.rows, this.columns);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the DataMatrix code.
|
||||
/// </summary>
|
||||
internal char[] DataMatrix()
|
||||
{
|
||||
int matrixColumns = this.columns;
|
||||
int matrixRows = this.rows;
|
||||
Ecc200Block matrix = new Ecc200Block(0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
foreach (Ecc200Block eccmatrix in ecc200Sizes)
|
||||
{
|
||||
matrix = eccmatrix;
|
||||
if (matrix.Width != columns || matrix.Height != rows)
|
||||
continue;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
char[] grid = new char[matrixColumns * matrixRows];
|
||||
Random rand = new Random();
|
||||
|
||||
for (int ccol = 0; ccol < matrixColumns; ccol++)
|
||||
grid[ccol] = (char)1;
|
||||
|
||||
for (int rrows = 1; rrows < matrixRows; rrows++)
|
||||
{
|
||||
grid[rrows * matrixRows] = (char)1;
|
||||
for (int ccol = 1; ccol < matrixColumns; ccol++)
|
||||
grid[rrows * matrixRows + ccol] = (char)rand.Next(2);
|
||||
}
|
||||
|
||||
if (grid == null || matrixColumns == 0)
|
||||
return null; //No barcode produced;
|
||||
return grid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Encodes the DataMatrix.
|
||||
/// </summary>
|
||||
internal char[] Iec16022Ecc200(int columns, int rows, string encoding, int barcodelen, string barcode, int len, int max, int ecc)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a DataMatrix image object.
|
||||
/// </summary>
|
||||
/// <param name="code">A hex string like "AB 08 C3...".</param>
|
||||
/// <param name="size">I.e. 26 for a 26x26 matrix</param>
|
||||
public XImage CreateImage(char[] code, int size)//(string code, int size)
|
||||
{
|
||||
return CreateImage(code, size, size, 10);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a DataMatrix image object.
|
||||
/// </summary>
|
||||
public XImage CreateImage(char[] code, int rows, int columns)
|
||||
{
|
||||
return CreateImage(code, rows, columns, 10);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a DataMatrix image object.
|
||||
/// </summary>
|
||||
public XImage CreateImage(char[] code, int rows, int columns, int pixelsize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
struct Ecc200Block
|
||||
{
|
||||
public int Height;
|
||||
public int Width;
|
||||
public int CellHeight;
|
||||
public int CellWidth;
|
||||
public int Bytes;
|
||||
public int DataBlock;
|
||||
public int RSBlock;
|
||||
|
||||
public Ecc200Block(int h, int w, int ch, int cw, int bytes, int datablock, int rsblock)
|
||||
{
|
||||
Height = h;
|
||||
Width = w;
|
||||
CellHeight = ch;
|
||||
CellWidth = cw;
|
||||
Bytes = bytes;
|
||||
DataBlock = datablock;
|
||||
RSBlock = rsblock;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// David Stephensen
|
||||
// Stefan Lange
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the base class of all 2D codes.
|
||||
/// </summary>
|
||||
public abstract class MatrixCode : CodeBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MatrixCode"/> class.
|
||||
/// </summary>
|
||||
public MatrixCode(string text, string encoding, int rows, int columns, XSize size)
|
||||
: base(text, size, CodeDirection.LeftToRight)
|
||||
{
|
||||
_encoding = encoding;
|
||||
if (String.IsNullOrEmpty(_encoding))
|
||||
_encoding = new String('a', Text.Length);
|
||||
|
||||
if (columns < rows)
|
||||
{
|
||||
_rows = columns;
|
||||
_columns = rows;
|
||||
}
|
||||
else
|
||||
{
|
||||
_columns = columns;
|
||||
_rows = rows;
|
||||
}
|
||||
|
||||
Text = text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the encoding. docDaSt
|
||||
/// </summary>
|
||||
public string Encoding
|
||||
{
|
||||
get { return _encoding; }
|
||||
set
|
||||
{
|
||||
_encoding = value;
|
||||
_matrixImage = null;
|
||||
}
|
||||
}
|
||||
string _encoding;
|
||||
|
||||
/// <summary>
|
||||
/// docDaSt
|
||||
/// </summary>
|
||||
public int Columns
|
||||
{
|
||||
get { return _columns; }
|
||||
set
|
||||
{
|
||||
_columns = value;
|
||||
_matrixImage = null;
|
||||
}
|
||||
}
|
||||
int _columns;
|
||||
|
||||
/// <summary>
|
||||
/// docDaSt
|
||||
/// </summary>
|
||||
public int Rows
|
||||
{
|
||||
get { return _rows; }
|
||||
set
|
||||
{
|
||||
_rows = value;
|
||||
_matrixImage = null;
|
||||
}
|
||||
}
|
||||
int _rows;
|
||||
|
||||
/// <summary>
|
||||
/// docDaSt
|
||||
/// </summary>
|
||||
public new string Text
|
||||
{
|
||||
get { return base.Text; }
|
||||
set
|
||||
{
|
||||
base.Text = value;
|
||||
_matrixImage = null;
|
||||
}
|
||||
}
|
||||
|
||||
internal XImage MatrixImage
|
||||
{
|
||||
get { return _matrixImage; }
|
||||
set { _matrixImage = value; }
|
||||
}
|
||||
XImage _matrixImage;
|
||||
|
||||
/// <summary>
|
||||
/// When implemented in a derived class renders the 2D code.
|
||||
/// </summary>
|
||||
protected internal abstract void Render(XGraphics gfx, XBrush brush, XPoint center);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified string can be used as Text for this matrix code type.
|
||||
/// </summary>
|
||||
protected override void CheckCode(string text)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Klaus Potzesny
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
#if true_
|
||||
/// <summary>
|
||||
/// Represents the data coded within the OMR code.
|
||||
/// </summary>
|
||||
class OmrData
|
||||
{
|
||||
private OmrData()
|
||||
{
|
||||
}
|
||||
|
||||
public static OmrData ForTesting
|
||||
{
|
||||
get
|
||||
{
|
||||
OmrData data = new OmrData();
|
||||
data.AddMarkDescription("LK");
|
||||
data.AddMarkDescription("DGR");
|
||||
data.AddMarkDescription("GM1");
|
||||
data.AddMarkDescription("GM2");
|
||||
data.AddMarkDescription("GM4");
|
||||
data.AddMarkDescription("GM8");
|
||||
data.AddMarkDescription("GM16");
|
||||
data.AddMarkDescription("GM32");
|
||||
data.AddMarkDescription("ZS1");
|
||||
data.AddMarkDescription("ZS2");
|
||||
data.AddMarkDescription("ZS3");
|
||||
data.AddMarkDescription("ZS4");
|
||||
data.AddMarkDescription("ZS5");
|
||||
data.InitMarks();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// NYI: Get OMR description read from text file.
|
||||
///// </summary>
|
||||
///// <returns>An OmrData object.</returns>
|
||||
//public static OmrData FromDescriptionFile(string filename)
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a mark description by name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name to for setting or unsetting the mark.</param>
|
||||
private void AddMarkDescription(string name)
|
||||
{
|
||||
if (_marksInitialized)
|
||||
throw new InvalidOperationException(BcgSR.OmrAlreadyInitialized);
|
||||
|
||||
_nameToIndex[name] = AddedDescriptions;
|
||||
++AddedDescriptions;
|
||||
}
|
||||
|
||||
private void InitMarks()
|
||||
{
|
||||
if (AddedDescriptions == 0)
|
||||
throw new InvalidOperationException();
|
||||
|
||||
_marks = new bool[AddedDescriptions];
|
||||
_marks.Initialize();
|
||||
_marksInitialized = true;
|
||||
}
|
||||
|
||||
private int FindIndex(string name)
|
||||
{
|
||||
if (!_marksInitialized)
|
||||
InitMarks();
|
||||
|
||||
if (!_nameToIndex.Contains(name))
|
||||
throw new ArgumentException(BcgSR.InvalidMarkName(name));
|
||||
|
||||
return (int)_nameToIndex[name];
|
||||
}
|
||||
|
||||
public void SetMark(string name)
|
||||
{
|
||||
int idx = FindIndex(name);
|
||||
_marks[idx] = true;
|
||||
}
|
||||
|
||||
public void UnsetMark(string name)
|
||||
{
|
||||
int idx = FindIndex(name);
|
||||
_marks[idx] = false;
|
||||
}
|
||||
|
||||
public bool[] Marks
|
||||
{
|
||||
get { return _marks; }
|
||||
}
|
||||
System.Collections.Hash_table nameToIndex = new Hash_table();
|
||||
bool[] marks;
|
||||
int addedDescriptions = 0;
|
||||
bool marksInitialized = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
//
|
||||
// PDFsharp - A library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Klaus Potzesny
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using PdfSharpCore.Fonts;
|
||||
using System;
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
/// <summary>
|
||||
/// Internal base class for several bar code types.
|
||||
/// </summary>
|
||||
public abstract class ThickThinBarCode : BarCode // TODO: The name is not optimal
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ThickThinBarCode"/> class.
|
||||
/// </summary>
|
||||
public ThickThinBarCode(string code, XSize size, CodeDirection direction)
|
||||
: base(code, size, direction)
|
||||
{ }
|
||||
|
||||
internal override void InitRendering(BarCodeRenderInfo info)
|
||||
{
|
||||
base.InitRendering(info);
|
||||
CalcThinBarWidth(info);
|
||||
info.BarHeight = Size.Height;
|
||||
// HACK in ThickThinBarCode
|
||||
if (TextLocation != TextLocation.None)
|
||||
info.BarHeight *= 4.0 / 5;
|
||||
|
||||
#if DEBUG_
|
||||
XColor back = XColors.LightSalmon;
|
||||
back.A = 0.3;
|
||||
XSolidBrush brush = new XSolidBrush(back);
|
||||
info.Gfx.DrawRectangle(brush, new XRect(info.Center - size / 2, size));
|
||||
#endif
|
||||
switch (Direction)
|
||||
{
|
||||
case CodeDirection.RightToLeft:
|
||||
info.Gfx.RotateAtTransform(180, info.Position);
|
||||
break;
|
||||
|
||||
case CodeDirection.TopToBottom:
|
||||
info.Gfx.RotateAtTransform(90, info.Position);
|
||||
break;
|
||||
|
||||
case CodeDirection.BottomToTop:
|
||||
info.Gfx.RotateAtTransform(-90, info.Position);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ration between thick an thin lines. Must be between 2 and 3.
|
||||
/// Optimal and also default value is 2.6.
|
||||
/// </summary>
|
||||
public override double WideNarrowRatio
|
||||
{
|
||||
get { return _wideNarrowRatio; }
|
||||
set
|
||||
{
|
||||
if (value > 3 || value < 2)
|
||||
throw new ArgumentOutOfRangeException("value", BcgSR.Invalid2of5Relation);
|
||||
_wideNarrowRatio = value;
|
||||
}
|
||||
}
|
||||
double _wideNarrowRatio = 2.6;
|
||||
|
||||
/// <summary>
|
||||
/// Renders a thick or thin line for the bar code.
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
/// <param name="isThick">Determines whether a thick or a thin line is about to be rendered.</param>
|
||||
internal void RenderBar(BarCodeRenderInfo info, bool isThick)
|
||||
{
|
||||
double barWidth = GetBarWidth(info, isThick);
|
||||
double height = Size.Height;
|
||||
double xPos = info.CurrPos.X;
|
||||
double yPos = info.CurrPos.Y;
|
||||
|
||||
switch (TextLocation)
|
||||
{
|
||||
case TextLocation.AboveEmbedded:
|
||||
height -= info.Gfx.MeasureString(Text, info.Font).Height;
|
||||
yPos += info.Gfx.MeasureString(Text, info.Font).Height;
|
||||
break;
|
||||
case TextLocation.BelowEmbedded:
|
||||
height -= info.Gfx.MeasureString(Text, info.Font).Height;
|
||||
break;
|
||||
}
|
||||
|
||||
XRect rect = new XRect(xPos, yPos, barWidth, height);
|
||||
info.Gfx.DrawRectangle(info.Brush, rect);
|
||||
info.CurrPos.X += barWidth;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders a thick or thin gap for the bar code.
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
/// <param name="isThick">Determines whether a thick or a thin gap is about to be rendered.</param>
|
||||
internal void RenderGap(BarCodeRenderInfo info, bool isThick)
|
||||
{
|
||||
info.CurrPos.X += GetBarWidth(info, isThick);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders a thick bar before or behind the code.
|
||||
/// </summary>
|
||||
internal void RenderTurboBit(BarCodeRenderInfo info, bool startBit)
|
||||
{
|
||||
if (startBit)
|
||||
info.CurrPos.X -= 0.5 + GetBarWidth(info, true);
|
||||
else
|
||||
info.CurrPos.X += 0.5; //GetBarWidth(info, true);
|
||||
|
||||
RenderBar(info, true);
|
||||
|
||||
if (startBit)
|
||||
info.CurrPos.X += 0.5; //GetBarWidth(info, true);
|
||||
}
|
||||
|
||||
internal void RenderText(BarCodeRenderInfo info)
|
||||
{
|
||||
if (info.Font == null)
|
||||
info.Font = new XFont(GlobalFontSettings.FontResolver.DefaultFontName, Size.Height / 6);
|
||||
XPoint center = info.Position + CalcDistance(Anchor, AnchorType.TopLeft, Size);
|
||||
|
||||
switch (TextLocation)
|
||||
{
|
||||
case TextLocation.Above:
|
||||
center = new XPoint(center.X, center.Y - info.Gfx.MeasureString(Text, info.Font).Height);
|
||||
info.Gfx.DrawString(Text, info.Font, info.Brush, new XRect(center, Size), XStringFormats.TopCenter);
|
||||
break;
|
||||
case TextLocation.AboveEmbedded:
|
||||
info.Gfx.DrawString(Text, info.Font, info.Brush, new XRect(center, Size), XStringFormats.TopCenter);
|
||||
break;
|
||||
case TextLocation.Below:
|
||||
center = new XPoint(center.X, info.Gfx.MeasureString(Text, info.Font).Height + center.Y);
|
||||
info.Gfx.DrawString(Text, info.Font, info.Brush, new XRect(center, Size), XStringFormats.BottomCenter);
|
||||
break;
|
||||
case TextLocation.BelowEmbedded:
|
||||
info.Gfx.DrawString(Text, info.Font, info.Brush, new XRect(center, Size), XStringFormats.BottomCenter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the width of a thick or a thin line (or gap). CalcLineWidth must have been called before.
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
/// <param name="isThick">Determines whether a thick line's with shall be returned.</param>
|
||||
internal double GetBarWidth(BarCodeRenderInfo info, bool isThick)
|
||||
{
|
||||
if (isThick)
|
||||
return info.ThinBarWidth * _wideNarrowRatio;
|
||||
return info.ThinBarWidth;
|
||||
}
|
||||
|
||||
internal abstract void CalcThinBarWidth(BarCodeRenderInfo info);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Klaus Potzesny
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies whether and how the text is displayed at the code area.
|
||||
/// </summary>
|
||||
public enum AnchorType
|
||||
{
|
||||
/// <summary>
|
||||
/// The anchor is located top left.
|
||||
/// </summary>
|
||||
TopLeft,
|
||||
|
||||
/// <summary>
|
||||
/// The anchor is located top center.
|
||||
/// </summary>
|
||||
TopCenter,
|
||||
|
||||
/// <summary>
|
||||
/// The anchor is located top right.
|
||||
/// </summary>
|
||||
TopRight,
|
||||
|
||||
/// <summary>
|
||||
/// The anchor is located middle left.
|
||||
/// </summary>
|
||||
MiddleLeft,
|
||||
|
||||
/// <summary>
|
||||
/// The anchor is located middle center.
|
||||
/// </summary>
|
||||
MiddleCenter,
|
||||
|
||||
/// <summary>
|
||||
/// The anchor is located middle right.
|
||||
/// </summary>
|
||||
MiddleRight,
|
||||
|
||||
/// <summary>
|
||||
/// The anchor is located bottom left.
|
||||
/// </summary>
|
||||
BottomLeft,
|
||||
|
||||
/// <summary>
|
||||
/// The anchor is located bottom center.
|
||||
/// </summary>
|
||||
BottomCenter,
|
||||
|
||||
/// <summary>
|
||||
/// The anchor is located bottom right.
|
||||
/// </summary>
|
||||
BottomRight,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Klaus Potzesny
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the drawing direction of the code.
|
||||
/// </summary>
|
||||
public enum CodeDirection
|
||||
{
|
||||
/// <summary>
|
||||
/// Does not rotate the code.
|
||||
/// </summary>
|
||||
LeftToRight,
|
||||
|
||||
/// <summary>
|
||||
/// Rotates the code 180° at the anchor position.
|
||||
/// </summary>
|
||||
BottomToTop,
|
||||
|
||||
/// <summary>
|
||||
/// Rotates the code 180° at the anchor position.
|
||||
/// </summary>
|
||||
RightToLeft,
|
||||
|
||||
/// <summary>
|
||||
/// Rotates the code 180° at the anchor position.
|
||||
/// </summary>
|
||||
TopToBottom,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Klaus Potzesny
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the type of the bar code.
|
||||
/// </summary>
|
||||
public enum CodeType
|
||||
{
|
||||
/// <summary>
|
||||
/// The standard 2 of 5 interleaved bar code.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
Code2of5Interleaved,
|
||||
|
||||
/// <summary>
|
||||
/// The standard 3 of 9 bar code.
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
Code3of9Standard,
|
||||
|
||||
/// <summary>
|
||||
/// The OMR code.
|
||||
/// </summary>
|
||||
Omr,
|
||||
|
||||
/// <summary>
|
||||
/// The data matrix code.
|
||||
/// </summary>
|
||||
DataMatrix,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Klaus Potzesny
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
/// <summary>
|
||||
/// docDaSt
|
||||
/// </summary>
|
||||
public enum DataMatrixEncoding
|
||||
{
|
||||
/// <summary>
|
||||
/// docDaSt
|
||||
/// </summary>
|
||||
Ascii,
|
||||
|
||||
/// <summary>
|
||||
/// docDaSt
|
||||
/// </summary>
|
||||
C40,
|
||||
|
||||
/// <summary>
|
||||
/// docDaSt
|
||||
/// </summary>
|
||||
Text,
|
||||
|
||||
/// <summary>
|
||||
/// docDaSt
|
||||
/// </summary>
|
||||
X12,
|
||||
|
||||
/// <summary>
|
||||
/// docDaSt
|
||||
/// </summary>
|
||||
// ReSharper disable once InconsistentNaming
|
||||
EDIFACT,
|
||||
|
||||
/// <summary>
|
||||
/// docDaSt
|
||||
/// </summary>
|
||||
Base256
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Klaus Potzesny
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
///// <summary>
|
||||
///// Valid mark distances for OMR Codes.
|
||||
///// </summary>
|
||||
//public enum MarkDistance
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// 2/6 inch, valid for printing with 6 lpi. (line height = 12 pt).
|
||||
// /// </summary>
|
||||
// Inch1_6,
|
||||
// /// <summary>
|
||||
// /// 2/6 inch, valid for printing with 6 lpi (line height = 12 pt).
|
||||
// /// </summary>
|
||||
// Inch2_6,
|
||||
// /// <summary>
|
||||
// /// 2/8 inch, valid for printing with 8 lpi (line height = 9 pt).
|
||||
// /// </summary>
|
||||
// Inch2_8
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Klaus Potzesny
|
||||
//
|
||||
// Copyright (c) 2005-2016 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.PdfSharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
namespace PdfSharpCore.Drawing.BarCodes
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies whether and how the text is displayed at the code.
|
||||
/// </summary>
|
||||
public enum TextLocation
|
||||
{
|
||||
/// <summary>
|
||||
/// No text is drawn.
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// The text is located above the code.
|
||||
/// </summary>
|
||||
Above,
|
||||
|
||||
/// <summary>
|
||||
/// The text is located below the code.
|
||||
/// </summary>
|
||||
Below,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The text is located above within the code.
|
||||
/// </summary>
|
||||
AboveEmbedded,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The text is located below within the code.
|
||||
/// </summary>
|
||||
BelowEmbedded,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user