I have a function to create a pdf which should return bitarray. Below is the code
Public Function GenPDF() As BitArray
Dim pdfdoc1 As BitArray
Dim doc As New Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35)
Try
Dim MemStream As New MemoryStream
Dim wri As PdfWriter = PdfWriter.GetInstance(doc, MemStream)
'Open Document to write
doc.Open()
'Write some content
Dim paragraph As New Paragraph("This is my first line using Paragraph.")
Dim pharse As New Phrase("This is my second line using Pharse.")
Dim chunk As New Chunk(" This is my third line using Chunk.")
' Now add the above created text using different class object to our pdf document
doc.Add(paragraph)
doc.Add(pharse)
doc.Add(chunk)
pdfdoc1 = MemStream.GetBuffer()
Catch dex As DocumentException
'Handle document exception
Catch ex As Exception
'Handle Other Exception
Finally
'Close document
doc.Close()
End Try
But it is throwing an error at this line pdfdoc1 = MemStream.GetBuffer()
value of type 1-dimensional array cannot be converted to system.collections.bitarray
Please help
From the MSDN documentation of BitArray the BitArray class represents something similar to an array of Booleans:
Although you might interpret this to mean that it stores 1s and 0s, what it is really saying is that it stores True and False.
On the other hand, MemoryStream.GetBuffer() returns an array of Byte. So, the two are not compatible, because a Byte is not a Boolean.
Try this: