PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 9:04 pm

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
PostPosted: Mon Sep 29, 2014 9:03 am 
Offline

Joined: Mon Sep 29, 2014 8:49 am
Posts: 1
I am trying to add bookmark to my pdf document but i get a null exception.
Here is the code

Code:
void addTable(String name){

                doc = new Migra.Document();
                Migra.Section sec = doc.AddSection();
                summaryTable = sec.AddTable();
                for (int i = 0; i <3; i++)
                {
                    column = summaryTable.AddColumn();
                }

              Row row1 = summaryTable.AddRow();
              Migra.Paragraph paragraph = row1.Cells[0].AddParagraph((RowNum + 1).ToString());

             paragraph = row1.Cells[1].AddParagraph();
             paragraph.Style = "TOC";
             Hyperlink hyperlink = paragraph.AddHyperlink(name);
             paragraph.Format.OutlineLevel = OutlineLevel.BodyText;
             hyperlink.AddText(name);
             hyperlink.AddPageRefField(name);

              MigraDoc.Rendering.DocumentRenderer docRenderer = new DocumentRenderer(doc);
              docRenderer.PrepareDocument();
              docRenderer.RenderObject(graph, "6cm", "11cm", "10cm", summaryTable);

}


It seems to fail on : docRenderer.RenderObject(graph, "6cm", "11cm", "10cm", summaryTable).
I am getting null exception on the docRenderer object.
If i remove method AddPageRefField everything seems to work fine.

graph is the object that returned from XGraphics.FromPdfPage(pdfPage) from the pdfDocument which i created before.


what did i do wrong here ?


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 29, 2014 10:15 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
I see just a code snippet. An SSCCE might help. The complete exception message including the stack trace might help.

See also:
viewtopic.php?f=2&t=832

_________________
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: No registered users and 360 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