Test
This commit is contained in:
		
							
								
								
									
										170
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/BarCode.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										170
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/BarCode.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,170 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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 PdfSharp.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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										54
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/BarCodeRenderInfo.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/BarCodeRenderInfo.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
			
		||||
//
 | 
			
		||||
// PDFsharp - A library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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 PdfSharp.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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										93
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/BcgSR.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/BcgSR.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,93 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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 PdfSharp.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);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										193
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/Code2of5Interleaved.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										193
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/Code2of5Interleaved.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,193 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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 PdfSharp.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
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										271
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/Code3of9Standard.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										271
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/Code3of9Standard.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,271 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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 PdfSharp.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, '*');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										169
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/CodeBase.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										169
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/CodeBase.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,169 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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 PdfSharp.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) },
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										217
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/CodeDataMatrix.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										217
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/CodeDataMatrix.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,217 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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;
 | 
			
		||||
#if GDI
 | 
			
		||||
using System.Drawing;
 | 
			
		||||
#endif
 | 
			
		||||
#if WPF
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
namespace PdfSharp.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);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										247
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/CodeOmr.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										247
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/CodeOmr.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,247 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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 PdfSharp.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);
 | 
			
		||||
#if true
 | 
			
		||||
            // HACK: Project Wallenwein: set LK
 | 
			
		||||
            value |= 1;
 | 
			
		||||
            _synchronizeCode = true;
 | 
			
		||||
#endif
 | 
			
		||||
            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)
 | 
			
		||||
        { }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										787
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/DataMatrixImage.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										787
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/DataMatrixImage.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,787 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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.Diagnostics;
 | 
			
		||||
#if GDI
 | 
			
		||||
using System.Drawing;
 | 
			
		||||
using System.Drawing.Imaging;
 | 
			
		||||
#endif
 | 
			
		||||
#if WPF
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// WPFHACK
 | 
			
		||||
#pragma warning disable 162
 | 
			
		||||
 | 
			
		||||
namespace PdfSharp.Drawing.BarCodes
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Creates the XImage object for a DataMatrix.
 | 
			
		||||
    /// </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)
 | 
			
		||||
        {
 | 
			
		||||
            _text = text;
 | 
			
		||||
            _encoding = encoding;
 | 
			
		||||
            _rows = rows;
 | 
			
		||||
            _columns = columns;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        string _encoding;
 | 
			
		||||
        readonly string _text;
 | 
			
		||||
        readonly int _rows;
 | 
			
		||||
        readonly int _columns;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Possible ECC200 Matrices.
 | 
			
		||||
        /// </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),    // Post
 | 
			
		||||
      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),    // Post
 | 
			
		||||
      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(), _rows, _columns);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates the DataMatrix code.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        internal char[] DataMatrix()
 | 
			
		||||
        {
 | 
			
		||||
            int matrixColumns = _columns;
 | 
			
		||||
            int matrixRows = _rows;
 | 
			
		||||
            int ecc = 200;
 | 
			
		||||
            if (String.IsNullOrEmpty(_encoding))
 | 
			
		||||
                _encoding = new String('a', _text.Length);
 | 
			
		||||
            int len = 0;
 | 
			
		||||
            int maxlen = 0;
 | 
			
		||||
            int ecclen = 0;
 | 
			
		||||
            char[] grid = null;
 | 
			
		||||
 | 
			
		||||
            if (matrixColumns != 0 && matrixRows != 0 && (matrixColumns & 1) != 0 && (matrixRows & 1) != 0 && ecc == 200)
 | 
			
		||||
                throw new ArgumentException(BcgSR.DataMatrixNotSupported);
 | 
			
		||||
 | 
			
		||||
            grid = Iec16022Ecc200(matrixColumns, matrixRows, _encoding, _text.Length, _text, len, maxlen, ecclen);
 | 
			
		||||
 | 
			
		||||
            if (grid == null || matrixColumns == 0)
 | 
			
		||||
                throw new ArgumentException(BcgSR.DataMatrixNull); //DaSt: ever happen?
 | 
			
		||||
            return grid;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Encodes the DataMatrix.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        internal char[] Iec16022Ecc200(int columns, int rows, string encoding, int barcodeLength, string barcode, int len, int max, int ecc)
 | 
			
		||||
        {
 | 
			
		||||
            char[] binary = new char[3000];  // encoded raw data and ecc to place in barcode
 | 
			
		||||
            Ecc200Block matrix = new Ecc200Block(0, 0, 0, 0, 0, 0, 0);
 | 
			
		||||
            for (int i = 0; i < 3000; i++)
 | 
			
		||||
                binary[i] = (char)0;
 | 
			
		||||
 | 
			
		||||
            foreach (Ecc200Block eccmatrix in ecc200Sizes)
 | 
			
		||||
            {
 | 
			
		||||
                matrix = eccmatrix;
 | 
			
		||||
                if (matrix.Width == columns && matrix.Height == rows)
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (matrix.Width == 0)
 | 
			
		||||
                throw new ArgumentException(BcgSR.DataMatrixInvalid(columns, rows));
 | 
			
		||||
 | 
			
		||||
            if (!Ecc200Encode(ref binary, matrix.Bytes, barcode, barcodeLength, encoding, ref len))
 | 
			
		||||
                throw new ArgumentException(BcgSR.DataMatrixTooBig);
 | 
			
		||||
 | 
			
		||||
            // ecc code
 | 
			
		||||
            Ecc200(binary, matrix.Bytes, matrix.DataBlock, matrix.RSBlock);
 | 
			
		||||
            // placement
 | 
			
		||||
            int x;
 | 
			
		||||
            int y;
 | 
			
		||||
            int NR;
 | 
			
		||||
            int[] places;
 | 
			
		||||
            int NC = columns - 2 * (columns / matrix.CellWidth);
 | 
			
		||||
            NR = rows - 2 * (rows / matrix.CellHeight);
 | 
			
		||||
            places = new int[NC * NR];
 | 
			
		||||
            Ecc200Placement(ref places, NR, NC);
 | 
			
		||||
            char[] grid = new char[columns * rows];
 | 
			
		||||
            for (y = 0; y < rows; y += matrix.CellHeight)
 | 
			
		||||
            {
 | 
			
		||||
                for (x = 0; x < columns; x++)
 | 
			
		||||
                    grid[y * columns + x] = (char)1;
 | 
			
		||||
                for (x = 0; x < columns; x += 2)
 | 
			
		||||
                    grid[(y + matrix.CellHeight - 1) * columns + x] = (char)1;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            for (x = 0; x < columns; x += matrix.CellWidth)
 | 
			
		||||
            {
 | 
			
		||||
                for (y = 0; y < rows; y++)
 | 
			
		||||
                    grid[y * columns + x] = (char)1;
 | 
			
		||||
                for (y = 0; y < rows; y += 2)
 | 
			
		||||
                    grid[y * columns + x + matrix.CellWidth - 1] = (char)1;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            for (y = 0; y < NR; y++)
 | 
			
		||||
            {
 | 
			
		||||
                for (x = 0; x < NC; x++)
 | 
			
		||||
                {
 | 
			
		||||
                    int v = places[(NR - y - 1) * NC + x];
 | 
			
		||||
                    if (v == 1 || v > 7 && ((binary[(v >> 3) - 1] & (1 << (v & 7))) != 0))
 | 
			
		||||
                        grid[(1 + y + 2 * (y / (matrix.CellHeight - 2))) * columns + 1 + x + 2 * (x / (matrix.CellWidth - 2))] = (char)1;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return grid;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Encodes the barcode with the DataMatrix ECC200 Encoding.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        internal bool Ecc200Encode(ref char[] t, int targetLength, string s, int sourceLength, string encoding, ref int len)
 | 
			
		||||
        {
 | 
			
		||||
            char enc = 'a';              // start in ASCII encoding mode
 | 
			
		||||
            int targetposition = 0;
 | 
			
		||||
            int sourceposition = 0;
 | 
			
		||||
            if (encoding.Length < sourceLength)
 | 
			
		||||
                return false;
 | 
			
		||||
 | 
			
		||||
            // do the encoding
 | 
			
		||||
            while (sourceposition < sourceLength && targetposition < targetLength)
 | 
			
		||||
            {
 | 
			
		||||
                char newenc = enc;        // suggest new encoding
 | 
			
		||||
                if (targetLength - targetposition <= 1 && (enc == 'c' || enc == 't') || targetLength - targetposition <= 2 && enc == 'x')
 | 
			
		||||
                    enc = 'a';             // auto revert to ASCII
 | 
			
		||||
#if !SILVERLIGHT
 | 
			
		||||
                // StL: Who wrote this nonsense?
 | 
			
		||||
                //newenc = char.Parse(encoding[sourceposition].ToString(CultureInfo.InvariantCulture).ToLower());
 | 
			
		||||
                newenc = char.ToLower(encoding[sourceposition]);
 | 
			
		||||
#else
 | 
			
		||||
        throw new NotImplementedException("char.Parse");
 | 
			
		||||
#endif
 | 
			
		||||
                switch (newenc)
 | 
			
		||||
                {                         // encode character
 | 
			
		||||
                    case 'c':                // C40
 | 
			
		||||
                    case 't':                // Text
 | 
			
		||||
                    case 'x':                // X12
 | 
			
		||||
                        {
 | 
			
		||||
                            char[] output = new char[6];
 | 
			
		||||
                            char p = (char)0;
 | 
			
		||||
 | 
			
		||||
                            string e = null;
 | 
			
		||||
                            string s2 = "!\"#$%&'()*+,-./:;<=>?@[\\]_";
 | 
			
		||||
                            string s3 = null;
 | 
			
		||||
                            if (newenc == 'c')
 | 
			
		||||
                            {
 | 
			
		||||
                                e = " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 | 
			
		||||
                                s3 = "`abcdefghijklmnopqrstuvwxyz{|}~±";
 | 
			
		||||
                            }
 | 
			
		||||
                            if (newenc == 't')
 | 
			
		||||
                            {
 | 
			
		||||
                                e = " 0123456789abcdefghijklmnopqrstuvwxyz";
 | 
			
		||||
                                s3 = "`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~±";
 | 
			
		||||
                            }
 | 
			
		||||
                            if (newenc == 'x')
 | 
			
		||||
                                e = " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\r*>";
 | 
			
		||||
                            do
 | 
			
		||||
                            {
 | 
			
		||||
                                char c = s[sourceposition++];
 | 
			
		||||
                                char w;
 | 
			
		||||
                                if ((c & 0x80) != 0)
 | 
			
		||||
                                {
 | 
			
		||||
                                    if (newenc == 'x')
 | 
			
		||||
                                    {
 | 
			
		||||
                                        //                     fprintf (stderr, "Cannot encode char 0x%02X in X12\n", c);
 | 
			
		||||
                                        return false;
 | 
			
		||||
                                    }
 | 
			
		||||
                                    c &= (char)0x7f;
 | 
			
		||||
                                    output[p++] = (char)1;
 | 
			
		||||
                                    output[p++] = (char)30;
 | 
			
		||||
                                }
 | 
			
		||||
                                w = e.IndexOf(c) == -1 ? (char)0 : e[e.IndexOf(c)];
 | 
			
		||||
                                if (w != (char)0)
 | 
			
		||||
                                    output[p++] = (char)((e.IndexOf(w) + 3) % 40);
 | 
			
		||||
                                else
 | 
			
		||||
                                {
 | 
			
		||||
                                    if (newenc == 'x')
 | 
			
		||||
                                    {
 | 
			
		||||
                                        //fprintf (stderr, "Cannot encode char 0x%02X in X12\n", c);
 | 
			
		||||
                                        return false;
 | 
			
		||||
                                    }
 | 
			
		||||
                                    if (c < 32)
 | 
			
		||||
                                    {             // shift 1
 | 
			
		||||
                                        output[p++] = (char)0;
 | 
			
		||||
                                        output[p++] = c;
 | 
			
		||||
                                    }
 | 
			
		||||
                                    else
 | 
			
		||||
                                    {
 | 
			
		||||
                                        w = s2.IndexOf(c) == -1 ? (char)0 : (char)s2.IndexOf(c);
 | 
			
		||||
                                        if (w != (char)0)
 | 
			
		||||
                                        {          // shift 2
 | 
			
		||||
                                            output[p++] = (char)1;
 | 
			
		||||
                                            output[p++] = w;
 | 
			
		||||
                                        }
 | 
			
		||||
                                        else
 | 
			
		||||
                                        {
 | 
			
		||||
                                            w = s3.IndexOf(c) == -1 ? (char)0 : (char)s3.IndexOf(c);
 | 
			
		||||
                                            if (w != (char)0)
 | 
			
		||||
                                            {
 | 
			
		||||
                                                output[p++] = (char)2;
 | 
			
		||||
                                                output[p++] = w;
 | 
			
		||||
                                            }
 | 
			
		||||
                                            else
 | 
			
		||||
                                                //fprintf (stderr, "Could not encode 0x%02X, should not happen\n", c);
 | 
			
		||||
                                                return false;
 | 
			
		||||
                                        }
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
 | 
			
		||||
                                if (p == 2 && targetposition + 2 == targetLength && sourceposition == sourceLength)
 | 
			
		||||
                                    output[p++] = (char)0; // shift 1 pad at end
 | 
			
		||||
                                while (p >= 3)
 | 
			
		||||
                                {
 | 
			
		||||
                                    int v = output[0] * 1600 + output[1] * 40 + output[2] + 1;
 | 
			
		||||
                                    if (enc != newenc)
 | 
			
		||||
                                    {
 | 
			
		||||
                                        if (enc == 'c' || enc == 't' || enc == 'x')
 | 
			
		||||
                                            t[targetposition++] = (char)254;  // escape C40/text/X12
 | 
			
		||||
                                        else if (enc == 'x')
 | 
			
		||||
                                            t[targetposition++] = (char)0x7C; // escape EDIFACT
 | 
			
		||||
                                        if (newenc == 'c')
 | 
			
		||||
                                            t[targetposition++] = (char)230;
 | 
			
		||||
                                        if (newenc == 't')
 | 
			
		||||
                                            t[targetposition++] = (char)239;
 | 
			
		||||
                                        if (newenc == 'x')
 | 
			
		||||
                                            t[targetposition++] = (char)238;
 | 
			
		||||
                                        enc = newenc;
 | 
			
		||||
                                    }
 | 
			
		||||
                                    t[targetposition++] = (char)(v >> 8);
 | 
			
		||||
                                    t[targetposition++] = (char)(v & 0xFF);
 | 
			
		||||
                                    p -= (char)3;
 | 
			
		||||
                                    output[0] = output[3];
 | 
			
		||||
                                    output[1] = output[4];
 | 
			
		||||
                                    output[2] = output[5];
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                            while (p != (char)0 && sourceposition < sourceLength);
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 'e':                // EDIFACT
 | 
			
		||||
                        {
 | 
			
		||||
                            char[] output = new char[4];
 | 
			
		||||
                            char p = (char)0;
 | 
			
		||||
                            if (enc != newenc)
 | 
			
		||||
                            {                   // can only be from C40/Text/X12
 | 
			
		||||
                                t[targetposition++] = (char)254;
 | 
			
		||||
                                enc = 'a';
 | 
			
		||||
                            }
 | 
			
		||||
                            while (sourceposition < sourceLength && /*encoding[sourceposition].ToString(CultureInfo.InvariantCulture).ToLower() == "e"*/
 | 
			
		||||
                              char.ToLower(encoding[sourceposition]) == 'e' && p < 4)
 | 
			
		||||
                                output[p++] = s[sourceposition++];
 | 
			
		||||
                            if (p < 4)
 | 
			
		||||
                            {
 | 
			
		||||
                                output[p++] = (char)0x1F;
 | 
			
		||||
                                enc = 'a';
 | 
			
		||||
                            }                   // termination
 | 
			
		||||
                            t[targetposition] = (char)((s[0] & 0x3F) << 2);
 | 
			
		||||
                            t[targetposition++] |= (char)((s[1] & 0x30) >> 4);
 | 
			
		||||
                            t[targetposition] = (char)((s[1] & 0x0F) << 4);
 | 
			
		||||
                            if (p == 2)
 | 
			
		||||
                                targetposition++;
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                t[targetposition++] |= (char)((s[2] & 0x3C) >> 2);
 | 
			
		||||
                                t[targetposition] = (char)((s[2] & 0x03) << 6);
 | 
			
		||||
                                t[targetposition++] |= (char)(s[3] & 0x3F);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 'a':                // ASCII
 | 
			
		||||
                        if (enc != newenc)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (enc == 'c' || enc == 't' || enc == 'x')
 | 
			
		||||
                                t[targetposition++] = (char)254;   // escape C40/text/X12
 | 
			
		||||
                            else
 | 
			
		||||
                                t[targetposition++] = (char)0x7C;  // escape EDIFACT
 | 
			
		||||
                        }
 | 
			
		||||
                        enc = 'a';
 | 
			
		||||
                        if (sourceLength - sourceposition >= 2 && char.IsDigit(s[sourceposition]) && char.IsDigit(s[sourceposition + 1]))
 | 
			
		||||
                        {
 | 
			
		||||
                            t[targetposition++] = (char)((s[sourceposition] - '0') * 10 + s[sourceposition + 1] - '0' + 130);
 | 
			
		||||
                            sourceposition += 2;
 | 
			
		||||
                        }
 | 
			
		||||
                        else if (s[sourceposition] > 127)
 | 
			
		||||
                        {
 | 
			
		||||
                            t[targetposition++] = (char)235;
 | 
			
		||||
                            t[targetposition++] = (char)(s[sourceposition++] - 127);
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                            t[targetposition++] = (char)(s[sourceposition++] + 1);
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 'b':                // Binary
 | 
			
		||||
                        {
 | 
			
		||||
                            int l = 0;          // how much to encode
 | 
			
		||||
                            if (encoding != null)
 | 
			
		||||
                            {
 | 
			
		||||
                                int p;
 | 
			
		||||
                                for (p = sourceposition; p < sourceLength && /*encoding[p].ToString(CultureInfo.InvariantCulture).ToLower() == "b"*/ char.ToLower(encoding[p]) == 'b'; p++)
 | 
			
		||||
                                    l++;
 | 
			
		||||
                            }
 | 
			
		||||
                            t[targetposition++] = (char)231;      // base256
 | 
			
		||||
                            if (l < 250)
 | 
			
		||||
                            {
 | 
			
		||||
                                t[targetposition] = (char)State255(l, targetposition);
 | 
			
		||||
                                targetposition++;
 | 
			
		||||
                            }
 | 
			
		||||
                            else
 | 
			
		||||
                            {
 | 
			
		||||
                                t[targetposition] = (char)State255(249 + (l / 250), targetposition);
 | 
			
		||||
                                targetposition++;
 | 
			
		||||
                                t[targetposition] = (char)State255(l % 250, targetposition);
 | 
			
		||||
                                targetposition++;
 | 
			
		||||
                            }
 | 
			
		||||
                            while (l-- != 0 && targetposition < targetLength)
 | 
			
		||||
                            {
 | 
			
		||||
                                t[targetposition] = (char)State255(s[sourceposition++], targetposition);
 | 
			
		||||
                                targetposition++;
 | 
			
		||||
                            }
 | 
			
		||||
                            enc = 'a';          // reverse to ASCII at end
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                        //      default:
 | 
			
		||||
                        //         fprintf (stderr, "Unknown encoding %c\n", newenc);
 | 
			
		||||
                        //         return 0;              // failed
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (len != 0)
 | 
			
		||||
                len = targetposition;
 | 
			
		||||
            if (targetposition < targetLength && enc != 'a')
 | 
			
		||||
            {
 | 
			
		||||
                if (enc == 'c' || enc == 'x' || enc == 't')
 | 
			
		||||
                    t[targetposition++] = (char)254;         // escape X12/C40/Text
 | 
			
		||||
                else
 | 
			
		||||
                    t[targetposition++] = (char)0x7C;        // escape EDIFACT
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (targetposition < targetLength)
 | 
			
		||||
                t[targetposition++] = (char)129;            // pad
 | 
			
		||||
 | 
			
		||||
            while (targetposition < targetLength)
 | 
			
		||||
            {                            // more padding
 | 
			
		||||
                int v = 129 + (((targetposition + 1) * 149) % 253) + 1;       // see Annex H
 | 
			
		||||
                if (v > 254)
 | 
			
		||||
                    v -= 254;
 | 
			
		||||
                t[targetposition++] = (char)v;
 | 
			
		||||
            }
 | 
			
		||||
            if (targetposition > targetLength || sourceposition < sourceLength)
 | 
			
		||||
                return false;                 // did not fit
 | 
			
		||||
            return true;                    // OK 
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        int State255(int value, int position)
 | 
			
		||||
        {
 | 
			
		||||
            return ((value + (((position + 1) * 149) % 255) + 1) % 256);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Places the data in the right positions according to Annex M of the ECC200 specification.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void Ecc200Placement(ref int[] array, int NR, int NC)
 | 
			
		||||
        {
 | 
			
		||||
            int r;
 | 
			
		||||
            int c;
 | 
			
		||||
            int p;
 | 
			
		||||
 | 
			
		||||
            // invalidate
 | 
			
		||||
            for (r = 0; r < NR; r++)
 | 
			
		||||
                for (c = 0; c < NC; c++)
 | 
			
		||||
                    array[r * NC + c] = 0;
 | 
			
		||||
            // start
 | 
			
		||||
            p = 1;
 | 
			
		||||
            r = 4;
 | 
			
		||||
            c = 0;
 | 
			
		||||
            do
 | 
			
		||||
            {
 | 
			
		||||
                // check corner
 | 
			
		||||
                if (r == NR && (c == 0))
 | 
			
		||||
                    Ecc200PlacementCornerA(ref array, NR, NC, p++);
 | 
			
		||||
                if (r == NR - 2 && c == 0 && ((NC % 4) != 0))
 | 
			
		||||
                    Ecc200PlacementCornerB(ref array, NR, NC, p++);
 | 
			
		||||
                if (r == NR - 2 && c == 0 && ((NC % 8) == 4))
 | 
			
		||||
                    Ecc200PlacementCornerC(ref array, NR, NC, p++);
 | 
			
		||||
                if (r == NR + 4 && c == 2 && ((NC % 8) == 0))
 | 
			
		||||
                    Ecc200PlacementCornerD(ref array, NR, NC, p++);
 | 
			
		||||
                // up/right
 | 
			
		||||
                do
 | 
			
		||||
                {
 | 
			
		||||
                    if (r < NR && c >= 0 && array[r * NC + c] == 0)
 | 
			
		||||
                        Ecc200PlacementBlock(ref array, NR, NC, r, c, p++);
 | 
			
		||||
                    r -= 2;
 | 
			
		||||
                    c += 2;
 | 
			
		||||
                }
 | 
			
		||||
                while (r >= 0 && c < NC);
 | 
			
		||||
                r++;
 | 
			
		||||
                c += 3;
 | 
			
		||||
                // down/left
 | 
			
		||||
                do
 | 
			
		||||
                {
 | 
			
		||||
                    if (r >= 0 && c < NC && array[r * NC + c] == 0)
 | 
			
		||||
                        Ecc200PlacementBlock(ref array, NR, NC, r, c, p++);
 | 
			
		||||
                    r += 2;
 | 
			
		||||
                    c -= 2;
 | 
			
		||||
                }
 | 
			
		||||
                while (r < NR && c >= 0);
 | 
			
		||||
                r += 3;
 | 
			
		||||
                c++;
 | 
			
		||||
            }
 | 
			
		||||
            while (r < NR || c < NC);
 | 
			
		||||
            // unfilled corner
 | 
			
		||||
            if (array[NR * NC - 1] == 0)
 | 
			
		||||
                array[NR * NC - 1] = array[NR * NC - NC - 2] = 1;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Places the ECC200 bits in the right positions.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void Ecc200PlacementBit(ref int[] array, int NR, int NC, int r, int c, int p, int b)
 | 
			
		||||
        {
 | 
			
		||||
            if (r < 0)
 | 
			
		||||
            {
 | 
			
		||||
                r += NR;
 | 
			
		||||
                c += 4 - ((NR + 4) % 8);
 | 
			
		||||
            }
 | 
			
		||||
            if (c < 0)
 | 
			
		||||
            {
 | 
			
		||||
                c += NC;
 | 
			
		||||
                r += 4 - ((NC + 4) % 8);
 | 
			
		||||
            }
 | 
			
		||||
            array[r * NC + c] = (p << 3) + b;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void Ecc200PlacementBlock(ref int[] array, int NR, int NC, int r, int c, int p)
 | 
			
		||||
        {
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, r - 2, c - 2, p, 7);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, r - 2, c - 1, p, 6);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, r - 1, c - 2, p, 5);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, r - 1, c - 1, p, 4);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, r - 1, c - 0, p, 3);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, r - 0, c - 2, p, 2);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, r - 0, c - 1, p, 1);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, r - 0, c - 0, p, 0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void Ecc200PlacementCornerA(ref int[] array, int NR, int NC, int p)
 | 
			
		||||
        {
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, NR - 1, 0, p, 7);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, NR - 1, 1, p, 6);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, NR - 1, 2, p, 5);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 0, NC - 2, p, 4);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 0, NC - 1, p, 3);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 1, NC - 1, p, 2);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 2, NC - 1, p, 1);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 3, NC - 1, p, 0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void Ecc200PlacementCornerB(ref int[] array, int NR, int NC, int p)
 | 
			
		||||
        {
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, NR - 3, 0, p, 7);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, NR - 2, 0, p, 6);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, NR - 1, 0, p, 5);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 0, NC - 4, p, 4);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 0, NC - 3, p, 3);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 0, NC - 2, p, 2);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 0, NC - 1, p, 1);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 1, NC - 1, p, 0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void Ecc200PlacementCornerC(ref int[] array, int NR, int NC, int p)
 | 
			
		||||
        {
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, NR - 3, 0, p, 7);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, NR - 2, 0, p, 6);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, NR - 1, 0, p, 5);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 0, NC - 2, p, 4);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 0, NC - 1, p, 3);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 1, NC - 1, p, 2);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 2, NC - 1, p, 1);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 3, NC - 1, p, 0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        void Ecc200PlacementCornerD(ref int[] array, int NR, int NC, int p)
 | 
			
		||||
        {
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, NR - 1, 0, p, 7);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, NR - 1, NC - 1, p, 6);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 0, NC - 3, p, 5);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 0, NC - 2, p, 4);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 0, NC - 1, p, 3);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 1, NC - 3, p, 2);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 1, NC - 2, p, 1);
 | 
			
		||||
            Ecc200PlacementBit(ref array, NR, NC, 1, NC - 1, p, 0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Calculate and append the Reed Solomon Code.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        void Ecc200(char[] binary, int bytes, int datablock, int rsblock)
 | 
			
		||||
        {
 | 
			
		||||
            int blocks = (bytes + 2) / datablock;
 | 
			
		||||
            int b;
 | 
			
		||||
            InitGalois(0x12d);
 | 
			
		||||
            InitReedSolomon(rsblock, 1);
 | 
			
		||||
            for (b = 0; b < blocks; b++)
 | 
			
		||||
            {
 | 
			
		||||
                int[] buf = new int[256];
 | 
			
		||||
                int[] ecc = new int[256];
 | 
			
		||||
                int n,
 | 
			
		||||
                  p = 0;
 | 
			
		||||
                for (n = b; n < bytes; n += blocks)
 | 
			
		||||
                    buf[p++] = binary[n];
 | 
			
		||||
                EncodeReedSolomon(p, buf, ref ecc);
 | 
			
		||||
                p = rsblock - 1;          // comes back reversed
 | 
			
		||||
                for (n = b; n < rsblock * blocks; n += blocks)
 | 
			
		||||
                    binary[bytes + n] = (char)ecc[p--];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static int gfpoly;
 | 
			
		||||
        static int symsize;             // in bits
 | 
			
		||||
        static int logmod;              // 2**symsize - 1
 | 
			
		||||
        static int rlen;
 | 
			
		||||
 | 
			
		||||
        static int[] log = null;
 | 
			
		||||
        static int[] alog = null;
 | 
			
		||||
        static int[] rspoly = null;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initialize the Galois Field.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="poly"></param>
 | 
			
		||||
        public static void InitGalois(int poly)
 | 
			
		||||
        {
 | 
			
		||||
            int m;
 | 
			
		||||
            int b;
 | 
			
		||||
            int p;
 | 
			
		||||
            int v;
 | 
			
		||||
 | 
			
		||||
            // Return storage from previous setup
 | 
			
		||||
            if (log != null)
 | 
			
		||||
            {
 | 
			
		||||
                log = null;
 | 
			
		||||
                alog = null;
 | 
			
		||||
                rspoly = null;
 | 
			
		||||
            }
 | 
			
		||||
            // Find the top bit, and hence the symbol size
 | 
			
		||||
            for (b = 1, m = 0; b <= poly; b <<= 1)
 | 
			
		||||
                m++;
 | 
			
		||||
            b >>= 1;
 | 
			
		||||
            m--;
 | 
			
		||||
            gfpoly = poly;
 | 
			
		||||
            symsize = m;
 | 
			
		||||
 | 
			
		||||
            // Calculate the log/alog tables
 | 
			
		||||
            logmod = (1 << m) - 1;
 | 
			
		||||
            log = new int[logmod + 1];
 | 
			
		||||
            alog = new int[logmod];
 | 
			
		||||
 | 
			
		||||
            for (p = 1, v = 0; v < logmod; v++)
 | 
			
		||||
            {
 | 
			
		||||
                alog[v] = p;
 | 
			
		||||
                log[p] = v;
 | 
			
		||||
                p <<= 1;
 | 
			
		||||
                if ((p & b) != 0) //DaSt: check!
 | 
			
		||||
                    p ^= poly;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes the Reed-Solomon Encoder.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static void InitReedSolomon(int nsym, int index)
 | 
			
		||||
        {
 | 
			
		||||
            int i;
 | 
			
		||||
            int k;
 | 
			
		||||
 | 
			
		||||
            if (rspoly != null)
 | 
			
		||||
                rspoly = null;
 | 
			
		||||
            rspoly = new int[nsym + 1];
 | 
			
		||||
 | 
			
		||||
            rlen = nsym;
 | 
			
		||||
 | 
			
		||||
            rspoly[0] = 1;
 | 
			
		||||
            for (i = 1; i <= nsym; i++)
 | 
			
		||||
            {
 | 
			
		||||
                rspoly[i] = 1;
 | 
			
		||||
                for (k = i - 1; k > 0; k--)
 | 
			
		||||
                {
 | 
			
		||||
                    if (rspoly[k] != 0) //DaSt: check!
 | 
			
		||||
                        rspoly[k] = alog[(log[rspoly[k]] + index) % logmod];
 | 
			
		||||
                    rspoly[k] ^= rspoly[k - 1];
 | 
			
		||||
                }
 | 
			
		||||
                rspoly[0] = alog[(log[rspoly[0]] + index) % logmod];
 | 
			
		||||
                index++;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Encodes the Reed-Solomon encoding
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void EncodeReedSolomon(int length, int[] data, ref int[] result)
 | 
			
		||||
        {
 | 
			
		||||
            int i;
 | 
			
		||||
            int k;
 | 
			
		||||
            int m;
 | 
			
		||||
            for (i = 0; i < rlen; i++)
 | 
			
		||||
                result[i] = 0;
 | 
			
		||||
            for (i = 0; i < length; i++)
 | 
			
		||||
            {
 | 
			
		||||
                m = result[rlen - 1] ^ data[i];
 | 
			
		||||
                for (k = rlen - 1; k > 0; k--)
 | 
			
		||||
                {
 | 
			
		||||
                    if ((m != 0) && (rspoly[k] != 0)) //DaSt: check!
 | 
			
		||||
                        result[k] = result[k - 1] ^ alog[(log[m] + log[rspoly[k]]) % logmod];
 | 
			
		||||
                    else
 | 
			
		||||
                        result[k] = result[k - 1];
 | 
			
		||||
                }
 | 
			
		||||
                if ((m != 0) && (rspoly[0] != 0)) //DaSt: check!
 | 
			
		||||
                    result[0] = alog[(log[m] + log[rspoly[0]]) % logmod];
 | 
			
		||||
                else
 | 
			
		||||
                    result[0] = 0;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <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)
 | 
			
		||||
        {
 | 
			
		||||
#if GDI
 | 
			
		||||
            Bitmap bm = new Bitmap(columns * pixelsize, rows * pixelsize);
 | 
			
		||||
            using (Graphics gfx = Graphics.FromImage(bm))
 | 
			
		||||
            {
 | 
			
		||||
                gfx.FillRectangle(System.Drawing.Brushes.White, new Rectangle(0, 0, columns * pixelsize, rows * pixelsize));
 | 
			
		||||
 | 
			
		||||
                for (int i = rows - 1; i >= 0; i--)
 | 
			
		||||
                {
 | 
			
		||||
                    for (int j = 0; j < columns; j++)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (code[((rows - 1) - i) * columns + j] == (char)1)
 | 
			
		||||
                            gfx.FillRectangle(System.Drawing.Brushes.Black, j * pixelsize, i * pixelsize, pixelsize, pixelsize);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            XImage image = XImage.FromGdiPlusImage(bm);
 | 
			
		||||
            image.Interpolate = false;
 | 
			
		||||
            return image;
 | 
			
		||||
#endif
 | 
			
		||||
#if WPF
 | 
			
		||||
            // WPFHACK
 | 
			
		||||
            return null;
 | 
			
		||||
#endif
 | 
			
		||||
#if CORE || NETFX_CORE || UWP
 | 
			
		||||
            return null;
 | 
			
		||||
#endif
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        struct Ecc200Block
 | 
			
		||||
        {
 | 
			
		||||
            public readonly int Height;
 | 
			
		||||
            public readonly int Width;
 | 
			
		||||
            public readonly int CellHeight;
 | 
			
		||||
            public readonly int CellWidth;
 | 
			
		||||
            public readonly int Bytes;
 | 
			
		||||
            public readonly int DataBlock;
 | 
			
		||||
            public readonly 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;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										239
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/DataMatrixImage.opensource.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										239
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/DataMatrixImage.opensource.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,239 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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;
 | 
			
		||||
#if GDI
 | 
			
		||||
using System.Drawing;
 | 
			
		||||
using System.Drawing.Imaging;
 | 
			
		||||
#endif
 | 
			
		||||
#if WPF
 | 
			
		||||
using System.Windows;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// ========================================================================================
 | 
			
		||||
// ========================================================================================
 | 
			
		||||
// ===== 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 PdfSharp.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)
 | 
			
		||||
        {
 | 
			
		||||
#if GDI
 | 
			
		||||
      Bitmap bm = new Bitmap(columns * pixelsize, rows * pixelsize);
 | 
			
		||||
      using (Graphics gfx = Graphics.FromImage(bm))
 | 
			
		||||
      {
 | 
			
		||||
        gfx.FillRectangle(System.Drawing.Brushes.White, new Rectangle(0, 0, columns * pixelsize, rows * pixelsize));
 | 
			
		||||
 | 
			
		||||
        for (int i = rows - 1; i >= 0; i--)
 | 
			
		||||
        {
 | 
			
		||||
          for (int j = 0; j < columns; j++)
 | 
			
		||||
          {
 | 
			
		||||
            if (code[((rows - 1) - i) * columns + j] == (char)1)
 | 
			
		||||
              gfx.FillRectangle(System.Drawing.Brushes.Black, j * pixelsize, i * pixelsize, pixelsize, pixelsize);
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Firebrick, pixelsize);
 | 
			
		||||
        gfx.DrawLine(pen, 0, 0, rows * pixelsize, columns * pixelsize);
 | 
			
		||||
        gfx.DrawLine(pen, columns * pixelsize, 0, 0, rows * pixelsize);
 | 
			
		||||
      }
 | 
			
		||||
      XImage image = XImage.FromGdiPlusImage(bm);
 | 
			
		||||
      image.Interpolate = false;
 | 
			
		||||
      return image;
 | 
			
		||||
#elif WPF
 | 
			
		||||
            return null;
 | 
			
		||||
#endif
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										137
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/MatrixCode.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/MatrixCode.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,137 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   David Stephensen
 | 
			
		||||
//   Stefan Lange
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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 PdfSharp.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)
 | 
			
		||||
        { }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										130
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/OmrData.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										130
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/OmrData.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,130 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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 PdfSharp.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
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										186
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/ThickThinBarcodeRenderer.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										186
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/ThickThinBarcodeRenderer.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,186 @@
 | 
			
		||||
//
 | 
			
		||||
// PDFsharp - A library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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 System;
 | 
			
		||||
 | 
			
		||||
namespace PdfSharp.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("Courier New", 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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										82
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/enums/AnchorType.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/enums/AnchorType.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,82 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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 PdfSharp.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,
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										57
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/enums/CodeDirection.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/enums/CodeDirection.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,57 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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 PdfSharp.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<38> at the anchor position.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        BottomToTop,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Rotates the code 180<38> at the anchor position.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        RightToLeft,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Rotates the code 180<38> at the anchor position.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        TopToBottom,
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										59
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/enums/CodeType.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/enums/CodeType.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,59 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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 PdfSharp.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-2017 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 PdfSharp.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
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										50
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/enums/MarkDistance.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/enums/MarkDistance.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,50 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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 PdfSharp.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
 | 
			
		||||
    //}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										64
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/enums/TextLocation.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								PrintPDF/PdfSharp/Drawing.BarCodes/enums/TextLocation.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,64 @@
 | 
			
		||||
#region PDFsharp - A .NET library for processing PDF
 | 
			
		||||
//
 | 
			
		||||
// Authors:
 | 
			
		||||
//   Klaus Potzesny
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2005-2017 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 PdfSharp.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