PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

render tables with migradoc
http://forum.pdfsharp.com/viewtopic.php?f=2&t=255
Page 1 of 1

Author:  a:m [ Tue Nov 06, 2007 5:19 pm ]
Post subject:  render tables with migradoc

hi!

i want to generate pdf-files (i'm using migradoc and pdfsharp) with several tables in them.
generally this is not a problem, but sometimes i get the exception:

"Der Wert 0 ist für emSize ungültig. emSize muss größer als 0 und kleiner und kleiner als oder gleich System.Single.MaxValue sein.\r\nParametername: emSize"

when i try to render a certain table. i use the method

DosumentRenderer.RenderObject(XGraphics, XUnit.FromCentimeter(), XUnit.FromCentimeter(), "19cm", myTable);

did anybody have the same problem? where do i have to search? i'm a little helpless, because this table is always generated in the same way and sometimes it works and sometimes it does not...

anna-maria

Author:  Thomas Hoevel [ Tue Nov 06, 2007 5:38 pm ]
Post subject: 

I get that error message in English:
Value of '0' is not valid for 'emSize'. 'emSize' should be greater than 0 and less than or equal to System.Single.MaxValue.
Parameter name: emSize

The error comes from .NET: from System.Drawing.DLL.

MigraDoc requested a font of size 0 - .NET doesn't allow this.
The problem is not the table, there is something wrong with (at least) one of your styles.

Author:  a:m [ Wed Nov 07, 2007 9:13 am ]
Post subject: 

thanks, thomas.

but now i've got a question concerning styles:
i wrote

Code:
Table myTable = new Table();
            myTable.Style = "Table";


is this not enough?
and why does it sometimes work and sometimes not? do you have any idea? if it doesn't have something to do with the table itself then it can't be the different content of the tables, or am i wrong?

anna-maria

Author:  a:m [ Wed Nov 07, 2007 9:35 am ]
Post subject: 

ok, i'm really really stupid.
i had an if-statement and i commented the line within it out but left the statement.
the next line is the line where the section with the table is added to the document. so if the if-statement is true, the table is added to the document, if not... it's not.

anna-maria

Author:  Thomas Hoevel [ Wed Nov 07, 2007 9:38 am ]
Post subject: 

If you don't set the Style property, style "Normal" will be used.

Style is just a string, but you should only use style names that exist in Styles.

Creating a new style:
Code:
Styles styles = document.Styles;
Style style = styles.AddStyle("Table", StyleNames.Normal);

Author:  trnilse [ Tue May 26, 2009 3:53 pm ]
Post subject: 

I had the same problem only it happened every time (I got the message "Value of '0' is not valid for 'emSize'. 'emSize' should be greater than 0 and less than or equal to System.Single.MaxValue.
Parameter name: emSize").

I was adding one paragraph and one table to the PDF by using RenderObject. Turns out I then had to call DocRenderer.PrepareDocument() twice to get it to work (before each call to RenderObject).

Update: The problem was actually that i was 'newing' up the migradoc document for each object, but i didn't reinitialize the DocumentRenderer with the new document... ups :?

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