내 응용 프로그램은 PDF 파일을 XML 파일로 base64, zLib 압축 문자열로 수신합니다. 적어도 그것이 내가 말한 형식입니다. 데이터베이스에 저장되면 그 문자열에서 PDF를 다시 만들어야합니다. 내가 알아낼 수있는 테스트 응용 프로그램을 만들었습니다. 아래의 함수는 문자열을 받아서 원래의 PDF를 재구성하는 데 사용할 수있을 것으로 믿어지는 디코딩 된, 부풀려진 형식으로 반환 할 예정입니다 (아직 없습니다).base64 문자열을 확장하는 데 문제가 있습니다. zlib 오류 : -3
나는 많은 연구를했으며 몇 가지 다른 라이브러리와이를 수행하는 방법을 찾았으며 개발자에게 자바 프로그램을 보내 주었다. 그러나 사용할 수있는 형식으로 문자열을 가져올 수 없습니다. ManagedZLib.dll과 아래 함수를 사용하면 가장 가까운 것 같습니다.
zStream.Read(decompressedBytes, 0, decodedBytes.Length - 1)
이는 "ZLIB 오류 : -3"생산 : 나는 압축을 시도 할 때까지 지금까지 내가 디버깅에서 말할 수있는, 모든 작동합니다. 그 오류에서 찾을 수있는 유일한 정보는 '데이터 오류'입니다. 웹에 관한 정보는 거의 없습니다.
이 오류를 지나치는 데 도움이되거나 내 목표를 달성하기위한 다른/더 나은 방법에 대한 생각은 대단히 감사합니다.
Public Function DecompressString4(ByVal origString As String) As String
Dim returnString = Nothing
' get the base64 content into String
ManagedZLib.ManagedZLib.Initialize()
'// parse the string into a byte array
Dim b64bytes() As Byte = System.Text.Encoding.UTF8.GetBytes(origString)
Dim decodedBytes() As Byte = Nothing
'decode the byte array into another byte array, but this time of Base 64.
Using ms As New MemoryStream(b64bytes)
Using zStream As New ManagedZLib.Base64Stream(ms, Base64Options.Decode)
ReDim decodedBytes(b64bytes.Length)
zStream.Read(decodedBytes, 0, b64bytes.Length)
End Using
End Using
decmpStrTxtBox.Text = Convert.ToString(decodedBytes)
Dim decompressedBytes() As Byte = Nothing
' inflate the base64 array
Using ms2 As New MemoryStream(decodedBytes)
Using zStream As New ManagedZLib.CompressionStream(ms2, CompressionOptions.Decompress)
'ReDim decompressedBytes(origString.Length)
ReDim decompressedBytes(decodedBytes.Length)
zStream.Read(decompressedBytes, 0, decodedBytes.Length - 1)
End Using
End Using
'write output to a stream
returnString = Convert.ToString(decompressedBytes)
ManagedZLib.ManagedZLib.Terminate()
Return returnString
End Function