PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Keep paragraph and table together https://forum.pdfsharp.net/viewtopic.php?f=2&t=1073 |
Page 1 of 1 |
Author: | JohanK [ Fri Feb 26, 2010 9:29 am ] |
Post subject: | Keep paragraph and table together |
I generating an exam document as a PDF file. Questions are always a paragraph, and in some cases the answers are multiple choices presented in a 4x4 table. Using KeepTogether and KeepWith I've been able to not get page breaks inside a question or inside a table. However I can't find how to force the paragraph and table to keep together. Of course I never want a page break between the question and the choices table. What to do? Code: Document document = new Document();
Section s = document.AddSection(); Paragraph p; foreach (Question q in sortedTest) { p = s.AddParagraph(); p.Format.KeepTogether = true; p.AddFormattedText(counter.ToString() + ". " + q.QuestionText, TextFormat.Bold); var table = new MigraDoc.DocumentObjectModel.Tables.Table(); ... Column column = table.AddColumn(MigraDoc.DocumentObjectModel.Unit.FromCentimeter(3.6)); ... row = table.AddRow(); if (choiceCounter == 0) { row.KeepWith = 3; } ... PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true, PdfFontEmbedding.Always); pdfRenderer.Document = document; pdfRenderer.RenderDocument(); |
Author: | DaleStan [ Fri Feb 26, 2010 7:40 pm ] |
Post subject: | Re: Keep paragraph and table together |
If MigraDoc supports nested tables, you could try creating an invisible table/cell around the question&answer. |
Author: | Thomas Hoevel [ Mon Mar 01, 2010 9:10 am ] |
Post subject: | Re: Keep paragraph and table together |
It's a bug that you cannot keep paragraph and table together. As a workaround: You can have question and answer in one table (borders can be set for every cell; so you can make borders visible for the multiple choices only). |
Author: | JohanK [ Mon Mar 01, 2010 9:31 am ] |
Post subject: | Re: Keep paragraph and table together |
Of course! Thank you. I "col-spanned" a new first row and put the question text in that cell instead of nesting a table. Works like I want it to. |
Author: | shooter [ Mon Sep 26, 2011 3:28 pm ] |
Post subject: | Re: Keep paragraph and table together |
I have tried to use this workaround to keep a title paragrah with a table, but I also have a header row on the table. The header row is still rendering but not behaving correctly as a header row, in that it only appear once and not after each page break in the table. Any solution? thanks |
Author: | Thomas Hoevel [ Tue Sep 27, 2011 8:11 am ] |
Post subject: | Re: Keep paragraph and table together |
shooter wrote: The header row is still rendering but not behaving correctly as a header row, in that it only appear once and not after each page break in the table. You can have more than 1 header rows, but header rows must begin with the first row.You can mark first and second row as header rows - both will be repeated on following pages. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |