on 02-12-2010 6:51 AM
Hi all,
I am trying to create a PDF file in XI using itext. The PDF file is getting created in my target ftp server but I am not able to open the PDF. It is throwing the below error while opening.
"Adobe Reader could not open the sample.pdf because it is either not a supported file or because the file has been damaged(for example,it was sent as an e mail attachment and wasn't correctly decoded)"
I am using the below code in my udf
String filename= "Sample.pdf";
try
{
Document document= new Document();
PdfWriter pdfwriter=PdfWriter.getInstance(document,new FileOutputStream(filename));
document.open();
document.add(new Paragraph("Hi How are you?"));
document.close();
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
conf.put(key,filename);
}
catch(Exception e)
{
}
return "";
Kindly let me know if you have any information on this.
With Regards
jaisu.
Edited by: jaisu118 on Feb 12, 2010 8:04 AM
/people/shabarish.vijayakumar/blog/2009/05/17/trouble-writing-out-a-pdf-in-xipi
can you refer that?
the output should be from a mapping (java) or a module
in your case it is a uDF and i dont think it will work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
please check in some JAVA forums,the code what you have written is correct or not.
develop one standalone java program test it,if it working fine then you can use the same in UDF.
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
I had used custom adapter module for creating the PDF file.
you have to use java mapping if you want to create pdf without using adapter module.
You need to import iText library available at http://itextpdf.com/.
code may look like this:
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
//1. AbstractTransformation class is imported.
// The associated jar file is: com.sap.xpi.ib.mapping.lib.jar
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.DynamicConfiguration;
import com.sap.aii.mapping.api.DynamicConfigurationKey;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
import com.sap.aii.mapping.api.InputHeader;
public class xyz extends AbstractTransformation {
public void transform(TransformationInput inp, TransformationOutput out) throws StreamTransformationException {
getTrace().addInfo("JAVA Mapping Called");
InputStream inData = inp.getInputPayload().getInputStream();
// pdf conversion code
out.getOutputPayload().getOutputStream().write(outData.getBytes("UTF-8"));
}}
check http://help.sap.com/javadocs/pi/SP3/xpi/index.html for java mapping api.
Thanks.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.