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

Exporting Grid With ImageColumn

3 Answers 134 Views
GridView
This is a migrated thread and some comments may be shown as answers.
RajaGopal
Top achievements
Rank 1
RajaGopal asked on 04 Sep 2014, 09:19 AM
Hi,

I have a Rad Grid with data columns and one Image column.

for printing the grid, creating the doc by exporting, so, while exporting image column is exporting as path of the Image instead of printing the image.

I am using WPF RAD Grid.

Please provide solution.

Thanks
Raj

3 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 04 Sep 2014, 01:38 PM
Hi Raj,


Thank you for contacting us. 

You could not export images, because you could not embed images in the supported formats.  
By that reason, you are getting the path of the image.  

For PDF export, you could check the following forum post, which illustrates how to export images from RadGridView


Regards,
Vanya Pavlova
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
RajaGopal
Top achievements
Rank 1
answered on 04 Sep 2014, 02:40 PM
Hi Vanya,

We are creating a Rad rich text box and passing the RadDocument as parameter to it.
Document creating by exporting the grid, using the following method.
private RadDocument CreateDocument(RadGridView grid, PrintSettings settings)
       {
           RadDocument document = null;
 
           using (var stream = new MemoryStream())
           {
               //BoardImage.IsVisible = false;
 
               grid.ElementExporting += ExportBoardList;
 
               grid.Export(stream, new GridViewExportOptions()
               {
                   Format = ExportFormat.Html,
                   ShowColumnFooters = grid.ShowColumnFooters,
                   ShowColumnHeaders = grid.ShowColumnHeaders,
                   ShowGroupFooters = grid.ShowGroupFooters
               });
 
               grid.ElementExporting -= ExportBoardList;
 
               stream.Position = 0;
 
               document = new HtmlFormatProvider().Import(stream);
               document.SectionDefaultPageOrientation = PageOrientation.Portrait;
               document.SectionDefaultPageSize = new Size(800, 1024);
               document.SectionDefaultPageOrientation = PageOrientation.Landscape;
               //BoardImage.IsVisible = false;
           }
 
           return document;
       }

and printing from Rad Rich Textbox, Able to print all the columns without any issues along with styles.
internal void Print()
        {
            var grid = RadGridViewBoards as RadGridView;
            if (grid != null)
            {
                m_RowNumber = 1;
 
                var rtb = new RadRichTextBox()
                {
                    Width = 1280,
                    IsReadOnly = true,
                    LayoutMode = DocumentLayoutMode.Paged,
                    IsSelectionEnabled = false,
                    IsSpellCheckingEnabled = false,
                    Document = CreateDocument(grid, new PrintSettings())
                };
                var window = new RadWindow()
                {
                    Height = 0,
                    Width = 0,
                    Opacity = 0,
                    Content = rtb
                };
                rtb.PrintCompleted += (s, e) =>
                {
                    window.Close();
                };
                window.Show();
 
                rtb.Print(string.Empty, PrintMode.Native);
            }
        }

I have the problem in printing the image to the Rad document passed to Rad Rich Textbox.
Please suggest if there ia a way in this procedure.
0
Petya
Telerik team
answered on 08 Sep 2014, 02:54 PM
Hello Raj,

In the CreateDocument() method you can specifically handle image values and add the raw data for each image like this:
EventHandler<GridViewElementExportingEventArgs> elementExporting = (s, e) =>
 {
     if (e.Value != null && e.Value.GetType() == typeof(BitmapImage))
     {
         e.Value = "<img src=\"" + (e.Value as BitmapImage).UriSource.OriginalString + "\" />";
         e.ShouldEncodeValue = false;
     }
     //...
 }

Please try this out and let us know how it goes.

Regards,
Petya
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
RajaGopal
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
RajaGopal
Top achievements
Rank 1
Petya
Telerik team
Share this question
or