I haven’t a clue why this won’t work and thought you all might be able to point out what I’m missing. (there are two examples below)
This will create a PDF file and save it to my drive and import it back into a SQL table.
This will export data to the same SQL table but when you go to open the PDF the file is corrupt.Code:Dim rpt As New LetterGen Dim ePDF As New Export.Pdf.PdfExport Dim memStream As New System.IO.MemoryStream Dim FileLen As Integer Dim FileByte() As Byte rpt.sLetterGen = LetterOutput rpt.Run(False) With ePDF .Version = Export.Pdf.PdfVersion.Pdf13 .Export(rpt.Document, "F:\PDF\TESTING.PDF") End With Dim fs As New FileStream _ ("F:\PDF\TESTING.PDF", FileMode.OpenOrCreate, _ FileAccess.Read) FileLen = fs.Length ReDim FileByte(FileLen) Dim FileStream As Stream = fs FileStream.Read(FileByte, 0, FileLen) Dim MyDoc As New StoredDocument MyDoc.DocID = 0 MyDoc.Doc = FileByte MyDoc.DocLength = FileLen MyDoc.DateDoc = Now MyDoc.DocContentTypeID = "01" Dim NewDocID As Integer = MyDoc.SetDocument(MyDoc)
"Acrobat could not open 'file name' because it is either not a supported file type or because the file has been corrupted..."
Code:Dim rpt As New LetterGen Dim ePDF As New Export.Pdf.PdfExport Dim memStream As New System.IO.MemoryStream Dim FileLen As Integer Dim FileByte() As Byte rpt.sLetterGen = LetterOutput rpt.Run(False) With ePDF .Version = Export.Pdf.PdfVersion.Pdf13 .Export(rpt.Document, memStream) End With FileLen = memStream.Length ReDim FileByte(FileLen) Dim FileStream As Stream = memStream FileStream.Read(FileByte, 0, FileLen) Dim MyDoc As New StoredDocument MyDoc.DocID = 0 MyDoc.Doc = FileByte MyDoc.DocLength = FileLen MyDoc.DateDoc = Now MyDoc.DocContentTypeID = "01" Dim NewDocID As Integer = MyDoc.SetDocument(MyDoc)


Reply With Quote