Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Apparently I was making it too complicated. Here is the final solution for taking a base64 deflated string, decoding it, then inflating it and outputting a PDF from it. It could easily be tweaked to return the resulting string if needed. I ended up having much better results by not including any libraries (that were supposed to make it easier :-) ). I didn't actually find an answer to the error I was receiving and only assume that library wasn't designed for my purposes. Using the built in .net classes did the trick much better (Convert.FromBase64String and System.IO.Compression.DeflateStream).</p> <p>I hope this helps someone in the future as I couldn't find an example of this anywhere.</p> <pre><code>Imports System.IO Imports System.IO.Compression Imports System.Text Public Sub DecompressString(ByVal origString As String) Dim decodedDeflatedBytes() As Byte = Nothing Dim decodedInflatedBytes() As Byte = Nothing 'parse the string into a decoded byte array decodedDeflatedBytes = Convert.FromBase64String(origString) 'once around the block to get the length of the buffer we'll need Dim decompressedBufferLength As Integer = 0 Using ms1 As New MemoryStream(decodedDeflatedBytes) Using dStream1 As System.IO.Compression.DeflateStream = New System.IO.Compression.DeflateStream(ms1, Compression.CompressionMode.Decompress) While dStream1.ReadByte &lt;&gt; -1 ' -1 indicates nothing left to read decompressedBufferLength += 1 End While End Using End Using 'a second time around the block to do the actual inflation now that we have the length Using ms2 As New MemoryStream(decodedDeflatedBytes) Using dStream2 As System.IO.Compression.DeflateStream = New System.IO.Compression.DeflateStream(ms2, Compression.CompressionMode.Decompress) ReDim decodedInflatedBytes(decompressedBufferLength - 1) '11711 dStream2.Read(decodedInflatedBytes, 0, decompressedBufferLength) '11712 End Using End Using 'output the PDF with a 'save as' prompt Response.ClearContent() Response.ClearHeaders() Response.Clear() Response.ContentType = "Application/pdf" Response.AddHeader("Content-Length", decodedInflatedBytes.Length.ToString) Response.AddHeader("content-disposition", "attachment;filename=YourReport.pdf") Response.BinaryWrite(decodedInflatedBytes) Response.End() End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload