You are viewing limited content. For full access, please sign in.

Discussion

Discussion

Handy trick to check for image integrity

SDK
posted on April 27, 2016 Show version history

We are running into situations where the DB record of a page is present, but the actual image is not. 

After some digging around, we found that the code below works well and quickly:

 

            Dim LF_PageInfo As PageInfoReader = LF_DocInfo.GetPageInfos
            Dim LF_PageSet As Laserfiche.RepositoryAccess.PageSet = New PageSet
            Dim ms As LaserficheReadStream
            Dim LF_PP As PagePart = New PagePart

            For Each PageInfo In LF_PageInfo
                'Try to read each page
                ms = PageInfo.ReadPagePart(LF_PP)
                'Evaluate
                If ms.Length > 0 Then
                    'If OK, add it to the PageSet
                    LF_PageSet.AddPage(PageInfo.PageNumber)
                End If
            Next

            'Make sure we have something to export
            If LF_PageSet.GetTotalPageCount > 0 Then

                'Set the Exporter Properties
                LF_DocExporter.IncludeAnnotations = False
                LF_DocExporter.BlackoutRedactions = False

                'Export the document
                LF_DocExporter.ExportPdf(LF_DocInfo, LF_PageSet, _
                         PdfExportOptions.None, sExportPath)
           End If

 

Note that this does not help with the situation where the image is present but corrupt.

0 0
You are not allowed to reply in this post.

Discussion 1

Sign in to reply to this post.