Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Ruler, Diagram and PDF-Export with correct dimensions (e.g. DinA4) (Read 4874 times)
eXTruDEr
YaBB Newbies
*
Offline


Mind con Fusion ;-)

Posts: 7
Joined: Jun 14th, 2016
Ruler, Diagram and PDF-Export with correct dimensions (e.g. DinA4)
Jun 14th, 2016 at 3:20pm
Print Post  
Hi,
I want to visualize a DinA4 Diagram inside of my tool.

For this I'm using the MindFusion.Pdf.PageSizes.A4 to get the correct Bounds.
I set a Ruler (Unit="Millimeter") around the Diagram to check its size.
I expected 210 mm x 297 mm, but observed 126 mm x 178 mm.  Shocked

Further I want to export the diagram to a PDF.
I set the PageSize of the PDF Exporter to MindFusion.Pdf.PageSize.A4, but the diagram inside of generated PDF is much smaller as expected.  Sad
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3148
Joined: Oct 19th, 2005
Re: Ruler, Diagram and PDF-Export with correct dimensions (e.g. DinA4)
Reply #1 - Jun 14th, 2016 at 4:27pm
Print Post  
Hi,

Do you mean you are directly assigning the MindFusion.Pdf.PageSizes.A4 size to the Bounds rectangle? The PageSizes values are actually specified in PDF 72 DPI units and will not match diagram's default 96 DPI units, so you will have to multiply by 96/72. Also if you are trying to measure some diagram node with size specified in millimeters, you will have to set diagram's MeasureUnit property too.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
eXTruDEr
YaBB Newbies
*
Offline


Mind con Fusion ;-)

Posts: 7
Joined: Jun 14th, 2016
Re: Ruler, Diagram and PDF-Export with correct dimensions (e.g. DinA4)
Reply #2 - Jun 16th, 2016 at 11:43am
Print Post  
Thx Smiley

Using your information, I could solve my problem with the PDF export.

BUT: If I use the PageSizes (*96/72) without any modifications to size the Bounds Rect of the diagram, the width of the diagram doesn't fit to the width of the PDF. So an empty DinA4 Diagram requires two DinA4 pages inside of the PDF. The second page contains only the right border of the diagram (width < 10 pixel).

Is the PDF exporter using any fix border for the diagram?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3148
Joined: Oct 19th, 2005
Re: Ruler, Diagram and PDF-Export with correct dimensions (e.g. DinA4)
Reply #3 - Jun 16th, 2016 at 12:10pm
Print Post  
Hi,

Try subtracting PdfExporter.Margins values from diagram.Bounds size or set smaller margins.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
eXTruDEr
YaBB Newbies
*
Offline


Mind con Fusion ;-)

Posts: 7
Joined: Jun 14th, 2016
Re: Ruler, Diagram and PDF-Export with correct dimensions (e.g. DinA4)
Reply #4 - Jun 16th, 2016 at 12:33pm
Print Post  
I had the same idea: I reduce the margins of the PDF exporter to Thickness(0, 0, 0, 0).
With this setting I got the result of my last post.

To solve the problem I reduced the width of the diagram.

Huh I'm still wondering why the ruler scale (in Millimeter) doesn't display the correct value for the width and height of the diagram. If I switch the ruler unit to pixel the sizes fit.
(The zero of the ruler starts at the top left corner of the diagram.)
For example the width of the diagram (about 210 mm) relates to 167 mm on the ruler.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3148
Joined: Oct 19th, 2005
Re: Ruler, Diagram and PDF-Export with correct dimensions (e.g. DinA4)
Reply #5 - Jun 17th, 2016 at 8:17am
Print Post  
It shows 210x297 size with following code, see linked test project -
Code
Select All
const double unitScale = 96.0 / 72.0;
var a4 = MindFusion.Pdf.PageSizes.A4;
diagram.Bounds = new Rect(
	0, 0, a4.Width * unitScale, a4.Height * unitScale);

diagram.Background = Brushes.Orange;

ruler.Unit = RulerUnit.Millimeter; 



https://mindfusion.eu/_samples/WpfRulerTest.zip

If you set Diagram.MeasureUnit after Bounds assignment, Bounds size is not automatically scaled to match new unit but it just keeps its assigned numerical values. If you want to scale diagram and item sizes to match new unit, call the ChangeUnit method instead.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
eXTruDEr
YaBB Newbies
*
Offline


Mind con Fusion ;-)

Posts: 7
Joined: Jun 14th, 2016
Re: Ruler, Diagram and PDF-Export with correct dimensions (e.g. DinA4)
Reply #6 - Jun 17th, 2016 at 9:00am
Print Post  
Hi,

I downloaded WpfRulerTest and start this project right once in Visual Studio. Here I get exactly the same error with the ruler (see Attachment)
  

MindFusionWPFRulerExample.png ( 35 KB | 108 Downloads )
MindFusionWPFRulerExample.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3148
Joined: Oct 19th, 2005
Re: Ruler, Diagram and PDF-Export with correct dimensions (e.g. DinA4)
Reply #7 - Jun 17th, 2016 at 12:38pm
Print Post  
Right, we've reproduced it on 120 DPI resolution settings, our developer is working on the fix.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3148
Joined: Oct 19th, 2005
Re: Ruler, Diagram and PDF-Export with correct dimensions (e.g. DinA4)
Reply #8 - Jun 17th, 2016 at 2:23pm
Print Post  
Hi,

This build should fix the wrong scale -
https://mindfusion.eu/_temp/ruler_fix.zip

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
eXTruDEr
YaBB Newbies
*
Offline


Mind con Fusion ;-)

Posts: 7
Joined: Jun 14th, 2016
Re: Ruler, Diagram and PDF-Export with correct dimensions (e.g. DinA4)
Reply #9 - Jun 20th, 2016 at 11:21am
Print Post  
Perfect !  Smiley
This new build is working fine.
Thank you for this fast bugfix.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint