Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iText v 7 error, "classes can only inherit from other classes" at "Inherits IDocumentReadyListener"

Tags:

vb.net

itext7

How do I solve the error of "classes can only inherit from other classes" at "Inherits IDocumentReadyListener"? This is in VB.net using iText v7 api. I am trying to get the bytearray from the pdf splitter.

Class ByteArrayPdfSplitter
    Inherits iText.Kernel.Utils.PdfSplitter

    Private currentOutputStream As MemoryStream

    Public Sub New(ByVal pdfDocument As iText.Kernel.Pdf.PdfDocument)
        MyBase.New(pdfDocument)
    End Sub

    Protected Overrides Function GetNextPdfWriter(ByVal documentPageRange As iText.Kernel.Utils.PageRange) As iText.Kernel.Pdf.PdfWriter
        currentOutputStream = New MemoryStream()
        Return New iText.Kernel.Pdf.PdfWriter(currentOutputStream)
    End Function

    Public ReadOnly Property CurrentMemoryStream As MemoryStream
        Get
            Return currentOutputStream
        End Get
    End Property

    Public Class DocumentReadyListender
        Inherits IDocumentReadyListener

        Private splitter As ByteArrayPdfSplitter

        Public Sub New(ByVal splitter As ByteArrayPdfSplitter)
            Me.splitter = splitter
        End Sub

        Public Sub DocumentReady(ByVal pdfDocument As iText.Kernel.Pdf.PdfDocument, ByVal pageRange As iText.Kernel.Utils.PageRange)
            pdfDocument.Close()
            Dim contents As Byte() = splitter.CurrentMemoryStream.ToArray()
            Dim pageNumber As String = pageRange.ToString()
        End Sub
    End Class

End Class
like image 590
John Reese Avatar asked Oct 23 '25 20:10

John Reese


1 Answers

IDocumentReadyListener is not a class, it's an interface, and whenever you implement an interface, the correct key word to indicate this is Implements, not Inherits. Thus:

Public Class DocumentReadyListender
        Implements IDocumentReadyListener

For some more backgrounds on interfaces read for example here.

like image 175
mkl Avatar answered Oct 26 '25 05:10

mkl