Hello Rafal,
Can you please send us classpeth entry?
Also make sure you append .; in your classpath.


Thanks,
Rajesh Suhas Sawant




________________________________
From: Rafał Laczek <rafal_lac...@wp.pl>
To: Chil-Hoan Kwon <chilho...@yahoo.ca>
Cc: Java EE (J2EE) Programming with Passion! 
<java-ee-j2ee-programming-with-passion@googlegroups.com>
Sent: Thu, 18 November, 2010 7:14:45 PM
Subject: Re: [java ee programming] fop.getDefaultHandler());


Hi Chil-Hoan,
 
Thank you very much for your detailed response.
My problem was with fop jar. I have updated it. Now I create PDF but it is 
empty...
I get following exception (I marked it).
The exception refers to FopFactory fopFactory = FopFactory.newInstance();
Below exception I also enclose code with the method that creates PDF.
Thanks in advance for help!
Regards,
Rafal
 
 Native Method 
) 
 ClassLoader.java:621 
) 
 SecureClassLoader.java:124 
) 
 URLClassLoader.java:260 
) 
 URLClassLoader.java:56 
) 
 URLClassLoader.java:195 
) 
 Native Method 
) 
 URLClassLoader.java:188 
) 
 ClassLoader.java:307 
) 
 Launcher.java:301 
) 
 ClassLoader.java:252 
) 
 ClassLoader.java:320 
) 
 Pdf.java:232 
) 
 Pdf.java:124 
) 
 java.lang.ClassNotFoundException 
: org.apache.xmlgraphics.image.loader.ImageContext 
 URLClassLoader.java:200 
) 
 Native Method 
) 
 URLClassLoader.java:188 
) 
 ClassLoader.java:307 
) 
 Launcher.java:301 
) 
 ClassLoader.java:252 
) 
 ClassLoader.java:320 
)
==================
CODE:
newBufferedOutputStream(newFileOutputStream(newFile("C:/PDFfile.pdf"))); 
// Creating FO ByteArrayOutputStream tmpUt = 
newByteArrayOutputStream(); 
// Using FOP to convert temporary file to PDF 
byte[] fo = tmpUt.toByteArray();
newByteArrayInputStream(fo); 
try{
MIME_PDF,out); TransformerFactory factory = TransformerFactory.newInstance(); 
Transformer transformer = factory.newTransformer(); Logger foLogger = 
Logger.getLogger(
"org.apache.fop");
SEVERE);
newStreamSource(bais); Result res = 
newSAXResult(fop.getDefaultHandler()); transformer.transform(src, res);  }
finally{ 
out.close();
}
Source src = 
foLogger.setLevel(Level.
Fop fop = fopFactory.newFop(MimeConstants.
FopFactory fopFactory = FopFactory.newInstance();  //HERE IS THE PROBLEM NOW 
InputStream bais = 
tmpUt.close();  
Document doc; 
String employeeNr; 
 
 
 
Dnia 18-11-2010 o godz. 14:09 Chil-Hoan Kwon napisał(a):
Hi Rafal,
>Do you write XML and fo:XSL files to generate PDF format?
>Why do you getDefaultHandler??
>I am writing simple steps for you:
>1. Create XML file and Save it at specific location.
>2. Create fo:XLS fils and Save it at specific location.
>3. Create Java file.
> - Set up a FOP driver
>   Driver driver = new Driver();
> - Set up the logger for the driver
>  Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO)
>  driver.setLogger(logger)
>- Declare Render format
> driver.setRenderer(Driver.RENDER_PDF)
>- invoke xml file and xsl file and put them into Handler
> XSLTInputHandler inputHandler = new XSLTInputHandler(xmlfile, xslFile)
>- Declare ByteSteream and read them byte
> ByteArrayOutPutStream outStream = new ByteArryaOutPutStream()
> driver.setOutputStream(outStream)
> driver.render(inputHandler.getParser(),inputHandler.getInputSource())
> byte[] content = outStream.toByteArray();
>- Display PDF
>response.setContentLength(content.length)
>response.setContentType("application/pdf")
>response.setHeader("       something.....")
>
>response.getoutputStream().write(content);
>response.getOutputSteram().flush()
>
>This is simple explanation (Web Based application) to implement PDF document 
>using xml and fo:XSL. 
>This will give you some idea how to write in Java.
>
>Good Luck!!!!
>
>Chil
>
>--- On Thu, 11/18/10, Rafał Laczek <rafal_lac...@wp.pl> wrote:
>
>
>>From: Rafał Laczek <rafal_lac...@wp.pl>
>>Subject: [java ee programming] fop.getDefaultHandler());
>>To: "Java EE (J2EE) Programming with Passion!" 
>><java-ee-j2ee-programming-with-passion@googlegroups.com>
>>Received: Thursday, November 18, 2010, 6:44 PM
>>
>>
>>Hi,
>>Can sobmbody advise me please why by fop.getDefaultHandler())  I get error: 
>>The 
>>method getDefaultHandler() is undefined for the type Fop.
>>
>>Thanks for help!
>>Regards,
>>Rafal
>>private staticvoidcreateReceiptPDF() throwsIOException, 
>>TransformerFactoryConfigurationError, FileNotFoundException, 
>>TransformerConfigurationException, TransformerException, FOPException {System.
>> 
>>out.println("createReceiptPDF() is invoked"); 
>>// Creating FO ( XSL-transformering uten FOP) 
>> 
>> 
>> 
>> 
>> 
>>ByteArrayOutputStream tmpUt =
>>newByteArrayOutputStream();
>>newStreamResult(tmpUt); 
>> 
>> 
>>// Using FOP to convert temporary file to PDF
>> 
>> 
>> byte 
>>[] fo = tmpUt.toByteArray();
>>new ByteArrayInputStream(fo); 
>>MIME_PDF,out); 
>> 
>> 
>>Transformer xformer = fact.newTransformer();
>>"org.apache.fop");
>>SEVERE);
>> 
>> 
>>// BufferedInputStream tmpIn = new BufferedInputStream(new 
FileInputStream(f));
>> 
>>Source src =
>>new
>>StreamSource(bais);
>>newSAXResult(fop.getDefaultHandler());
>>//The method getDefaultHandler() is undefined for the type Fop 
>>xformer.transform(src, result);
>>
>>-- 
>>You received this message because you are subscribed to the Google
>>Groups "Java EE (J2EE) Programming with Passion!" group.
>>To post to this group, send email to
>>java-ee-j2ee-programming-with-passion@googlegroups.com
>>To unsubscribe from this group, send email to
>>java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
>>For more options, visit this group at
>>http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en
>
>>
>>Result res =
>> 
>> 
>> 
>>foLogger.setLevel(Level.
>> 
>> Logger foLogger = Logger.getLogger(
>>FopFactory fopFactory = FopFactory.newInstance();Fop fop = 
>>fopFactory.newFop(MimeConstants.
>>InputStream bais =
>> 
>>tmpUt.close();
>>  
>>Result result =
>> 
>>OutputStream out;
>>Document doc;
>>String employeeNr;
>>TransformerFactory fact = TransformerFactory.newInstance();  
>

-- 
You received this message because you are subscribed to the Google
Groups "Java EE (J2EE) Programming with Passion!" group.
To post to this group, send email to
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en
 

BufferedOutputStream out = 
at java.lang.ClassLoader.loadClassInternal(
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.net.URLClassLoader.findClass(
at java.security.AccessController.doPrivileged(
at java.net.URLClassLoader$1.run(
Caused by: 
at Pdf.main(
at Pdf.createReceiptPDF(
at java.lang.ClassLoader.loadClassInternal(
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.net.URLClassLoader.findClass(
at java.security.AccessController.doPrivileged(
at java.net.URLClassLoader$1.run(
at java.net.URLClassLoader.access$000(
at java.net.URLClassLoader.defineClass(
at java.security.SecureClassLoader.defineClass(
at java.lang.ClassLoader.defineClass(
Exception in thread "main" java.lang.NoClassDefFoundError: 
org/apache/xmlgraphics/image/loader/ImageContextat 
java.lang.ClassLoader.defineClass1(

-- 
You received this message because you are subscribed to the Google
Groups "Java EE (J2EE) Programming with Passion!" group.
To post to this group, send email to
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en

Reply via email to