|
PDFsharp - moved to http://forum.pdfsharp.net/ Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
|
Important Notice:
We regret to inform you that our free phpBB forum hosting service will be discontinued by the end of June 30, 2024.
If you wish to migrate to our paid hosting service, please contact billing@hostonnet.com.
View previous topic :: View next topic |
Author |
Message |
archdukefranz
Joined: 03 Sep 2008 Posts: 1
|
Posted: Wed Sep 03, 2008 11:18 am Post subject: Performance |
|
|
Its taking a minute and a half to create a pdf with about 181 rows
Is that normal, seems excessive to me... here is my code anyway
Code: | public static MigraDoc.DocumentObjectModel.Document createPdfDocument(ListView objectList)
{
MigraDoc.DocumentObjectModel.Document document = new MigraDoc.DocumentObjectModel.Document();
document.Info.Title = objectList.ListTitle;
document.Info.Author = "ObjectViews";
MigraDoc.DocumentObjectModel.Style style;
// Get the predefined style Normal.
style = document.Styles["Normal"];
// Because all styles are derived from Normal, the next line changes the
// font of the whole document. Or, more exactly, it changes the font of
// all styles and paragraphs that do not redefine the font.
style.Font.Name = "Verdana";
style.Font.Name = "Times New Roman";
style.Font.Size = 10;
MigraDoc.DocumentObjectModel.Section section = document.AddSection();
section.PageSetup.LeftMargin = new MigraDoc.DocumentObjectModel.Unit(0);
section.PageSetup.TopMargin = new MigraDoc.DocumentObjectModel.Unit(0);
section.PageSetup.BottomMargin = new MigraDoc.DocumentObjectModel.Unit(0);
MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();
table.Borders.Width = 0.25;
table.Borders.Left.Width = 0.5;
table.Borders.Right.Width = 0.5;
table.Rows.LeftIndent = 0;
for (int i = 0; i < objectList.ListMap.ColumnCount; i++)
{
if (objectList.ListMap[i].Type != "display")
continue;
Column column = objectList.ListMap[i];
MigraDoc.DocumentObjectModel.Tables.Column c = table.AddColumn(new MigraDoc.DocumentObjectModel.Unit(double.Parse(column.Width), MigraDoc.DocumentObjectModel.UnitType.Point));
}
MigraDoc.DocumentObjectModel.Tables.Row row = table.AddRow();
for (int i = 0; i < objectList.ListMap.ColumnCount; i++)
{
if (objectList.ListMap[i].Type != "display")
continue;
Column column = objectList.ListMap[i];
row.Cells[i].AddParagraph(objectList.ObjectViewManager.GetString(column.Label));
}
for (int j = 0; j < objectList.list.Count; j++)
{
object entity = objectList.list[j];
row = table.AddRow();
for (int i = 0; i < objectList.ListMap.ColumnCount; i++)
{
if (objectList.ListMap[i].Type != "display")
continue;
Column column = objectList.ListMap[i];
object value = ObjectViewUtils.GetValue(entity, column.Member);
if (value == null) row.Cells[i].AddParagraph("");
else if (value.GetType().Name == "DateTime") row.Cells[i].AddParagraph(((DateTime)value).ToString(column.Format));
else row.Cells[i].AddParagraph(value.ToString());
}
}
return document;
} |
Code: | pdfRenderer.Document = createPdfDocument(objectList);
pdfRenderer.RenderDocument();
MemoryStream stream = new MemoryStream();
pdfRenderer.Save(stream, false);
Page.Response.Clear();
Page.Response.ContentType = "application/pdf";
Page.Response.AddHeader("content-length", stream.Length.ToString());
Page.Response.BinaryWrite(stream.ToArray());
Page.Response.Flush();
stream.Close();
Page.Response.End(); |
|
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Wed Sep 03, 2008 2:03 pm Post subject: |
|
|
This is a known MigraDoc problem with the rendering of tables. _________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
|
|
|
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 vote in polls in this forum
|
|