Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Apache FOP to load images with data url in PDF using xsl-fo

Thread view: 
Edward - 03 Feb 2006 15:24 GMT
I am trying to use Apache FOP to load images with data url into a PDF
using XSL-FO.  My application has no trouble loading images when they
are loaded from a file or from a servlet generated image using
fo:external-graphic.

I have a requirement to generate these images without an external file
or servlet embedded in xsl-fo but with a string of Base64 data passed
as a parameter.  I have not been able to get to this work.  I have an
application that a former co-worker wrote that was able to accomplish
this and I have tried cloning their code but still cannot succeed in
this.

I see in the other application there is a line of code (which I added
to my application):

System.setProperty("java.protocol.handler.pkgs","org.apache.fop.util.protocols");

which I assume is used to tell FOP where to look for its protocols.
The other application also has added in two classes in a similar
package that looks like it was acquired from Apache (I added these
classes as well, in the same package):

   org.apache.fop.util.protocols.data/Handler.java
   org.apache.fop.util.protocols.data/RFC2397URLConnection.java

Within Handler is a variable that I assume defines the data protocol:

   public static final String PROTOCOL = "data";

and within RFC2397URLConnection is a class:

   public void connect() {
       if (data != null) {
           return;
       }
       ParsedURLDataProtocolHandler handler = new
ParsedURLDataProtocolHandler();
       data = handler.parseURL(getURL().toString());
       headerFields.put("content-type", data.contentType);
   }

All well and good.  But here is the rub, in my application this code
never gets called, while in the application that I am trying to copy it
does (verified by putting simple System.out.println's in the methods to
see when they are called).

Thinking that perhaps the other application had different libraries, I
deleted all of the common libraries from my application and added them
into mine, using the same classpath as the other (and triple checked to
make sure that fop.jar and batik.jar were the same).  Also note that
for testing purposes the image is a simple hard-coded Base64 string
that I put in both applications to make sure that my problem was not
related to the way that the data was generated.

Note also that the working code runs as a standalone Java program while
my code is a servlet based web app running in WSAD and I have been
doing this testing in WSAD 5.0.0.

In both the working and non-working apps the external-graphics are
identical:

<fo:external-graphic
src="url('data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7')"
height="3cm" width="3cm" />

Anybody have any idea what I am missing?  Or can anyone point me to any
good FOP resources/forums?  I have been searching and have not been
able to find any yet.  I also cannot even find from where within
http://xmlgraphics.apache.org/fop/ that my ex-colleague even got the
org.apache.fop.util.protocols.data package or the
java.protocol.handler.pkgs code.  Please help!

Thanks.

Edward
Richard Wheeldon - 03 Feb 2006 18:25 GMT
> I am trying to use Apache FOP to load images with data url into a PDF
> using XSL-FO.

Either download the latest subversion snapshot or apply this patch:
http://issues.apache.org/bugzilla/attachment.cgi?id=17336

See the bug report for details:
http://issues.apache.org/bugzilla/show_bug.cgi?id=38135

If you have any problems with it, email me,

Richard


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.