cancel
Showing results for 
Search instead for 
Did you mean: 

Extract attachments as separated files

Former Member
0 Kudos

Hi all,

I need to extract attachments from the Pdf file as separated files while the user uploades a pdf file to the SAP system.

I'm using an offline scenario (JAVA).

May be PdfObject is what I need, but I don't know how exactly I can do this.

Thanks,

Michael Beilin

Accepted Solutions (1)

Accepted Solutions (1)

NoJo
Active Participant
0 Kudos

the same methods of the PDf Object are available for Java and ABAP because the are accesed via a SOAP call from both stacks, so this should work

thats abap coding

  • Create PDF Object.

l_pdfobj = l_fp->create_pdf_object( connection = p_dest ).

  • Set document. l_pdf is the PDF data including the attachments

l_pdfobj->set_document( pdfdata = l_pdf ).

  • Set task to get attachments.

l_pdfobj->set_task_getattachments( ).

  • Execute, call ADS.

l_pdfobj->execute( ).

  • Get result.

l_attachments = l_pdfobj->get_attachments( ).

hope it helps

Former Member
0 Kudos

Hi,

I'm not familiar with ABAP coding, I'm using WebDynpro for Java.

I have the context attribute of binary type that is bined to data attribute of FileUpload element.

ABAP coding:

  • Create PDF Object.

l_pdfobj = l_fp->create_pdf_object( connection = p_dest ).

How can I do the same in Java?

Thanks

Micahel Beilin

NoJo
Active Participant
0 Kudos

i'll discuss it with my java friends!

Former Member
0 Kudos

Hi Norbert,

Thaks for your cooperation

Michael Beilin

chintan_virani
Active Contributor
0 Kudos

Have a look at [Interface IWDPDFDocumentAttachmentList|http://help.sap.com/javadocs/NW04S/current/wd/com/sap/tc/webdynpro/clientserver/adobe/pdfdocument/api/IWDPDFDocumentAttachmentList.html]. It may be the one you are looking for.

Chintan

NoJo
Active Participant
0 Kudos

hi,

Michael Chytracek, one of our java developers has given me the following hint:

Important:use the "new!" API u201CPDFDocumentu201D because the old u201CPDFObjectu201D API can not handle attachments. Attachment API for the Interactive form have been made available with the following:

NW04s SP09 Web Dynpro Runtime + hotfix release (Note: 982023)

NW04s SP10 Web Dynpro Runtime + hotfix release (Note: 984868)

SP11 onwards > Base SAP release

IWDPDFDocumentAccessibleContext pdfContext = WDPDFDocumentFactory.getDocumentHandler().getDocumentAccessibleContext();
pdfContext.setPDF(pdf);
         
IWDPDFDocument pdfDocument = pdfContext.execute();
IWDPDFDocumentAttachment[]     attachments = pdfDocument.getAllAttachments();
for(int i = 0; i < attachments.length; i++){
    IWDPDFDocumentAttachment att = attachments<i>;
    .......
    }

br norbert

Former Member
0 Kudos

Hi Norbert,

Thanks for your help. I have try your solution, but without success.

In method

pdfContext.setPDF(pdf);

"pdf" parameter is of type "binary" that is binded to FileUpload Element also.

But in attachments.length I get 0 value(the pdf file has 2 attachments).

Have any idea what may be the problem?

Thanks,

Michael Beilin

NoJo
Active Participant
0 Kudos

could you post an example of the content of the attachment array?

do the attributes look like this??

NAME

FILENAME

MIMETYPE

FILESIZE

CREATIONTIME

MODIFICATIONTIME

DESCRIPTION

DATA

Former Member
0 Kudos

Hi Norbert,

I have that structure in every att (attachments instance), but attachments is empty!

I see in debugger that pdfContext.setPDF(my binary source) is filled correctly with data from pdf file.

And after

IWDPDFDocument pdfDocument = pdfContext.execute();

IWDPDFDocumentAttachment[] attachments = pdfDocument.getAllAttachments();

commands I see that attachments.length = 0.

May be something missing?

Thanks

Michael Beilin

NoJo
Active Participant
0 Kudos

did you be aware:

NW04s SP09 Web Dynpro Runtime + hotfix release (Note: 982023)

NW04s SP10 Web Dynpro Runtime + hotfix release (Note: 984868)

SP11 onwards > Base SAP release

??

stupid question: are there attachments in the pdf, which ones??

Former Member
0 Kudos

Hi Norbert,

Yes, there are 2 attachments in the pdf file.

Retrieving data from pdf is working also fine for me.

I use the following command for that:

WDInteractiveFormHelper.transferPDFDataIntoContext(binaryPdfSource, pdfDataSource);

And we are in NW04s SP 15.

Thanks for help

Michael Beilin

NoJo
Active Participant
0 Kudos

hm, no idea, perhaps attachments are not supported for java stack, or just for this release...perhaps michael could give it a try again...

Former Member
0 Kudos

Any ideas guys?

Michael

Former Member
0 Kudos

hi...

try adding this line

pdfContext.getTaskSetter().addGetAllAttachmentsTask();

just after

IWDPDFDocument pdfDocument = pdfContext.execute();

- Akshay

Edited by: Akshay Khakurdikar on Nov 18, 2009 5:53 AM

Former Member
0 Kudos

Hi Akshay,

Thanks for help.

Unsuccessfully .

I have opened OSS.

Michael

Former Member
0 Kudos

hi...

Try the same thing which i said in earlier post... but one change.. the order is other way..

pdfContext.getTaskSetter().addGetAllAttachmentsTask(); 

IWDPDFDocument pdfDocument = pdfContext.execute();

i tried this way it worked for me...

- Akshay

Answers (3)

Answers (3)

chintan_virani
Active Contributor
0 Kudos

See if below blog helps:-

[Demystifying Attachments with SAP Interactive Forms|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/8498] [original link is broken] [original link is broken] [original link is broken];

Chintan

Former Member
0 Kudos

Hi, Chintan

Nice blog.But, here you need to go to the backend R/3 to extract the attachemnts from the pdf.

PDFObjects are available in webdynpro for Java as well. So, there has to be a way to replicate the attachment-extracting functionality (that was achieved in R/3), in webdynpro for java too.

Thanks,

Michael Beilin

NoJo
Active Participant
0 Kudos

there is a mthod for the PDF object - must be the same for java --> get_attachments()

you get an array of the attachments

NoJo
Active Participant
0 Kudos

have a look at report FP_PDF_TEST_15 in your system...

Former Member
0 Kudos

I'm using WebDynpro for JAVA ,not ABAP