PDFsharp & MigraDoc Foundation http://forum.pdfsharp.com/ |
|
Migradoc page break in table http://forum.pdfsharp.com/viewtopic.php?f=2&t=4321 |
Page 1 of 1 |
Author: | justUser [ Mon Feb 07, 2022 12:38 pm ] |
Post subject: | Migradoc page break in table |
Hi, i have problem with migradoc. I`am trying to create table by mixing PdfSharp and Migadoc. My code: Code: private void GeneratePdf(ref HttpResponseMessage response, string recordId, Model model) { PdfDocument documentpdf = new PdfDocument(); PdfPage page = documentpdf.AddPage(); page.Width = XUnit.FromMillimeter(210); page.Height = XUnit.FromMillimeter(297); XGraphics gfx = XGraphics.FromPdfPage(page); gfx.MUH = PdfFontEncoding.Unicode; XFont fontX = new XFont(SomeFont, 20, XFontStyle.Underline); Font font = new Font(SomeFont, 11); Document doc = new Document(); Section section = doc.AddSection(); //logo AddLogoWithTitle(page, gfx, fontX, SomeDate); MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable(); table.Style = "Table"; table.Format.Font = font; table.Format.Borders.Distance = "0.3cm"; table.Borders.Bottom.Color = MigraDoc.DocumentObjectModel.Colors.DarkGray; table.KeepTogether = false; Column col1a = table.AddColumn("2cm"); col1a.Format.Alignment = ParagraphAlignment.Right; Column col1aMid = table.AddColumn("2cm"); Column col2a = table.AddColumn("2cm"); col2a.Format.Alignment = ParagraphAlignment.Left; Column col1b = table.AddColumn("2cm"); col1b.Format.Alignment = ParagraphAlignment.Right; Column col1bMid = table.AddColumn("2cm"); Column col2b = table.AddColumn("2cm"); col2b.Format.Alignment = ParagraphAlignment.Left; Row row = table.AddRow(); row.HeadingFormat = true; //calling it multiple times with other values CreateSectionPartLabelWith3Merged("someString", model.property, table,row); DocumentRenderer docRenderer = new DocumentRenderer(doc); #region Generowanie pliku i renderowanie tabel docRenderer.PrepareDocument(); docRenderer.RenderObject(gfx, 5, XUnit.FromCentimeter(4), "12cm", table); } private void CreateSectionPartLabelWith3Merged(string partLabel, string partValue, MigraDoc.DocumentObjectModel.Tables.Table table, Row row) { row = table.AddRow(); row.Cells[0].Format.Font.Bold = true; row.Cells[1].MergeRight = 4; row.Cells[0].Format.Font.Size = 11; row.Cells[0].AddParagraph(partLabel); row.Cells[1].AddParagraph(partValue); } private void AddLogoWithTitle(PdfPage page, XGraphics gfx, XFont fontX, string createDate) { XRect rectTitle = new XRect(0, 45, page.Width, 70); gfx.DrawString("Some text" + createDate, fontX, XBrushes.Black, rectTitle, XStringFormats.Center); string path = "SomePath" XImage logoImage = XImage.FromFile(path); gfx.DrawImage(logoImage, 10, 10, 187, 40); } The problem is when i call function to add next row with section and table reach end of page, then my text doesn`t appear on the next page (next page doesn`t exist, just text out of page boundary). I was trying to change table.KeepTogether to false or setting KeepWith to some number but still same problem. |
Author: | TH-Soft [ Mon Feb 07, 2022 12:42 pm ] |
Post subject: | Re: Migradoc page break in table |
justUser wrote: The problem is when i call function to add next row with section and table reach end of page, then my text doesn`t appear on the next page (next page doesn`t exist, just text out of page boundary). I was trying to change table.KeepTogether to false or setting KeepWith to some number but still same problem. Here is a sample that creates a document page by page, allowing PDFsharp code to add content to each page:viewtopic.php?p=9293#p9293 |
Author: | justUser [ Mon Feb 07, 2022 1:38 pm ] |
Post subject: | Re: Migradoc page break in table |
Ok, thanks for quick response, I added Code: PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(); and call RenderDocument(); on this object but then i got exception: "DocumentRenderer" must be set before calling "PrepareDocumentRenderer" I know that for you is soo simple, but i am new in this library and i dont know that correct flow. EDIT: doesnt matter, i used only migradoc without pdfsharp |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |