PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu May 02, 2024 6:19 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Performance
PostPosted: Wed Sep 03, 2008 11:18 am 
Offline

Joined: Wed Sep 03, 2008 10:01 am
Posts: 1
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();


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Sep 03, 2008 2:03 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3097
Location: Cologne, Germany
This is a known MigraDoc problem with the rendering of tables.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 82 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:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group