PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 10:48 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Height
PostPosted: Tue Jun 09, 2009 4:55 am 
Offline

Joined: Sun Jun 07, 2009 11:07 am
Posts: 5
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)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jun 09, 2009 8:11 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jun 09, 2009 11:02 am 
Offline

Joined: Sun Jun 07, 2009 11:07 am
Posts: 5
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?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 364 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