Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 689361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:19:28+00:00 2026-05-14T02:19:28+00:00

I have a function to create a pdf which should return bitarray. Below is

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:19:29+00:00Added an answer on May 14, 2026 at 2:19 am

    From the MSDN documentation of BitArray the BitArray class represents something similar to an array of Booleans:

    Manages a compact array of bit values, which are represented as Booleans, where true indicates that the bit is on (1) and false indicates the bit is off (0).

    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:

    Public Function GenPDF() As Byte() ' Don't forget to change your return type.
        Dim pdfdoc1 As Byte()          ' Changed this to the correct type.
        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
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function: def create(sender, **kw): [...] Which should be called when the
I have function some_func_1 which will create an object of type some_type and will
I wanted to create a function which would return the path of the current
I have this code guile> (cairo-pdf-surface-create foo.pdf 100.0 100.0) ; and get this error
I have this function: CREATE OR REPLACE FUNCTION CREATE_AIRSPACE_AVAILABILITY_RECORD (cur_user VARCHAR, start_time VARCHAR, start_date
I have this function to create a request to another file to update the
I have the following function: CREATE FUNCTION [dbo].[ListStockBySubCategory] ( @CategoryID varchar(10), @SubCategoryID varchar(10), @startRowIndex
I have a stored function CREATE OR REPLACE FUNCTION schedule(name in varchar2,pass in varchar2
I have a javascript function create(tagName, options) and the options variable is a JSON
I have a function and I create a snippet in modx revolution: function functionName(){

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.