Convert Octet Stream To Pdf



Some scanners mail the scanned pdf file as an application octet-stream with pdf extension these are indeed pdf files currently they are not. When you try to download an unknown type of file from the Web or in an email attachment, your computer may identify it as an 'octet-stream' file. These OCTET-STREAM files may be opened by renaming the extension of the attached file to a specific file extension, and then by using an application with support for opening such files. For example, an.octet-stream file may be renamed to a.txt file (if it is indeed a.txt file), and Notepad may then be used to open the file. This means the user.

Guitar

  1. Application Octet Stream File
  2. Binary Octet Stream
  3. Convert Octet Stream To Word
  4. Convert Application/octet-stream To Pdf C#
Hi,
I have a byteArray which is a docx. I'm trying to convert it to pdf and add it to the Response object so the user can download it or open it.
OctetI've tried this which the pdf is corrupted
Convert octet stream file to pdf'docArray is the byte file from the db
Try
Dim doc As Spire.Doc.Document = New Spire.Doc.Document()
Dim oFileStream As System.IO.FileStream

Application Octet Stream File


Convert Octet Stream To Pdf oFileStream = New System.IO.FileStream(strTempName, System.IO.FileMode.Create)

Binary Octet Stream

'Write file to stream
oFileStream.Write(docArray, 0, docArray.Length - 1)
'Add docx to stream
doc.LoadFromStream(oFileStream, Spire.Doc.FileFormat.Docx)
'Covert docx to PDF
doc.SaveToStream(oFileStream, Spire.Doc.FileFormat.PDF)
Dim streamLength As Integer = Convert.ToInt32(oFileStream.Length)
Dim fileData As Byte() = New Byte(streamLength) {}
' Read the file into a byte array
oFileStream.Read(fileData, 0, streamLength)
oFileStream.Close()
strTempName = strTempName.Substring(0, strTempName.IndexOf('.'))
Context.Response.Clear()

Convert Octet Stream To Word

Context.Response.AddHeader('Content-Disposition', 'inline;attachment; filename='' & strTempName & '.pdf' & '')
Context.Response.AddHeader('Content-Length', fileData.Length.ToString())
Context.Response.ContentType = 'application/octet-stream'
Context.Response.BinaryWrite(fileData)
Context.Response.Flush()
Catch ex As Exception
Context.Response.ContentType = 'text/plain'
Context.Response.Write(ex.Message)
Finally
Context.Response.[End]()
End Try
And this gives me errors..

Convert Application/octet-stream To Pdf C#


Using ms As Stream = New MemoryStream(docArray, True)
ms.Write(docArray, 0, docArray.Length)
doc.SaveToStream(ms, Spire.Doc.FileFormat.PDF)
Convert Octet Stream To PdfPlease help.
Thanks,
J Torres