Export and save file with Web API

Thread is closed for posting
2 posts, 0 answers
  1. 63F75A2C-1F16-4AED-AFE8-B1BBD57646AD
    63F75A2C-1F16-4AED-AFE8-B1BBD57646AD avatar
    1572 posts
    Member since:
    Oct 2004

    Posted 04 Dec 2015 Link to this post

    Requirements

    Telerik Product and Version 

    UI for ASP.NET AJAX 2015 Q3


    Supported Browsers and Platforms


    Components/Widgets used (JS frameworks, etc.)

    .NET 3.5/4.0/4.5  C#



    PROJECT DESCRIPTION 

    This sample demonstrates how you can use the ClientExportManager to export content to .PDF and save the file to a specified folder with Web API using an ExportController. The sample contains two pages, the first one (ExportOrgChart.aspx) shows only export of a div containing a RadOrgChart, without saving the file to a specific folder. The second page (ExportSaveOrgChart.aspx) exports and saves the .PDF file to the "files" folder. This is made possible with the ExportController's SaveFile() method. First the data is encoded in the onClientPdfExporting handler and sent to the server with an AJAX request. The SaveFile() method then processes it and saves the file to the "files" folder appending a GUID to the filename. The routing is configured in the Global.asax file.

  2. 06A85FE1-CF53-4B22-A168-3A3467646C27
    06A85FE1-CF53-4B22-A168-3A3467646C27 avatar
    3 posts
    Member since:
    Feb 2013

    Posted 31 Jul 2017 in reply to 63F75A2C-1F16-4AED-AFE8-B1BBD57646AD Link to this post

    I have downloaded the attachment and its working fine .the saved image file is downloading in local files folder . While implementing  the export functionality in my solution , If i refer the  ControllerUrl property in pageload its not getting refered correctly .

    > In your attached solution i have changed the ExportController class file path then its not worked for me .Please tell me how to refer the API path in locally without appfolder .

    And also i have used the following method its works fine except some cases of Bar chart 

     [WebMethod]
            public static void UploadImagetelerik(string svgString)
            {
                string chartimagefilename = System.Guid.NewGuid().ToString();
                string fileNameWitPath = AppDomain.CurrentDomain.BaseDirectory + @"pages\temp\" + chartimagefilename + ".png";
                ChartImageFileName_newexport = ChartImageFileName_newexport + "," + chartimagefilename;
                System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
                xmlDoc.LoadXml(svgString);
                SvgDocument svgDoc = SvgDocument.Open(xmlDoc);
                svgDoc.Transforms = new SvgTransformCollection();
                svgDoc.Transforms.Add(new SvgScale(1, 1));
                svgDoc.Width = new SvgUnit(svgDoc.Width.Type, svgDoc.Width);
                svgDoc.Height = new SvgUnit(svgDoc.Height.Type, svgDoc.Height);
                svgDoc.Draw().Save(fileNameWitPath.ToString(), System.Drawing.Imaging.ImageFormat.Jpeg);

            }

     

    I have facing following error 

    ColorBlend object that was set is not valid.
    Position's first element must be equal to 0.
     ColorBlend objects must be constructed with the same number of positions and color values.
     Positions must be between 0.0 and 1.0, 1.0 indicating the last element in the array.

    Please tell me the solution for Export and save the chart as png image in local folder .

    Thanks 

     

Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.