PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
C# Align left and right on same line https://forum.pdfsharp.net/viewtopic.php?f=2&t=4073 |
Page 1 of 1 |
Author: | ingomanthey [ Mon Dec 16, 2019 3:01 pm ] |
Post subject: | C# Align left and right on same line |
Hi, I am working with MigraDoc for the first time. I want to use it to create an invoice.I use the invoice example and would like to adapt it to my needs. My problem at the moment is that I want to display the addressFrame on the left as in the example, but on the right side, "InvoiceNumber," Date, Customer Number ". I think I could do that with a table. The table has 2 columns and the first one addressFrame and in the second insert the text. Unfortunately, I don't find an example of this on Google. Code: addressFrame = section.AddTextFrame(); addressFrame.Height = "3.0cm"; addressFrame.Width = "7.0cm"; addressFrame.Left = ShapePosition.Left; addressFrame.RelativeHorizontal = RelativeHorizontal.Margin; addressFrame.Top = "5.0cm"; addressFrame.RelativeVertical = RelativeVertical.Page; This is the sample code. Can someone help me here how I create the table and assign the frame to the first column. Thanks in advance for every tip and tip regards Ingo |
Author: | IRlyDunno [ Tue Dec 17, 2019 12:38 pm ] |
Post subject: | Re: C# Align left and right on same line |
This should be quite simple, just create a table Code: Document doc = new Document(); var section = doc.AddSection(); // Create the table on the section var table = section.AddTable(); Unit width, height; PageSetup.GetPageSize(section.PageFormat, out width, out height); // Add 2 columns, in this case I'll give half of the page to each of them. table.AddColumn(width / 2); table.AddColumn(width / 2); var row = table.AddRow(); // left cell row[0].Add(/* add what you want to the left cell */); row[0].Format.Alignment = ParagraphAlignment.Left; // this might not be enough to align all elements, try setting their alignment one by one // right cell row[1].Add(/* add what you want to the right cell */); row[1].Format.Alignment = ParagraphAlignment.Right; // this might not be enough to align all elements, try setting their alignment one by one Do note that I have not tested this, consider it pseudo code / template |
Author: | ingomanthey [ Wed Dec 18, 2019 2:40 pm ] |
Post subject: | Re: C# Align left and right on same line |
Thank you!!! |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |