コード例 #1
0
        /// <summary>
        /// Initialization of the section
        /// </summary>
        /// <param name="rp"></param>
        public Section(BaseReport rp)
            : base(rp)
        {
            FPageGroupCountList = new TotalPages();
            FStream             = new MemoryStream();
#if REPMAN_ZLIB
            FDecompStream = new MemoryStream();
#endif
            Height              = DEF_DRAWWIDTH;
            Width               = Height;
            Components          = new PrintPosItems();
            ExternalTable       = "REPMAN_REPORTS";
            ExternalField       = "REPORT";
            ExternalSearchField = "REPORT_NAME";
            ForcePrint          = false;
            dpires              = DEFAULT_DPI_BACK;
            DrawStyle           = ImageDrawStyleType.Full;
            StreamFormat        = StreamFormatType.Text;
            Width               = DEF_DRAWWIDTH;
            Height              = DEF_DRAWHEIGHT;
            ChildSubReportName  = "";
            SubReportName       = "";
            GroupName           = "";
            ChangeExpression    = "";
            BeginPageExpression = "";
            SkipToPageExpre     = "";
            SkipExpreH          = "";
            SkipExpreV          = "";
            BackExpression      = "";
            ExternalFilename    = ""; ExternalConnection = ""; ExternalTable = "";
            ExternalField       = ""; ExternalSearchField = ""; ExternalSearchValue = "";
        }
コード例 #2
0
        /// <summary>
        /// Draw an object to the PDF file
        /// </summary>
        /// <param name="page">MetaPage conatining the object</param>
        /// <param name="obj">Object to be drawn</param>
        public void DrawObject(MetaPage page, MetaObject obj)
        {
            if (CalculateOnly)
            {
                return;
            }
            int          X, Y, W, H, S;
            int          Width, Height, posx, posy;
            Rectangle    rec;
            int          aalign;
            MemoryStream stream;
            string       astring;

            posx = obj.Left;
            posy = obj.Top;
            switch (obj.MetaType)
            {
            case MetaObjectType.Text:
                MetaObjectText objt = (MetaObjectText)obj;
                FPDFFile.Canvas.Font.WFontName = page.GetWFontNameText(objt);
                FPDFFile.Canvas.Font.FontName  = FPDFFile.Canvas.Font.WFontName.Replace(" ", "");
                FPDFFile.Canvas.Font.LFontName = page.GetLFontNameText(objt);
                FPDFFile.Canvas.Font.Style     = objt.FontStyle;
                // Transparent ?
                FPDFFile.Canvas.Font.Name        = (PDFFontType)objt.Type1Font;
                FPDFFile.Canvas.Font.Size        = objt.FontSize;
                FPDFFile.Canvas.Font.Color       = objt.FontColor;
                FPDFFile.Canvas.Font.Bold        = (objt.FontStyle & 1) > 0;
                FPDFFile.Canvas.Font.Italic      = (objt.FontStyle & 2) > 0;
                FPDFFile.Canvas.Font.Underline   = (objt.FontStyle & 4) > 0;
                FPDFFile.Canvas.Font.StrikeOut   = (objt.FontStyle & 8) > 0;
                FPDFFile.Canvas.Font.BackColor   = objt.BackColor;
                FPDFFile.Canvas.Font.Transparent = objt.Transparent;
                FPDFFile.Canvas.UpdateFonts();
                aalign  = objt.Alignment;
                rec     = new Rectangle(posx, posy, posx + objt.Width, posy + objt.Height);
                astring = page.GetText(objt);
                FPDFFile.Canvas.TextRect(rec, astring, aalign, objt.CutText,
                                         objt.WordWrap, objt.FontRotation, objt.RightToLeft);
                break;

            case MetaObjectType.Draw:
                MetaObjectDraw objd = (MetaObjectDraw)obj;
                Width  = objd.Width;
                Height = objd.Height;
                FPDFFile.Canvas.BrushStyle = objd.BrushStyle;
                FPDFFile.Canvas.PenStyle   = objd.PenStyle;
                FPDFFile.Canvas.PenColor   = objd.PenColor;
                FPDFFile.Canvas.BrushColor = objd.BrushColor;
                FPDFFile.Canvas.PenWidth   = objd.PenWidth;
                X = (int)FPDFFile.Canvas.PenWidth / 2;
                Y = X;
                W = Width - FPDFFile.Canvas.PenWidth + 1;
                H = Height - FPDFFile.Canvas.PenWidth + 1;
                if (FPDFFile.Canvas.PenWidth == 0)
                {
                    W--;
                    H--;
                }
                if (W < H)
                {
                    S = W;
                }
                else
                {
                    S = H;
                }
                ShapeType shape = (ShapeType)objd.DrawStyle;
                if ((shape == ShapeType.Square) || (shape == ShapeType.RoundSquare) ||
                    (shape == ShapeType.Circle))
                {
                    X = X + (int)((W - S) / 2);
                    Y = Y + (int)((H - S) / 2);
                    W = S;
                    H = S;
                }
                switch (shape)
                {
                case ShapeType.Rectangle:
                case ShapeType.Square:
                    FPDFFile.Canvas.Rectangle(X + posx, Y + posy, X + posx + W, Y + posy + H);
                    break;

                case ShapeType.RoundRect:
                case ShapeType.RoundSquare:
                    FPDFFile.Canvas.RoundedRectangle(X + posx, Y + posy, X + posx + W, Y + posy + H, Rectangle_Radius);
                    break;

                case ShapeType.Ellipse:
                case ShapeType.Circle:
                    FPDFFile.Canvas.Ellipse(X + posx, Y + posy, X + posx + W, Y + posy + H);
                    break;

                case ShapeType.HorzLine:
                    FPDFFile.Canvas.Line(X + posx, Y + posy, X + posx + W, Y + posy);
//							if (objd.PenStyle >= 3 && objd.PenStyle <= 4)
//							{
//								FPDFFile.Canvas.PenStyle = 6;
//								FPDFFile.Canvas.Line(X + posx, Y + posy, X + posx, Y + posx + H);
//							}
                    break;

                case ShapeType.VertLine:
                    FPDFFile.Canvas.Line(X + posx, Y + posy, X + posx, Y + posy + H);
                    break;

                case ShapeType.Oblique1:
                    FPDFFile.Canvas.Line(X + posx, Y + posy, X + posx + W, Y + posy + H);
                    break;

                case ShapeType.Oblique2:
                    FPDFFile.Canvas.Line(X + posx, Y + posy + H, X + posx + W, Y + posy);
                    break;
                }
                break;

            case MetaObjectType.Image:
                MetaObjectImage obji = (MetaObjectImage)obj;
                // In pdf draw also preview only images
                //if (!obji.PreviewOnly)
                {
                    Width  = obji.Width;
                    Height = obji.Height;
                    rec    = new Rectangle(posx, posy, Width, Height);
                    stream = page.GetStream(obji);
                    ImageDrawStyleType dstyle = (ImageDrawStyleType)obji.DrawImageStyle;
                    long intimageindex        = -1;
                    if (obji.SharedImage)
                    {
                        intimageindex = obji.StreamPos;
                    }
                    bool adaptsize = false;
                    if (dstyle == ImageDrawStyleType.Full)
                    {
                        adaptsize = true;
                        dstyle    = ImageDrawStyleType.Crop;
                    }
                    switch (dstyle)
                    {
                    case ImageDrawStyleType.Full:
                        FPDFFile.Canvas.DrawImage(rec, stream, obji.DPIRes, false, false, intimageindex);
                        break;

                    case ImageDrawStyleType.Stretch:
                        FPDFFile.Canvas.DrawImage(rec, stream, 0, false, false, intimageindex);
                        break;

                    case ImageDrawStyleType.Crop:
                        int bitmapwidth  = 0;
                        int bitmapheight = 0;
                        using (Image nimage = Image.FromStream(stream))
                        {
                            bitmapwidth  = nimage.Width;
                            bitmapheight = nimage.Height;
                        }
                        if (adaptsize)
                        {
                            double nwidth  = bitmapwidth * Twips.TWIPS_PER_INCH / obji.DPIRes;
                            double nheight = bitmapheight * Twips.TWIPS_PER_INCH / obji.DPIRes;
                            if (nwidth > rec.Width)
                            {
                                rec = new Rectangle(rec.Left, rec.Top, Convert.ToInt32(nwidth), Height);
                            }
                            if (nheight > rec.Height)
                            {
                                rec = new Rectangle(rec.Left, rec.Top, rec.Width, Convert.ToInt32(nheight));
                            }
                        }

                        double propx = (double)rec.Width / bitmapwidth;
                        double propy = (double)rec.Height / bitmapheight;
                        H = 0;
                        W = 0;
                        if (propy > propx)
                        {
                            H   = Convert.ToInt32(Math.Round(rec.Height * propx / propy));
                            rec = new Rectangle(rec.Left, Convert.ToInt32(rec.Top + (rec.Height - H) / 2), rec.Width, H);
                        }
                        else
                        {
                            W   = Convert.ToInt32(rec.Width * propy / propx);
                            rec = new Rectangle(rec.Left + (rec.Width - W) / 2, rec.Top, W, rec.Height);
                        }
                        FPDFFile.Canvas.DrawImage(rec, stream, 0, false, false, intimageindex);
                        break;

                    case ImageDrawStyleType.Tile:
                    case ImageDrawStyleType.Tiledpi:
                        FPDFFile.Canvas.DrawImage(rec, stream, PDFFile.CONS_PDFRES, true, true, intimageindex);
                        break;
                    }
                }
                break;
            }
        }