I have got a dynamic text, which has an unknown number of lines. This number of lines can be between 1 and for example 1000. Now I want do create a PDF document, which automatically creates a new page if a specific number of lines is reached.
I already found that it would probably work with MigraDoc, but I tested it already and well.. it didn't work like I tested it.
// You always need a MigraDoc document for rendering.
Document doc = new Document();
MigraDoc.DocumentObjectModel.Section sec = doc.AddSection();
// Add a single paragraph with some text and format information.
MigraDoc.DocumentObjectModel.Paragraph para = sec.AddParagraph();
para.Format.Alignment = ParagraphAlignment.Justify;
para.Format.Font.Name = "Times New Roman";
para.Format.Font.Size = 12;
para.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.DarkGray;
para.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.DarkGray;
para.AddText("Duisism odigna acipsum delesenisl ");
para.AddFormattedText("ullum in velenit", TextFormat.Bold);
para.AddText(" ipit iurero dolum zzriliquisis nit wis dolore vel et nonsequipit, velendigna " +
"auguercilit lor se dipisl duismod tatem zzrit at laore magna feummod oloborting ea con vel " +
"essit augiati onsequat luptat nos diatum vel ullum illummy nonsent \nA \n B\nV \nD \nE\nF\nG\nA \n B\nV \nD \nE\nF\nG\nA \n B\nV \nD \nE\nF\nG\nA \n B\nV \nD \nE\nF\nG\nA \n B\nV \nD \nE\nF\nGnit ipis et nonsequis " +
"niation utpat. Odolobor augait et non etueril landre min ut ulla feugiam commodo lortie ex " +
"essent augait el ing eumsan hendre feugait prat augiatem amconul laoreet. ≤≥≈≠");
para.Format.Borders.Distance = "5pt";
para.Format.Borders.Color = MigraDoc.DocumentObjectModel.Colors.Gold;
// Create a renderer and prepare (=layout) the document
MigraDoc.Rendering.DocumentRenderer docRenderer = new DocumentRenderer(doc);
docRenderer.PrepareDocument();
This is the code I took from a MigraDoc example, but it doesn't really work as I want. Instead of creating a new page after the appropiate number of lines, it just writes further out of the border of the first page.
Can you give me an example where multiline text creates a new page if the appropiate number of lines ist reached?