PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

emSize cannot be 0
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1368
Page 1 of 1

Author:  Rovliet [ Fri Oct 08, 2010 11:23 am ]
Post subject:  emSize cannot be 0

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?

Author:  henrylar [ Fri Oct 08, 2010 4:12 pm ]
Post subject:  Re: emSize cannot be 0

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

Author:  Thomas Hoevel [ Mon Oct 11, 2010 7:27 am ]
Post subject:  Re: emSize cannot be 0

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.

Author:  Rovliet [ Tue Oct 12, 2010 9:57 am ]
Post subject:  Re: emSize cannot be 0

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 448 times

Author:  Thomas Hoevel [ Tue Oct 12, 2010 10:01 am ]
Post subject:  Re: emSize cannot be 0

Rovliet wrote:
strange that I cannot upload a MDDDL file?

Not strange, just upload a ZIP file.

viewtopic.php?f=2&t=832

Author:  Rovliet [ Tue Oct 12, 2010 3:11 pm ]
Post subject:  Re: emSize cannot be 0

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.

Author:  Thomas Hoevel [ Thu Oct 14, 2010 7:31 am ]
Post subject:  Re: emSize cannot be 0

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

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