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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With