This is a migrated thread and some comments may be shown as answers.

Export to HTML / png

2 Answers 92 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
ITA
Top achievements
Rank 1
ITA asked on 09 Sep 2013, 08:26 AM
Hi,

in your OrgChart example i found a way to Export the diagram to png or html. Two questions:

1) why ist the Background of the Image black if i Export the Diagramm to png?
2) where do i find the "HTMLExportHelper.CreateHTMLFile(this.diagram);" HTMLExportHelper?

Thanks
Best Regards
Rene

2 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 12 Sep 2013, 06:43 AM
Hi Rene,

You are allowed to customize the Background of the created image like this:
private void ExportToImage(object sender, RoutedEventArgs e)
{
    using (var stream = File.Open(@"c:\temp\xDiagram.png", FileMode.Create))
    {
        xDiagram.ExportToImage(stream, backgroundBrush: new SolidColorBrush(Colors.BlanchedAlmond));
    }
}
You can find more information here. Please note that the default Background of the RadDiagram in the Office_Black theme is Transparent.

Regarding the HTMLExportHelper class, you will be to copy and use it if you install our WPF demos. Let me know whether you would like me to send that class to you.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
ITA
Top achievements
Rank 1
answered on 12 Sep 2013, 10:55 AM
Hi,

thanks for this information - but: I get an error in this function:
private static string LoadStringFromFile(string path)
{
       string javaScript = string.Empty;
       using (var stream = ExtensionUtilities.GetStream(path))
       {
    using (var reader = new StreamReader(stream))
                    {
             javaScript = reader.ReadToEnd();
    }
        }
        return javaScript;
}

stream = null !!!!!

In the ExtensionUtilities.cs:
public static Stream GetStream(string relativeUri, string assemblyName)
{
     try
     {
          if (Application.Current == null) return null;
          if (relativeUri.StartsWith("/", StringComparison.Ordinal)) relativeUri = relativeUri.Remove(0, 1);
          if (assemblyName.ToLower().EndsWith(".dll", StringComparison.Ordinal)) assemblyName = assemblyName.Replace(".dll", string.Empty);
               
          var res = Application.GetResourceStream(new Uri(assemblyName + ";component/" + relativeUri, UriKind.Relative)) ??
              Application.GetResourceStream(new Uri(relativeUri, UriKind.Relative));
 
          if (res != null) return res.Stream;
}
catch (Exception)
{
       return null;
}
    return null;
}

res = null !!! It seams that something is wrong with the relativeUri: "Common/ExportToHTML/JavaScript.js"
assemblyName= "ITA-AbasOrganigramm" - which is wright!

Where is the problem?

Best Regards
Rene
Tags
Diagram
Asked by
ITA
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
ITA
Top achievements
Rank 1
Share this question
or