PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jul 14, 2024 11:55 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: emSize cannot be 0
PostPosted: Fri Oct 08, 2010 11:23 am 
Offline

Joined: Fri Oct 08, 2010 11:03 am
Posts: 3
I'm am under the assumption that if I do the following:
Code:
SetStyles(doc, MigraDoc.DocumentObjectModel.Unit.FromCentimeter("21"))
Dim docRenderer As MigraDoc.Rendering.DocumentRenderer = New MigraDoc.Rendering.DocumentRenderer(doc)
docRenderer.PrepareDocument()

and SetStyle contains the initialization of style as found elsewhere in this forum, that a new paragraph created with .AddParagraph is of the style StyleNames.Normal.

However, when I do a .renderobject with this paragraph I get the error: Value of '0' is not valid for 'emSize'. 'emSize' should be greater than 0 and less than or equal to System.Single.MaxValue

Even when I set style active for the paragraph with para.Style = StyleNames.Normal it doesn´t work.

However when I do: para.Format.Font.Size = MigraDoc.DocumentObjectModel.Unit.FromPoint(iFontSize) the .renderobject succeeds.

How come the style is not being applied?


Top
 Profile  
Reply with quote  
 Post subject: Re: emSize cannot be 0
PostPosted: Fri Oct 08, 2010 4:12 pm 
Offline

Joined: Tue Aug 31, 2010 6:16 pm
Posts: 10
I ran into something similar. When I did create a new document, I needed to re-associate my XGraphics object with my new MigraDoc document/page because the XGraphics encapsulates the use of a document/page.

My C# example is as follows:

*******************************
//We need to make a new page here.
myPDFPage = AddPDFPage(pdfdocument);

//Reinitialize XGraphics
gfx = XGraphics.FromPdfPage(myPDFPage);
font = new XFont("Arial", 11, XFontStyle.Regular);
gfx.DrawString(" ", font, XBrushes.Black,
new XRect(0, 0, myPDFPage.Width, myPDFPage.Height), XStringFormats.Center);

gfx.MUH = PdfFontEncoding.Unicode;
gfx.MFEH = PdfFontEmbedding.Default;

// You always need a MigraDoc document for rendering.
myMigraDocPage = myMigradocDoc.AddSection();

//...Later I perform the following bound with the new doc/page created above.
myMigradocDoc = myMigraDocPage.Document;
docRenderer = new DocumentRenderer(myMigradocDoc);
docRenderer.PrepareDocument();

docRenderer.RenderObject(gfx,...)
*******************************

Hope this thought helps.

Henry


Top
 Profile  
Reply with quote  
 Post subject: Re: emSize cannot be 0
PostPosted: Mon Oct 11, 2010 7:27 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Rovliet wrote:
SetStyle contains the initialization of style as found elsewhere in this forum [...] How come the style is not being applied?

With neither sample code nor MDDDL file there is nothing I can do.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: emSize cannot be 0
PostPosted: Tue Oct 12, 2010 9:57 am 
Offline

Joined: Fri Oct 08, 2010 11:03 am
Posts: 3
In this post are the MDDDL file for the report and a ASP.net VB file that creates the report.

If I comment out the lines that define the paragraph (around line 131), I get em-size error, although the paragraph has a defined style.


Attachments:
File comment: ASP.net vb-code for creating a report.
pdf_test.zip [1.93 KiB]
Downloaded 451 times
File comment: MDDDL file for the report
pdf.zip [1.15 KiB]
Downloaded 447 times


Last edited by Rovliet on Tue Oct 12, 2010 10:34 am, edited 3 times in total.
Top
 Profile  
Reply with quote  
 Post subject: Re: emSize cannot be 0
PostPosted: Tue Oct 12, 2010 10:01 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Rovliet wrote:
strange that I cannot upload a MDDDL file?

Not strange, just upload a ZIP file.

viewtopic.php?f=2&t=832

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: emSize cannot be 0
PostPosted: Tue Oct 12, 2010 3:11 pm 
Offline

Joined: Fri Oct 08, 2010 11:03 am
Posts: 3
Thomas Hoevel wrote:
Rovliet wrote:
strange that I cannot upload a MDDDL file?

Not strange, just upload a ZIP file.

viewtopic.php?f=2&t=832


I would think that such a forum-close format would be allowed thats why.
I enclosed the needed files in my previous post.


Top
 Profile  
Reply with quote  
 Post subject: Re: emSize cannot be 0
PostPosted: Thu Oct 14, 2010 7:31 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Rovliet wrote:
I would think that such a forum-close format would be allowed thats why.

Using a ZIP file ensures that the file I download is the file you uploaded.
There are so many character sets that I don't trust text files (including XML or HTML) to be handled correctly. We've seen wonderful changes occur when sending XML or HTML as an e-mail attachment. ZIP files normally don't get tampered - and they have a CRC check that detects modifications.

Back to topic: I can create a document from your MDDDL file without error.

I'm sorry but I don't have the time to build a project around your ASPX file so I haven't tried that yet.

By the way:
Information you should include when asking for support here
When asking for support, please indicate what you're using:
  • [...]
  • GDI+ or WPF build
  • the version of PDFsharp/MigraDoc Foundation

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 41 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