PDFsharp & MigraDoc Foundation

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

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Tue Nov 06, 2007 5:19 pm 
Offline

Joined: Tue Nov 06, 2007 5:05 pm
Posts: 3
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Nov 06, 2007 5:38 pm 
Offline
PDFsharp Guru
User avatar

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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Nov 07, 2007 9:13 am 
Offline

Joined: Tue Nov 06, 2007 5:05 pm
Posts: 3
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Nov 07, 2007 9:35 am 
Offline

Joined: Tue Nov 06, 2007 5:05 pm
Posts: 3
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Nov 07, 2007 9:38 am 
Offline
PDFsharp Guru
User avatar

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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 26, 2009 3:53 pm 
Offline

Joined: Tue May 26, 2009 3:32 pm
Posts: 6
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 :?


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

All times are UTC


Who is online

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