PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Dec 13, 2017 3:35 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Pdfsharp and tables
PostPosted: Fri Jun 09, 2017 12:49 pm 
Offline

Joined: Fri Jun 09, 2017 12:42 pm
Posts: 7
Hello,

I develop a project in C# (.Net 4.5) and I must generate a PDF from users.
I found more projects allows this but PDFsharp is only .NET library compatible with my licence (CC-By-SA 4.0).
However, I have a problem : PDFsharp can create tables ?

Thanks for your answers !

(PS : sorry for english)


Top
 Profile  
Reply with quote  
 Post subject: Re: Pdfsharp and tables
PostPosted: Fri Jun 09, 2017 3:49 pm 
Offline
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 308
Location: CCAA
Hi!
v_k wrote:
However, I have a problem: PDFsharp can create tables?
A table is text with some lines drawn around it. PDFsharp can draw text and it can draw lines, so it can create tables.

MigraDoc makes creating tables easier:
http://pdfsharp.net/wiki/Invoice-sample.ashx

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
 Post subject: Re: Pdfsharp and tables
PostPosted: Fri Jun 09, 2017 7:29 pm 
Offline

Joined: Fri Jun 09, 2017 12:42 pm
Posts: 7
Oh, it was in "Invoice". Thanks and sorry :-)


Top
 Profile  
Reply with quote  
 Post subject: Re: Pdfsharp and tables
PostPosted: Sat Jun 10, 2017 3:37 pm 
Offline

Joined: Fri Jun 09, 2017 12:42 pm
Posts: 7
Hello,

I has started on MigraDoc but I have error with a function :
Quote:
this.table.SetEdge(0, 0, 6, 2, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
(it in example - l 107)

Quote:
L'index était hors limites. Il ne doit pas être négatif et doit être inférieur à la taille de la collection.
Nom du paramètre : index

The index was out of bounds. It must not be negative and must be less than the size of the collection.
Parameter Name: index

Why ?

I wanted begin by generate headers to my table with 7 columns but I don't understand SetEdge() function.
this.table.SetEdge(a, b, c, d, Edge.Box, BorderStyle.Single, 0.75, Color.Empty)
Who is it a, b, c and d ?


Top
 Profile  
Reply with quote  
 Post subject: Re: Pdfsharp and tables
PostPosted: Sat Jun 17, 2017 9:27 am 
Offline

Joined: Fri Jun 09, 2017 12:42 pm
Posts: 7
Nobody ? :(


Top
 Profile  
Reply with quote  
 Post subject: Re: Pdfsharp and tables
PostPosted: Sun Jun 18, 2017 8:19 am 
Offline
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 308
Location: CCAA
Hi!
v_k wrote:
Who is it a, b, c and d ?
Columns and rows.
Make sure your table has enough rows and columns. You cannot draw an edge around six columns when the table only has five columns.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
 Post subject: Re: Pdfsharp and tables
PostPosted: Sun Jun 18, 2017 10:25 am 
Offline

Joined: Fri Jun 09, 2017 12:42 pm
Posts: 7
Ok, and I looked Migradoc source to help me.

this.table.SetEdge(a, b, c, d, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
Image
If I understood, a & b is the first line/column and c & d, the last line/column.

For the example (yeah, Excel powa), code is
Code:
this.table.SetEdge(0, 0, 2, 6, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
// with Excel coords
//this.table.SetEdge(A1.x, A1.y, C7.x, C7.y, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);


It's good ?


Top
 Profile  
Reply with quote  
 Post subject: Re: Pdfsharp and tables
PostPosted: Mon Jun 19, 2017 8:17 am 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2740
Location: Cologne, Germany
Hi!

I guess you will need "(0, 0, 3, 7, ...)" instead of "(0, 0, 2, 6, ...)".
You will not get an exception if the values are too small, so it is safe to try "2, 6" first.
Parameters three and four are the count of columns in the frame, not the co-ordinates of the lower right point.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: Pdfsharp and tables
PostPosted: Mon Jun 19, 2017 8:54 am 
Offline

Joined: Fri Jun 09, 2017 12:42 pm
Posts: 7
OK, thanks :)


Top
 Profile  
Reply with quote  
 Post subject: Re: Pdfsharp and tables
PostPosted: Mon Jun 19, 2017 9:46 am 
Offline

Joined: Fri Jun 09, 2017 12:42 pm
Posts: 7
hmm, an another problem (the last ? :mrgreen: )
I have 4 persons, in 4 cities :
  • John in New-York
  • Tamara, Toronto
  • Emily, Paris
  • Tim, Madrid

With this code :
Code:
this.table.SetEdge(0, 0, this.table.Columns.Count, this.table.Rows.Count, Edge.Box, BorderStyle.Single, 0.75);
// this.table.Columns.Count = 2
// this.table.Rows.Count = 5

// first cell in first line :
// this.table.Rows.Items[1].Cells.Items[0].Elements.Items[0].Elements.Items[0].Content =  "John"


But when the PDF is generated :

Image

Why ?

EDIT : it's okay, my fault, I have a error with columns headers :
Code:
row.Cells[i].MergeDown = 1;


With 0, it's better :)


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] 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:  
Powered by phpBB® Forum Software © phpBB Group