Пример #1
0
        private void Show(IList <Interpress.Library.ReconstructorEngine.OutElements.OutPage> output)
        {
            MyImaging myImg = new MyImaging();
            int       s     = 1;


            foreach (OutPage outPage in output)
            {
                Bitmap firstBitmap = CreateFirstPageBitmap();

                foreach (OutImage outImage in outPage.Images)
                {
                    using (Graphics g = Graphics.FromImage(firstBitmap))
                    {
                        g.DrawImage(
                            outImage.Img,
                            new Rectangle((int)outImage.LocationPixel.X, (int)outImage.LocationPixel.Y, outImage.Img.Width, outImage.Img.Height)
                            , 0, 0,
                            outImage.Img.Width,
                            outImage.Img.Height, GraphicsUnit.Pixel);
                    }
                }

                if (s == 1)
                {
                    imageviewerright.LoadImages(getBytes(firstBitmap));
                }
                s++;
                firstBitmap.Save(@"c:\\temp\result\" + i + "-" + outPage.Images.Count + ".jpeg");
            }

            i++;
        }
Пример #2
0
        /// <summary>
        /// Bitmap 72dpi olarak ayarlanır.
        /// </summary>
        /// <param name="bmp"></param>
        /// <returns></returns>
        protected Bitmap Decrease72Dpi(Bitmap bmp, float rate)
        {
            MyImaging myImg = new MyImaging();

            MemoryStream ms = new MemoryStream();

            bmp.Save(ms, ImageFormat.Jpeg);

            byte[] bmpArray = ms.GetBuffer();

            bmpArray = myImg.ChangeResolution(bmpArray, rate, 72);

            //bmpArray=myImg.ScaleTo(bmpArray, bmp.Width, bmp.Height);

            ms.SetLength(0);
            ms.Write(bmpArray, 0, bmpArray.Count());

            Bitmap bmp72dpi = (Bitmap)Image.FromStream(ms);



            ms.Dispose();

            return(bmp72dpi);
        }
Пример #3
0
        /// <summary>
        /// Eğer Zonetype text türünden ise Crop ve BlackandWhite işlemleri yapılır. Değilse Sadece crop işlemi yapılır.
        /// </summary>
        /// <param name="pageBitmap"></param>
        /// <param name="zone"></param>
        /// <returns></returns>
        protected Bitmap GetCroppedAndBlackWhite(Bitmap pageBitmap, Zone zone)
        {
            MyImaging myImg = new MyImaging();

            if (zone.Type != ZoneType.Image && zone.Type != ZoneType.Table && zone.Type != ZoneType.Spot)
            {
                return(myImg.GetBlackWhite8Bit(myImg.Crop(pageBitmap, zone.Reg)));
            }
            else
            {
                return(myImg.Crop(pageBitmap, zone.Reg));
            }
        }
Пример #4
0
        /// <summary>
        /// Text Zone'u iki eşit parçaya böler
        /// </summary>
        /// <param name="outImage"></param>
        /// <param name="zone"></param>
        /// <returns></returns>
        protected OutImage[] SeparateTextZone(OutImage outImage, Zone zone)
        {
            MyImaging myImg = new MyImaging();

            Graphics grp = Graphics.FromImage(outImage.Img);

            OutImage[] separetedZones = { new OutImage(), new OutImage() };

            //ortadaki karakteri çizme
            //grp.DrawLine(new Pen(Brushes.Red), 0, zone.Chars[zone.Chars.Count / 2 ].ZoneRect.Top - 2, outImage.Img.Width, zone.Chars[zone.Chars.Count / 2].ZoneRect.Top - 2);

            //grp.DrawRectangle(new Pen(Brushes.Red), new Rectangle((int)zone.Chars[zone.Chars.Count / 2].ZoneRect.X, (int)zone.Chars[zone.Chars.Count / 2].ZoneRect.Y,(int) zone.Chars[zone.Chars.Count / 2].ZoneRect.Width,(int) zone.Chars[zone.Chars.Count / 2].ZoneRect.Height));


            #region Text Zone'u ortadaki karalteri baz alarak ikiye bölme işlemi

            try
            {
                Region cropRegion = new Region(new RectangleF(0, 0, outImage.Img.Width, zone.Chars[zone.Chars.Count / 2].ZoneRect.Top - 5));

                separetedZones[0].Img = myImg.Crop(outImage.Img, cropRegion);

                separetedZones[0].Reg = cropRegion;


                Region cropRegion2 = new Region(new RectangleF(0, cropRegion.GetBounds(grp).Height, outImage.Img.Width, outImage.Img.Height - cropRegion.GetBounds(grp).Height));

                separetedZones[1].Img = myImg.Crop(outImage.Img, cropRegion2);

                separetedZones[1].Reg = cropRegion2;
            }
            catch (Exception)
            {
                throw new Exception("Text Zone Parçalanamıyor.Karakter bilgisi doğru gelmemiş olabilir.");
            }

            #endregion
            grp.Dispose();
            return(separetedZones);
        }
Пример #5
0
        private void SeperateZones(InPage page)
        {
            MyImaging imaging = new MyImaging();

            foreach (var item in page.Zones)
            {
                Bitmap bmp = imaging.Crop(page.Img, item.Reg);
                if (item.Type == ZoneType.Header || item.Type == ZoneType.Text || item.Type == ZoneType.Title || item.Type == ZoneType.Spot || item.Type == ZoneType.Footer)
                {
                    Bitmap blackandwhite = imaging.GetBlackWhite(bmp);
                    //blackandwhite.Save("c:\\temp\\"+item.Number+".jpg");
                    //blackandwhite.Save("c:\\temp\\"+item.Type+" - "+ item.Number + ".bmp");
                }
                else if (item.Type == ZoneType.Image)
                {
                    Bitmap resized = imaging.ResizeFast(bmp, bmp.Width, bmp.Height);
                    //resized.Save("c:\\temp\\" +item.Type+" - "+ item.Number + ".jpg");
                }
                //else
                //bmp.Save("c:\\temp\\"+item.Type+" - " +item.Number+".jpg");
            }
        }
Пример #6
0
        public override IList <OutElements.OutPage> Process(IList <InElements.InPage> pages)
        {
            MyImaging myImg = new MyImaging();

            IList <OutPage> outPages = new List <OutPage>();

            OutPage outPage = new OutPage(); //Ana sayfa

            float endHeightPoint = 5;
            float endWidthPoint;
            float headerBottomPoint = 5;
            int   pageColumn;
            float lastZoneXPoint;
            float imageBottomPoint;
            float scale;
            int   pageHeight = Utils.ConvertMMtoPixel(268, 72), pageWidth = Utils.ConvertMMtoPixel(190, 72);



            foreach (InPage page in pages)
            {
                pageColumn     = 1;
                lastZoneXPoint = 0;
                endWidthPoint  = 5;
                #region Header Yerleştirme

                foreach (Zone zone in page.Zones)
                {
                    //Sayfanın üst kısmına Header Yerleştirme.
                    if (zone.Type == ZoneType.Header)
                    {
                        OutImage outImage = new OutImage();

                        outImage.Img = GetCroppedAndBlackWhite(page.Img, zone);

                        scale = 72 / outImage.Img.HorizontalResolution;

                        outImage.Img = Decrease72Dpi(outImage.Img, scale);

                        Graphics grp = Graphics.FromImage(outImage.Img);


                        outImage.Reg     =
                            outImage.Reg =
                                new Region(new RectangleF(zone.Reg.GetBounds(grp).X *scale,
                                                          zone.Reg.GetBounds(grp).Y *scale, zone.Reg.GetBounds(grp).Width *scale,
                                                          zone.Reg.GetBounds(grp).Height *scale));

                        while (outImage.Img.Width > pageWidth)
                        {
                            outImage.Img = myImg.ResizeFast(outImage.Img, (int)(outImage.Img.Width * (0.90)),
                                                            (int)(outImage.Img.Height * (0.90)));
                        }

                        int leftSpace = (pageWidth - outImage.Img.Width) / 2;

                        outImage.LocationPixel = new PointF(leftSpace, endHeightPoint);

                        endHeightPoint += outImage.Img.Height + 5;

                        headerBottomPoint = endHeightPoint;

                        endWidthPoint = 5;

                        outPage.Images.Add(outImage);

                        grp.Dispose();
                    }
                }

                #endregion

                #region Text Zone'ları Yerleştirme

                SortedDictionary <int, Zone> sortedTextZones = SelectAndSortTextZones(page.Zones);
                //Text Zone'ların Sıralanması işlemi.

                //Text Zoneları yerleştirme.
                foreach (Zone zone in sortedTextZones.Values)
                {
                    OutImage outImage = new OutImage();

                    outImage.Img = GetCroppedAndBlackWhite(page.Img, zone);

                    scale = 72 / outImage.Img.HorizontalResolution;

                    outImage.Img = Decrease72Dpi(outImage.Img, scale);

                    CalculateCharRect(zone, outImage.Img, scale);

                    Graphics grp = Graphics.FromImage(outImage.Img);


                    outImage.Reg =
                        new Region(new RectangleF(zone.Reg.GetBounds(grp).X *scale, zone.Reg.GetBounds(grp).Y *scale,
                                                  zone.Reg.GetBounds(grp).Width *scale, zone.Reg.GetBounds(grp).Height *scale));



                    //TextZone'un Sayafayanın kalan alanına sığıp sığamadığının kontrolü yapılır.
                    if (outImage.Reg.GetBounds(grp).Height > (pageHeight - endHeightPoint))
                    {
                        //Sığmıyorsa sayfadaki yeni bir Text kolonuna sığıp sığamadığının kontrolü. Orayada sığmıyorsa Parçalama işlemi yapılır. Sığıyorsa yeni kolona yerleştrilir.
                        if (pageColumn == 1 && outImage.Reg.GetBounds(grp).Height > (pageHeight - endHeightPoint) &&
                            outImage.Reg.GetBounds(grp).Height / 2 < (pageHeight - endHeightPoint))
                        {
                            OutImage[] separatedImages = SeparateTextZone(outImage, zone);

                            for (int i = 0; i < separatedImages.Length; i++)
                            {
                                separatedImages[i].LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                                lastZoneXPoint += endWidthPoint;



                                if (i != separatedImages.Length - 1)
                                //son parça text zone olup olmadığına göre 2. kolon için değerleri ayarlama
                                {
                                    endWidthPoint += separatedImages[i].Img.Width + 10;
                                    endHeightPoint = headerBottomPoint;//HATAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa- Yukarıdaki text in width i yerine kesilmiş olan textin with ini alıyor
                                }
                                else
                                {
                                    endHeightPoint += separatedImages[i].Img.Height;
                                }
                                pageColumn = i + 1;
                                outPage.Images.Add(separatedImages[i]);
                            }
                        }
                        else
                        {
                            if (outImage.Img.Width < pageWidth - lastZoneXPoint &&
                                outImage.Img.Height < pageHeight - headerBottomPoint)
                            //yeni kolona sığıyor mu kontrolü yapılır sığmıyorsa yeni page oluşturulur.
                            {
                                endWidthPoint = lastZoneXPoint + 10;

                                outImage.LocationPixel = new PointF(endWidthPoint, headerBottomPoint);

                                endHeightPoint = outImage.Img.Height + headerBottomPoint;

                                lastZoneXPoint = endWidthPoint + outImage.Img.Width;

                                pageColumn++;


                                outPage.Images.Add(outImage);
                            }
                            else
                            {
                                outPages.Add(outPage); //ilk sayfayı listeye ekle yeni bir sayfa aç
                                OutPage newOutPage = new OutPage();
                                endWidthPoint     = 5;
                                endHeightPoint    = 5;
                                pageColumn        = 1;
                                headerBottomPoint = 5;

                                if (outImage.Img.Height < pageHeight - headerBottomPoint)
                                //yeni sayfaya sığıyorsa yerleştir.
                                {
                                    outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                                    endHeightPoint += outImage.Img.Height;
                                    lastZoneXPoint  = endWidthPoint + outImage.Img.Width;

                                    newOutPage.Images.Add(outImage);

                                    pageHeight = Utils.ConvertMMtoPixel(282, 72);
                                    //yeni sayfa için yükseklik değerini günceleldik.


                                    outPage = newOutPage;
                                }
                                else //yeni sayfaya sığmıyorsa parçalayıp yerleştir.
                                {
                                    OutImage[] separatedImages = SeparateTextZone(outImage, zone);

                                    for (int i = 0; i < separatedImages.Length; i++)
                                    {
                                        separatedImages[i].LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                                        lastZoneXPoint += endWidthPoint;



                                        if (i != separatedImages.Length - 1)
                                        //son parça text zone olup olmadığına göre 2. kolon için değerleri ayarlama
                                        {
                                            endWidthPoint += separatedImages[i].Img.Width + 10;
                                            endHeightPoint = headerBottomPoint;
                                        }
                                        else
                                        {
                                            endHeightPoint += separatedImages[i].Img.Height;
                                        }
                                        pageColumn = i + 1;

                                        outPage = newOutPage;

                                        outPage.Images.Add(separatedImages[i]);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (pageColumn != 1)
                        {
                            outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                            endHeightPoint += outImage.Img.Height;

                            lastZoneXPoint = endWidthPoint + outImage.Img.Width;

                            outPage.Images.Add(outImage);
                        }
                        else
                        {
                            float leftspace = 0;
                            if (sortedTextZones.Count == 1)
                            {
                                leftspace = (pageWidth - outImage.Img.Width - 5) / 2;
                            }
                            outImage.LocationPixel = new PointF(endWidthPoint + leftspace, endHeightPoint);

                            endHeightPoint += outImage.Img.Height;


                            if (lastZoneXPoint < endWidthPoint + outImage.Img.Width)//Text zone'larından en geniş olanının değerini sakla (image yazının üstüne gelmemesi için)
                            {
                                lastZoneXPoint = endWidthPoint + outImage.Img.Width;
                            }

                            outPage.Images.Add(outImage);
                        }
                    }

                    grp.Dispose();
                }

                #endregion
            }


            outPages.Add(outPage);


            return(outPages);
        }
Пример #7
0
        public override IList <OutElements.OutPage> Process(IList <InElements.InPage> pages)
        {
            MyImaging myImg = new MyImaging();

            IList <OutPage> outPages = new List <OutPage>();

            OutPage outPage = new OutPage(); //İlk Syafa

            float endHeightPoint = 5;
            float endWidthPoint;
            float headerBottomPoint = 5;
            int   pageColumn;
            float lastZoneXPoint;
            float scale;
            int   pageHeight = Utils.ConvertMMtoPixel(268, 72), pageWidth = Utils.ConvertMMtoPixel(190, 72);

            foreach (InPage page in pages)
            {
                pageColumn     = 1;
                lastZoneXPoint = 0;
                endWidthPoint  = 5;

                #region Header Yerleştirme
                foreach (Zone zone in page.Zones)
                {
                    //Sayfanın üst kısmına Header Yerleştirme.
                    if (zone.Type == ZoneType.Header)
                    {
                        OutImage outImage = new OutImage();

                        outImage.Img = GetCroppedAndBlackWhite(page.Img, zone);

                        scale = 72 / outImage.Img.HorizontalResolution;

                        outImage.Img = Decrease72Dpi(outImage.Img, scale);

                        Graphics grp = Graphics.FromImage(outImage.Img);


                        outImage.Reg = outImage.Reg = new Region(new RectangleF(zone.Reg.GetBounds(grp).X *scale, zone.Reg.GetBounds(grp).Y *scale, zone.Reg.GetBounds(grp).Width *scale, zone.Reg.GetBounds(grp).Height *scale));

                        while (outImage.Img.Width > pageWidth)
                        {
                            outImage.Img = myImg.ResizeFast(outImage.Img, (int)(outImage.Img.Width * (0.90)), (int)(outImage.Img.Height * (0.90)));
                        }

                        int leftSpace = (pageWidth - outImage.Img.Width) / 2;

                        outImage.LocationPixel = new PointF(leftSpace, endHeightPoint);

                        endHeightPoint += outImage.Img.Height + 5;

                        headerBottomPoint = endHeightPoint;

                        endWidthPoint = 5;

                        outPage.Images.Add(outImage);

                        grp.Dispose();
                    }
                }
                #endregion

                #region Title Yerleşirme (Opsiyonel Eğer varsa)

                foreach (Zone zone in page.Zones)
                {
                    //Sayfanın üst kısmına Header Yerleştirme.
                    if (zone.Type == ZoneType.Title)
                    {
                        OutImage outImage = new OutImage();

                        outImage.Img = GetCroppedAndBlackWhite(page.Img, zone);

                        scale = 72 / outImage.Img.HorizontalResolution;

                        outImage.Img = Decrease72Dpi(outImage.Img, scale);

                        Graphics grp = Graphics.FromImage(outImage.Img);


                        outImage.Reg = outImage.Reg = new Region(new RectangleF(zone.Reg.GetBounds(grp).X *scale, zone.Reg.GetBounds(grp).Y *scale, zone.Reg.GetBounds(grp).Width *scale, zone.Reg.GetBounds(grp).Height *scale));

                        while (outImage.Img.Width > pageWidth)
                        {
                            outImage.Img = myImg.ResizeFast(outImage.Img, (int)(outImage.Img.Width * (0.90)), (int)(outImage.Img.Height * (0.90)));
                        }

                        int leftSpace = (pageWidth - outImage.Img.Width) / 2;

                        outImage.LocationPixel = new PointF(leftSpace, endHeightPoint);

                        endHeightPoint += outImage.Img.Height + 5;

                        headerBottomPoint = endHeightPoint;

                        endWidthPoint = 5;

                        outPage.Images.Add(outImage);

                        grp.Dispose();
                    }
                }


                #endregion

                #region Image Yerleştirme

                endHeightPoint += 5;

                foreach (Zone zone in page.Zones)
                {
                    //Sayfanın alt kısmına Image Yerleştirme.
                    if (zone.Type == ZoneType.Image)
                    {
                        OutImage outImage = new OutImage();

                        outImage.Img = GetCroppedAndBlackWhite(page.Img, zone);

                        scale = 72 / outImage.Img.HorizontalResolution;

                        outImage.Img = Decrease72Dpi(outImage.Img, scale);

                        Graphics grp = Graphics.FromImage(outImage.Img);

                        outImage.Reg = outImage.Reg = new Region(new RectangleF(zone.Reg.GetBounds(grp).X *scale, zone.Reg.GetBounds(grp).Y *scale, zone.Reg.GetBounds(grp).Width *scale, zone.Reg.GetBounds(grp).Height *scale));

                        int maxResizeCount = 1;

                        Bitmap tempImage = Interpress.Library.Libraries.DbtLibrary.Image.Image.Clone(outImage.Img);


                        while (tempImage.Width > pageWidth - lastZoneXPoint && maxResizeCount < 6)//sağa yerleştirebilmek için %20 küçülterek ilerle
                        {
                            tempImage = myImg.ResizeFast(tempImage, (int)(tempImage.Width * (0.80)), (int)(tempImage.Height * (0.80)));

                            maxResizeCount++;

                            if (maxResizeCount == 6)
                            {
                                tempImage = (Bitmap)outImage.Img.Clone();

                                while (tempImage.Height > pageHeight - endHeightPoint && maxResizeCount < 11) //aşağı yerleştirebilmek için %20 küçülterek ilerle
                                {
                                    tempImage = myImg.ResizeFast(tempImage, (int)(tempImage.Width * (0.80)),
                                                                 (int)(tempImage.Height * (0.80)));
                                    maxResizeCount++;
                                }
                            }
                        }
                        if (0 < maxResizeCount && maxResizeCount < 6) //sağa yerleştirmeye
                        {
                            if (pageColumn == 1)                      //tek kolan var ise yeni kolona yerleştir sığmıyorsa yeni sayfa yarat
                            {
                                if (tempImage.Height < pageHeight - headerBottomPoint)
                                {
                                    outImage.Img           = (Bitmap)tempImage.Clone();
                                    outImage.LocationPixel = new PointF(lastZoneXPoint, headerBottomPoint);
                                    //yeni
                                    endWidthPoint   = lastZoneXPoint;
                                    lastZoneXPoint += outImage.Img.Width;

                                    if (endHeightPoint < headerBottomPoint + outImage.Img.Height)              //sayfa yatayındaki en uzun heigth point noktasını tut.Zone'lar üstüste gelmemesi için.
                                    {
                                        endHeightPoint = headerBottomPoint + outImage.Img.Height;
                                    }


                                    pageColumn++;
                                }

                                else
                                {
                                    maxResizeCount = 11;
                                }
                            }

                            else if (tempImage.Height < pageHeight - endHeightPoint)     //birden fazla kolon var ise son zone'un altına sığıyorsa yerleştir.sığmıyorsa yeni sayfa yarat.
                            {
                                outImage.Img           = (Bitmap)tempImage.Clone();
                                outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);
                                //yeni
                                endHeightPoint += outImage.Img.Height + 5;
                                lastZoneXPoint += outImage.Img.Width;
                            }
                            else
                            {
                                maxResizeCount = 11;
                            }
                        }


                        else if (5 < maxResizeCount && maxResizeCount < 11) //alta yerleştir
                        {
                            if (tempImage.Width < pageWidth - endWidthPoint)
                            //genişliği sığıyosarsa yerleştir sığmıyor ise yeni sayfa yarat.
                            {
                                outImage.Img           = outImage.Img = (Bitmap)tempImage.Clone();
                                outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);
                                //yeni
                                endHeightPoint += outImage.Img.Height + 5;
                                lastZoneXPoint  = endWidthPoint + outImage.Img.Width;
                            }
                            else
                            {
                                maxResizeCount = 11;
                            }
                        }


                        if (maxResizeCount == 11)   // Syafaya Sığmadı. Yeni page yaratıp ona yerleştir.
                        {
                            outPages.Add(outPage);  //sayfayı kaydet yeni bir sayfas oluştur



                            OutPage newOutPage = new OutPage();


                            while (tempImage.Width > pageWidth)
                            {
                                tempImage = myImg.ResizeFast(tempImage, (int)(tempImage.Width * (0.80)), (int)(tempImage.Height * (0.80)));
                            }

                            endWidthPoint     = 5;
                            endHeightPoint    = 5;
                            pageColumn        = 1;
                            headerBottomPoint = 5;

                            outImage.Img = (Bitmap)tempImage.Clone();

                            outImage.Reg = new Region(new RectangleF(endWidthPoint, endHeightPoint, tempImage.Width, tempImage.Height));

                            outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                            lastZoneXPoint  = outImage.Img.Width + endWidthPoint;
                            endHeightPoint += outImage.Img.Height + 5;

                            pageHeight = Utils.ConvertMMtoPixel(282, 72);         //yeni sayfa için yükseklik değerini günceleldik.

                            newOutPage.Images.Add(outImage);

                            outPage = newOutPage;
                        }
                        else  //ilk sayfaya sığdı region değerlerini düzeltiyoruz ve ilk sayfaya ekliyoruz.
                        {
                            outImage.Reg = new Region(new RectangleF(outImage.LocationPixel.X, outImage.LocationPixel.Y, tempImage.Width, tempImage.Height));


                            outPage.Images.Add(outImage);
                        }

                        tempImage.Dispose();
                        grp.Dispose();
                    }
                }


                #endregion

                #region Text Zone'ları Yerleştirme

                SortedDictionary <int, Zone> sortedTextZones = SelectAndSortTextZones(page.Zones); //Text Zone'ların Sıralanması işlemi.

                //Text Zoneları yerleştirme.
                foreach (Zone zone in sortedTextZones.Values)
                {
                    OutImage outImage = new OutImage();

                    outImage.Img = GetCroppedAndBlackWhite(page.Img, zone);

                    scale = 72 / outImage.Img.HorizontalResolution;

                    outImage.Img = Decrease72Dpi(outImage.Img, scale);

                    CalculateCharRect(zone, outImage.Img, scale);

                    Graphics grp = Graphics.FromImage(outImage.Img);


                    outImage.Reg = new Region(new RectangleF(zone.Reg.GetBounds(grp).X *scale, zone.Reg.GetBounds(grp).Y *scale, zone.Reg.GetBounds(grp).Width *scale, zone.Reg.GetBounds(grp).Height *scale));



                    //TextZone'un Sayafayanın kalan alanına sığıp sığamadığının kontrolü yapılır.
                    if (outImage.Reg.GetBounds(grp).Height > (pageHeight - endHeightPoint))
                    {
                        //Sığmıyorsa sayfadaki yeni bir Text kolonuna sığıp sığamadığının kontrolü. Orayada sığmıyorsa Parçalama işlemi yapılır. Sığıyorsa yeni kolona yerleştrilir.
                        if (pageColumn == 1 && outImage.Reg.GetBounds(grp).Height > (pageHeight - endHeightPoint) &&
                            outImage.Reg.GetBounds(grp).Height / 2 < (pageHeight - endHeightPoint))
                        {
                            OutImage[] separatedImages = SeparateTextZone(outImage, zone);

                            for (int i = 0; i < separatedImages.Length; i++)
                            {
                                separatedImages[i].LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                                lastZoneXPoint += endWidthPoint;



                                if (i != separatedImages.Length - 1)
                                //son parça text zone olup olmadığına göre 2. kolon için değerleri ayarlama
                                {
                                    endWidthPoint += separatedImages[i].Img.Width + 10;
                                    endHeightPoint = headerBottomPoint;
                                }
                                else
                                {
                                    endHeightPoint += separatedImages[i].Img.Height;
                                }
                                pageColumn = i + 1;
                                outPage.Images.Add(separatedImages[i]);
                            }
                        }
                        else
                        {
                            if (outImage.Img.Width < pageWidth - lastZoneXPoint && outImage.Img.Height < pageHeight - headerBottomPoint)
                            //yeni kolona sığıyor mu kontrolü yapılır sığmıyorsa yeni page oluşturulur.
                            {
                                endWidthPoint = lastZoneXPoint + 10;

                                outImage.LocationPixel = new PointF(endWidthPoint, headerBottomPoint);

                                endHeightPoint = outImage.Img.Height + headerBottomPoint;

                                lastZoneXPoint = endWidthPoint + outImage.Img.Width;

                                pageColumn++;


                                outPage.Images.Add(outImage);
                            }
                            else
                            {
                                outPages.Add(outPage); //ilk sayfayı listeye ekle yeni bir sayfa aç
                                OutPage newOutPage = new OutPage();
                                endWidthPoint     = 5;
                                endHeightPoint    = 5;
                                pageColumn        = 1;
                                headerBottomPoint = 5;

                                if (outImage.Img.Height < pageHeight - headerBottomPoint) //yeni sayfaya sığıyorsa yerleştir.
                                {
                                    outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                                    endHeightPoint += outImage.Img.Height;
                                    lastZoneXPoint  = endWidthPoint + outImage.Img.Width;

                                    newOutPage.Images.Add(outImage);

                                    pageHeight = Utils.ConvertMMtoPixel(282, 72);
                                    //yeni sayfa için yükseklik değerini günceleldik.


                                    outPage = newOutPage;
                                }
                                else                                            //yeni sayfaya sığmıyorsa parçalayıp yerleştir.
                                {
                                    OutImage[] separatedImages = SeparateTextZone(outImage, zone);

                                    for (int i = 0; i < separatedImages.Length; i++)
                                    {
                                        separatedImages[i].LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                                        lastZoneXPoint += endWidthPoint;



                                        if (i != separatedImages.Length - 1)
                                        //son parça text zone olup olmadığına göre 2. kolon için değerleri ayarlama
                                        {
                                            endWidthPoint += separatedImages[i].Img.Width + 10;
                                            endHeightPoint = headerBottomPoint;
                                        }
                                        else
                                        {
                                            endHeightPoint += separatedImages[i].Img.Height;
                                        }
                                        pageColumn = i + 1;

                                        outPage = newOutPage;

                                        outPage.Images.Add(separatedImages[i]);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (pageColumn != 1)
                        {
                            outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                            endHeightPoint += outImage.Img.Height;

                            lastZoneXPoint = endWidthPoint + outImage.Img.Width;

                            outPage.Images.Add(outImage);
                        }
                        else
                        {
                            outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                            endHeightPoint += outImage.Img.Height;

                            if (lastZoneXPoint < endWidthPoint + outImage.Img.Width)   //Text zone'larından en geniş olanının değerini sakla (image yazının üstüne gelmemesi için)
                            {
                                lastZoneXPoint = endWidthPoint + outImage.Img.Width;
                            }

                            outPage.Images.Add(outImage);
                        }
                    }

                    grp.Dispose();
                }

                #endregion
            }


            outPages.Add(outPage); //son sayfada eklenir.


            return(outPages);
        }