Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Missing new line in text when export to PDF (Read 4199 times)
nezzy
YaBB Newbies
*
Offline



Posts: 25
Joined: May 31st, 2010
Missing new line in text when export to PDF
Jul 14th, 2010 at 9:18am
Print Post  
Hi.
I have a DiagramLite application that is used to draw some shapes and links. I want to export this to PDF, so I can print them later. If I have a shape with text in it, e.g
"This i a test for

carriage return
and
    
   
blanks"
It comes out in the PDF document like this
"This i a test for
carriage return
and
blanks"
Somewhere my blank lines are removed. When I debug and make override of the Draw method, the text looks OK. The XML also looks OK.
Any ideas??
Regards
Anders
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Missing new line in text when export to PDF
Reply #1 - Jul 14th, 2010 at 9:59am
Print Post  
Hi,

It seems our PdfGraphics.DrawString method skips empty lines. You might try to set the EnableStyledText property on the shapes before exporting - this should call DrawString for each line separately on the correct positions.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
nezzy
YaBB Newbies
*
Offline



Posts: 25
Joined: May 31st, 2010
Re: Missing new line in text when export to PDF
Reply #2 - Jul 14th, 2010 at 12:47pm
Print Post  
Hi again.
I tried what you proposed, but with the same result. Both for user-defined shapes and standard shapes. Any more ideas?
Regards,
Anders
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Missing new line in text when export to PDF
Reply #3 - Jul 14th, 2010 at 1:48pm
Print Post  
It worked in my test, node #2 here has a few blank lines:
http://mindfusion.eu/_temp/styledtext.pdf

Are you sure you have set EnabledStyledText for each individual node? Setting Diagram.EnabledStyledText won't affect existing nodes but only new ones.

Stoyan
  
Back to top
 
IP Logged
 
nezzy
YaBB Newbies
*
Offline



Posts: 25
Joined: May 31st, 2010
Re: Missing new line in text when export to PDF
Reply #4 - Jul 14th, 2010 at 2:12pm
Print Post  
Ahhhh
My mistake. I thought that it would be enough by setting the property for the diagram and then loading with LoadFromString(str).
I now have set the property for each node, and it works fine.
Many thanks.
Regards
Anders
  
Back to top
 
IP Logged
 
nezzy
YaBB Newbies
*
Offline



Posts: 25
Joined: May 31st, 2010
Re: Missing new line in text when export to PDF
Reply #5 - Jul 15th, 2010 at 1:50pm
Print Post  
Hi again.
Guess I was to quick.
I have a custom node, I don't get it to work with blanks for this one. I have a override of the draw method. It looks like this.
What am I missing?
Regards
Anders
Code
Select All
public override void Draw(MindFusion.Drawing.IGraphics graphics, MindFusion.Diagramming.RenderOptions options)
{
this.EnableStyledText = true;
//Get textarea for myText
SizeF textSize = graphics.MeasureString(myText, Font, (int)Bounds.Width, TextFormat);
RectangleF myTextBounds = RectangleF.FromLTRB(
                Bounds.X, Bounds.Y, Bounds.Right, textSize.Height);
//Draw the text
graphics.DrawString(myText, Font, System.Drawing.Brushes.Black, myTextBounds, TextFormat);
}
  

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Missing new line in text when export to PDF
Reply #6 - Jul 15th, 2010 at 4:16pm
Print Post  
Hi,

Call Diagram.DrawStyledText() to draw it as EnableStyledText does for ShapeNodes.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
nezzy
YaBB Newbies
*
Offline



Posts: 25
Joined: May 31st, 2010
Re: Missing new line in text when export to PDF
Reply #7 - Jul 16th, 2010 at 6:22am
Print Post  
Hi.
Many thanks !
You are the king Smiley
Regards
Anders
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint