Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic PDF Export Clipping Node Content (Read 3342 times)
choohj70
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 77
Joined: Sep 23rd, 2008
PDF Export Clipping Node Content
May 27th, 2010 at 6:53pm
Print Post  
I am experiencing a weird behavior when exporting a diagram to PDF. When looking at the screen, the node has sufficient margin around it and is able to fit the content. When exported to PDF, the margin is smaller and in many cases, the content is cut off because the node is smaller than the content.

Below is the code that I am using to export.
How can this be resolved?

Dim pdf As New MindFusion.Diagramming.Export.PdfExporter
Dim path As String = Server.MapPath("~\PDF\") + fileName

pdf.PageOrientation = MindFusion.Pdf.PageOrientation.Landscape
pdf.PageSize = MindFusion.Pdf.PageSize.Letter
pdf.Margins.Top = 10
pdf.Margins.Left = 10
pdf.Margins.Right = 10
pdf.Margins.Bottom = 10

pdf.AutoScale = AutoScale.FitToPage
pdf.DisableTextClipping = True
pdf.EnableBackground = False
pdf.Scale = 1.0
pdf.InvisibleItems = False

pdf.Export(diagramView.Diagram, path)

Thank you.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: PDF Export Clipping Node Content
Reply #1 - May 27th, 2010 at 7:14pm
Print Post  
The Java and .NET text measuring functions return slightly different results, so the control can't produce exactly the same text layout on the server as on the client side. The only work-around I can think of is to loop over the nodes and subtract a point or half a point from their font size before exporting, so they can fit more text.

Stoyan
  
Back to top
 
IP Logged
 
choohj70
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 77
Joined: Sep 23rd, 2008
Re: PDF Export Clipping Node Content
Reply #2 - May 27th, 2010 at 8:47pm
Print Post  
Is there a way to measure the difference perhaps in pixels?

Thank you.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: PDF Export Clipping Node Content
Reply #3 - May 28th, 2010 at 12:38pm
Print Post  
It might be possible - try calling diagram.measureString on the client, submitting the value to the server and comparing with server-side MeasureString result. Then you could multiply the server side font size by the ratio of the two values. I have tested this and the ratio was something like 5 / 6 for a 4mm Arial font - the following two calls returned 12x5 and 10x4 sizes:

Dimension2D d = diagram.measureString("TEST", new Font("Arial", 0, 4)); // java
SizeF s = diagram.MeasureString("TEST", new Font("Arial", 4, GraphicsUnit.Millimeter), 1000, StringFormat.GenericDefault); // C#

Stoyan
  
Back to top
 
IP Logged
 
choohj70
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 77
Joined: Sep 23rd, 2008
Re: PDF Export Clipping Node Content
Reply #4 - May 28th, 2010 at 2:24pm
Print Post  
Stoyan,

Thank you. That is exactly what I was thinking.
Now, is there a way to decrease the font sizes ONLY for exporting to PDF without affecting the diagram shown on the screen?

Thank you again.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: PDF Export Clipping Node Content
Reply #5 - May 28th, 2010 at 2:35pm
Print Post  
You could copy the diagram by calling diagramCopy.LoadFromString(diagram.SaveToString()), modify the cloned nodes and then export diagramCopy.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
choohj70
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 77
Joined: Sep 23rd, 2008
Re: PDF Export Clipping Node Content
Reply #6 - May 28th, 2010 at 5:10pm
Print Post  
Stoyan,
Shouldn't the code for .NET use GraphicsUnit.Point rather than GraphicsUnit.Millimeter. If I am not mistaken, the Java function specifies the font size in points. Correct?

Thank you.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: PDF Export Clipping Node Content
Reply #7 - May 28th, 2010 at 6:49pm
Print Post  
Hi,

The scale transform used to implement the MeasureUnit feature also scales the fonts in Java, so that value specifies size in the currently set unit. In .NET that happens only if you use the World unit.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint