예제 #1
0
 /**
  *  Draws the point, text and borders of this cell.
  *
  */
 internal virtual void Paint(
     Page page,
     float x,
     float y,
     float w,
     float h)
 {
     if (background != -1)
     {
         DrawBackground(page, x, y, w, h);
     }
     if (image != null)
     {
         image.SetLocation(x + left_padding, y + top_padding);
         image.DrawOn(page);
     }
     DrawBorders(page, x, y, w, h);
     if (text != null)
     {
         DrawText(page, x, y, w);
     }
     if (point != null)
     {
         if (point.align == Align.LEFT)
         {
             point.x = x + 2 * point.r;
         }
         else if (point.align == Align.RIGHT)
         {
             point.x = (x + w) - this.right_padding / 2;
         }
         point.y = y + h / 2;
         page.SetBrushColor(point.GetColor());
         if (point.GetURIAction() != null)
         {
             page.AddAnnotation(new Annotation(
                                    point.GetURIAction(),
                                    null,
                                    point.x - point.r,
                                    page.height - (point.y - point.r),
                                    point.x + point.r,
                                    page.height - (point.y + point.r),
                                    null,
                                    null,
                                    null));
         }
         page.DrawPoint(point);
     }
 }
예제 #2
0
        public static float DrawImg(PDF pdf, Page page, string imgfile, float offsetY)
        {
            System.Drawing.Image image = System.Drawing.Image.FromFile(imgfile);
            double val    = (double)pdfUtil.PDFpageeffwidth / (double)image.Width;
            double val2   = (double)(pdfUtil.PDFpageeffHeight - offsetY) / (double)image.Height;
            double factor = System.Math.Min(val, val2);

            PDFjet.NET.Image image2 = new PDFjet.NET.Image(pdf, new System.IO.BufferedStream(new System.IO.FileStream(imgfile, System.IO.FileMode.Open, System.IO.FileAccess.Read)), ImageType.JPG);
            image2.SetLocation(pdfUtil.PDFleft_margin, pdfUtil.PDFtop_margin + offsetY);
            image2.ScaleBy(factor);
            image2.DrawOn(page);
            return(image2.GetHeight());
        }
예제 #3
0
        /**
         *  Draws the point, text and borders of this cell.
         */
        internal void Paint(
            Page page,
            float x,
            float y,
            float w,
            float h)
        {
            if (background != -1)
            {
                DrawBackground(page, x, y, w, h);
            }
            if (image != null)
            {
                if (GetTextAlignment() == Align.LEFT)
                {
                    image.SetLocation(x + leftPadding, y + topPadding);
                    image.DrawOn(page);
                }
                else if (GetTextAlignment() == Align.CENTER)
                {
                    image.SetLocation((x + w / 2f) - image.GetWidth() / 2f, y + topPadding);
                    image.DrawOn(page);
                }
                else if (GetTextAlignment() == Align.RIGHT)
                {
                    image.SetLocation((x + w) - (image.GetWidth() + leftPadding), y + topPadding);
                    image.DrawOn(page);
                }
            }
            if (barCode != null)
            {
                try {
                    if (GetTextAlignment() == Align.LEFT)
                    {
                        barCode.DrawOnPageAtLocation(page, x + leftPadding, y + topPadding);
                    }
                    else if (GetTextAlignment() == Align.CENTER)
                    {
                        float barcodeWidth = barCode.DrawOn(null)[0];
                        barCode.DrawOnPageAtLocation(page, (x + w / 2f) - barcodeWidth / 2f, y + topPadding);
                    }
                    else if (GetTextAlignment() == Align.RIGHT)
                    {
                        float barcodeWidth = barCode.DrawOn(null)[0];
                        barCode.DrawOnPageAtLocation(page, (x + w) - (barcodeWidth + leftPadding), y + topPadding);
                    }
                }
                catch (Exception e) {
                    Console.WriteLine(e.ToString());
                }
            }
            if (textBlock != null)
            {
                textBlock.SetLocation(x + leftPadding, y + topPadding);
                textBlock.DrawOn(page);
            }
            DrawBorders(page, x, y, w, h);
            if (text != null && !text.Equals(""))
            {
                DrawText(page, x, y, w, h);
            }
            if (point != null)
            {
                if (point.align == Align.LEFT)
                {
                    point.x = x + 2 * point.r;
                }
                else if (point.align == Align.RIGHT)
                {
                    point.x = (x + w) - this.rightPadding / 2;
                }
                point.y = y + h / 2;
                page.SetBrushColor(point.GetColor());
                if (point.GetURIAction() != null)
                {
                    page.AddAnnotation(new Annotation(
                                           point.GetURIAction(),
                                           null,
                                           point.x - point.r,
                                           point.y - point.r,
                                           point.x + point.r,
                                           point.y + point.r,
                                           null,
                                           null,
                                           null));
                }
                page.DrawPoint(point);
            }

            if (drawable != null)
            {
                drawable.SetPosition(x + leftPadding, y + topPadding);
                drawable.DrawOn(page);
            }
        }