private ContentInfoDTO DrawPatches(Rectangle pageRect, PdfContentByte canvas, Point chartPoint,
            Point endUpBarPoint, ContentInfoDTO maxElements,
            System.Data.IDataReader reader)
        {
            var result = new ContentInfoDTO {RowNumber = 0, ColumnNumber = maxElements.ColumnNumber};
            var squarePoint = new Point(SideBorder + BorderPage, chartPoint.Y - ConvertUtil.MMToPdfFloat(6) - PatchSize);
            var maxColumnsPerRow = maxElements.ColumnNumber;
            var maxPatches = maxElements.ColumnNumber*maxElements.RowNumber;
            var countPacthes = 0;
            bool lastLineWasCompleted;
            do
            {
                var colorName = reader.GetString(0);

                if (!colorName.ToUpper().Equals("JUMP"))
                {
                    DrawSquare(canvas, squarePoint, reader);
                }
                countPacthes++;

                lastLineWasCompleted = false;
                if (countPacthes%maxColumnsPerRow == 0)
                {
                    CreatePreDiamont(canvas, pageRect, squarePoint);
                    CreatePosDiamont(canvas, pageRect, endUpBarPoint, squarePoint);
                    squarePoint = new Point(SideBorder + BorderPage, squarePoint.Y - PatchSize);
                    result.RowNumber++;
                    lastLineWasCompleted = true;
                }
                else
                {
                    squarePoint = new Point(squarePoint.X + PatchSize, squarePoint.Y);
                }

                if (countPacthes == maxPatches)
                {
                    break;
                }
            } while (reader.Read());

            if (!lastLineWasCompleted)
            {
                CreatePreDiamont(canvas, pageRect, squarePoint);
                CreatePosDiamont(canvas, pageRect, endUpBarPoint, squarePoint);
                result.RowNumber++;
            }
            return result;
        }
        private void DrawBarCode(PdfContentByte canvas, Rectangle pageRect, string extraData, ContentInfoDTO data)
        {
            var isisBarcode = new IsisBarcode();
            var result = new Point(SideBorder + BorderPage,
                                   pageRect.Height - (BorderPage + LeaderEdge + BarHeight + 1));
            isisBarcode.IsisPoint = result;
            //
            var chartLayout = ConvertUtil.PrepareHex((int)data.RowNumber);
            chartLayout += ConvertUtil.PrepareHex((int)data.ColumnNumber);
            chartLayout += ConvertUtil.PrepareHex((int)ConvertUtil.PdfToMMUnit25(PatchSize));
            chartLayout += ConvertUtil.PrepareHex((int)ConvertUtil.PdfToMMUnit25(PatchSize));
            chartLayout = chartLayout.ToUpper();

            if (!string.IsNullOrEmpty(extraData))
            {
                extraData = " " + extraData.ToUpper();
                chartLayout += extraData.Length % 2 == 2 ? " " + extraData : extraData;
            }
            //
            isisBarcode.Code = chartLayout;
            isisBarcode.PlaceBarcode(canvas, BaseColor.BLACK, BaseColor.BLACK);
        }
 /// <summary>
 /// Calculates the total patches per page.
 /// </summary>
 /// <param name="pageRect">The page rect.</param>
 /// <returns></returns>
 public ContentInfoDTO CalculateTotalPatchesPerPage(Rectangle pageRect)
 {
     var result = new ContentInfoDTO();
     var usableXSpace = pageRect.Right - 2 * (BorderPage + WPosMarker + DiamontDist1 + DiamontDist2);
     result.ColumnNumber = Math.Floor(usableXSpace / PatchSize);
     var usableYSpace = pageRect.Top - (BorderPage + TrailerEdge + LeaderEdge + BarHeight + PosBar2Chart);
     result.RowNumber = Math.Floor(usableYSpace / PatchSize);
     return result;
 }
        public void InsertBarCode(String pdfFile, string extraData, ContentInfoDTO dataInfo)
        {
            var pdfOutputFile = new FileStream(FinalFileFormatter(pdfFile), FileMode.Create);
            var pdfReader = new PdfReader(pdfFile);
            var pdfStamper = new PdfStamper(pdfReader, pdfOutputFile);
            var overContent = pdfStamper.GetOverContent(1);

            var pageRect = new Rectangle((float)ConvertUtil.INToPdf(10.5), (float)ConvertUtil.INToPdf(12.48));
            DrawBarCode(overContent, pageRect, extraData, dataInfo);
            pdfStamper.Close();
            pdfReader.Close();
        }