PDFsharp & MigraDoc Foundation http://forum.pdfsharp.de/ |
|
Table not showing up http://forum.pdfsharp.de/viewtopic.php?f=2&t=2711 |
Page 1 of 1 |
Author: | sidkdbl07 [ Sat Jan 18, 2014 7:25 am ] |
Post subject: | Table not showing up |
I get my template loaded and the strings intro, title and person are rendered properly, but my table doesn't show up. Any ideas as to what I'm doing wrong? Code: class Program
{ static void Main(string[] args) { SIMSEntities db = new SIMSEntities(); Guid id = Guid.Parse("1D883A82-76B7-4B25-8F5C-5680118C779B"); Deliverable deliverable = db.Deliverables.Single(i => i.id == id); PdfDocument pdf = new PdfDocument(); //create the first page PdfPage pg = new PdfPage(); PdfDocument template = PdfReader.Open(@"Z:/myTemplate.pdf", PdfDocumentOpenMode.Import); pg = pdf.AddPage(template.Pages[0]); XGraphics graphic = XGraphics.FromPdfPage(pg); XTextFormatter tf = new XTextFormatter(graphic); //Introduction to every page string intro = "The following quality controls were documented in the SIMS Deliverable tool."; string title = "Title: " + deliverable.title; string person = "Person Responsible: " + deliverable.Person.FullName; Document doc = new Document(); Section section = doc.AddSection(); Paragraph para = section.AddParagraph(); para.Format.Font.Name = "Verdana"; para.Format.Font.Size = 8; para.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.Black; para.AddText(intro); para.AddLineBreak(); para.AddLineBreak(); para.AddText(title); para.AddLineBreak(); para.AddText(person); var table = section.AddTable(); table.Borders.Width = 0.25; table.Rows.LeftIndent = 0; Column column = table.AddColumn("5cm"); column.Format.Alignment = ParagraphAlignment.Left; column = table.AddColumn("4cm"); column.Format.Alignment = ParagraphAlignment.Left; column = table.AddColumn("6cm"); column.Format.Alignment = ParagraphAlignment.Left; Row row = table.AddRow(); row.Cells[0].AddParagraph("Type of Review"); row.Cells[0].MergeDown = 1; row.Cells[1].AddParagraph("Date Required"); row.Cells[2].AddParagraph("Date Completed"); row = table.AddRow(); row.Cells[1].AddParagraph("Comments"); row.Cells[1].MergeRight = 1; table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 0.75, Color.Empty); //int numberOrRows = 0; //var actions = deliverable.DeliverableActions.ToList(); //foreach (DeliverableAction a in actions) //{ // row = table.AddRow(); // row.HeadingFormat = false; // row.Cells[0].AddParagraph(a.TypeAction.type_name); // row.Cells[1].AddParagraph(((a.date_required_completed.HasValue) ? a.date_required_completed.Value.ToString("dd/mm/yyyy") : "")); // row.Cells[2].AddParagraph(((a.date_completed.HasValue) ? a.date_completed.Value.ToString("dd/mm/yyyy") : "")); // row = table.AddRow(); // row.Cells[1].AddParagraph(a.comments); // numberOrRows = numberOrRows + 2; //}//end DA loop //table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 0.75); MigraDoc.Rendering.DocumentRenderer docRenderer = new MigraDoc.Rendering.DocumentRenderer(doc); docRenderer.PrepareDocument(); docRenderer.RenderObject(graphic, XUnit.FromCentimeter(2), XUnit.FromCentimeter(4), "18cm", para); // string SaveLocationPdf = ServerSavePath + deliverable.id.ToString() + "_Report.pdf"; string SaveLocationPdf = "qac_" + deliverable.title + ".pdf"; pdf.Save(@"Z:\" + SaveLocationPdf); pdf.Close(); } |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |