on 06-08-2006 1:15 PM
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!
You have to create the class com.xml2pdf.XmlToPdf by your own.
Regards
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.