PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Nov 19, 2018 5:25 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sun Mar 09, 2014 1:03 pm 
Offline

Joined: Fri Mar 07, 2014 8:52 am
Posts: 2
For some page configuration
NullReferenceException (Object reference not set to an instance of an object.)
occurs in
Code:
MigraDoc.Rendering.TableRenderer.CreateNextBottomBorderPosition()
MigraDoc.Rendering.TableRenderer.CreateBottomBorderMap()
MigraDoc.Rendering.TableRenderer.InitFormat(Area area, FormatInfo previousFormatInfo)
MigraDoc.Rendering.TableRenderer.Format(Area area, FormatInfo previousFormatInfo)
MigraDoc.Rendering.TopDownFormatter.FormatOnAreas(XGraphics gfx, Boolean topLevel)
MigraDoc.Rendering.FormattedDocument.Format(XGraphics gfx)
MigraDoc.Rendering.DocumentRenderer.PrepareDocument()


in code like this
Code:
document = CreateDocument(... some params ...);
MigraDoc.Rendering.DocumentRenderer docRenderer = new DocumentRenderer(document);
docRenderer.PrepareDocument();


I was able to reproduce this bug in console C# application with "PDFSharp + MigraDoc" installed via NuGet
Code:
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
using PdfSharp.Pdf;
using System.Diagnostics;

namespace PDFSharpTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var doc = new Document();
            Section section = doc.AddSection();

            var table = section.AddTable();
            table.Borders.Width = 0.25;

            table.AddColumn();
            table.AddColumn();
            table.AddColumn();

            Row row;
            row = table.AddRow(); // row 1
                row.Cells[0].AddParagraph("Item 11");
                row.Cells[0].MergeDown = 5;

                row.Cells[1].AddParagraph("Item 21");
                row.Cells[1].MergeDown = 1;

                row.Cells[2].AddParagraph("Item 31");
                row.Cells[2].MergeDown = 2;

            row = table.AddRow(); // row 2

            row = table.AddRow(); // row 3
                row.Cells[1].AddParagraph("Item 23");
                row.Cells[1].MergeDown = 1;

            row = table.AddRow(); // row 4
                row.Cells[2].AddParagraph("Item 34");
                row.Cells[2].MergeDown = 2;

            row = table.AddRow(); // row 5
                row.Cells[1].AddParagraph("Item 25");
                row.Cells[1].MergeDown = 1;

            row = table.AddRow(); // row 6

            var pdfRenderer = new PdfDocumentRenderer(true, PdfFontEmbedding.Always);
            pdfRenderer.Document = doc;
            pdfRenderer.RenderDocument();
            pdfRenderer.PdfDocument.Save("Result.pdf");
            // ...and start a viewer.
            Process.Start("Result.pdf");
        }
    }
}


Code:
An unhandled exception of type 'System.NullReferenceException' occurred in MigraDoc.Rendering.dll
Additional information: Object reference not set to an instance of an object.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 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