PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

MigraDoc to VB.Net
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2422
Page 1 of 1

Author:  Jwiedmier [ Wed May 01, 2013 3:02 pm ]
Post subject:  MigraDoc to VB.Net

I have been using MigraDoc with our C# applications with great success, however we have a VB.Net that I have rarely had to work with but a report is needed from it I thought it would be pretty simple to just use MigraDoc there.

I am not nearly as good with VB.Net but I did get the code converted from one of our C# apps but had no luck actually getting it to work.

I then tried going with the invoice example and ran into the same issues.

Has anyone had success doing this that would help me.
The following code gives me the error of Style is not Defined

Code:
    Public Sub DefineStyles()
        'Get the predefined style Normal.
        Dim style As Style = Me.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 = Me.document.Styles(StyleNames.Header)
        style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right)

        style = Me.document.Styles(StyleNames.Footer)
        style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center)

        ' Create a new style called Table based on style Normal
        style = Me.document.Styles.AddStyle("Table", "Normal")
        style.Font.Name = "Verdana"
        style.Font.Name = "Times New Roman"
        style.Font.Size = 9

        ' Create a new style called Reference based on style Normal
        style = Me.document.Styles.AddStyle("Reference", "Normal")
        style.ParagraphFormat.SpaceBefore = "5mm"
        style.ParagraphFormat.SpaceAfter = "5mm"
        style.ParagraphFormat.TabStops.AddTabStop("16cm", TabAlignment.Right)
    End Sub

Author:  Thomas Hoevel [ Thu May 02, 2013 9:13 am ]
Post subject:  Re: MigraDoc to VB.Net

Probably the Imports statement (or even the reference) is missing for that class.
Try "Imports MigraDoc.DocumentObjectModel" or use "MigraDoc.DocumentObjectModel.Style".

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/