override protected void DoPrint(PrintOut adriver, int aposx, int aposy, int newwidth, int newheight, MetaFile metafile, Point MaxExtent, ref bool PartialPrint) { base.DoPrint(adriver, aposx, aposy, newwidth, newheight, metafile, MaxExtent, ref PartialPrint); MemoryStream FMStream = GetStream(); if (FMStream == null) { return; } if (FMStream.Length == 0) { return; } MetaObjectImage metaobj = new MetaObjectImage(); metaobj.MetaType = MetaObjectType.Image; metaobj.Top = aposy; metaobj.Left = aposx; metaobj.Width = PrintWidth; metaobj.Height = PrintHeight; metaobj.CopyMode = 20; metaobj.DrawImageStyle = DrawStyle; metaobj.DPIRes = dpires; metaobj.PreviewOnly = false; if (OldStreamPos >= 0) { metaobj.StreamPos = OldStreamPos; metaobj.SharedImage = true; } else { metaobj.StreamPos = metafile.Pages[metafile.CurrentPage].AddStream(FMStream, SharedImage != SharedImageType.None); if (SharedImage != SharedImageType.None) { OldStreamPos = metaobj.StreamPos; } metaobj.SharedImage = SharedImage != SharedImageType.None; } metaobj.StreamSize = FMStream.Length; metafile.Pages[metafile.CurrentPage].Objects.Add(metaobj); }
/// <summary> /// Prints the full section in a specific position of the page, the section will iterate the /// child components, printing each one /// </summary> /// <param name="adriver"></param> /// <param name="aposx"></param> /// <param name="aposy"></param> /// <param name="newwidth"></param> /// <param name="newheight"></param> /// <param name="metafile"></param> /// <param name="MaxExtent"></param> /// <param name="PartialPrint"></param> override protected void DoPrint(PrintOut adriver, int aposx, int aposy, int newwidth, int newheight, MetaFile metafile, Point MaxExtent, ref bool PartialPrint) { int i; PrintPosItem compo; int newposx, newposy; bool intPartialPrint; bool DoPartialPrint; MemoryStream astream; ExpressionItem compe = null; base.DoPrint(adriver, aposx, aposy, newwidth, newheight, metafile, MaxExtent, ref PartialPrint); // Draw the background if needed if (BackStyle != BackStyleType.Design) { astream = GetStream(); if (astream == null) { return; } if (astream.Length > 0) { MetaObjectImage obj = new MetaObjectImage(); obj.MetaType = MetaObjectType.Image; obj.Top = aposy; obj.Left = aposx; obj.Height = PrintHeight; obj.Width = PrintWidth; obj.DrawImageStyle = DrawStyle; obj.DPIRes = dpires; obj.PreviewOnly = BackStyle == BackStyleType.Preview; obj.DPIRes = dpires; if (OldStreamPos >= 0) { obj.StreamPos = OldStreamPos; obj.SharedImage = true; } else { obj.StreamPos = metafile.Pages[metafile.CurrentPage].AddStream(astream, SharedImage != SharedImageType.None); if (SharedImage != SharedImageType.None) { OldStreamPos = obj.StreamPos; } obj.SharedImage = SharedImage != SharedImageType.None; } obj.StreamSize = astream.Length; metafile.Pages[metafile.CurrentPage].Objects.Add(obj); } } DoPartialPrint = false; // Look for a partial print for (i = 0; i < Components.Count; i++) { compo = Components[i]; if (compo is ExpressionItem) { compe = (ExpressionItem)compo; if (compe.IsPartial) { DoPartialPrint = true; break; } } } PartialPrint = false; for (i = 0; i < Components.Count; i++) { compo = Components[i]; newwidth = -1; newheight = -1; // Component alignment switch (compo.Align) { case PrintItemAlign.None: newposx = aposx + compo.PosX; newposy = aposy + compo.PosY; break; case PrintItemAlign.Bottom: newposx = aposx + compo.PosX; newposy = aposy + LastExtent.Y - compo.LastExtent.Y; break; case PrintItemAlign.Right: newposx = aposx + LastExtent.X - compo.LastExtent.X; newposy = aposy + compo.PosY; break; case PrintItemAlign.BottomRight: newposx = aposx + compo.PosX; newposy = aposy + LastExtent.Y - compo.LastExtent.Y; break; case PrintItemAlign.LeftRight: newposx = aposx; newposy = aposy + compo.PosY; newwidth = LastExtent.X; break; case PrintItemAlign.TopBottom: newposx = aposx + compo.PosX; newposy = aposy + compo.PosY; newheight = LastExtent.Y; break; case PrintItemAlign.AllClient: newposx = aposx; newposy = aposy; newwidth = LastExtent.X; newheight = LastExtent.Y; break; default: newposx = aposx + compo.PosX; newposy = aposy + compo.PosY; break; } if (DoPartialPrint) { bool compoprinted = false; if (compo is ExpressionItem) { compe = (ExpressionItem)compo; if (compe.IsPartial) { intPartialPrint = false; compo.Print(adriver, newposx, newposy, newwidth, newheight, metafile, MaxExtent, ref intPartialPrint); if (intPartialPrint) { PartialPrint = true; } compoprinted = true; } } if ((!compoprinted) && compo.PartialFlag && (!PartialPrint)) { intPartialPrint = false; compo.PartialFlag = false; compo.Print(adriver, newposx, newposy, newwidth, newheight, metafile, MaxExtent, ref intPartialPrint); } if ((compe == null) && ((compo.Align == PrintItemAlign.TopBottom) || (compo.Align == PrintItemAlign.AllClient))) { bool dummypartial = false; compo.Print(adriver, newposx, newposy, newwidth, newheight, metafile, MaxExtent, ref dummypartial); } } else { compo.PartialFlag = false; // Evaluates print condition of each comonent if (compo.EvaluatePrintCondition()) { intPartialPrint = false; // For aligned to bottom elements, the partial print will // force to align bottom at the last section of the partial // print if (PartialPrint && ((compo.Align == PrintItemAlign.Bottom) || (compo.Align == PrintItemAlign.BottomRight))) { compo.PartialFlag = true; } else { compo.Print(adriver, newposx, newposy, newwidth, newheight, metafile, MaxExtent, ref intPartialPrint); } if (intPartialPrint) { PartialPrint = true; } if (compo is ExpressionItem) { compe = (ExpressionItem)compo; if (compe.IsGroupPageCount) { if (compe.LastMetaIndex > 0) { AddPageGroupCountItem(metafile.CurrentPage, compe.LastMetaIndex, compe.DisplayFormat); } } } } } } }
public override void DrawChart(Series nseries, MetaFile ametafile, int posx, int posy, object achart) { System.Windows.Forms.DataVisualization.Charting.Chart nchart = new System.Windows.Forms.DataVisualization.Charting.Chart(); float afontsize = Convert.ToSingle(Math.Round(nseries.FontSize * nseries.Resolution / 100)); //achart.BackColor:=clTeeColor; nchart.BackColor = Color.White; /*achart.LeftAxis.LabelsFont.Name:=nchart.WFontName; * achart.BottomAxis.LabelsFont.Name:=nchart.WFontName; * achart.Legend.Font.Name:=nchart.WFontName; * achart.LeftAxis.LabelsFont.Style:=CLXIntegerToFontStyle(nchart.FontStyle); * achart.BottomAxis.LabelsFont.Style:=CLXIntegerToFontStyle(nchart.FontStyle); * achart.Legend.Font.Size:=aFontSize; * achart.Legend.Font.Style:=CLXIntegerToFontStyle(nchart.FontStyle);*/ /*achart.Legend.Visible:=nchart.ShowLegend;*/ // autorange and other ranges /*achart.LeftAxis.Maximum:=Series.HighValue; * achart.LeftAxis.Minimum:=Series.LowValue; * achart.LeftAxis.Automatic:=false; * achart.LeftAxis.AutomaticMaximum:=Series.AutoRangeH; * achart.LeftAxis.AutomaticMinimum:=Series.AutoRangeL; * achart.LeftAxis.LabelsAngle:=nchart.VertFontRotation mod 360; * achart.LeftAxis.LabelsFont.Size:=Round(nchart.VertFontSize*nchart.Resolution/100); * achart.BottomAxis.LabelsAngle:=nchart.HorzFontRotation mod 360; * achart.BottomAxis.LabelsFont.Size:=Round(nchart.HorzFontSize*nchart.Resolution/100);*/ nchart.ChartAreas.Add(""); if (nseries.Effect3D) { nchart.ChartAreas[0].Area3DStyle.Enable3D = nseries.Effect3D;; nchart.ChartAreas[0].Area3DStyle.IsClustered = true; } //nchart.ChartAreas[0].AxisX.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dot; //nchart.ChartAreas[0].AxisY.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dot; //nchart.ChartAreas[0].AxisY.MinorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dot; //nchart.ChartAreas[0].AxisX.MinorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dot; nchart.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dot; nchart.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dot; if (nseries.Logaritmic) { nchart.ChartAreas[0].AxisY.IsLogarithmic = true; nchart.ChartAreas[0].AxisY.LogarithmBase = nseries.LogBase; } nchart.ChartAreas[0].AxisY.IsReversed = nseries.Inverted; //nchart.ChartAreas[0].AxisX.IntervalAutoMode = System.Windows.Forms.DataVisualization.Charting.IntervalAutoMode.VariableCount; nchart.ChartAreas[0].AxisX.IntervalAutoMode = System.Windows.Forms.DataVisualization.Charting.IntervalAutoMode.FixedCount; nchart.ChartAreas[0].AxisX.LabelStyle.Interval = 1; if (!nseries.AutoRangeH) { //nchart.ChartAreas[0].AxisX.IntervalAutoMode = System.Windows.Forms.DataVisualization.Charting.IntervalAutoMode. nchart.ChartAreas[0].AxisY.Maximum = nseries.HighValue; } if (nseries.VertFontRotation != 0) { nchart.ChartAreas[0].AxisY.LabelStyle = new System.Windows.Forms.DataVisualization.Charting.LabelStyle(); nchart.ChartAreas[0].AxisY.LabelStyle.Angle = nseries.VertFontRotation; } if (nseries.HorzFontRotation != 0) { nchart.ChartAreas[0].AxisY.LabelStyle = new System.Windows.Forms.DataVisualization.Charting.LabelStyle(); nchart.ChartAreas[0].AxisY.LabelStyle.Angle = nseries.HorzFontRotation; } if (!nseries.AutoRangeL) { //nchart.ChartAreas[0].AxisX.IntervalAutoMode = System.Windows.Forms.DataVisualization.Charting.IntervalAutoMode. nchart.ChartAreas[0].AxisY.Minimum = nseries.LowValue; } if (nseries.ShowLegend) { nchart.Legends.Add(""); } // Create series int acolor = 0; int idxserie = 0; foreach (SeriesItem sitem in nseries.SeriesItems) { System.Windows.Forms.DataVisualization.Charting.Series chartserie = nchart.Series.Add(sitem.Caption); switch (sitem.ChartStyle) { case ChartType.Area: chartserie.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Area; break; case ChartType.Gantt: case ChartType.Arrow: chartserie.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; break; case ChartType.Bar: switch (nseries.MultiBar) { case BarType.Stacked: chartserie.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedColumn; break; case BarType.Stacked100: chartserie.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedColumn100; break; default: chartserie.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; break; } break; case ChartType.Bubble: chartserie.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bubble; break; case ChartType.Horzbar: switch (nseries.MultiBar) { case BarType.Stacked: chartserie.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedBar; break; case BarType.Stacked100: chartserie.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedBar100; break; default: chartserie.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bar; break; } break; case ChartType.Line: chartserie.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; break; case ChartType.Pie: chartserie.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie; break; case ChartType.Point: chartserie.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; break; } chartserie.Label = sitem.Caption; if (nseries.ShowHint) { chartserie.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Square; } else { chartserie.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.None; } if (sitem.ChartStyle == ChartType.Pie) { // Set these other two properties so that you can see the connecting lines nchart.Series[0].BorderWidth = 1; nchart.Series[0].BorderColor = System.Drawing.Color.FromArgb(26, 59, 105); // Set the pie label as well as legend text to be displayed as percentage // The P2 indicates a precision of 2 decimals //nchart.Series[0].Label = "#VALX #PERCENT{P2} #VAL"; nchart.Series[0].Label = "#PERCENT{P2}"; nchart.Series[0]["PieLabelStyle"] = "Outside"; //nchart.Legends[0].CustomItems.Add(npoint.Color, sitem.ValueCaptions[j]); //nchart.Series[0].LegendText = "#VALX (#PERCENT) #VAL"; nchart.Series[0].LegendText = "#VALX #VAL"; //this.Chart2.Series[0].LegendText = "#VALX (#PERCENT)" //nchart.Legends[0].= sitem.ValueCaptions[j]; //n.Legends.Add("Legend1"); nchart.Legends[0].Enabled = true; nchart.Legends[0].Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Bottom; nchart.Legends[0].Alignment = System.Drawing.StringAlignment.Center; } if (sitem.Color > 0) { chartserie.Color = GraphicUtils.ColorFromInteger(sitem.Color); } else { chartserie.Color = GraphicUtils.ColorFromInteger(SeriesColors[acolor]); } double total = 0; if (nseries.MarkStyle == 1) { for (int j = 0; j < sitem.Values.Count; j++) { object nobj = sitem.Values[j]; if (DoubleUtil.IsNumericType(nobj)) { total = total + Convert.ToDouble(nobj); } } } for (int j = 0; j < sitem.Values.Count; j++) { string ncaption = sitem.ValueCaptions[j]; if (ncaption == null) { ncaption = ""; } int idx = chartserie.Points.AddXY(ncaption, sitem.Values[j]); System.Windows.Forms.DataVisualization.Charting.DataPoint npoint = chartserie.Points[idx]; if (sitem.ChartStyle != ChartType.Pie) { if (nseries.ShowHint) { switch (nseries.MarkStyle) { case 1: npoint.Label = ""; if ((DoubleUtil.IsNumericType(sitem.Values[j])) && (total != 0)) { npoint.Label = (Convert.ToDouble(sitem.Values[j]) / total * 100).ToString("N2") + "%"; } break; case 6: npoint.Label = ""; if (DoubleUtil.IsNumericType(sitem.Values[j])) { double nuevo_valor = Convert.ToDouble(sitem.Values[j]); npoint.Label = nuevo_valor.ToString("N1") + "%"; } break; default: npoint.Label = sitem.Values[j].ToString(); break; } } else { npoint.Label = ""; } } if (nseries.SeriesItems.Count < 2) { if (sitem.Colors[j] >= 0) { npoint.Color = GraphicUtils.ColorFromInteger(sitem.Colors[j]); } else { npoint.Color = GraphicUtils.ColorFromInteger(SeriesColors[acolor]); } if ((sitem.ChartStyle == ChartType.Pie) || nseries.ShowLegend) { if (sitem.ChartStyle == ChartType.Pie) { } else { if (j != 0) { nchart.Legends[0].CustomItems.Add(npoint.Color, sitem.ValueCaptions[j]); } else { nchart.Legends.Add(sitem.ValueCaptions[j]); } } acolor = ((acolor + 1) % (MAX_SERIECOLORS)); } } else { if (sitem.Colors[j] >= 0) { npoint.Color = GraphicUtils.ColorFromInteger(sitem.Colors[j]); } else { npoint.Color = GraphicUtils.ColorFromInteger(SeriesColors[acolor]); } } } acolor = ((acolor + 1) % (MAX_SERIECOLORS)); idxserie++; } Bitmap nbitmap = new Bitmap(Convert.ToInt32(Convert.ToSingle(Twips.TwipsToInch(nseries.PrintWidth)) * nseries.Resolution), Convert.ToInt32(Convert.ToSingle(Twips.TwipsToInch(nseries.PrintHeight)) * nseries.Resolution), PixelFormat.Format24bppRgb); Rectangle rec = new Rectangle(0, 0, nbitmap.Width, nbitmap.Height); nchart.SetBounds(0, 0, nbitmap.Width, nbitmap.Height); nchart.Update(); nchart.DrawToBitmap(nbitmap, rec); System.IO.MemoryStream mstream = new MemoryStream(); nbitmap.Save(mstream, ImageFormat.Bmp); MetaObjectImage metaobj = new MetaObjectImage(); metaobj.MetaType = MetaObjectType.Image; metaobj.Top = posy; metaobj.Left = posx; metaobj.Width = nseries.PrintWidth; metaobj.Height = nseries.PrintHeight; metaobj.CopyMode = 20; metaobj.DrawImageStyle = ImageDrawStyleType.Stretch; metaobj.DPIRes = Convert.ToInt32(nseries.Resolution); metaobj.PreviewOnly = false; metaobj.StreamPos = ametafile.Pages[ametafile.CurrentPage].AddStream(mstream, false); metaobj.SharedImage = false; metaobj.StreamSize = mstream.Length; ametafile.Pages[ametafile.CurrentPage].Objects.Add(metaobj); base.DrawChart(nseries, ametafile, posx, posy, achart); }
/// <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; } }