cancel
Showing results for 
Search instead for 
Did you mean: 

Reading pdf file with tabular data and chinese characters

Amey-Mogare
Contributor
0 Kudos

Hi,

I have a scenario where I need to accept .pdf file from user and upload its content to SAP R/3 using RFC calls.

The PDF file also contains text (Chinese characters) besides the tabular data (containing numeric values).

WD application needs to accept the PDF file and intelligently identify the tabular data and use specific columns of the tabular data to match against records in SAP.

Any ideas/help in order to achieve above scenario will be greatly appreciated.

Thanks and regards,

Amey Mogare

Accepted Solutions (0)

Answers (2)

Answers (2)

Amey-Mogare
Contributor
0 Kudos

Closed due to no response for long time.

Former Member
0 Kudos

Hi

Please use Adobe Lifecycle designer to create such forms. The Form data can easily be bound to Context Attributes and can be conviniently processed in Web Dynpro code.

There are a lot of resources available on sdn and help.sap for working with Adobe Interactive forms. See the following tutorials in particular.

[SAP Interactive forms by Adobe|/docs/DOC-8661#section19 [original link is broken]]

Regards

kk

Amey-Mogare
Contributor
0 Kudos

Hi KK,

Thank you for your reply.

I know about Adobe Life cycle and interactive forms.

But I dont want to create new pdf forms.

User will upload a PDF file through file upload UI element and I have to read its data and bind it to context.

How this can be done?

Thanks and regards,

Amey Mogare

Former Member
0 Kudos

Hi Amey,

I have an idea to achieve this but I have not tried it.

You can create similar interactive form UI element with format you want user to upload in invisible mode.

After this when you upload interactive form through upload UI element read the binary code of that file and populate it with the context attribute which you have used for property pdfSource of invisible interactive form element.

This way you will be able to take the interactive form in webDynpro context and then the node you have shared with pdf using dataSource property will be updated with the new values.

Please let me know if this succeed.

Ninad

Amey-Mogare
Contributor
0 Kudos

Hi Ninad,

That was a wonderful idea. I will surely try that too.

During googling about this, I found this link where it show how to extract PDF data into XML and process it.

http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/com.sap.km.cm.docs/lw/interactiveforms/sap%20intera...

This is the code I have written on upload button to convert pdf content into XML:-


	try {
		IWDResource pdfResource = wdContext.currentContextElement().getCtx_va_pdfResource();
		InputStream pdfInputStream = pdfResource.read(false);
		int l_int_ResourceSize = pdfInputStream.available();
		byte[] buffer = new byte[pdfInputStream.available()];
		int l_int_NumOfBytesRead = pdfInputStream.read(buffer);
		IWDPDFDocumentHandler pdfDocumentHandler = WDPDFDocumentFactory.getDocumentHandler();
		IWDPDFDocumentAccessibleContext documentAccessibleContext = pdfDocumentHandler.getDocumentAccessibleContext();
		documentAccessibleContext.setPDF(buffer);
		IWDPDFDocument pdfDocument = documentAccessibleContext.execute();
		ByteArrayInputStream dataInputStream = (ByteArrayInputStream) pdfDocument.getData();
	} 
	catch (Exception e) {
		myMessage.reportException(e.toString(), false);
	}

But I dont have any idea what to do next when I have "ByteArrayInputStream" with me.

How do I convert / access XML from this ByteArrayInputStream?

Can you suggest anything here?

Thanks and regards,

Amey Mogare