PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

RenderDocument Too sLow
https://forum.pdfsharp.net/viewtopic.php?f=2&t=381
Page 1 of 1

Author:  CarlosMag [ Sun May 04, 2008 7:51 pm ]
Post subject:  RenderDocument Too sLow

Hello...

I'm building a Table in a PDF Document in a ASP.NET 2.0 Web Site with then MigraDoc.DocumentObjectModel.Document.

I make a Table with 400 rows (more or less) and when I Render the Document it uses 100% of CPU and it taking a long time to resolve this.

This is my Document generation code.

// Create a new MigraDoc document
Document document = new Document();

document.Info.Title = "MyFileName";
document.Info.Subject = "MySubject";
document.Info.Author = "MyAuthor";
Section section = document.Sections.AddSection();

Table table = new Table();
table.Borders.Width = 0.75;
table.Format.Font.Size = 8;

Column column;
for (Int32 i = 0; i < Headers.Length;i++ ) //Headers is an Array with the Headers List Names
{
column = table.AddColumn(Unit.FromCentimeter(2));
switch (dt.Columns[i].DataType.FullName)
{
case "System.Decimal":
case "System.Int16":
case "System.Int32":
case "System.Int64":
case "System.Double":
column.Format.Alignment = ParagraphAlignment.Right;
break;
case "System.DateTime":
column.Format.Alignment = ParagraphAlignment.Center;
break;
default:
column.Format.Alignment = ParagraphAlignment.Left;
break;
}
}

//Header Row
Row row = table.AddRow();
Cell cell;
row.Shading.Color = Colors.PaleGoldenrod;
for (int i = 0; i < Headers.Length; i++)
{
cell = row.Cells[i];
cell.AddParagraph(Headers[i]);
}

//Data Rows
foreach (DataRow oRow in dt.Rows) //dt is a DataTable
{
row = table.AddRow();
for (int i = 0; i < Headers.Length; i++)
{
cell = row.Cells[i];
cell.AddParagraph(Convert.ToString(oRow[i]));
}
}

table.SetEdge(0, 0, Headers.Length, dt.Rows.Count, Edge.Box, BorderStyle.Single, 1.5, Colors.Black);

table.KeepTogether = false;

section.Add(table);

PdfDocumentRenderer renderer = new PdfDocumentRenderer();
renderer.Document = document;
renderer.RenderDocument(); //Here is the Slow code

There is something wrong?
Thanks afterhand
CarlosMag

Author:  Thomas Hoevel [ Mon May 05, 2008 8:11 am ]
Post subject: 

Hello!

This is a known issue.
Previous discussion
This will be optimized in a future release of PDFsharp.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/