The MindFusion Forums
Flow Diagramming Components >> ASP.NET MVC >> Mulitple text on shapes in diagram exports
https://mindfusion.eu/Forum/YaBB.pl?num=1496996498

Message started by Sven on Jun 9th, 2017 at 8:21am

Title: Mulitple text on shapes in diagram exports
Post by Sven on Jun 9th, 2017 at 8:21am
Dear support,

i would like to have some multiple text on shapes. In order of that, I've found the solution "Add icon and additional text to node" in the forum "Flow Diagramming Components › Html Canvas & JavaScript".

To my regret, i had to find, that the additional text is only available in the front end but not in the diagram export like image or PDF.
Is there any way to add multiple text to a shape in a c# class without using table nodes? :-/
front-end.png ( 7 KB | 158 Downloads )
pdf-export.png ( 2 KB | 147 Downloads )

Title: Re: Mulitple text on shapes in diagram exports
Post by Slavcho on Jun 9th, 2017 at 8:49am
Hi Sven,

You will need to custom-draw the texts on server side too where the exporter runs. Before exporting, set the CustomDraw property of ShapeNodes to Additional / Additional2 (first clips to node shape, second does not), add handler for the Diagram.DrawNode event and call IGraphics.DrawString for each additional text you need exported. The PdfGraphics.DrawString implementation will then insert appropriate PDF objects to render text.

Regards,
Slavcho
Mindfusion

Title: Re: Mulitple text on shapes in diagram exports
Post by Sven on Jun 9th, 2017 at 9:47am
Hi Slavcho,

thanks for your quick help. Now I'm able to add additional text in the export of the diagram.
Unfortunately, I have some difficulties with the bounds of the additional text.
I had tried to use the node bounds, but it doesn't work.

Here is the code that I use to draw the additional text:

        private void Diagram_DrawNode(object sender, DrawNodeEventArgs e)
        {
            if (e.Node.Tag != null && e.Node.Tag.ToString() != "0" && e.Node.Tag.ToString() != "")
            {
                e.Graphics.DrawString(e.Node.Tag.ToString(), e.Node.Font, new SolidBrush(Color.Black), e.Node.Bounds.X, e.Node.Bounds.Y);
            }
        }

In the attachment, there is a screenshot of the exported PDF-file. Do you have any idea how to set the bounds correctly?
pdf-export2_pdf.png ( 2 KB | 151 Downloads )

Title: Re: Mulitple text on shapes in diagram exports
Post by Slavcho on Jun 9th, 2017 at 9:49am
Hi Sven,

Try using GetLocalBounds() instead.

Regards,
Slavcho

Title: Re: Mulitple text on shapes in diagram exports
Post by Sven on Jun 9th, 2017 at 11:30am
Hi Slavcho,

i can't access to the GetLocalBounds-method out of the Diagram_DrawNode-event.
Is there any other solution or can you share an example with me how it could be works?

Title: Re: Mulitple text on shapes in diagram exports
Post by Slavcho on Jun 9th, 2017 at 1:18pm
DrawNodeEventArgs.Bounds should be in local coordinates actually, have you tried it?

Regards,
Slavcho

Title: Re: Mulitple text on shapes in diagram exports
Post by Sven on Jun 9th, 2017 at 1:26pm
Hi Slavcho,

that works for me. Thanks a lot!

The MindFusion Forums » Powered by YaBB 2.6.11!
YaBB Forum Software © 2000-2024. All Rights Reserved.