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

Text not printing normally after display a graphic frame
https://forum.pdfsharp.net/viewtopic.php?f=3&t=3119
Page 1 of 1

Author:  mdejolier [ Mon Jun 01, 2015 8:44 am ]
Post subject:  Text not printing normally after display a graphic frame

Good morning,

I am a new user of pdfsharp. I work as a volunteer for the Child's Dream foundation in Thailand, so having a free component is for them invaluable. Thanks a lot.

I am creating a document containing both charts and texts. I insert a first line of text, then a pie chart, then more lines of text using the drawstring method. If I select Xbrushes.black for the first line following the graph, nothing at all is printed after the chart. If I select any other color, than the whole text following the graph appears normally.
Here is the piece of code:
Code:
        Myframe.Draw(gfx)    'print the graph
        Startx = 30
        StartY += Ysize + 20    'increment Y position by graph height
        ThisString = "The detailed expenses are as follows:"
        Rect = New XRect(Startx, StartY, 500, 20)
        Sf = New XStringFormat
        Sf.Alignment = XStringAlignment.Near
        Sf.LineAlignment = XLineAlignment.Near
        gfx.DrawString(ThisString, H0Font, XBrushes.DarkGreen, Rect, Sf)
        For Each MyRow As DataRow In AllData.Rows
            Startx = 50
            StartY += 20
            If StartY + 20 > MaxHeight Then
                Page = Document.AddPage
                gfx = XGraphics.FromPdfPage(Page)
                PrintHeader(Page, gfx, Document)
                Startx = 50
            End If
            ThisString = MyRow("Label")
            Rect = New XRect(Startx, StartY, 500, 20)
            Sf = New XStringFormat
            Sf.Alignment = XStringAlignment.Near
            Sf.LineAlignment = XLineAlignment.Near
            gfx.DrawString(ThisString, MyFont, XBrushes.Black, Rect, Sf)
        Next

Using Darkgreen for the first line works. using black doesn't.

Author:  Thomas Hoevel [ Mon Jun 01, 2015 8:50 am ]
Post subject:  Re: Text not printing normally after display a graphic frame

Hi!

It would help to know which version you are using and to get an SSCCE.
See also:
viewtopic.php?f=2&t=832

Does this occur with both the GDI+ and the WPF builds?

Author:  mdejolier [ Mon Jun 01, 2015 3:05 pm ]
Post subject:  Re: Text not printing normally after display a graphic frame

Version is 1.32.2608
I only use GDI+
I just tried with another application who was working fine with a paragraph in darkgray after a graph frame. I change the color to black, and the text disappeared . Here is the code:
Code:
        Myframe.Add(MyChart)
        Myframe.Draw(gfx)
        StartY += 420
        Startx = 40
        Dim Para As New Paragraph
        Dim Section As New Section
        Dim Doc As New Document
        Section = Doc.AddSection
        Para = Section.AddParagraph
        Para.AddText(AllOtherCountries)
        Para.Format.Alignment = ParagraphAlignment.Center
        Para.Format.Font.Name = "Calibri"
        Para.Format.Font.Size = 10
        Para.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.DarkGray
        Dim DocRenderer As MigraDoc.Rendering.DocumentRenderer = New DocumentRenderer(Doc)
        DocRenderer.PrepareDocument()
        DocRenderer.RenderObject(gfx, Startx, StartY, 450, Para)

Author:  Thomas Hoevel [ Mon Jun 01, 2015 3:15 pm ]
Post subject:  Re: Text not printing normally after display a graphic frame

mdejolier wrote:
Here is the code
That is just a code snippet, not a complete VS project.
You do not show the code that generates the chart.

Author:  mdejolier [ Mon Jun 01, 2015 3:20 pm ]
Post subject:  Re: Text not printing normally after display a graphic frame

Sorry, here is the full class.

Attachments:
StatisticsObject.rar [2.2 KiB]
Downloaded 458 times

Author:  mdejolier [ Tue Jun 02, 2015 12:06 am ]
Post subject:  Re: Text not printing normally after display a graphic frame

Good morning Thomas,

I created a small project to reproduce the problem. It is only when color.black is selected that the text after a chart does not display, all other colors show normally. The problem is the same if I use Migradoc methods or the simple drawstring method.
I had to take out the Pdfsharp DLLs because the .rar file was to big, so the references will be missing
Best regards,
Michel

Attachments:
PdfSharpForTesting.rar [62.35 KiB]
Downloaded 453 times

Author:  Thomas Hoevel [ Tue Jun 02, 2015 9:36 am ]
Post subject:  Re: Text not printing normally after display a graphic frame

It's working with the NuGet package MigraDoc 1.50 beta (include pre-releases in the NuGet manager).

I can replicate the problem with MigraDoc 1.32 from NuGet.

I'm not sure but it could be the bug discussed here if you want to stick to 1.32 and modify the source yourself:
viewtopic.php?p=6842#p6842

IMHO there is no reason not to use MigraDoc 1.50 beta.

Author:  mdejolier [ Tue Jun 02, 2015 10:00 am ]
Post subject:  Re: Text not printing normally after display a graphic frame

Thanks a lot. i will follow your advice.
By the way, the Child's Dream foundation is using Visual Basic (2012) for developments, so I have converted a lot of your examples in VB when learning how to use PdfSharp. If you want them for your samples directory, just let me know, I will be glad to send them to you.
Regards
Michel

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