You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by pa...@mangoosta.net on 2002/06/07 12:28:56 UTC

Problem with image resolution in FOP

Hi all,

I am trying to fit a barcode image into a FOP 0.20.3 document (PDF). The
image is much bigger in the PDF (screen or printed) than when i view it
into an imaging tool.
I have a constraint on the barcode image that make it impossible for the
width to be less than about 250 pixels (I need to put 17 characters on
this barcode). I can decrease this value a bit but not much.
By reading the resources pages, I figured out that FOP was running at a
fixed 'dots per inch' value (Actually 72 dpi).
I looked at the source code and found org.apache.fop.svg.PdfTranscoder and
org.apache.fop.svg.SVGElement seem to handle this issue.
I have tried to hack these values using the following formula:

value = 1/dpi-value*2.54.

But it does not scale down. In fact, I am wondering if SVG is really
involved in scaling the image (I use an fo:external-graphic).
I also tried setting content-width and content-height to 50% but then FOP
complains that "No conversion is defined". Seems to be it won't get the %
character.
Can anyone with similar experience help ?

Thanks in advance

Pascal




Re: Problem with image resolution in FOP

Posted by "J.Pietschmann" <j3...@yahoo.de>.
pascal.munerot@mangoosta.net wrote:
> I am trying to fit a barcode image into a FOP 0.20.3 document (PDF). The
> image is much bigger in the PDF (screen or printed) than when i view it
> into an imaging tool.
> I have a constraint on the barcode image that make it impossible for the
> width to be less than about 250 pixels (I need to put 17 characters on
> this barcode). I can decrease this value a bit but not much.

Pixels are well suited for bitmaps and stuff that has naturally,
well, pixels, like monitors. The concept breaks down when stuff is
rendered to continuous media, like paper. You use measurements like
centimeters in this case. When you supply a bitmap, a factor of
1/72 inch/pixel is used to calculate width on paper from pixel
measurements.
SVG is vector graphic. You can use cm or mm for measurements
there as well. Your SVG should specify a height and width in cm
or mm or in or pt. Use the same height and width on the
fo:external-graphics or fo:instream-foreign-object holding the
SVG:
          <fo:instream-foreign-object width="5cm" height="1cm">
           <svg:svg xmlns:svg="http://www.w3.org/2000/svg"
             width="5cm" height="1cm">
             <svg:g stroke="black" stroke-width="0.8mm">
               <svg:rect fill="none" width="5cm" height="1cm"/>
             </svg:g>
           </svg:svg>
         </fo:instream-foreign-object>

There are perhaps some round-off errors and some clipping issues.
The SVG content should stay away a bit off the edge of the
containing rectangle, and you should print it, not judge how
it is rendered on screen.

> I also tried setting content-width and content-height to 50% but then FOP
> complains that "No conversion is defined". Seems to be it won't get the %
> character.
Neither of these properties are currently implemented, and
it wouldn't help anyway.

J.Pietschmann