Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

%pdf error in downloading pdf from Function module

Hi,

I am trying to download pdf from a LinkToaction UI element.

I recieve %pdf" error when trying to download using below code. from backend perspective ABAPer said they are able to download PDF from ABAP program. Lokks like I am doing some mistake somewhere in below code.

From the backend, pdf is coming in a table in the form of SOLI-Text Line (TLine - SO_TEXT255)

In webdynpro I am tried to take each line from that table and attched to a IWDResource as below.

Please correct me if anything wrong here to get out of %pdf" error.

IModel_Pdf_FileNode Model = wdContext.nodeModel_Pdf_File();
IPDFElement pdf = wdContext.nodePDF().currentPDFElement();
if (Model != null && Model.size() > 0) 
 {
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
try {
   for (int i = 0; i < Model.size(); i++){
      IModel_Pdf_FileElement Element =
									Model.getModel_Pdf_FileElementAt(i);
	baos.write(Element.getLine().getBytes());
   }
    IWDResource resource =WDResourceFactory.createCachedResource(
		baos.toByteArray(),
		"Test",
		WDWebResourceType.PDF);
    pdf.setBinaryResource(resource);

Thanks

Praveen

Not what you were looking for? View more on this topic or Ask a question