public void AddChartToPage(Document pdfDoc, int scalePercent = 100, float spacingBefore = 50, float spacingAfter = 10, float widthPercentage = 80) { using (var chartimage = new MemoryStream()) { _chart.SaveImage(chartimage, ChartImageFormat.Bmp); //BMP gives the best compression result var iTextSharpImage = PdfImageHelper.GetITextSharpImageFromByteArray(chartimage.ToArray()); iTextSharpImage.ScalePercent(scalePercent); iTextSharpImage.Alignment = Element.ALIGN_CENTER; var table = new PdfGrid(1) { WidthPercentage = widthPercentage, SpacingBefore = spacingBefore, SpacingAfter = spacingAfter }; table.AddCell(iTextSharpImage); pdfDoc.Add(table); } }
public void AddChartToPage(PlotModel model, Document pdfDoc, int width, int height, float spacingBefore = 50, float spacingAfter = 10, float widthPercentage = 80) { using (var chartimage = new MemoryStream()) { //BMP gives the best compression result var pngExporter = new PngExporter { Width = width, Height = height, Background = OxyColors.White }; pngExporter.Export(model, chartimage); var imageBytes = chartimage.ToArray(); var iTextSharpImage = PdfImageHelper.GetITextSharpImageFromByteArray(imageBytes); iTextSharpImage.Alignment = Element.ALIGN_CENTER; var table = new PdfGrid(1) { WidthPercentage = widthPercentage, SpacingBefore = spacingBefore, SpacingAfter = spacingAfter }; table.AddCell(iTextSharpImage); pdfDoc.Add(table); } }
/// <summary> /// /// </summary> /// <returns></returns> public PdfPCell RenderingCell(CellAttributes attributes) { PdfPCell pdfCell = new PdfPCell(); PdfGrid table = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_LTR }; iTextSharp.text.Image photo = PdfImageHelper.GetITextSharpImageFromByteArray(SharksLogo); photo.WidthPercentage = 60; table.AddCell(new PdfPCell(photo, true) { Border = 0 }); string coachName = attributes.RowData.TableRowData[0].PropertyValue.ToSafeString(); string coachPhone = attributes.RowData.TableRowData[1].PropertyValue.ToSafeString(); List <string> players = attributes.RowData.TableRowData[2].PropertyValue as List <string>; foreach (string p in players) { table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(p)) { Border = 0, Padding = 0 }); } table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process("")) { Border = 0 }); table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process("")) { Border = 0 }); if (!string.IsNullOrWhiteSpace(coachName)) { table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process("Head Coach")) { Border = 0 }); table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(coachName + " " + coachPhone)) { Border = 1 }); } pdfCell.AddElement(table); return(pdfCell); }