PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Sep 27, 2024 2:11 am

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: Fri Apr 17, 2009 4:03 pm 
Offline

Joined: Fri Apr 17, 2009 3:59 pm
Posts: 4
Hi to everyone, I'm trying migradoc and pdfsharp in my .NET project. I created a test project with the above code copied and adapted from c# sample. When I try to execute it I receive the ArgumentOutOfRangeException on this line: pdfr.RenderDocument()

Could you help me to find the problem?

Thank you very much!!

Code:
Imports PdfSharp
Imports PdfSharp.Drawing
Imports PdfSharp.Pdf
Imports PdfSharp.Pdf.IO
Imports MigraDoc.DocumentObjectModel
Imports MigraDoc.Rendering
Imports MigraDoc.DocumentObjectModel.Tables

Public Class ReportTest
    Public Sub New()
        Me.create()
    End Sub

    Public Sub create()
        Dim document1 As Document

        document1 = New Document()

        Dim tableBorder As Color = New Color(81, 125, 192)
        Dim tableBlue As Color = New Color(235, 240, 249)
        Dim tableGray As Color = New Color(242, 242, 242)

        document1.Info.Title = "Test report Condotte"
        document1.Info.Author = "Leo"

        Dim style As Style

        style = document1.Styles("Normal")
        style.Font.Name = "Verdana"

        style = document1.Styles.AddStyle("Table", "Normal")
        style.Font.Name = "Verdana"
        style.Font.Size = 10

        Dim t As Table
        Dim section As Section

        section = document1.AddSection()

        t = section.AddTable()
        t.Style = "Table"
        t.Borders.Color = tableBorder
        t.Borders.Width = 0.25
        t.Borders.Left.Width = 0.5
        t.Borders.Right.Width = 0.5
        t.Rows.LeftIndent = 0

        Dim c As Column

        c = t.AddColumn("1cm")
        c.Format.Alignment = ParagraphAlignment.Center

        c = t.AddColumn("5cm")
        c.Format.Alignment = ParagraphAlignment.Center

        c = t.AddColumn("4cm")
        c.Format.Alignment = ParagraphAlignment.Center

        Dim r As Row = t.AddRow()
        r.HeadingFormat = True
        r.Format.Alignment = ParagraphAlignment.Center
        r.Format.Font.Bold = True

        r.Shading.Color = tableBlue

        r.Cells(0).AddParagraph("Item")
        r.Cells(0).Format.Font.Bold = False

        r.Cells(1).AddParagraph("Test Report")
        r.Cells(1).MergeRight = 2


        ' t.SetEdge(0, 0, 6, 2, Edge.Box, BorderStyle.Single, 3, Color.Empty)

        document1.UseCmykColor = True
        Dim pdfr As PdfDocumentRenderer

        pdfr = New PdfDocumentRenderer(True, PdfFontEmbedding.Always)
        pdfr.Document = document1

        pdfr.RenderDocument()

        pdfr.Save("HelloWorld.pdf")
       
    End Sub

End Class


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 20, 2009 10:17 am 
Offline

Joined: Fri Apr 17, 2009 3:59 pm
Posts: 4
I found the problem!
It was my fault on line r.Cells(1).MergeRight = 2. I can't merge 2 cells on right because I have only one.


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 34 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