cancel
Showing results for 
Search instead for 
Did you mean: 

Java Mapping.....Activation cancelled.

Former Member
0 Kudos

In this blog,

/people/divya.vidyanandanprabhu/blog/2005/06/28/converting-xml-to-pdf-using-xi

it was specified that XmlToPdf.class will be there in dom4j-1.6.1.jar. But it was not there when i opened with Winzip, actually it was in itext-1.4.1.jar file. When i generated java source file for this class file, XmlToPdf(String,String) Constructor was not there.

But in the User defined Java mapping program they specified with 2 String args. Thats why am getting Activation cancelled in IR saying that XmlToPdf(String,String) was not there. Help me

Thanks a lot!

Accepted Solutions (0)

Answers (1)

Answers (1)

stefan_grube
Active Contributor
0 Kudos

You have to create the class com.xml2pdf.XmlToPdf by your own.

Regards

Stefan

Former Member
0 Kudos

Hi stefan

I created this com.xml2pdf.XmlToPdf:

package com.xml2pdf;

import com.lowagie.text.Document;

import com.lowagie.text.DocumentException;

import com.lowagie.text.pdf.PdfWriter;

import java.io.*;

public class XmlToPdf extends XmlToXXX

{

public XmlToPdf()

{

}

public XmlToPdf(String s)

{

super(s);

}

protected final void addWriter(Document document, OutputStream outputstream)

throws DocumentException

{ PdfWriter.getInstance(document, outputstream);

}

public static void main(String args[])

{ int i = 0;

if(args.length > 1)

{ try

{

XmlToPdf xmltopdf;

if(args.length > 2)

xmltopdf = new XmlToPdf(args[2]);

else

xmltopdf = new XmlToPdf();

xmltopdf.parse(new FileInputStream(args[0]), new FileOutputStream(args[1]));

}

catch(Exception exception)

{

i = 2;

exception.printStackTrace(System.err);

}

} else

{

i = 1;

System.err.println("Usage: XmlToPdf [XML file in] [PDF file out] [optional page size]");

}

System.exit(i);

}

}

and this is my XmlToXXX

package com.xml2pdf;

import com.lowagie.text.*;

import com.lowagie.text.xml.XmlParser;

import java.io.*;

import java.lang.reflect.Field;

import java.lang.reflect.Modifier;

public abstract class XmlToXXX

{

public XmlToXXX()

{

this(PageSize.LETTER);

}

public XmlToXXX(String s)

{

this(getPageSize(s));

}

private XmlToXXX(Rectangle rectangle)

{

pageSize = rectangle;

}

public final void parse(InputStream inputstream, OutputStream outputstream)

throws DocumentException

{

Document document = new Document(pageSize);

addWriter(document, outputstream);

XmlParser.parse(document, inputstream);

}

private static Rectangle getPageSize(String s)

{

Rectangle rectangle = PageSize.LETTER;

Object obj = null;

try

{

Field field = com.lowagie.text.PageSize.class.getDeclaredField(s.toUpperCase());

rectangle = field != null && Modifier.isStatic(field.getModifiers()) && field.getType().equals(com.lowagie.text.Rectangle.class) ? (Rectangle)field.get(null) : rectangle;

}

catch(Exception exception)

{

System.err.println(exception.getMessage());

}

return rectangle;

}

protected abstract void addWriter(Document document, OutputStream outputstream)

throws DocumentException;

protected Rectangle pageSize;

}

Whats the wrong in my code?