예제 #1
0
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// PDF QR Code constructor
        /// </summary>
        /// <param name="Document">Parent PDF document.</param>
        /// <param name="DataString">Data string to encode.</param>
        /// <param name="ErrorCorrection">Error correction code.</param>
        ////////////////////////////////////////////////////////////////////
        public PdfQRCode
        (
            PdfDocument Document,
            String DataString,
            ErrorCorrection ErrorCorrection
        ) : base(Document, ObjectType.Stream, "/XObject")
        {
            // create resource code
            ResourceCode = Document.GenerateResourceNumber('X');

            // create QR Code object
            QREncoder Encoder = new QREncoder();

            QRCodeMatrix    = Encoder.EncodeQRCode(DataString, ErrorCorrection);
            MatrixDimension = Encoder.MatrixDimension;

            // create stream length object
            ImageLengthObject = new PdfObject(Document, ObjectType.Other);
            Dictionary.AddIndirectReference("/Length", ImageLengthObject);

            // set default values
            ModuleSize = 4;
            QuietZone  = 16;

            // exit
            return;
        }
예제 #2
0
        public PdfImage
        (
            PdfDocument Document,
            QREncoder QREncoder
        ) : this(Document)
        {
            // barcode width and height
            WidthPix  = QREncoder.QRCodeImageDimension;
            HeightPix = QREncoder.QRCodeImageDimension;

            // black and white barcode image
            BWImage = QREncoder.ConvertQRCodeMatrixToPixels();

            // image control for PDF417 code
            ReverseBW = true;
            SaveAs    = SaveImageAs.BWImage;

            // write image stream to pdf file
            WriteObjectToPdfFile();
            return;
        }
예제 #3
0
        /// <summary>
        /// Load image from QRCode encoder
        /// </summary>
        /// <param name="QREncoder">QRCode encoder</param>
        public void LoadImage
        (
            QREncoder QREncoder
        )
        {
            // barcode width and height
            WidthPix  = QREncoder.QRCodeImageDimension;
            HeightPix = WidthPix;

            // black and white barcode image
            BWImage = QREncoder.ConvertQRCodeMatrixToPixels();

            // set save as to BWImage
            SaveAs    = SaveImageAs.BWImage;
            ReverseBW = true;

            // write to output file
            WriteObjectToPdfFile();

            // exit
            return;
        }
예제 #4
0
        ////////////////////////////////////////////////////////////////////
        // Write object to PDF file
        ////////////////////////////////////////////////////////////////////

        internal void ConstructorHelper
        (
            String DataString,
            String[]                SegDataString,
            ErrorCorrection ErrorCorrection,
            Int32 QuietZone = 4
        )
        {
            // create QR Code object
            QREncoder Encoder = new QREncoder();

            if (DataString != null)
            {
                Encoder.EncodeQRCode(DataString, ErrorCorrection, QuietZone);
            }
            else
            {
                Encoder.EncodeQRCode(SegDataString, ErrorCorrection, QuietZone);
            }

            // output matrix
            // NOTE: Black=true, White=flase
            BWImage = Encoder.OutputMatrix;

            // image width and height in pixels
            MatrixDimension = Encoder.MatrixDimension;
            WidthPix        = MatrixDimension + 2 * QuietZone;
            HeightPix       = WidthPix;

            // image control for QR code
            ImageControl           = new PdfImageControl();
            ImageControl.ReverseBW = true;
            ImageControl.SaveAs    = SaveImageAs.BWImage;

            // write stream object
            WriteObjectToPdfFile();
            return;
        }
        ////////////////////////////////////////////////////////////////////
        // Constructor
        ////////////////////////////////////////////////////////////////////

        public PdfQRCode
        (
            PdfDocument Document,
            String DataString,
            ErrorCorrection ErrorCorrection
        ) : base(Document, true, "/XObject")
        {
            // create resource code
            ResourceCode = Document.GenerateResourceNumber('X');

            // create QR Code object
            QREncoder Encoder = new QREncoder();

            QRCodeMatrix    = Encoder.EncodeQRCode(DataString, ErrorCorrection);
            MatrixDimension = Encoder.MatrixDimension;

            // create stream length object
            ImageLengthObject = new PdfObject(Document, false);
            AddToDictionary("/Length", ImageLengthObject.ObjectNumber.ToString() + " 0 R");

            // exit
            return;
        }
예제 #6
0
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// PDF QR Code constructor
        /// </summary>
        /// <param name="Document">Parent PDF document.</param>
        /// <param name="SegDataString">Data string array to encode.</param>
        /// <param name="ErrorCorrection">Error correction code.</param>
        /// <remarks>
        /// The program will calculate the best encoding mode for each segment.
        /// </remarks>
        ////////////////////////////////////////////////////////////////////
        public PdfQRCode(
			PdfDocument		Document,
			String[]		SegDataString,
			ErrorCorrection	ErrorCorrection
			)
            : base(Document, ObjectType.Stream, "/XObject")
        {
            // create resource code
            ResourceCode = Document.GenerateResourceNumber('X');

            // create QR Code object
            QREncoder Encoder = new QREncoder();
            QRCodeMatrix = Encoder.EncodeQRCode(SegDataString, ErrorCorrection);
            MatrixDimension = Encoder.MatrixDimension;

            // create stream length object
            ImageLengthObject = new PdfObject(Document, ObjectType.Other);
            Dictionary.AddIndirectReference("/Length", ImageLengthObject);

            // exit
            return;
        }