2010-03-12 3 views
1

저는 bitarray를 반환해야하는 pdf를 만드는 함수가 있습니다. 아래의 코드유형 1 차원 배열의 값을 system.collections.bitarray로 변환 할 수 없습니다.

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 

입니다 그러나 그것은 = 유형 1 차원 배열의 값이 을 system.collections.bitarray로 변환 할 수 없습니다() MemStream.GetBuffer이

답변

0
도와주세요이 라인 pdfdoc1에서 오류를 던지고있다 사실 일 것을 나타낸다

은 부울로서 표현되는 비트 값의 조밀 한 어레이를 관리 : BitArray BitArray 클래스 MSDN 문서에서

는 불리언 배열 비슷한 나타낸다 e 비트가 켜짐 (1)이고 거짓이면 비트가 꺼짐 (0)임을 나타냅니다.

이 그것을 1과 0을 저장하는 것을 의미하는 것으로 해석 할 수도 있지만

, 무슨 정말 말하는 것은 참과 거짓에 저장한다는 것입니다.

한편, MemoryStream.GetBuffer()은 Byte 배열을 반환합니다. 따라서 Byte는 부울이 아니기 때문에이 둘은 호환되지 않습니다.

이 시도 :

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 
관련 문제