cancel
Showing results for 
Search instead for 
Did you mean: 

PDF to XML Conversion in sap pi

Former Member
0 Kudos

Hello Experts,

My Scenario is file to IDOC where in I receive PDF file as an Input, Convert it to XML and map to target IDOC fields. I have used java mapping with the below code.

public class TestReadPDF extends AbstractTransformation

{

public void transform(InputStream inputstream, OutputStream outputstream) throws StreamTransformationException

{

try

{

String msgType = "MT_DUMMY";

String nameSpace = "http://dumy_poc_purchaseorders";

String str;

String str1;

String str2;

str="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+ "<ns0:"+msgType+" "+"xmlns:ns0=\""+nameSpace+"\">";

str = str + "\n<Record>";

PdfReader reader = new PdfReader(inputstream);

PdfTextExtractor pdf = new PdfTextExtractor(reader);

str1 = pdf.getTextFromPage(1);

str2 = pdf.getTextFromPage(2);

str= str1+str2+"\n</Record>"+"\n</ns0:MT_DUMMY>";

byte by[] = str.getBytes(); outputstream.write(by);

reader.close();

outputstream.close();

}

catch(Exception e)

{ e.printStackTrace();

}

}

@Override

public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException

{

// TODO Auto-generated method stub

}

}

Unfortunately I am receiving the empty output after mapping.

Kindly help on the same.

Thanks in advance for help!!

Regards,

Prashanth Bharadwaj.Ch

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member468891
Discoverer
0 Kudos

Hi Evgeniy,
could you please help me on a high level design of the similar problem.
We have customers they are sending us purchase orders in PDF format. We are using SAP ECC system and looking for a solution based on SAP PO/PI to convert PDF to XML and to send this as an IDOC from PO to ECC. We also using Adobe Document Services Server to create and to send PDF-files via Email. Is it possible to create XML files from PDF using PO and ADS? Could you please describe possible way (high level) .

Thank you in advance.

Dmitri

Former Member
0 Kudos

Hi Evgeniy,

Thank you so much for your kindly reply.

I will work on it and update on the same.

former_member190293
Active Contributor
0 Kudos

Hi Prashanth!

@Override
public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException
{
this.transform(in.getInputPayload().getInputStream(), out.getOutputPayload().getOutputStream());
}

Regards, Evgeniy.