Skip to Content

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

PDFAttachment API is not functioning properly

Hi,

Can u tell me if we how can we retrive attachments from the interactive form of a web dynpro application at runtime?

I am able to attach documnets to PDF form programetically but unable to retrive it.

Even i am able to successfully save entire PDF document with these attachments on local machine but unable to retrive attachments from PDF document.

I have tried 3 methods provided by API to detach attachments but seems to be none of them or working.I have tried with SP9,SP10, and base relese of SP11.

Here is code snippet.Please do let me know any body has done any thing to retrive these attachments.

IWDPDFDocumentAccessibleContext acc =WDPDFDocumentFactory.getDocumentHandler().getDocumentAccessibleContext();

acc.setPDF(wdContext.currentContextElement().getPdfSource());

pdfDoc = (IWDPDFDocument) acc.execute();

IWDPDFDocumentAttachment[] attList = pdfDoc.getAllAttachments();

//IWDPDFDocumentAttachmentList li = pdfDoc.getAttachmentList();

messageMan.reportSuccess("Processing attachments " + attList.length);

replied

Hello Sudheer,

One peice of code is missing in your implementation. It should go as follows:

IWDPDFDocumentAccessibleContext acc =WDPDFDocumentFactory.getDocumentHandler().getDocumentAccessibleContext();

acc.setPDF(wdContext.currentContextElement().getPdfSource());

<b>acc.getTaskSetter().addGetAllAttachmentsTask();</b>

pdfDoc = (IWDPDFDocument) acc.execute();

IWDPDFDocumentAttachment[] attList = pdfDoc.getAllAttachments();

//IWDPDFDocumentAttachmentList li = pdfDoc.getAttachmentList();

messageMan.reportSuccess("Processing attachments " + attList.length);

The code inbetween in the bold, indicates the web dynpro framework to get the attachments attached. Without this, Web Dynpro would have tried to get the attachments

on every roundtrip even when you do not want it.

Best Regards,

Krish

Message was edited by: Krish

Krishanu Biswas

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