Open virajkanwade opened 1 year ago
FormatResult FormatBookmarkField(BookmarkField bookmarkField)
{
this.fieldInfos.AddBookmark(bookmarkField.Name);
return FormatResult.Ignore;
}
this.fieldInfos
is null which is raising this exception.
public void RenderObject(XGraphics graphics, XUnit xPosition, XUnit yPosition, XUnit width, DocumentObject documentObject)
{
if (graphics == null)
throw new ArgumentNullException("graphics");
if (documentObject == null)
throw new ArgumentNullException("documentObject");
if (!(documentObject is Shape) && !(documentObject is Table) &&
!(documentObject is Paragraph))
throw new ArgumentException(AppResources.ObjectNotRenderable, "documentObject");
Renderer renderer = Renderer.Create(graphics, this, documentObject, null);
renderer.Format(new Rectangle(xPosition, yPosition, width, double.MaxValue), null);
RenderInfo renderInfo = renderer.RenderInfo;
renderInfo.LayoutInfo.ContentArea.X = xPosition;
renderInfo.LayoutInfo.ContentArea.Y = yPosition;
renderer = Renderer.Create(graphics, this, renderer.RenderInfo, null);
renderer.Render();
}
RenderObject
creates new renderer objects but passes null to fieldInfos
.
I am trying to add Table of Contents to the PDF. I referred: http://www.pdfsharp.net/wiki/HelloMigraDoc-sample.ashx http://www.pdfsharp.com/PDFsharp/index.php?option=com_content&task=view&id=55&Itemid=63
But when I try to paragraph.AddBookmark and then DocumentRenderer.RenderObject, it raises this exception.
Sample code:
What am I missing here?
I am using the packages from nuget.