PDFsharp & MigraDoc Foundation http://forum.pdfsharp.com/ |
|
PageBreak in Migradoc Table Row http://forum.pdfsharp.com/viewtopic.php?f=2&t=4189 |
Page 1 of 1 |
Author: | apa1379 [ Thu Oct 15, 2020 5:22 am ] |
Post subject: | PageBreak in Migradoc Table Row |
Hello, I get no further on the subject. How can I make a line span several pages? My Code: void FillTimeTableContent(int kw, EmployeeModel employee, Table table, Section section) { // Iterate the invoice items Decimal totalExtendedTime = 0; Decimal dailyExtendedTime = 0; Color TableBorder = new Color(101, 130, 95); DateTime date; Paragraph paragraph = section.AddParagraph(); var orderDispoViews = GlobalConfig.Connection.GetOrderDispoViewWithCWAndEmp(kw, employee.id); var props = orderDispoViews.Select(x => DateTime.Parse(x.startDate)).Distinct().OrderBy(x => x); Row row; foreach (var weekday in props) { int i = 0; foreach (var orderDispo in orderDispoViews) { if (weekday == DateTime.Parse(orderDispo.startDate)) { ICustomer customer = new PrivateCustomerModel(); customer = GlobalConfig.Connection.GetFilterBusinessCustomerWithQuoteName(orderDispo.idquote); if (customer.Id == 0) customer = GlobalConfig.Connection.GetFilterPrivateCustomerWithOrderId(orderDispo.id); var targetObject = new TargetObjectModel(); targetObject = GlobalConfig.Connection.GetTargetObjectWithOrderId(orderDispo.id); row = table.AddRow(); //row.KeepWith = 2; if (i == 0) { int _mergeDown = orderDispoViews.Where(x => DateTime.Parse(x.startDate) == DateTime.Parse(orderDispo.startDate)).Count(); row.Cells[0].MergeDown = _mergeDown; row.Cells[0].AddParagraph($"{weekday.ToString("dddd", new CultureInfo("de-DE"))},\n{weekday.ToString("dd.MM.yyyy", new CultureInfo("de-DE"))}"); row.Format.Font.Size = 8; row.Cells[0].Format.Font.Bold = true; } if (customer.DisplayName.Contains('_')) row.Cells[1].AddParagraph(customer.DisplayName.Substring(0, customer.DisplayName.IndexOf('_'))); else row.Cells[1].AddParagraph(customer.DisplayName); row.Format.Font.Size = 8; row.Cells[1].Format.Alignment = ParagraphAlignment.Left; row.Cells[2].AddParagraph(orderDispo.service); row.Format.Font.Size = 8; row.Cells[2].Format.Alignment = ParagraphAlignment.Left; if (string.IsNullOrEmpty(targetObject.Description)) row.Cells[3].AddParagraph($"\n{targetObject.Street} {targetObject.HouseNumber}\n {targetObject.ZipCode} {targetObject.City}"); else row.Cells[3].AddParagraph($"{targetObject.Description}\n{targetObject.Street} {targetObject.HouseNumber}\n {targetObject.ZipCode} {targetObject.City}"); row.Format.Font.Size = 8; row.Cells[3].Format.Alignment = ParagraphAlignment.Left; row.Cells[4].AddParagraph($"{orderDispo.startTime} - {orderDispo.endTime}"); row.Format.Font.Size = 8; row.Cells[4].Format.Alignment = ParagraphAlignment.Left; row.Cells[5].AddParagraph(orderDispo.times); row.Format.Font.Size = 8; row.Cells[5].Format.Alignment = ParagraphAlignment.Right; var extendedTime = Decimal.Parse(orderDispo.times); dailyExtendedTime += extendedTime; i++; } } table.SetEdge(0, table.Rows.Count-1, 8, 1, Edge.Box, MigraDoc.DocumentObjectModel.BorderStyle.Single, 1, TableBorder); row = table.AddRow(); row.Cells[5].AddParagraph($"\n{dailyExtendedTime}"); row.Format.Font.Size = 8; row.Format.Font.Bold = true; row.Cells[5].Format.Alignment = ParagraphAlignment.Right; totalExtendedTime += dailyExtendedTime; dailyExtendedTime = 0; } row = table.AddRow(); row.Format.Font.Size = 8; row.Format.Font.Bold = true; row.Cells[0].AddParagraph($"\nGesamt"); row.Cells[0].MergeRight = 4; row.Cells[0].Format.Alignment = ParagraphAlignment.Left; row.Cells[5].AddParagraph($"\n{totalExtendedTime}"); row.Cells[5].Format.Alignment = ParagraphAlignment.Right; } public string saveFileInTemp(Document document, string _fileName) { document.UseCmykColor = true; //const bool unicode = false; //const PdfFontEmbedding embedding = PdfFontEmbedding.Always; //PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode); PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always); // Associate the MigraDoc document with a renderer pdfRenderer.Document = document; // Layout and render document to PDF pdfRenderer.RenderDocument(); //gibt es das temp-Verzeichnis??? string destPath = CreateOrOpenFile("temp"); deleteFiles(destPath); //eindeutigen Filename _fileName = GetUniqueFileName(destPath, _fileName); _fileName = String.Concat(_fileName, ".pdf"); destPath = Path.Combine(destPath, _fileName); // Save the document... pdfRenderer.PdfDocument.Save(destPath); Process.Start(destPath); return destPath; } Many thanks for the help |
Author: | TH-Soft [ Thu Oct 15, 2020 8:58 am ] |
Post subject: | Re: PageBreak in Migradoc Table Row |
MigraDoc table rows never have pagebreaks. When using tables, make sure no row is larger than a single page. This may change in the future, but that's how it is now. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |