Export to HTML / png

3 posts, 0 answers
  1. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 09 Sep 2013 Link to this post

    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. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 12 Sep 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 12 Sep 2013 Link to this post

    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
Back to Top