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

Height
https://forum.pdfsharp.net/viewtopic.php?f=2&t=753
Page 1 of 1

Author:  tmiller_15 [ Tue Jun 09, 2009 4:55 am ]
Post subject:  Height

I hope someone can help as this is starting to drive me crazy.
I am mixing a pdf and migradoc together. I am creating a paragraph in the migra doc that can be really long and possibly run over several pages. However when I combine them both together the paragraph does not run on to a second page. I then need to be able to get the location of the end of the paragraph so that I can add some more info to the bottom of it. Please find my code below.

All help is very much appreciated.

Dim document As New PdfDocument
Dim page As New PdfPage
document.AddPage(page)
Dim ps As PageSize = PageSize.A4
page.Size = ps
Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
Dim image As XImage
image = XImage.FromFile("I:\Documents\Work\Images\CCLogoReflectionLarge.png")
gfx.DrawImage(image, -16, 10, 128, 128)
Dim font As New XFont("Book Antiqua", 8, XFontStyle.Regular)
Dim text As String = "company"
Dim text2 As String = "Sustainability Pty Ltd"
gfx.DrawString(text, font, XBrushes.Black, 83, 21)
gfx.DrawString(text2, font, XBrushes.Black, 83, 34)
gfx.DrawString("PO Box", font, XBrushes.Black, 83, 47)
gfx.DrawString("Berowr", font, XBrushes.Black, 83, 60)
gfx.DrawString("Phone ", font, XBrushes.Black, 83, 73)
gfx.DrawString("Fax", font, XBrushes.Black, 83, 86)
gfx.DrawString("Email ", font, XBrushes.Black, 83, 99)
Dim font2 As New XFont("Book Antiqua", 28, XFontStyle.Regular)
gfx.DrawString("Project Induction Form", font2, XBrushes.Black, 297.5, 120, XStringFormats.Center)
Dim font3 As New XFont("Book Antiqua", 11, XFontStyle.Regular)

Dim doc As New Document
Dim sec As Section = doc.AddSection()

Dim table As Table = sec.AddTable()
table.Borders.Visible = False
table.Columns.Width = "6.93cm"
table.TopPadding = 3

Dim column As Column = table.AddColumn()
column.Format.Alignment = ParagraphAlignment.Left

column = table.AddColumn()
column.Format.Alignment = ParagraphAlignment.Center

column = table.AddColumn()
column.Format.Alignment = ParagraphAlignment.Right

Dim row As Row = table.AddRow()

row.Cells(0).AddParagraph("Project No: ")
row.Cells(1).AddParagraph("Project Name: ")
row.Cells(2).AddParagraph("Date: ")

row = table.AddRow()

row.Cells(0).AddParagraph("Given Names: ")
row.Cells(1).AddParagraph("Last Name: ")

row = table.AddRow()

row.Cells(0).AddParagraph("Day Time Contact No: ")
row.Cells(1).AddParagraph("After Hours Contact No: ")


row = table.AddRow()
row.Cells(0).AddParagraph("Next Of Kin: ")
row.Cells(1).AddParagraph("Next Of Contact No: ")

row = table.AddRow()
row.Cells(0).AddParagraph("Address: ")
row.Cells(1).AddParagraph("Suburb: ")
row.Cells(2).AddParagraph("State: ")

row = table.AddRow()
row.Cells(0).AddParagraph("Post Code: ")

row = table.AddRow()
row.Cells(0).AddParagraph("Company: ")
row.Cells(1).AddParagraph("Supervisor: ")

row = table.AddRow()
row.Cells(0).AddParagraph("Work Cover No: ")
row.Cells(1).AddParagraph("Work Cover Date: ")

Dim pen As New XPen(XColors.Black, 1.0)

gfx.DrawRectangle(pen, 0, 140, 595, 125)

gfx.DrawString("Discipline / Trade and brief explanation of work", font3, XBrushes.Black, 3, 278)

Dim par As Paragraph = sec.AddParagraph()
par.AddText("Computer Programer")
par.Format.Font.Name = "Book Antiqua"
par.Format.Font.Size = 10
par.Format.Font.Bold = False
par.AddLineBreak()
par.AddLineBreak()
par.AddText("This is the paragraph that can be realy long")

Dim docRenderer As MigraDoc.Rendering.DocumentRenderer = New DocumentRenderer(doc)
docRenderer.PrepareDocument()
docRenderer.RenderObject(gfx, XUnit.FromPoint(3), XUnit.FromPoint(140), "20cm", table)
docRenderer.RenderObject(gfx, XUnit.FromPoint(3), XUnit.FromPoint(285), "20cm", par)

Author:  Thomas Hoevel [ Tue Jun 09, 2009 8:11 am ]
Post subject: 

At first glance I'd say you don't use anything that can't be done with MigraDoc - maybe except the Rectangle, but that can be drawn using the Border feature of MigraDoc.

Use MigraDoc to draw the text and the logo and let MigraDoc deal with pagebreaks etc.
You can still add XGraphics while creating the PDF document.

Author:  tmiller_15 [ Tue Jun 09, 2009 11:02 am ]
Post subject: 

Hi thanks for the reply.

I am not sure on how do the first bit in migradoc any suggestions.
Is there any way that you can position things in migradoc like in pdfsharp? Also what do you mean you can still use xgraphics while creating the pdf?

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