PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jun 30, 2024 12:02 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Fri Feb 26, 2010 9:29 am 
Offline

Joined: Fri Feb 26, 2010 9:12 am
Posts: 2
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();


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 26, 2010 7:40 pm 
Offline

Joined: Mon Jan 04, 2010 2:44 pm
Posts: 23
If MigraDoc supports nested tables, you could try creating an invisible table/cell around the question&answer.


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 01, 2010 9:10 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3100
Location: Cologne, Germany
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).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 01, 2010 9:31 am 
Offline

Joined: Fri Feb 26, 2010 9:12 am
Posts: 2
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 26, 2011 3:28 pm 
Offline

Joined: Thu Sep 15, 2011 12:30 pm
Posts: 2
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


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 27, 2011 8:11 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3100
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 63 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group