• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

FOP and SVG Files

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. I have created some .svg images from JFreeChart and want to embed them in a PDF document using FOP. Try as I might, using the External Graphic Inline Graphic route I cannot get it to display. Has anyone out there taken an existing svg file and embedded it successfully using FOP.

Many thanks in anticipation

matt
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How exactly are you trying to do the embedding? These pages give a few hints on how to do it.
[ July 22, 2008: Message edited by: Ulf Dittmer ]
 
Matt James
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply, but I cannot find examples of what I want to do.

I am trying to create a PDF report that has a graph at the top and a table of data underneath. I generate the Graph and the rest of the report XML in java and then pull them together in a PDF with FOP and XSLT.

At first, i used a jpeg for the graph (created by JFreeChart) and I could add that using fo:external-graphic. However, the graph was blurred so I decided to try and use SVG as I can create an SVG file from JFreeChart.

If I do this with the SVG file, where $graph_img1 is my .svg file:



I get :

[Fatal Error] :1:40: Invalid encoding name "Cp1252".
22-Jul-2008 19:56:06 org.apache.fop.image.analyser.ImageReaderFactory make
WARNING: No ImageReader found for file:C:/Work........graph1.svg


If I try and do this where svgString is the whole svg XML starting from <svg....



I get

Error(Unknown location): fo:instream-foreign-object is missing child elements.
Required Content Model: one (1) non-XSL namespace child


Have you got any suggestions.

Many thanks

matt
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a shot in the dark, but why not try and use some other encoding than "Cp1252", since that's what the error message is complaining about? The default encoding for XML is UTF-8, so that might be worth a try.
 
Matt James
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for this, good advice , I think that this has moved me forward. I am now getting another error indicating that it is trying a bit harder to show this image. It is too late to investigate this now, I will pick it up again tomorrow.

The error is ...

SEVERE: svg graphic could not be built: file:C:/Work/...0_graph01.svg:-1
An I/O error occured while processing the URI:
"file:C:/Work....0_graph01.svg#clipPath1"
specified on the element <rect>
org.apache.batik.bridge.BridgeException: file:C:/Work/...0_graph01.svg:-1
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As an aside, since it was quality issues that led you down this path, you might want to check out what FOP's SVG rasterizer makes of the SVG. That's probably what FOP uses internally anyway (since PDF can't include SVG, just images).

If the standalone rasterizer can't create a high quality rendering, then it seems likely that the embedded SVG won't be of high quality either.

(Note that I've never done exactly this myself, but it seems like a reasonable assumption based on my understanding of FOP and PDF).
 
Matt James
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again

I feel that I have made progress (by getting the URL right) but it is still not right. By using the FOP below I can now see the image starting to render (just see the top left hand corner) in the PDF. Its quality looks good but there is only a small amount of it there.

I can view the whole svg image in my Safari web browser.

Is there some fo:external-graphic attribute that I should be setting ?

The semi working fo is below (where graph_img1 is the svg file):



many thanks again

matt
 
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic