Hi
Stepping back for a night helps!!
Got desired result by amending code as follows -
Code:
Dim docRenderer As MigraDoc.Rendering.DocumentRenderer
docRenderer = New DocumentRenderer(document)
' Addhandler to update progressbar
AddHandler docRenderer.PrepareDocumentProgress, AddressOf UpdateBar
docRenderer.PrepareDocument()
and then adding the handler subroutine
Code:
' UpdateBar has the same signature as PrepareDocumentProgressEventHandler.
Public Sub UpdateBar(ByVal sender As Object, ByVal e As DocumentRenderer.PrepareDocumentProgressEventArgs)
Me.ProgressBar1.Maximum = e.Maximum
Me.ProgressBar1.Value = e.Value
Me.TextBox1.Text = "Preparing PDF Page " & e.Value.ToString
System.Windows.Forms.Application.DoEvents()
End Sub
Not sure if this the most elegant but it worked.
Also limited test showed that total elapsed time to create my 24page pdf file was almost same whether I used
docrenderer with preparedocument and then renderpage
or
PdfDocumentRenderer with PrepareRenderPages and Renderpages
or
PdfDocumentRenderer with Renderdocument
First option has advantage of showing progress in a long running document