1645988 - How to modify image size when using the RAS SDK in a VS .NET application

SAP Knowledge Base Article - Public

1645988 - How to modify image size when using the RAS SDK in a VS .NET application

Symptom

  • Images inserted into a report display as they are stored in a database
  • How to modify the image size so all images are consistent?

Environment

  • Crystal Reports for Visual Studio 2010
  • VS2010

Resolution

  • Use the following code to control the image size:
Public Class Form1
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim boReport As CrystalDecisions.CrystalReports.Engine.ReportDocument = Nothing
        Dim boPicture As CrystalDecisions.ReportAppServer.ReportDefModel.PictureObject = Nothing
        Dim boClientDoc As CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument = Nothing
        Dim boReportObject As CrystalDecisions.ReportAppServer.ReportDefModel.ReportObject = Nothing
        Dim boNewObject As CrystalDecisions.ReportAppServer.ReportDefModel.ReportObject = Nothing
 
        Try
            boReport = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
            boReport.Load("c:\Crystal\My_test.rpt")
            boClientDoc = boReport.ReportClientDocument
 
            boPicture = boClientDoc.ReportDefController.ReportObjectController.ImportPicture("test.bmp", _
            boClientDoc.ReportDefController.ReportDefinition.PageHeaderArea.Sections(0), 5, 5)
 
            For Each boReportObject In             boClientDoc.ReportDefController.ReportObjectController.GetReportObjectsByKind _
            (CrystalDecisions.ReportAppServer.ReportDefModel.CrReportObjectKindEnum.crReportObjectKindPicture)
                If boReportObject.Name = boPicture.Name Then
                    boNewObject = boReportObject.Clone(True)
                    boNewObject.Width = 14800
                    boNewObject.Height = 14800
 
                    boClientDoc.ReportDefController.ReportObjectController.Modify(boReportObject, boNewObject)
                End If
            Next
            Me.CrystalReportViewer1.ReportSource = boReport
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class
 

 

Keywords

CR2010 2010 CR4VS2010 CR4VS VS2010 NET2010 Crystal Reports for .NET Framework 4.0 crforvs 13 picture pic graphic resize smaller bigger , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio