APEX + Cocoon = PDF (and more)
Published by Carl Backstrom on Wednesday, March 21, 2007 at 12:28 PMSo you want your PDF printing but playing with JSP's and java libraries isn't your thing. Well there is another way to setup PDF and RTF output. The key is in the cryptic last paragrach of the APEX + PDF howto
>>
Other XSL-FO Processing Engines
If you prefer to use another XSL-FO Processing Engine, you will need to create an endpoint that provides similar functionality to the example JSP provided for the Apache FOP example above.
>>
Well I do prefer another XSL-FO Processing engine which is Apache Cocoon and Apache Tomcat. Cocoon is my favorite web framework other than APEX of course and I've used them together on many occasions.
Instead of a long drawn out howto I instead created this viewlet to show you the steps of the process.
The files you will need can be found through these links.
Cocoon
Tomcat
fop_post.zip
APEX and Cocoon Viewlet
If you have any questions please feel free to leave some comments but I think the setup and usage is very simple.

Looks cool. Thanks.
Great alternative Carl. Always love to see the viewlets as demos on how to do stuff - so much easier to follow.
Regards,
Jon.
Nice alternative.
Is it possible to install Cocoon on the Oracle Application Server 10.1.2.0.2?
Regards,
Guido
Thank you, works like a charm!
If you use JDK 1.6 instead of JDK 1.5, then you need to change the ExcaliburDataSourceFactory.java file. The changes that you need to make can be found here:
http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/databases/ibatis/ExcaliburDataSourceFactory.java?view=markup&pathrev=495744
Hey Carl,
I have a problem with your cocoon solution!
When I try to generate a pdf from Shared Components(Test Report) i receive this message:
"Adobe reader could not open 'mistakes.pdf' because it is either not a supported file type or because the file has been damaged (for example it was sent as an email attachment and wasn't correctly decoded)"
Can you help me with that?
Thread in APEX Forum:
http://forums.oracle.com/forums/thread.jspa?threadID=488120&tstart=0&start=15
Thank you,
Tim
Hi,
Thank you very much for your alternative. This is very simple and the viewlet helped a lot. I tried to install it on Solaris. There was a problem with JMS installation with Tomcat. I tried to build the JMS according to Tomcat web site. It worked fine. Thanks again for your wonderful article.
Carl,
I can get Tomcat and Cocoon working fine. However, the fop_post's sitemap.xmap is giving me some problems.
org.apache.cocoon.ProcessingException: Unknown request object encountered named xml : null
I think this error refers to the form-name parameter. What form-name does APEX post to Cocoon, when it sends the XML stream?
I am having problems with opening the pdf reports. It says there is an error. When I switch to the word outputs it only has the word 'unauthorized' on it.
Hi
I want to print totallity of a page APEX in pdf. Is it possible ?
Any way to compile Cocoon 2.1.10 for JAVA 1.4.2?
Hello,
I've never tried with Java 1.42
The Cocoon requirements say http://cocoon.apache.org/2.1/installing/requirements.html
1.3 and up
You also have to take the Tomcat requirements into account but it looks like most of those will run in 1.3 and up as well.
http://tomcat.apache.org/whichversion.html
Carl
Thank you for the tut. After typing build war.. I get the following error
Target "War" does not exist on this project. I took the fop.war file provide in the APEX directory and plugged it in the cocoon main directory and still got this error. Where do I put the war file and what do I name it prior to building cocoon?
{PR}
My cocoon build fails with:
...
cocoon-block-databases-patch:
Processing: C:\APEX_FOP\cocoon-2.1.10\src\blocks\databases\conf\databases-trans.xmap
Writing: C:\APEX_FOP\cocoon-2.1.10\build\webapp\sitemap.xmap
BUILD FAILED
C:\APEX_FOP\cocoon-2.1.10\tools\targets\webapp-build.xml:113: The following error ocurred while executing this line:
C:APEX_FOP\cocoon-2.1.10\build\cocoon\temp\blocks-build.xml:1636:
error occurred while executing this line:
C:APEX_FOP\cocoon-2.1.10\build\cocoon\temp\blocks-build.xml:165:
FileNotFoundException: java.io.FileNotFoundException: C:\APEX_FOP\cocoon-2.1.10\build\webapp\sitemap.xmap (The requested operation cannot be performed on a file with a user-mapped section open)
sitemap.xmap was successfully written to several lines above with no problem. I have restarted twice and got a bit furthur each time.
What to look for? Where to go?
I am using jdk1.5.0_06.
All else is the same.
Hello,
Pedro
The fop.war solution that ships with APEX is different than this solution, and I'm not sure they would work together nicely.
The Cocoon solution is an alternative to the fop solution.
Karen
That looks like it's a Cocoon build issue.
I'd take a look at the cocoon forum here http://www.nabble.com/Cocoon-f111.html as you will probably get better information than I can give you. That section of my install has always just worked.
Is there any way to use cocoon in order to perform an Advanced printing like a master detail report ?
Tks
Tullio
Hi Carl,I've installed tomcat+cocoon by your way, all is running, but if i try print from apex application, in tomcat log (on screen) i can see conversion progress otherwise apex ends with "page not found"
However APEX is runing on Oracle Apache web server, not on installed tomcat with cocoon. Can i to use apex application with this configuration(Oracle Apache+apex, tomcat+cocoon), or apex must be configured on tomcat web server ?
(so how to "connect" apex on tomcat ?)
Thanks !
Wil.
Carl -
I too am curious how to use Cocoon with Oracle's Application Server (10.1.3). I am currently using OAS as my Apex front-end and would like to take advantage of Cocoon. All signs seem to point to Tomcat/Cocoon and not OAS/Cocoon. Does it create any issues if you install Tomcat on the same server as OAS?
Tony,
you should be able to install the war file into an existing OC4J container (which is part of the IAS 10.1.3). There is no need to install Tomcat as well.
You could do it if you wanted to, but there is really no need to manage another J2EE container.
You should give it a try.
Regards,
~Dietmar.
I got Cocoon deployed to OAS and things are mostly working. It appears as though the XLS export doesn't work. I also haven't been able to get a RTF report template to work. I get an error during the generation of the document "C:\cocoon\styles\main.css" is missing. Why is it looking on my local machine for a css file when the RTF is in Apex?
Thank you Carl, it is a very usefull step by step installation guide, however
I have the same problem as Tony:
quote (I get an error during the generation of the document "C:\cocoon\styles\main.css" is missing.)
although if I use the default layout it works but if I creat an RTF it doesn't.
do you have a step by step guide for the layout creation ?
Best Regards.
Great,
I like your alternative Carl.
Unfortunatly image, formating and others include clob are not include in PDF. :-(
Thx for your stuff.
Dave
Oupss.. Sorry.
My condolences to Carl's friends and family
Dave
For resolving Excel, HTML and XML output see here:
http://rste.blogspot.com/2008/07/excel-export-from-apex-cocoon.html
Dave
Apex + Cocoon works nicely for me. Except i cannot get dynamic images to work. I tried the technique provided at: http://marcsewtz.blogspot.com/2008/06/one-question-about-pdf-printing-feature.html
I get not error message but the image is not showing in the pdf either. Is it possible to use base64 encoded images from xml with Apex + Cocoon?
Hello
Great, averything working.
However could you show how to get printing in custom RTF?
Welcome to lineage 2 adena Our WoW Gold, wow power leveling Online Maple Story mesos Store wow gold for World Guild Wars Gold Of Warcraft power leveling, Cheap 2moon dil WoW Gold, FFXI Gil World Of lotro gold Warcraft Gold, final fantasy gil warcraft goldlord of the rings gold