/// <summary> /// Draws the screenshot png. /// </summary> /// <param name="page">Page.</param> /// <param name="bounds">Bounds.</param> private static void DrawScreenshot(ScreenshotReport report, PdfPage page, PdfStandardRectangle bounds) { var l = bounds.LLX; var t = bounds.LLY; var ms = new MemoryStream(report.screenshot); var png = new PdfPngImage(ms); var whP = png.Width / (double)png.Height; // TODO [email protected]: If, for some strange reason, the height and width are stupid // disproprtional, the bottom of the image will hang of the page. // What I'm saying is: this bitch needs clipping. var w = bounds.Width; var h = ((double)w * (double)png.Height) / (double)png.Width; page.Graphics.DrawImage(png, l, t, w, h); }
/// <summary> /// Draws the header of the screenshot report. /// </summary> private static void DrawHeader(ScreenshotReport report, PdfPage page, PdfStandardRectangle bounds, PdfStandardFont title, PdfStandardFont subtitle) { var layout = NewLayout(PdfStringHorizontalAlign.Center); layout.Height = bounds.Height; layout.Width = bounds.Width; var pen = NewPen(); var g = page.Graphics; var l = bounds.LLX; var r = bounds.URX; layout.X = l; layout.Y = bounds.LLY; g.DrawString(report.title, NewAppearance(title), layout); layout.Y += PdfTextEngine.GetStringHeight("Dg", title, layout.Width); g.DrawString(report.subtitle, NewAppearance(subtitle), layout); layout.Y += PdfTextEngine.GetStringHeight("Dg", title, layout.Width); g.DrawLine(pen, l, layout.Y - 1, r, layout.Y - 1); }
/// <summary> /// Draws the reports contents to the page. /// </summary> /// <param name="page">Page.</param> /// <param name="bounds">Bounds.</param> private static void DrawContent(ScreenshotReport report, PdfPage page, PdfStandardRectangle bounds, PdfStandardFont header, PdfStandardFont content) { var g = page.Graphics; var table = BuildReportContentTable(report.tableData, header, content); var xoffset = 0.0; var yoffset = 0.0; for (int c = 0; c < table.length; c++) { var col = table[c]; yoffset = 0.0; for (int r = 0; r < col.length; r++) { var l = NewLayout(); l.X = bounds.LLX + xoffset + (5 * c); l.Y = bounds.LLY + yoffset; l.Width = col.columnWidth; l.Height = col.rowHeight; g.DrawString(table[c][r], col.appearance, l); yoffset += col.rowHeight; } xoffset += col.columnWidth; } { var l = NewLayout(); l.X = bounds.LLX; l.Y = bounds.LLY + yoffset; l.Width = bounds.Width; l.Height = bounds.URY - l.Y; g.DrawString(report.notes, NewAppearance(content), l); } /* * var yoffset = 0.0; * var xoffset = 0.0; * * for (int c = 0; c < table.length; c++) { * var col = table[c]; * * if (c > 0) { * xoffset += col.columnWidth; * } * * var layout = NewLayout(); * layout.Width = col.columnWidth; * layout.Y = bounds.LLY; * layout.X = bounds.LLX + xoffset; * * for (int r = 0; r < col.length; r++) { * g.DrawString(col[r], col.appearance, layout); * layout.Y += col.rowHeight; * if (layout.Y > yoffset) { * yoffset = layout.Y; * } * } * } * * var looks = NewAppearance(content); * var l = NewLayout(); * l.X = bounds.LLX; * l.Y = yoffset; * l.Width = bounds.Width; * l.Height = bounds.Height - (bounds.LLY - yoffset); * * g.DrawString(report.notes, looks, l); */ }