PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 11:27 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Mon Jun 01, 2015 8:44 am 
Offline

Joined: Sat May 23, 2015 9:37 am
Posts: 6
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 01, 2015 8:50 am 
Offline
PDFsharp Guru
User avatar

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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 01, 2015 3:05 pm 
Offline

Joined: Sat May 23, 2015 9:37 am
Posts: 6
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)


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 01, 2015 3:15 pm 
Offline
PDFsharp Guru
User avatar

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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 01, 2015 3:20 pm 
Offline

Joined: Sat May 23, 2015 9:37 am
Posts: 6
Sorry, here is the full class.


Attachments:
StatisticsObject.rar [2.2 KiB]
Downloaded 458 times
Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 02, 2015 12:06 am 
Offline

Joined: Sat May 23, 2015 9:37 am
Posts: 6
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
Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 02, 2015 9:36 am 
Offline
PDFsharp Guru
User avatar

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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 02, 2015 10:00 am 
Offline

Joined: Sat May 23, 2015 9:37 am
Posts: 6
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


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

All times are UTC


Who is online

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