on 10-11-2007 7:25 AM
Hi,
I have a problem in opening the pdf file using .net code from SAP-SPOOL .I am getting error as follows..
"There was a error in opening a document.The file is damaged and could not be repaired".
I am extracting data from SAP-SPOOL to .net environment using sap.connector with Rfc.In this rfc, I have to open a PDF file which is in a table format which contains two columns(tdformat,tdline).
Please help me out.Thanks in advance..
This is my code..
pdfproxy = New SAPProxy1(cs)
pdfproxy.Connection.Open()
pdfproxy.Z_Rfc_Po_Pdf_Create( strpurchaseorder, bytecount, pdft)
pdfproxy.Connection.Close()
Dim ds As DataSet = New DataSet
ds.Tables.Add(pdft.ToADODataTable)
Dim sb As StringBuilder = New StringBuilder
For Each dr As DataRow In ds.Tables(0).Rows
Dim dataline As String = dr(0) & dr(1)
If dataline.Length < 134 Then
dataline = dataline.PadRight(134, " ")
End If
sb.Append(dataline)
Next
Dim pdf As String = sb.ToString
Dim context As System.Web.HttpContext
context = System.Web.HttpContext.Current
Dim response As System.Web.HttpResponse
response = context.Response
Dim pdfLength = pdf.Length
' create name for PDF
Dim pdfBytes() As Byte = encoding.GetBytes(pdf.ToCharArray(), 0, pdfLength)
response.ClearHeaders()
response.ContentType = "application/Pdf"
response.AppendHeader("content-disposition", "attachment; filename=" + strfilename)
response.OutputStream.Write(pdfBytes, 0, pdfLength)
response.Flush()
response.SuppressContent = True
response.end()
Hi,
Atlast i got a Solution to my Question.
The Problem is that in my SAP-Code they have been translated the PDF into 255 string.But i am retreiving using 132 string.So, i resolved in this way.
For Each dr As DataRow In ds.Tables(0).Rows
Dim dataline As String = dr(0)
<b> If dataline.Length < 255 Then
dataline = dataline.PadRight(255, " ")
End If</b>
sb.Append(dataline)
Next.
May be this Thread is useful to Others.
Regards,
Rajender.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.