The C1Report provides support for displaying various images (jpeg, bmp, tiff, etc). However, it currently does not provide support for displaying Multi-Paged Tiff Images. This blog explains a workaround to load Multi-Paged Tiff Images in C1Report using two approaches:

  1. C1PrintDocument
  2. C1Report

The workaround is as follows:

  1. Save all the frames of Multi-Page Tiff Images.
  2. Add these images one-by-one to the C1Report/C1PrintDocument.

Saving Multi-Page Tiff Image

The following method is used to save image frames of Multi-Page Tiff Images:

'Method to save frames of Multi-Page Tiff Image  
Sub SaveTiffImage(filename As String)  
   Dim imgOriginal As Image = Image.FromFile(filename)  
   Dim objDimension As FrameDimension  
   objDimension = New FrameDimension(imgOriginal.FrameDimensionsList(0))  
   Dim nPageNo As Integer = imgOriginal.GetFrameCount(objDimension)  
   If nPageNo > 0 Then  
      Try  
         ' import tiff images to the doc viewer  
         For i As Integer = 0 To nPageNo - 1  
            ' Set the active frame  
            imgOriginal.SelectActiveFrame(FrameDimension.Page, i)  
            ' Draw active frame  
            imgOriginal.Save("SaveImg" & i.ToString() & ".jpg")  
         Next i  
      Catch ex As Exception  
         ' MessageBox.Show(ex.Message)  
      End Try  
   End If  
End Sub

Using C1PrintDocument

Once the tiff image frames are saved in multiple images it is quite easy to create a C1PrintDocument. All you need to do is create RenderImage objects and add these to the C1PrintDocument.Body.Children. The following is the code to do the same:

'Using C1PrintDocument  
Sub C1PrintDocApproach()  
    Dim doc As New C1PrintDocument()  
    SaveTiffImage("..\\..\\C1Image.tif")  

    Dim r0 As New RenderImage()  
    r0.Image = Image.FromFile("SaveImg0.jpg")  
    Dim r1 As New RenderImage()  
    r1.Image = Image.FromFile("SaveImg1.jpg")  
    Dim r2 As New RenderImage()  
    r2.Image = Image.FromFile("SaveImg2.jpg")  
    Dim r3 As New RenderImage()  
    r3.Image = Image.FromFile("SaveImg3.jpg")  
    Dim r4 As New RenderImage()  
    r4.Image = Image.FromFile("SaveImg4.jpg")  
    Dim r5 As New RenderImage()  
    r5.Image = Image.FromFile("SaveImg5.jpg")  
    Dim r6 As New RenderImage()  
    r6.Image = Image.FromFile("SaveImg6.jpg")  

    doc.Body.Children.Add(r0)  
    doc.Body.Children.Add(r1)  
    doc.Body.Children.Add(r2)  
    doc.Body.Children.Add(r3)  
    doc.Body.Children.Add(r4)  
    doc.Body.Children.Add(r5)  
    doc.Body.Children.Add(r6)  
    'Display the C1PrintDocument in C1PrintPreviewControl  
    C1PrintPreviewControl1.Document = doc  
End Sub

Using C1Report

Adding multiple images in C1Report will require a little more effort than C1PrintDocument. The easiest way is to create a report definition file with the tiff image and add the tiff image frame by frame in code. The following code can be used to save the few images of multi-page tiff files physically and then add the images one-by-one to the report definition file:

C1Report1.Load("..\\..\\MultiPageImageTest.xml", "MultiPageImageReport") 'This report already has a field in the xml with the same tiff image loaded in the picture property that is necessary to render the first field  
'Save the tiff image  
SaveTiffImage("..\\..\\C1Image.tif")  

'Default field  
Dim defField As Field = C1Report1.Sections.Detail.Fields(0)  
defField.Visible = False 'Hiding the default field in the report  

'Adding first field  
Dim Field1 As Field = C1Report1.Sections.Detail.Fields.Add("f1", "", defField.Left, defField.Top + 1, defField.Width, defField.Height)  
Field1.PictureAlign = PictureAlignEnum.CenterTop  
Field1.BackColor = Color.Transparent  
Field1.CanGrow = True  
Field1.PictureScale = PictureScaleEnum.Scale  
Field1.Picture = Image.FromFile("SaveImg0.jpg")  

'Adding second field  
Dim Field2 As Field = C1Report1.Sections.Detail.Fields.Add("f2", "", Field1.Left, Field1.Height, Field1.Width, Field1.Height)  
Field2.PictureAlign = PictureAlignEnum.CenterTop  
Field2.BackColor = Color.Transparent  
Field2.CanGrow = True  
Field2.PictureScale = PictureScaleEnum.Scale  
Field2.Picture = Image.FromFile("SaveImg1.jpg")  

'Adding third field  
Dim Field3 As Field = C1Report1.Sections.Detail.Fields.Add("f3", "", Field2.Left, Field1.Height + Field2.Height + 1, Field2.Width, Field2.Height)  
Field3.PictureAlign = PictureAlignEnum.CenterTop  
Field3.BackColor = Color.Transparent  
Field3.CanGrow = True  
Field3.PictureScale = PictureScaleEnum.Scale  
Field3.Picture = Image.FromFile("SaveImg2.jpg")  

.......

For complete code please refer to the attached sample. Download Sample