PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Jan 27, 2020 10:59 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
PostPosted: Mon Dec 16, 2019 3:01 pm 
Offline

Joined: Mon Dec 16, 2019 2:46 pm
Posts: 4
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


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 17, 2019 12:38 pm 
Offline

Joined: Tue Aug 06, 2019 10:45 am
Posts: 30
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


Top
 Profile  
Reply with quote  
PostPosted: Wed Dec 18, 2019 2:40 pm 
Offline

Joined: Mon Dec 16, 2019 2:46 pm
Posts: 4
Thank you!!!


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