Dispose Method for FlexReport?

Posted by: cvandien on 30 April 2019, 12:02 pm EST

  • Posted 30 April 2019, 12:02 pm EST

    Hello,

    Esha provided the following code (works great) for rasterizing a .PDF page and displaying it an ImageField so that I could co-mingle the .PDF with other report elements…

    I need to delete the images that are created when the form closes and (assuming) I need to dispose of the ImageField to break the connection to the Imge Files so I can do a File.Delete(filename) command.

    Setting the objects to Nothing does not resolve the issue… What is the referred process of disposing the Report?

    Here’s the code that derives each .PDF page:

                C1PdfDocumentSource1.LoadFromFile("\\TCHWhiteCloud\WhiteCloudAttachments\Active Admit Nurses.pdf")
    
                'Create JPEGFilter object
                Dim filter As New JpegFilter()
                filter.FileName = "../../Images/" & Globals.Username.ToUpper & ".jpg"
    
                C1PdfDocumentSource1.Export(filter)
    
                Dim d As New System.IO.DirectoryInfo(directoryName)
                'Dim img As ImageField
    
                For i As Integer = 1 To d.GetFiles.GetUpperBound(0) + 1
                    img = New ImageField
                    Dim subSection As SubSection = C1FlexReport1.Sections.Detail.SubSections.Add()
                    subSection.Visible = True
                    subSection.Height = C1FlexReport1.Layout.PageSize.Height
                    subSection.AutoHeight = AutoSizeBehavior.None
    
                    img.Top = 0
                    img.Left = 0
                    img.MarginTop = 0
                    img.MarginBottom = 0
                    img.Height = 1440 * 8.9
                    img.Width = 1440 * 7.9
                    'img.AutoHeight = AutoSizeBehavior.GrowAndShrink
                    'img.AutoWidth = AutoSizeBehavior.GrowAndShrink
                    img.PictureScale = PictureScaleEnum.Scale
                    img.BackColor = Color.LightGray
    
                    img.Border.Color = Color.Black
                    img.Border.Style = BorderStyleEnum.Solid
    
                    img.Picture = Image.FromFile(Path.Combine(directoryName, Globals.Username.ToUpper & "_page" & i & ".jpg"))
    
                    subSection.Fields.Add(img)
    
                Next
    
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels